mirror of
https://github.com/bitwarden/android.git
synced 2026-02-03 18:17:54 -06:00
Remove flaky tests (#6278)
This commit is contained in:
parent
c16da5090e
commit
913d877737
@ -1,6 +1,5 @@
|
||||
package com.x8bit.bitwarden.ui.vault.feature.qrcodescan
|
||||
|
||||
import androidx.camera.core.ImageProxy
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
|
||||
import com.bitwarden.ui.platform.feature.qrcodescan.util.FakeQrCodeAnalyzer
|
||||
@ -20,7 +19,6 @@ class QrCodeScanScreenTest : BitwardenComposeTest() {
|
||||
private var onNavigateBackCalled = false
|
||||
private var onNavigateToManualCodeEntryScreenCalled = false
|
||||
|
||||
private val imageProxy: ImageProxy = mockk()
|
||||
private val qrCodeAnalyzer = FakeQrCodeAnalyzer()
|
||||
|
||||
private val mutableEventFlow = bufferedMutableSharedFlow<QrCodeScanEvent>()
|
||||
@ -56,30 +54,6 @@ class QrCodeScanScreenTest : BitwardenComposeTest() {
|
||||
assertTrue(onNavigateToManualCodeEntryScreenCalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when a scan is successful a result will be sent`() = runTest {
|
||||
val result = "testCode"
|
||||
|
||||
qrCodeAnalyzer.scanResult = result
|
||||
qrCodeAnalyzer.analyze(imageProxy)
|
||||
|
||||
verify {
|
||||
viewModel.trySendAction(QrCodeScanAction.QrCodeScanReceive(result))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when a scan is unsuccessful a result will not be sent`() = runTest {
|
||||
val result = "testCode"
|
||||
|
||||
qrCodeAnalyzer.scanResult = null
|
||||
qrCodeAnalyzer.analyze(imageProxy)
|
||||
|
||||
verify(exactly = 0) {
|
||||
viewModel.trySendAction(QrCodeScanAction.QrCodeScanReceive(result))
|
||||
}
|
||||
}
|
||||
|
||||
@Config(qualifiers = "land")
|
||||
@Test
|
||||
fun `clicking on manual text should send ManualEntryTextClick in landscape mode`() = runTest {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.bitwarden.ui.platform.components.camera
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.camera.compose.CameraXViewfinder
|
||||
import androidx.camera.core.CameraSelector
|
||||
import androidx.camera.core.ImageAnalysis
|
||||
@ -38,6 +39,8 @@ fun CameraPreview(
|
||||
context: Context = LocalContext.current,
|
||||
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
|
||||
) {
|
||||
// We simply do not draw anything when running in tests to avoid flaky HardwareRenderer issues
|
||||
if ("robolectric" == Build.FINGERPRINT) return
|
||||
val surfaceRequests = remember { MutableStateFlow<SurfaceRequest?>(null) }
|
||||
val preview = rememberPreview { surfaceRequests.value = it }
|
||||
val imageAnalyzer = rememberImageAnalyzer(qrCodeAnalyzer = qrCodeAnalyzer)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user