Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/release/3.2.x' into release/3.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuraiKek committed Mar 30, 2023
2 parents 54e4fa2 + 188a725 commit 81e255e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import testhelpers.recyclerScrollTo
import testhelpers.setViewVisibility
import testhelpers.takeScreenshot
import timber.log.Timber
import java.util.Locale

@RunWith(AndroidJUnit4::class)
class HomeFragmentTest : BaseUITest() {
Expand Down Expand Up @@ -400,13 +401,22 @@ class HomeFragmentTest : BaseUITest() {
private fun homeFragmentItemsLiveData(
tracingStateItem: TracingStateItem = HomeData.Tracing.LOW_RISK_ITEM_WITH_ENCOUNTERS,
submissionTestResultItems: List<TestResultItem> = listOf(HomeData.Submission.TEST_UNREGISTERED_ITEM),
showRampDownNotice: Boolean = false
showRampDownNotice: Boolean = true
): LiveData<List<HomeItem>> =
MutableLiveData(
mutableListOf<HomeItem>().apply {

if (showRampDownNotice) {
add(getRampDownNotice())
val germanTitle = "Acthung!"
val englishTitle = "Important!"
val germanSubtitle =
"Es wird nur noch bis zum 30. April 2023 möglich sein, andere Personen über die Corona-Warn-App zu warnen!"
val englishSubtitle =
"You will only be able to warn others through the Crorona-Warn-App until April 30, 2023"
when (Locale.getDefault().displayLanguage) {
"de" -> add(getRampDownNotice(germanTitle, germanSubtitle))
else -> add(getRampDownNotice(englishTitle, englishSubtitle))
}
}

val hideTracingState = submissionTestResultItems.any {
Expand All @@ -428,12 +438,12 @@ class HomeFragmentTest : BaseUITest() {
}
)

private fun getRampDownNotice() = RampDownNoticeCard.Item(
private fun getRampDownNotice(title: String, subtitle: String) = RampDownNoticeCard.Item(
onClickAction = {},
rampDownNotice = RampDownNotice(
visible = true,
title = "Betriebsende",
subtitle = "Der Betrieb der Corona-Warn-App wird am xx.xx.xxxx eingestellt.",
title = title,
subtitle = subtitle,
description = "",
faqUrl = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import de.rki.coronawarnapp.environment.EnvironmentSetup
import de.rki.coronawarnapp.environment.EnvironmentSetup.Type.Companion.toEnvironmentType
import de.rki.coronawarnapp.eol.AppEol
import de.rki.coronawarnapp.eol.EolSetting
import de.rki.coronawarnapp.test.debugoptions.ui.EnvironmentState.Companion.toEnvironmentState
import de.rki.coronawarnapp.util.coroutine.AppScope
Expand All @@ -14,11 +15,13 @@ import de.rki.coronawarnapp.util.viewmodel.CWAViewModel
import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch

class DebugOptionsFragmentViewModel @AssistedInject constructor(
private val envSetup: EnvironmentSetup,
private val eolSetting: EolSetting,
private val eol: AppEol,
dispatcherProvider: DispatcherProvider,
private val environmentSunset: EnvironmentSunset,
@AppScope private val appScope: CoroutineScope,
Expand All @@ -36,23 +39,25 @@ class DebugOptionsFragmentViewModel @AssistedInject constructor(
environmentStateFlow.value = it
environmentStateChange.postValue(it)
}
cleanCachedData()
cleanCachedDataIfNotEol()
}

fun selectEnvironmentType(type: String) {
envSetup.currentEnvironment = type.toEnvironmentType()
envSetup.toEnvironmentState().let {
environmentStateFlow.value = it
}
cleanCachedData()
cleanCachedDataIfNotEol()
}

fun setAllowedFlag(flag: Boolean) = launch {
eolSetting.setLoggerAllowed(flag)
}

private fun cleanCachedData() = appScope.launch {
environmentSunset.reset()
private fun cleanCachedDataIfNotEol() = appScope.launch {
if (!eol.isEol.first()) {
environmentSunset.reset()
}
}

@AssistedFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.rki.coronawarnapp.test.debugoptions.ui

import de.rki.coronawarnapp.environment.EnvironmentSetup
import de.rki.coronawarnapp.eol.AppEol
import de.rki.coronawarnapp.eol.EolSetting
import io.kotest.matchers.shouldBe
import io.mockk.MockKAnnotations
Expand All @@ -21,6 +22,7 @@ class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() {
@MockK private lateinit var environmentSetup: EnvironmentSetup
@MockK private lateinit var environmentSunset: EnvironmentSunset
@MockK private lateinit var eolSetting: EolSetting
@MockK private lateinit var eol: AppEol

private var currentEnvironment = EnvironmentSetup.Type.DEV

Expand All @@ -44,6 +46,7 @@ class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() {
every { environmentSetup.currentEnvironment } answers { currentEnvironment }
every { environmentSetup.launchEnvironment } returns null
every { eolSetting.isLoggerAllowed } returns flowOf(false)
every { eol.isEol } returns flowOf(false)
}

private fun createViewModel(): DebugOptionsFragmentViewModel = DebugOptionsFragmentViewModel(
Expand All @@ -52,6 +55,7 @@ class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() {
environmentSunset = environmentSunset,
appScope = TestScope(),
eolSetting = eolSetting,
eol = eol
)

@Test
Expand Down

0 comments on commit 81e255e

Please sign in to comment.