@@ -22,11 +22,10 @@ import com.airbnb.mvrx.test.MavericksTestRule
22
22
import im.vector.app.features.settings.devices.v2.DeviceFullInfo
23
23
import im.vector.app.features.settings.devices.v2.GetDeviceFullInfoListUseCase
24
24
import im.vector.app.features.settings.devices.v2.RefreshDevicesUseCase
25
- import im.vector.app.features.settings.devices.v2.details.extended.DeviceExtendedInfo
26
25
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
27
- import im.vector.app.features.settings.devices.v2.list.DeviceType
28
26
import im.vector.app.test.fakes.FakeActiveSessionHolder
29
27
import im.vector.app.test.fakes.FakeVerificationService
28
+ import im.vector.app.test.fixtures.aDeviceFullInfo
30
29
import im.vector.app.test.test
31
30
import im.vector.app.test.testDispatcher
32
31
import io.mockk.every
@@ -39,8 +38,6 @@ import org.junit.After
39
38
import org.junit.Before
40
39
import org.junit.Rule
41
40
import org.junit.Test
42
- import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
43
- import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
44
41
45
42
private const val A_TITLE_RES_ID = 1
46
43
private const val A_DEVICE_ID = " device-id"
@@ -146,7 +143,7 @@ class OtherSessionsViewModelTest {
146
143
@Test
147
144
fun `given enable select mode action when handling the action then viewState is updated with correct info` () {
148
145
// Given
149
- val deviceFullInfo = givenDeviceFullInfo (A_DEVICE_ID , isSelected = false )
146
+ val deviceFullInfo = aDeviceFullInfo (A_DEVICE_ID , isSelected = false )
150
147
val devices: List <DeviceFullInfo > = listOf (deviceFullInfo)
151
148
givenGetDeviceFullInfoListReturns(filterType = defaultArgs.defaultFilter, devices)
152
149
val expectedState = OtherSessionsViewState (
@@ -170,8 +167,8 @@ class OtherSessionsViewModelTest {
170
167
@Test
171
168
fun `given disable select mode action when handling the action then viewState is updated with correct info` () {
172
169
// Given
173
- val deviceFullInfo1 = givenDeviceFullInfo (A_DEVICE_ID , isSelected = true )
174
- val deviceFullInfo2 = givenDeviceFullInfo (A_DEVICE_ID , isSelected = true )
170
+ val deviceFullInfo1 = aDeviceFullInfo (A_DEVICE_ID , isSelected = true )
171
+ val deviceFullInfo2 = aDeviceFullInfo (A_DEVICE_ID , isSelected = true )
175
172
val devices: List <DeviceFullInfo > = listOf (deviceFullInfo1, deviceFullInfo2)
176
173
givenGetDeviceFullInfoListReturns(filterType = defaultArgs.defaultFilter, devices)
177
174
val expectedState = OtherSessionsViewState (
@@ -195,7 +192,7 @@ class OtherSessionsViewModelTest {
195
192
@Test
196
193
fun `given toggle selection for device action when handling the action then viewState is updated with correct info` () {
197
194
// Given
198
- val deviceFullInfo = givenDeviceFullInfo (A_DEVICE_ID , isSelected = false )
195
+ val deviceFullInfo = aDeviceFullInfo (A_DEVICE_ID , isSelected = false )
199
196
val devices: List <DeviceFullInfo > = listOf (deviceFullInfo)
200
197
givenGetDeviceFullInfoListReturns(filterType = defaultArgs.defaultFilter, devices)
201
198
val expectedState = OtherSessionsViewState (
@@ -219,8 +216,8 @@ class OtherSessionsViewModelTest {
219
216
@Test
220
217
fun `given select all action when handling the action then viewState is updated with correct info` () {
221
218
// Given
222
- val deviceFullInfo1 = givenDeviceFullInfo (A_DEVICE_ID , isSelected = false )
223
- val deviceFullInfo2 = givenDeviceFullInfo (A_DEVICE_ID , isSelected = true )
219
+ val deviceFullInfo1 = aDeviceFullInfo (A_DEVICE_ID , isSelected = false )
220
+ val deviceFullInfo2 = aDeviceFullInfo (A_DEVICE_ID , isSelected = true )
224
221
val devices: List <DeviceFullInfo > = listOf (deviceFullInfo1, deviceFullInfo2)
225
222
givenGetDeviceFullInfoListReturns(filterType = defaultArgs.defaultFilter, devices)
226
223
val expectedState = OtherSessionsViewState (
@@ -244,8 +241,8 @@ class OtherSessionsViewModelTest {
244
241
@Test
245
242
fun `given deselect all action when handling the action then viewState is updated with correct info` () {
246
243
// Given
247
- val deviceFullInfo1 = givenDeviceFullInfo (A_DEVICE_ID , isSelected = false )
248
- val deviceFullInfo2 = givenDeviceFullInfo (A_DEVICE_ID , isSelected = true )
244
+ val deviceFullInfo1 = aDeviceFullInfo (A_DEVICE_ID , isSelected = false )
245
+ val deviceFullInfo2 = aDeviceFullInfo (A_DEVICE_ID , isSelected = true )
249
246
val devices: List <DeviceFullInfo > = listOf (deviceFullInfo1, deviceFullInfo2)
250
247
givenGetDeviceFullInfoListReturns(filterType = defaultArgs.defaultFilter, devices)
251
248
val expectedState = OtherSessionsViewState (
@@ -272,21 +269,4 @@ class OtherSessionsViewModelTest {
272
269
) {
273
270
every { fakeGetDeviceFullInfoListUseCase.execute(filterType, any()) } returns flowOf(devices)
274
271
}
275
-
276
- private fun givenDeviceFullInfo (deviceId : String , isSelected : Boolean ): DeviceFullInfo {
277
- return DeviceFullInfo (
278
- deviceInfo = DeviceInfo (
279
- deviceId = deviceId,
280
- ),
281
- cryptoDeviceInfo = null ,
282
- roomEncryptionTrustLevel = RoomEncryptionTrustLevel .Trusted ,
283
- isInactive = true ,
284
- isCurrentDevice = true ,
285
- deviceExtendedInfo = DeviceExtendedInfo (
286
- deviceType = DeviceType .MOBILE ,
287
- ),
288
- matrixClientInfo = null ,
289
- isSelected = isSelected,
290
- )
291
- }
292
272
}
0 commit comments