Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class MainActivityViewModel @AssistedInject constructor(
private val rPcrExtractor: RapidPcrQrCodeExtractor,
private val coronaTestQRCodeHandler: CoronaTestQRCodeHandler,
private val coronaTestRestoreHandler: CoronaTestRestoreHandler,
private val appEol: AppEol,
coronaTestRepository: CoronaTestRepository,
familyTestRepository: FamilyTestRepository,
checkInRepository: CheckInRepository,
personCertificatesProvider: PersonCertificatesProvider,
valueSetRepository: ValueSetsRepository,
tracingSettings: TracingSettings,
appEol: AppEol,
) : CWAViewModel(
dispatcherProvider = dispatcherProvider
) {
Expand Down Expand Up @@ -162,6 +162,10 @@ class MainActivityViewModel @AssistedInject constructor(
}

fun onNavigationUri(uriString: String) = launch {
if (appEol.isEol.first()) {
Timber.d("EOL -> skip deep-links")
return@launch
}
when {
CheckInsFragment.canHandle(uriString) -> event.postValue(
MainActivityEvent.GoToCheckInsFragment(uriString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@ class MainActivityViewModelTest2 : BaseTest() {
}
}

@Test
fun `onNavigationUri - R-PCR test uri string at EOL`() {
every { appEol.isEol } returns flowOf(true)
val coronaTestQrCode = CoronaTestQRCode.RapidPCR(
rawQrCode = "rawQrCode",
hash = "hash",
createdAt = Instant.EPOCH
)
val uriString = "R-PCR uri string"
val result = CoronaTestQRCodeHandler.TestRegistrationSelection(coronaTestQrCode)

coEvery { rPcrExtractor.canHandle(uriString) } returns true
coEvery { rPcrExtractor.extract(uriString) } returns coronaTestQrCode
coEvery { coronaTestQRCodeHandler.handleQrCode(coronaTestQrCode) } returns result

createInstance().onNavigationUri(uriString)

coVerify(exactly = 0) { coronaTestQRCodeHandler.handleQrCode(coronaTestQrCode) }
}

@Test
fun `onNavigationUri - RAT test uri string`() {
val coronaTestQrCode = CoronaTestQRCode.RapidAntigen(
Expand All @@ -215,6 +235,27 @@ class MainActivityViewModelTest2 : BaseTest() {
}
}

@Test
fun `onNavigationUri - RAT test uri string at EOL`() {
every { appEol.isEol } returns flowOf(true)
val coronaTestQrCode = CoronaTestQRCode.RapidAntigen(
rawQrCode = "rawQrCode",
hash = "hash",
createdAt = Instant.EPOCH
)
val uriString = "RAT uri string"
val result = CoronaTestQRCodeHandler.TestRegistrationSelection(coronaTestQrCode)

coEvery { raExtractor.canHandle(uriString) } returns true
coEvery { raExtractor.extract(uriString) } returns coronaTestQrCode
coEvery { coronaTestQRCodeHandler.handleQrCode(coronaTestQrCode) } returns result

createInstance().onNavigationUri(uriString)
coVerify(exactly = 0) {
coronaTestQRCodeHandler.handleQrCode(coronaTestQrCode)
}
}

@Test
fun `restoreCoronaTest calls CoronaTestRestoreHandler`() {
val recycledPCR = PCRCoronaTest(
Expand Down