mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-01 11:46:57 +01:00
Fix broken tests.
This commit is contained in:
parent
8663fe8c74
commit
38cd2be332
@ -73,7 +73,7 @@ class GetDeviceFullInfoListUseCase @Inject constructor(
|
|||||||
val roomEncryptionTrustLevel = getEncryptionTrustLevelForDeviceUseCase.execute(currentSessionCrossSigningInfo, cryptoDeviceInfo)
|
val roomEncryptionTrustLevel = getEncryptionTrustLevelForDeviceUseCase.execute(currentSessionCrossSigningInfo, cryptoDeviceInfo)
|
||||||
val isInactive = checkIfSessionIsInactiveUseCase.execute(deviceInfo.lastSeenTs ?: 0)
|
val isInactive = checkIfSessionIsInactiveUseCase.execute(deviceInfo.lastSeenTs ?: 0)
|
||||||
val isCurrentDevice = currentSessionCrossSigningInfo.deviceId == cryptoDeviceInfo?.deviceId
|
val isCurrentDevice = currentSessionCrossSigningInfo.deviceId == cryptoDeviceInfo?.deviceId
|
||||||
val deviceUserAgent = parseDeviceUserAgentUseCase.execute(deviceInfo.lastSeenUserAgent)
|
val deviceUserAgent = parseDeviceUserAgentUseCase.execute(deviceInfo.getBestLastSeenUserAgent())
|
||||||
DeviceFullInfo(deviceInfo, cryptoDeviceInfo, roomEncryptionTrustLevel, isInactive, isCurrentDevice, deviceUserAgent)
|
DeviceFullInfo(deviceInfo, cryptoDeviceInfo, roomEncryptionTrustLevel, isInactive, isCurrentDevice, deviceUserAgent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class GetDeviceFullInfoUseCase @Inject constructor(
|
|||||||
val roomEncryptionTrustLevel = getEncryptionTrustLevelForDeviceUseCase.execute(currentSessionCrossSigningInfo, cryptoInfo)
|
val roomEncryptionTrustLevel = getEncryptionTrustLevelForDeviceUseCase.execute(currentSessionCrossSigningInfo, cryptoInfo)
|
||||||
val isInactive = checkIfSessionIsInactiveUseCase.execute(info.lastSeenTs ?: 0)
|
val isInactive = checkIfSessionIsInactiveUseCase.execute(info.lastSeenTs ?: 0)
|
||||||
val isCurrentDevice = currentSessionCrossSigningInfo.deviceId == cryptoInfo.deviceId
|
val isCurrentDevice = currentSessionCrossSigningInfo.deviceId == cryptoInfo.deviceId
|
||||||
val deviceUserAgent = parseDeviceUserAgentUseCase.execute(info.lastSeenUserAgent)
|
val deviceUserAgent = parseDeviceUserAgentUseCase.execute(info.getBestLastSeenUserAgent())
|
||||||
DeviceFullInfo(
|
DeviceFullInfo(
|
||||||
deviceInfo = info,
|
deviceInfo = info,
|
||||||
cryptoDeviceInfo = cryptoInfo,
|
cryptoDeviceInfo = cryptoInfo,
|
||||||
|
@ -46,6 +46,7 @@ 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 {
|
||||||
|
|
||||||
@ -90,21 +91,24 @@ class GetDeviceFullInfoListUseCaseTest {
|
|||||||
lastSeenTs = A_TIMESTAMP_1,
|
lastSeenTs = A_TIMESTAMP_1,
|
||||||
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,
|
||||||
lastSeenTs = A_TIMESTAMP_2,
|
lastSeenTs = A_TIMESTAMP_2,
|
||||||
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,
|
||||||
lastSeenTs = A_TIMESTAMP_3,
|
lastSeenTs = A_TIMESTAMP_3,
|
||||||
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)
|
||||||
@ -188,12 +192,21 @@ 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 { 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(
|
||||||
|
DeviceType.MOBILE,
|
||||||
|
"Xiaomi Mi 9T",
|
||||||
|
"Android 11",
|
||||||
|
"Element dbg",
|
||||||
|
"1.5.0-dev"
|
||||||
|
)
|
||||||
|
|
||||||
return deviceInfo
|
return deviceInfo
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class GetDeviceFullInfoUseCaseTest {
|
|||||||
// Given
|
// Given
|
||||||
val currentSessionCrossSigningInfo = givenCurrentSessionCrossSigningInfo()
|
val currentSessionCrossSigningInfo = givenCurrentSessionCrossSigningInfo()
|
||||||
val deviceInfo = DeviceInfo(
|
val deviceInfo = DeviceInfo(
|
||||||
lastSeenTs = A_TIMESTAMP
|
lastSeenTs = A_TIMESTAMP,
|
||||||
)
|
)
|
||||||
fakeActiveSessionHolder.fakeSession.fakeCryptoService.myDevicesInfoWithIdLiveData = MutableLiveData(Optional(deviceInfo))
|
fakeActiveSessionHolder.fakeSession.fakeCryptoService.myDevicesInfoWithIdLiveData = MutableLiveData(Optional(deviceInfo))
|
||||||
fakeActiveSessionHolder.fakeSession.fakeCryptoService.myDevicesInfoWithIdLiveData.givenAsFlow()
|
fakeActiveSessionHolder.fakeSession.fakeCryptoService.myDevicesInfoWithIdLiveData.givenAsFlow()
|
||||||
@ -92,6 +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)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull()
|
val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user