diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt index 351d6b8eb0..741fb15cc3 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt @@ -171,13 +171,15 @@ class DevicesViewModelTest { deviceInfo = mockk(), cryptoDeviceInfo = verifiedCryptoDeviceInfo, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, - isInactive = false + isInactive = false, + isCurrentDevice = true ) val deviceFullInfo2 = DeviceFullInfo( deviceInfo = mockk(), cryptoDeviceInfo = unverifiedCryptoDeviceInfo, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, - isInactive = true + isInactive = true, + isCurrentDevice = false ) val deviceFullInfoList = listOf(deviceFullInfo1, deviceFullInfo2) val deviceFullInfoListFlow = flowOf(deviceFullInfoList) diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCaseTest.kt index 54b160f196..89516745bf 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCaseTest.kt @@ -106,19 +106,22 @@ class GetDeviceFullInfoListUseCaseTest { deviceInfo = deviceInfo1, cryptoDeviceInfo = cryptoDeviceInfo1, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, - isInactive = true + isInactive = true, + isCurrentDevice = true ) val expectedResult2 = DeviceFullInfo( deviceInfo = deviceInfo2, cryptoDeviceInfo = cryptoDeviceInfo2, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, - isInactive = false + isInactive = false, + isCurrentDevice = false ) val expectedResult3 = DeviceFullInfo( deviceInfo = deviceInfo3, cryptoDeviceInfo = cryptoDeviceInfo3, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, - isInactive = false + isInactive = false, + isCurrentDevice = false ) val expectedResult = listOf(expectedResult3, expectedResult2, expectedResult1) every { filterDevicesUseCase.execute(any(), any()) } returns expectedResult @@ -160,6 +163,7 @@ class GetDeviceFullInfoListUseCaseTest { private fun givenCurrentSessionCrossSigningInfo(): CurrentSessionCrossSigningInfo { val currentSessionCrossSigningInfo = mockk() every { getCurrentSessionCrossSigningInfoUseCase.execute() } returns flowOf(currentSessionCrossSigningInfo) + every { currentSessionCrossSigningInfo.deviceId } returns A_DEVICE_ID_1 return currentSessionCrossSigningInfo } diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesViewNavigatorTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesViewNavigatorTest.kt index a1f0918b31..7b8b6ee82d 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesViewNavigatorTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesViewNavigatorTest.kt @@ -17,6 +17,7 @@ package im.vector.app.features.settings.devices.v2 import android.content.Intent +import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsActivity import im.vector.app.features.settings.devices.v2.overview.SessionOverviewActivity import im.vector.app.test.fakes.FakeContext @@ -30,6 +31,8 @@ import org.junit.Before import org.junit.Test private const val A_SESSION_ID = "session_id" +private const val A_TITLE_RESOURCE_ID = 1234 +private val A_DEFAULT_FILTER = DeviceManagerFilterType.INACTIVE class VectorSettingsDevicesViewNavigatorTest { @@ -61,10 +64,10 @@ class VectorSettingsDevicesViewNavigatorTest { @Test fun `given an intent when navigating to other sessions list then it starts the correct activity`() { - val intent = givenIntentForOtherSessions() + val intent = givenIntentForOtherSessions(A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true) context.givenStartActivity(intent) - vectorSettingsDevicesViewNavigator.navigateToOtherSessions(context.instance) + vectorSettingsDevicesViewNavigator.navigateToOtherSessions(context.instance, A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true) verify { context.instance.startActivity(intent) @@ -77,9 +80,9 @@ class VectorSettingsDevicesViewNavigatorTest { return intent } - private fun givenIntentForOtherSessions(): Intent { + private fun givenIntentForOtherSessions(titleResourceId: Int, defaultFilter: DeviceManagerFilterType, includeCurrentSession: Boolean): Intent { val intent = mockk() - every { OtherSessionsActivity.newIntent(context.instance) } returns intent + every { OtherSessionsActivity.newIntent(context.instance, titleResourceId, defaultFilter, includeCurrentSession) } returns intent return intent } } diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCaseTest.kt index 1254e2a80a..2bb5168190 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCaseTest.kt @@ -33,7 +33,8 @@ private val activeVerifiedDevice = DeviceFullInfo( trustLevel = DeviceTrustLevel(crossSigningVerified = true, locallyVerified = true) ), roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, - isInactive = false + isInactive = false, + isCurrentDevice = true ) private val inactiveVerifiedDevice = DeviceFullInfo( deviceInfo = DeviceInfo(deviceId = "INACTIVE_VERIFIED_DEVICE"), @@ -43,7 +44,8 @@ private val inactiveVerifiedDevice = DeviceFullInfo( trustLevel = DeviceTrustLevel(crossSigningVerified = true, locallyVerified = true) ), roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, - isInactive = true + isInactive = true, + isCurrentDevice = false ) private val activeUnverifiedDevice = DeviceFullInfo( deviceInfo = DeviceInfo(deviceId = "ACTIVE_UNVERIFIED_DEVICE"), @@ -53,7 +55,8 @@ private val activeUnverifiedDevice = DeviceFullInfo( trustLevel = DeviceTrustLevel(crossSigningVerified = false, locallyVerified = false) ), roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, - isInactive = false + isInactive = false, + isCurrentDevice = false ) private val inactiveUnverifiedDevice = DeviceFullInfo( deviceInfo = DeviceInfo(deviceId = "INACTIVE_UNVERIFIED_DEVICE"), @@ -63,7 +66,8 @@ private val inactiveUnverifiedDevice = DeviceFullInfo( trustLevel = DeviceTrustLevel(crossSigningVerified = false, locallyVerified = false) ), roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, - isInactive = true + isInactive = true, + isCurrentDevice = false ) private val devices = listOf( diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt index 9c7515f2da..16cb925e6e 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt @@ -85,6 +85,7 @@ class GetDeviceFullInfoUseCaseTest { fakeActiveSessionHolder.fakeSession.fakeCryptoService.cryptoDeviceInfoWithIdLiveData.givenAsFlow() val trustLevel = givenTrustLevel(currentSessionCrossSigningInfo, cryptoDeviceInfo) val isInactive = false + val isCurrentDevice = true every { checkIfSessionIsInactiveUseCase.execute(any()) } returns isInactive // When @@ -96,6 +97,7 @@ class GetDeviceFullInfoUseCaseTest { cryptoDeviceInfo = cryptoDeviceInfo, roomEncryptionTrustLevel = trustLevel, isInactive = isInactive, + isCurrentDevice = isCurrentDevice ) verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } verify { getCurrentSessionCrossSigningInfoUseCase.execute() }