Code review fixes.

This commit is contained in:
Onuray Sahin 2022-09-29 17:35:47 +03:00
parent 38cd2be332
commit 6d459a0bc9
9 changed files with 52 additions and 61 deletions

View File

@ -18,7 +18,7 @@ package im.vector.app.features.settings.devices.v2
import im.vector.app.features.settings.devices.v2.list.DeviceType import im.vector.app.features.settings.devices.v2.list.DeviceType
data class DeviceUserAgent( data class DeviceExtendedInfo(
/** /**
* One of MOBILE, WEB, DESKTOP or UNKNOWN. * One of MOBILE, WEB, DESKTOP or UNKNOWN.
*/ */

View File

@ -26,5 +26,5 @@ data class DeviceFullInfo(
val roomEncryptionTrustLevel: RoomEncryptionTrustLevel, val roomEncryptionTrustLevel: RoomEncryptionTrustLevel,
val isInactive: Boolean, val isInactive: Boolean,
val isCurrentDevice: Boolean, val isCurrentDevice: Boolean,
val deviceUserAgent: DeviceUserAgent, val deviceExtendedInfo: DeviceExtendedInfo,
) )

View File

@ -22,7 +22,7 @@ import javax.inject.Inject
class ParseDeviceUserAgentUseCase @Inject constructor() { class ParseDeviceUserAgentUseCase @Inject constructor() {
fun execute(userAgent: String?): DeviceUserAgent { fun execute(userAgent: String?): DeviceExtendedInfo {
if (userAgent == null) return createUnknownUserAgent() if (userAgent == null) return createUnknownUserAgent()
return when { return when {
@ -34,7 +34,7 @@ class ParseDeviceUserAgentUseCase @Inject constructor() {
} }
} }
private fun parseAndroidUserAgent(userAgent: String): DeviceUserAgent { private fun parseAndroidUserAgent(userAgent: String): DeviceExtendedInfo {
val appName = userAgent.substringBefore("/") val appName = userAgent.substringBefore("/")
val appVersion = userAgent.substringAfter("/").substringBefore(" (") val appVersion = userAgent.substringAfter("/").substringBefore(" (")
val deviceInfoSegments = userAgent.substringAfter("(").substringBeforeLast(")").split("; ") val deviceInfoSegments = userAgent.substringAfter("(").substringBeforeLast(")").split("; ")
@ -48,19 +48,19 @@ class ParseDeviceUserAgentUseCase @Inject constructor() {
deviceModel = deviceInfoSegments.getOrNull(0) deviceModel = deviceInfoSegments.getOrNull(0)
deviceOperatingSystem = deviceInfoSegments.getOrNull(1) deviceOperatingSystem = deviceInfoSegments.getOrNull(1)
} }
return DeviceUserAgent(DeviceType.MOBILE, deviceModel, deviceOperatingSystem, appName, appVersion) return DeviceExtendedInfo(DeviceType.MOBILE, deviceModel, deviceOperatingSystem, appName, appVersion)
} }
private fun parseIosUserAgent(userAgent: String): DeviceUserAgent { private fun parseIosUserAgent(userAgent: String): DeviceExtendedInfo {
val appName = userAgent.substringBefore("/") val appName = userAgent.substringBefore("/")
val appVersion = userAgent.substringAfter("/").substringBefore(" (") val appVersion = userAgent.substringAfter("/").substringBefore(" (")
val deviceInfoSegments = userAgent.substringAfter("(").substringBeforeLast(")").split("; ") val deviceInfoSegments = userAgent.substringAfter("(").substringBeforeLast(")").split("; ")
val deviceModel = deviceInfoSegments.getOrNull(0) val deviceModel = deviceInfoSegments.getOrNull(0)
val deviceOperatingSystem = deviceInfoSegments.getOrNull(1) val deviceOperatingSystem = deviceInfoSegments.getOrNull(1)
return DeviceUserAgent(DeviceType.MOBILE, deviceModel, deviceOperatingSystem, appName, appVersion) return DeviceExtendedInfo(DeviceType.MOBILE, deviceModel, deviceOperatingSystem, appName, appVersion)
} }
private fun parseDesktopUserAgent(userAgent: String): DeviceUserAgent { private fun parseDesktopUserAgent(userAgent: String): DeviceExtendedInfo {
val browserSegments = userAgent.split(" ") val browserSegments = userAgent.split(" ")
val browserName = when { val browserName = when {
isFirefox(browserSegments) -> { isFirefox(browserSegments) -> {
@ -86,17 +86,17 @@ class ParseDeviceUserAgentUseCase @Inject constructor() {
} else { } else {
deviceOperatingSystemSegments.getOrNull(0) deviceOperatingSystemSegments.getOrNull(0)
} }
return DeviceUserAgent(DeviceType.DESKTOP, browserName, deviceOperatingSystem, null, null) return DeviceExtendedInfo(DeviceType.DESKTOP, browserName, deviceOperatingSystem, null, null)
} }
private fun parseWebUserAgent(userAgent: String): DeviceUserAgent { private fun parseWebUserAgent(userAgent: String): DeviceExtendedInfo {
return parseDesktopUserAgent(userAgent).copy( return parseDesktopUserAgent(userAgent).copy(
deviceType = DeviceType.WEB deviceType = DeviceType.WEB
) )
} }
private fun createUnknownUserAgent(): DeviceUserAgent { private fun createUnknownUserAgent(): DeviceExtendedInfo {
return DeviceUserAgent(DeviceType.UNKNOWN) return DeviceExtendedInfo(DeviceType.UNKNOWN)
} }
private fun isFirefox(browserSegments: List<String>): Boolean { private fun isFirefox(browserSegments: List<String>): Boolean {

View File

@ -58,7 +58,7 @@ class GetDeviceFullInfoUseCase @Inject constructor(
roomEncryptionTrustLevel = roomEncryptionTrustLevel, roomEncryptionTrustLevel = roomEncryptionTrustLevel,
isInactive = isInactive, isInactive = isInactive,
isCurrentDevice = isCurrentDevice, isCurrentDevice = isCurrentDevice,
deviceUserAgent = deviceUserAgent, deviceExtendedInfo = deviceUserAgent,
) )
} else { } else {
null null

View File

@ -244,7 +244,7 @@ class DevicesViewModelTest {
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
isInactive = false, isInactive = false,
isCurrentDevice = true, isCurrentDevice = true,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
val deviceFullInfo2 = DeviceFullInfo( val deviceFullInfo2 = DeviceFullInfo(
deviceInfo = mockk(), deviceInfo = mockk(),
@ -252,7 +252,7 @@ class DevicesViewModelTest {
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning,
isInactive = true, isInactive = true,
isCurrentDevice = false, isCurrentDevice = false,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
val deviceFullInfoList = listOf(deviceFullInfo1, deviceFullInfo2) val deviceFullInfoList = listOf(deviceFullInfo1, deviceFullInfo2)
val deviceFullInfoListFlow = flowOf(deviceFullInfoList) val deviceFullInfoListFlow = flowOf(deviceFullInfoList)

View File

@ -46,7 +46,6 @@ private const val A_DEVICE_ID_3 = "device-id-3"
private const val A_TIMESTAMP_1 = 100L private const val A_TIMESTAMP_1 = 100L
private const val A_TIMESTAMP_2 = 200L private const val A_TIMESTAMP_2 = 200L
private const val A_TIMESTAMP_3 = 300L private const val A_TIMESTAMP_3 = 300L
private const val A_USER_AGENT = "Element dbg/1.5.0-dev (Xiaomi Mi 9T; Android 11; RKQ1.200826.002 test-keys; Flavour GooglePlay; MatrixAndroidSdk2 1.5.2)"
class GetDeviceFullInfoListUseCaseTest { class GetDeviceFullInfoListUseCaseTest {
@ -92,7 +91,6 @@ class GetDeviceFullInfoListUseCaseTest {
isInactive = true, isInactive = true,
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
cryptoDeviceInfo = cryptoDeviceInfo1, cryptoDeviceInfo = cryptoDeviceInfo1,
lastSeenUserAgent = A_USER_AGENT
) )
val deviceInfo2 = givenADevicesInfo( val deviceInfo2 = givenADevicesInfo(
deviceId = A_DEVICE_ID_2, deviceId = A_DEVICE_ID_2,
@ -100,7 +98,6 @@ class GetDeviceFullInfoListUseCaseTest {
isInactive = false, isInactive = false,
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
cryptoDeviceInfo = cryptoDeviceInfo2, cryptoDeviceInfo = cryptoDeviceInfo2,
lastSeenUserAgent = A_USER_AGENT
) )
val deviceInfo3 = givenADevicesInfo( val deviceInfo3 = givenADevicesInfo(
deviceId = A_DEVICE_ID_3, deviceId = A_DEVICE_ID_3,
@ -108,7 +105,6 @@ class GetDeviceFullInfoListUseCaseTest {
isInactive = false, isInactive = false,
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning,
cryptoDeviceInfo = cryptoDeviceInfo3, cryptoDeviceInfo = cryptoDeviceInfo3,
lastSeenUserAgent = A_USER_AGENT
) )
val deviceInfoList = listOf(deviceInfo1, deviceInfo2, deviceInfo3) val deviceInfoList = listOf(deviceInfo1, deviceInfo2, deviceInfo3)
every { fakeFlowSession.liveMyDevicesInfo() } returns flowOf(deviceInfoList) every { fakeFlowSession.liveMyDevicesInfo() } returns flowOf(deviceInfoList)
@ -118,7 +114,7 @@ class GetDeviceFullInfoListUseCaseTest {
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
isInactive = true, isInactive = true,
isCurrentDevice = true, isCurrentDevice = true,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
val expectedResult2 = DeviceFullInfo( val expectedResult2 = DeviceFullInfo(
deviceInfo = deviceInfo2, deviceInfo = deviceInfo2,
@ -126,7 +122,7 @@ class GetDeviceFullInfoListUseCaseTest {
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
isInactive = false, isInactive = false,
isCurrentDevice = false, isCurrentDevice = false,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
val expectedResult3 = DeviceFullInfo( val expectedResult3 = DeviceFullInfo(
deviceInfo = deviceInfo3, deviceInfo = deviceInfo3,
@ -134,7 +130,7 @@ class GetDeviceFullInfoListUseCaseTest {
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning,
isInactive = false, isInactive = false,
isCurrentDevice = false, isCurrentDevice = false,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
val expectedResult = listOf(expectedResult3, expectedResult2, expectedResult1) val expectedResult = listOf(expectedResult3, expectedResult2, expectedResult1)
every { filterDevicesUseCase.execute(any(), any()) } returns expectedResult every { filterDevicesUseCase.execute(any(), any()) } returns expectedResult
@ -192,20 +188,15 @@ class GetDeviceFullInfoListUseCaseTest {
isInactive: Boolean, isInactive: Boolean,
roomEncryptionTrustLevel: RoomEncryptionTrustLevel, roomEncryptionTrustLevel: RoomEncryptionTrustLevel,
cryptoDeviceInfo: CryptoDeviceInfo, cryptoDeviceInfo: CryptoDeviceInfo,
lastSeenUserAgent: String,
): DeviceInfo { ): DeviceInfo {
val deviceInfo = mockk<DeviceInfo>() val deviceInfo = mockk<DeviceInfo>()
every { deviceInfo.deviceId } returns deviceId every { deviceInfo.deviceId } returns deviceId
every { deviceInfo.lastSeenTs } returns lastSeenTs every { deviceInfo.lastSeenTs } returns lastSeenTs
every { deviceInfo.getBestLastSeenUserAgent() } returns lastSeenUserAgent every { deviceInfo.getBestLastSeenUserAgent() } returns ""
every { getEncryptionTrustLevelForDeviceUseCase.execute(any(), cryptoDeviceInfo) } returns roomEncryptionTrustLevel every { getEncryptionTrustLevelForDeviceUseCase.execute(any(), cryptoDeviceInfo) } returns roomEncryptionTrustLevel
every { checkIfSessionIsInactiveUseCase.execute(lastSeenTs) } returns isInactive every { checkIfSessionIsInactiveUseCase.execute(lastSeenTs) } returns isInactive
every { parseDeviceUserAgentUseCase.execute(lastSeenUserAgent) } returns DeviceUserAgent( every { parseDeviceUserAgentUseCase.execute(any()) } returns DeviceExtendedInfo(
DeviceType.MOBILE, DeviceType.MOBILE,
"Xiaomi Mi 9T",
"Android 11",
"Element dbg",
"1.5.0-dev"
) )
return deviceInfo return deviceInfo

View File

@ -32,13 +32,13 @@ private val A_USER_AGENT_LIST_FOR_ANDROID = listOf(
"Element/1.0.0 (Linux; Android 7.0; SM-G610M Build/NRD90M; Flavour GPlay; MatrixAndroidSdk2 1.0)", "Element/1.0.0 (Linux; Android 7.0; SM-G610M Build/NRD90M; Flavour GPlay; MatrixAndroidSdk2 1.0)",
) )
private val AN_EXPECTED_RESULT_LIST_FOR_ANDROID = listOf( private val AN_EXPECTED_RESULT_LIST_FOR_ANDROID = listOf(
DeviceUserAgent(DeviceType.MOBILE, "Xiaomi Mi 9T", "Android 11", "Element dbg", "1.5.0-dev"), DeviceExtendedInfo(DeviceType.MOBILE, "Xiaomi Mi 9T", "Android 11", "Element dbg", "1.5.0-dev"),
DeviceUserAgent(DeviceType.MOBILE, "Samsung SM-G960F", "Android 6.0.1", "Element", "1.5.0"), DeviceExtendedInfo(DeviceType.MOBILE, "Samsung SM-G960F", "Android 6.0.1", "Element", "1.5.0"),
DeviceUserAgent(DeviceType.MOBILE, "Google Nexus 5", "Android 7.0", "Element", "1.5.0"), DeviceExtendedInfo(DeviceType.MOBILE, "Google Nexus 5", "Android 7.0", "Element", "1.5.0"),
DeviceUserAgent(DeviceType.MOBILE, "Google (Nexus) 5", "Android 7.0", "Element", "1.5.0"), DeviceExtendedInfo(DeviceType.MOBILE, "Google (Nexus) 5", "Android 7.0", "Element", "1.5.0"),
DeviceUserAgent(DeviceType.MOBILE, "Google (Nexus) (5)", "Android 7.0", "Element", "1.5.0"), DeviceExtendedInfo(DeviceType.MOBILE, "Google (Nexus) (5)", "Android 7.0", "Element", "1.5.0"),
DeviceUserAgent(DeviceType.MOBILE, "SM-A510F Build/MMB29", "Android 6.0.1", "Element", "1.0.0"), DeviceExtendedInfo(DeviceType.MOBILE, "SM-A510F Build/MMB29", "Android 6.0.1", "Element", "1.0.0"),
DeviceUserAgent(DeviceType.MOBILE, "SM-G610M Build/NRD90M", "Android 7.0", "Element", "1.0.0"), DeviceExtendedInfo(DeviceType.MOBILE, "SM-G610M Build/NRD90M", "Android 7.0", "Element", "1.0.0"),
) )
private val A_USER_AGENT_LIST_FOR_IOS = listOf( private val A_USER_AGENT_LIST_FOR_IOS = listOf(
@ -48,10 +48,10 @@ private val A_USER_AGENT_LIST_FOR_IOS = listOf(
"Element/1.8.21 (iPad Pro (12.9-inch) (3rd generation); iOS 15.2; Scale/3.00)", "Element/1.8.21 (iPad Pro (12.9-inch) (3rd generation); iOS 15.2; Scale/3.00)",
) )
private val AN_EXPECTED_RESULT_LIST_FOR_IOS = listOf( private val AN_EXPECTED_RESULT_LIST_FOR_IOS = listOf(
DeviceUserAgent(DeviceType.MOBILE, "iPhone", "iOS 15.2", "Element", "1.8.21"), DeviceExtendedInfo(DeviceType.MOBILE, "iPhone", "iOS 15.2", "Element", "1.8.21"),
DeviceUserAgent(DeviceType.MOBILE, "iPhone XS Max", "iOS 15.2", "Element", "1.8.21"), DeviceExtendedInfo(DeviceType.MOBILE, "iPhone XS Max", "iOS 15.2", "Element", "1.8.21"),
DeviceUserAgent(DeviceType.MOBILE, "iPad Pro (11-inch)", "iOS 15.2", "Element", "1.8.21"), DeviceExtendedInfo(DeviceType.MOBILE, "iPad Pro (11-inch)", "iOS 15.2", "Element", "1.8.21"),
DeviceUserAgent(DeviceType.MOBILE, "iPad Pro (12.9-inch) (3rd generation)", "iOS 15.2", DeviceExtendedInfo(DeviceType.MOBILE, "iPad Pro (12.9-inch) (3rd generation)", "iOS 15.2",
"Element", "1.8.21"), "Element", "1.8.21"),
) )
@ -61,8 +61,8 @@ private val A_USER_AGENT_LIST_FOR_DESKTOP = listOf(
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) ElementNightly/2022091301 Chrome/104.0.5112.102 Electron/20.1.1 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) ElementNightly/2022091301 Chrome/104.0.5112.102 Electron/20.1.1 Safari/537.36",
) )
private val AN_EXPECTED_RESULT_LIST_FOR_DESKTOP = listOf( private val AN_EXPECTED_RESULT_LIST_FOR_DESKTOP = listOf(
DeviceUserAgent(DeviceType.DESKTOP, "Electron", "Macintosh", null, null), DeviceExtendedInfo(DeviceType.DESKTOP, "Electron", "Macintosh", null, null),
DeviceUserAgent(DeviceType.DESKTOP, "Electron", "Windows NT 10.0", null, null), DeviceExtendedInfo(DeviceType.DESKTOP, "Electron", "Windows NT 10.0", null, null),
) )
private val A_USER_AGENT_LIST_FOR_WEB = listOf( private val A_USER_AGENT_LIST_FOR_WEB = listOf(
@ -77,15 +77,15 @@ private val A_USER_AGENT_LIST_FOR_WEB = listOf(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
) )
private val AN_EXPECTED_RESULT_LIST_FOR_WEB = listOf( private val AN_EXPECTED_RESULT_LIST_FOR_WEB = listOf(
DeviceUserAgent(DeviceType.WEB, "Chrome", "Macintosh", null, null), DeviceExtendedInfo(DeviceType.WEB, "Chrome", "Macintosh", null, null),
DeviceUserAgent(DeviceType.WEB, "Chrome", "Windows NT 10.0", null, null), DeviceExtendedInfo(DeviceType.WEB, "Chrome", "Windows NT 10.0", null, null),
DeviceUserAgent(DeviceType.WEB, "Firefox", "Macintosh", null, null), DeviceExtendedInfo(DeviceType.WEB, "Firefox", "Macintosh", null, null),
DeviceUserAgent(DeviceType.WEB, "Safari", "Macintosh", null, null), DeviceExtendedInfo(DeviceType.WEB, "Safari", "Macintosh", null, null),
DeviceUserAgent(DeviceType.WEB, "Chrome", "Android 9", null, null), DeviceExtendedInfo(DeviceType.WEB, "Chrome", "Android 9", null, null),
DeviceUserAgent(DeviceType.WEB, "Safari", "iPad", null, null), DeviceExtendedInfo(DeviceType.WEB, "Safari", "iPad", null, null),
DeviceUserAgent(DeviceType.WEB, "Safari", "iPhone", null, null), DeviceExtendedInfo(DeviceType.WEB, "Safari", "iPhone", null, null),
DeviceUserAgent(DeviceType.WEB, "Firefox", "Windows NT 6.0", null, null), DeviceExtendedInfo(DeviceType.WEB, "Firefox", "Windows NT 6.0", null, null),
DeviceUserAgent(DeviceType.WEB, "Edge", "Windows NT 10.0", null, null), DeviceExtendedInfo(DeviceType.WEB, "Edge", "Windows NT 10.0", null, null),
) )
private val AN_UNKNOWN_USER_AGENT_LIST = listOf( private val AN_UNKNOWN_USER_AGENT_LIST = listOf(
@ -93,8 +93,8 @@ private val AN_UNKNOWN_USER_AGENT_LIST = listOf(
"Curl Client/1.0", "Curl Client/1.0",
) )
private val AN_UNKNOWN_USER_AGENT_EXPECTED_RESULT_LIST = listOf( private val AN_UNKNOWN_USER_AGENT_EXPECTED_RESULT_LIST = listOf(
DeviceUserAgent(DeviceType.UNKNOWN, null, null, null, null), DeviceExtendedInfo(DeviceType.UNKNOWN, null, null, null, null),
DeviceUserAgent(DeviceType.UNKNOWN, null, null, null, null), DeviceExtendedInfo(DeviceType.UNKNOWN, null, null, null, null),
) )
class ParseDeviceUserAgentUseCaseTest { class ParseDeviceUserAgentUseCaseTest {

View File

@ -17,7 +17,7 @@
package im.vector.app.features.settings.devices.v2.filter package im.vector.app.features.settings.devices.v2.filter
import im.vector.app.features.settings.devices.v2.DeviceFullInfo import im.vector.app.features.settings.devices.v2.DeviceFullInfo
import im.vector.app.features.settings.devices.v2.DeviceUserAgent import im.vector.app.features.settings.devices.v2.DeviceExtendedInfo
import im.vector.app.features.settings.devices.v2.list.DeviceType import im.vector.app.features.settings.devices.v2.list.DeviceType
import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldContainAll import org.amshove.kluent.shouldContainAll
@ -37,7 +37,7 @@ private val activeVerifiedDevice = DeviceFullInfo(
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
isInactive = false, isInactive = false,
isCurrentDevice = true, isCurrentDevice = true,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
private val inactiveVerifiedDevice = DeviceFullInfo( private val inactiveVerifiedDevice = DeviceFullInfo(
deviceInfo = DeviceInfo(deviceId = "INACTIVE_VERIFIED_DEVICE"), deviceInfo = DeviceInfo(deviceId = "INACTIVE_VERIFIED_DEVICE"),
@ -49,7 +49,7 @@ private val inactiveVerifiedDevice = DeviceFullInfo(
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Trusted,
isInactive = true, isInactive = true,
isCurrentDevice = false, isCurrentDevice = false,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
private val activeUnverifiedDevice = DeviceFullInfo( private val activeUnverifiedDevice = DeviceFullInfo(
deviceInfo = DeviceInfo(deviceId = "ACTIVE_UNVERIFIED_DEVICE"), deviceInfo = DeviceInfo(deviceId = "ACTIVE_UNVERIFIED_DEVICE"),
@ -61,7 +61,7 @@ private val activeUnverifiedDevice = DeviceFullInfo(
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning,
isInactive = false, isInactive = false,
isCurrentDevice = false, isCurrentDevice = false,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
private val inactiveUnverifiedDevice = DeviceFullInfo( private val inactiveUnverifiedDevice = DeviceFullInfo(
deviceInfo = DeviceInfo(deviceId = "INACTIVE_UNVERIFIED_DEVICE"), deviceInfo = DeviceInfo(deviceId = "INACTIVE_UNVERIFIED_DEVICE"),
@ -73,7 +73,7 @@ private val inactiveUnverifiedDevice = DeviceFullInfo(
roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning, roomEncryptionTrustLevel = RoomEncryptionTrustLevel.Warning,
isInactive = true, isInactive = true,
isCurrentDevice = false, isCurrentDevice = false,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
private val devices = listOf( private val devices = listOf(

View File

@ -19,7 +19,7 @@ package im.vector.app.features.settings.devices.v2.overview
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.asFlow import androidx.lifecycle.asFlow
import im.vector.app.features.settings.devices.v2.DeviceFullInfo import im.vector.app.features.settings.devices.v2.DeviceFullInfo
import im.vector.app.features.settings.devices.v2.DeviceUserAgent import im.vector.app.features.settings.devices.v2.DeviceExtendedInfo
import im.vector.app.features.settings.devices.v2.ParseDeviceUserAgentUseCase import im.vector.app.features.settings.devices.v2.ParseDeviceUserAgentUseCase
import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase
import im.vector.app.features.settings.devices.v2.list.DeviceType import im.vector.app.features.settings.devices.v2.list.DeviceType
@ -92,7 +92,7 @@ class GetDeviceFullInfoUseCaseTest {
val isInactive = false val isInactive = false
val isCurrentDevice = true val isCurrentDevice = true
every { checkIfSessionIsInactiveUseCase.execute(any()) } returns isInactive every { checkIfSessionIsInactiveUseCase.execute(any()) } returns isInactive
every { parseDeviceUserAgentUseCase.execute(any()) } returns DeviceUserAgent(DeviceType.MOBILE) every { parseDeviceUserAgentUseCase.execute(any()) } returns DeviceExtendedInfo(DeviceType.MOBILE)
// When // When
val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull() val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull()
@ -104,7 +104,7 @@ class GetDeviceFullInfoUseCaseTest {
roomEncryptionTrustLevel = trustLevel, roomEncryptionTrustLevel = trustLevel,
isInactive = isInactive, isInactive = isInactive,
isCurrentDevice = isCurrentDevice, isCurrentDevice = isCurrentDevice,
deviceUserAgent = DeviceUserAgent(DeviceType.MOBILE) deviceExtendedInfo = DeviceExtendedInfo(DeviceType.MOBILE)
) )
verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } verify { fakeActiveSessionHolder.instance.getSafeActiveSession() }
verify { getCurrentSessionCrossSigningInfoUseCase.execute() } verify { getCurrentSessionCrossSigningInfoUseCase.execute() }