diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/contactdiary/ui/ContactDiaryTestFragment.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/contactdiary/ui/ContactDiaryTestFragment.kt index 7ff3c8f2039548359ae0d95a8412e986c6c077f9..cfdd87475055c07c19a3c39bbc002a167f44e2ed 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/contactdiary/ui/ContactDiaryTestFragment.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/contactdiary/ui/ContactDiaryTestFragment.kt @@ -5,8 +5,8 @@ import android.os.Bundle import android.view.View import androidx.fragment.app.Fragment import de.rki.coronawarnapp.R -import de.rki.coronawarnapp.contactdiary.ui.durationpicker.ContactDiaryDurationPickerFragment -import de.rki.coronawarnapp.contactdiary.ui.durationpicker.toContactDiaryFormat +import de.rki.coronawarnapp.ui.durationpicker.DurationPicker +import de.rki.coronawarnapp.ui.durationpicker.toContactDiaryFormat import de.rki.coronawarnapp.databinding.FragmentTestContactDiaryBinding import de.rki.coronawarnapp.test.menu.ui.TestMenuItem import de.rki.coronawarnapp.util.di.AutoInject @@ -21,7 +21,7 @@ import javax.inject.Inject class ContactDiaryTestFragment : Fragment(R.layout.fragment_test_contact_diary), AutoInject, - ContactDiaryDurationPickerFragment.OnChangeListener { + DurationPicker.OnChangeListener { @Inject lateinit var viewModelFactory: CWAViewModelFactoryProvider.Factory private val vm: ContactDiaryTestFragmentViewModel by cwaViewModels { viewModelFactory } @@ -49,15 +49,11 @@ class ContactDiaryTestFragment : locationVisitsCleanButton.setOnClickListener { vm.clearLocationVisits() } personEncountersCleanButton.setOnClickListener { vm.clearPersonEncounters() } durationValue.setOnClickListener { - val args = Bundle() - args.putString( - ContactDiaryDurationPickerFragment.DURATION_ARGUMENT_KEY, - binding.durationValue.text.toString() - ) - - val durationPicker = ContactDiaryDurationPickerFragment() - durationPicker.arguments = args - durationPicker.setTargetFragment(this@ContactDiaryTestFragment, 0) + val durationPicker = DurationPicker.Builder() + .duration(binding.durationValue.text.toString()) + .title(getString(R.string.duration_dialog_title)) + .build() + durationPicker.setDurationChangeListener(this@ContactDiaryTestFragment) durationPicker.show(parentFragmentManager, "ContactDiaryDurationPickerFragment") } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/ContactDiaryLocationListFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/ContactDiaryLocationListFragment.kt index 0f0c7b70793d83e01fff88271e34ad82d0d05fa4..534f274d562592f2e69995d75a001a54e982ab6d 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/ContactDiaryLocationListFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/ContactDiaryLocationListFragment.kt @@ -8,10 +8,9 @@ import androidx.navigation.fragment.navArgs import de.rki.coronawarnapp.R import de.rki.coronawarnapp.contactdiary.ui.day.ContactDiaryDayFragment import de.rki.coronawarnapp.contactdiary.ui.day.ContactDiaryDayFragmentDirections -import de.rki.coronawarnapp.contactdiary.ui.durationpicker.ContactDiaryDurationPickerFragment +import de.rki.coronawarnapp.ui.durationpicker.DurationPicker import de.rki.coronawarnapp.contactdiary.util.MarginRecyclerViewDecoration import de.rki.coronawarnapp.databinding.ContactDiaryLocationListFragmentBinding -import de.rki.coronawarnapp.ui.doNavigate import de.rki.coronawarnapp.util.di.AutoInject import de.rki.coronawarnapp.util.lists.diffutil.update import de.rki.coronawarnapp.util.onScroll @@ -20,13 +19,11 @@ import de.rki.coronawarnapp.util.ui.observe2 import de.rki.coronawarnapp.util.ui.viewBindingLazy import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactoryProvider import de.rki.coronawarnapp.util.viewmodel.cwaViewModelsAssisted -import org.joda.time.Duration import javax.inject.Inject class ContactDiaryLocationListFragment : Fragment(R.layout.contact_diary_location_list_fragment), - AutoInject, - ContactDiaryDurationPickerFragment.OnChangeListener { + AutoInject { private val binding: ContactDiaryLocationListFragmentBinding by viewBindingLazy() @@ -64,13 +61,14 @@ class ContactDiaryLocationListFragment : } viewModel.openDialog.observe2(this) { - val args = Bundle() - args.putString(ContactDiaryDurationPickerFragment.DURATION_ARGUMENT_KEY, it) - - val durationPicker = ContactDiaryDurationPickerFragment() - durationPicker.arguments = args - durationPicker.setTargetFragment(this@ContactDiaryLocationListFragment, 0) - durationPicker.show(parentFragmentManager, "ContactDiaryDurationPickerFragment") + val durationPicker = DurationPicker.Builder() + .duration(it) + .title(getString(R.string.duration_dialog_title)) + .build() + durationPicker.show(parentFragmentManager, "DurationPicker") + durationPicker.setDurationChangeListener { duration -> + viewModel.onDurationSelected(duration) + } } viewModel.openCommentInfo.observe2(this) { @@ -80,8 +78,4 @@ class ContactDiaryLocationListFragment : ) } } - - override fun onChange(duration: Duration) { - viewModel.onDurationSelected(duration) - } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/DiaryLocationViewHolder.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/DiaryLocationViewHolder.kt index 04b9002702564da8d4e563cf8e35509226cb22e0..20ebb65500b9cfbf443ab374e222f3a59b7b348a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/DiaryLocationViewHolder.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/location/DiaryLocationViewHolder.kt @@ -3,8 +3,8 @@ package de.rki.coronawarnapp.contactdiary.ui.day.tabs.location import android.view.ViewGroup import android.view.accessibility.AccessibilityEvent import de.rki.coronawarnapp.R -import de.rki.coronawarnapp.contactdiary.ui.durationpicker.toContactDiaryFormat import de.rki.coronawarnapp.contactdiary.util.setClickLabel +import de.rki.coronawarnapp.ui.durationpicker.toContactDiaryFormat import de.rki.coronawarnapp.databinding.ContactDiaryLocationListItemBinding import de.rki.coronawarnapp.ui.lists.BaseAdapter import de.rki.coronawarnapp.util.lists.BindableVH diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporter.kt index 56cf164dfaaa4eec768466c8a7df5eff3d14e31a..4cb7160f87fa67b31e8e3db60b49d77139410b14 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporter.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporter.kt @@ -5,7 +5,7 @@ import dagger.Reusable import de.rki.coronawarnapp.R import de.rki.coronawarnapp.contactdiary.model.ContactDiaryLocationVisit import de.rki.coronawarnapp.contactdiary.model.ContactDiaryPersonEncounter -import de.rki.coronawarnapp.contactdiary.ui.durationpicker.toReadableDuration +import de.rki.coronawarnapp.ui.durationpicker.toReadableDuration import de.rki.coronawarnapp.util.TimeAndDateExtensions.toLocalDate import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.coroutine.DispatcherProvider diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/adapter/day/DayDataNestedAdapter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/adapter/day/DayDataNestedAdapter.kt index adeb5f4ab50a89894610b09b4fbf56f144456a6b..b0cc6fb871c794021930ae919214725af1a11d9b 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/adapter/day/DayDataNestedAdapter.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/adapter/day/DayDataNestedAdapter.kt @@ -3,7 +3,7 @@ package de.rki.coronawarnapp.contactdiary.ui.overview.adapter.day import android.view.View import android.view.ViewGroup import de.rki.coronawarnapp.R -import de.rki.coronawarnapp.contactdiary.ui.durationpicker.toReadableDuration +import de.rki.coronawarnapp.ui.durationpicker.toReadableDuration import de.rki.coronawarnapp.contactdiary.util.clearAndAddAll import de.rki.coronawarnapp.databinding.ContactDiaryOverviewNestedListItemBinding import de.rki.coronawarnapp.ui.lists.BaseAdapter diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt index 1feb415e71dd3e6ce4951b4e8dff34ccc8caa7ae..6424a0ef5f904ae99a655f7981b765056854d097 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt @@ -49,6 +49,8 @@ interface RiskLevelResult { aggregatedRiskResult?.mostRecentDateWithLowRisk } + val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + enum class FailureReason(val failureCode: String) { UNKNOWN("unknown"), TRACING_OFF("tracingOff"), diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt index 8911020fcceda4ed3392ce67d19b7d5bad108f87..7ce685ff0adb00c276cc5f1ab1c41e5827f12d30 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt @@ -30,6 +30,8 @@ private object InitialLowLevelRiskLevelResult : RiskLevelResult { override val exposureWindows: List<ExposureWindow>? = null override val matchedKeyCount: Int = 0 override val daysWithEncounters: Int = 0 + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // TODO("Not yet implemented") } private object UndeterminedRiskLevelResult : RiskLevelResult { @@ -40,4 +42,6 @@ private object UndeterminedRiskLevelResult : RiskLevelResult { override val exposureWindows: List<ExposureWindow>? = null override val matchedKeyCount: Int = 0 override val daysWithEncounters: Int = 0 + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // TODO("Not yet implemented") } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt index deddc698d80068ace635d18f229796dada054d07..bdb133d2e01213e721b373fa0818e7ac99096b4c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt @@ -33,6 +33,9 @@ data class RiskLevelTaskResult( exposureWindows = null ) + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // TODO("Not yet implemented") + override fun toString(): String = "RiskLevelTaskResult(" + "calculatedAt=$calculatedAt, " + "failureReason=$failureReason, " + diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt new file mode 100644 index 0000000000000000000000000000000000000000..b62398a1c0f006b6fd1008914a491c8eb0c2ead0 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt @@ -0,0 +1,6 @@ +package de.rki.coronawarnapp.risk + +interface TraceLocationCheckInRisk { + val checkInId: Long + val riskState: RiskState +} diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/DurationExtension.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/durationpicker/DurationExtension.kt similarity index 93% rename from Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/DurationExtension.kt rename to Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/durationpicker/DurationExtension.kt index dad157251d0fcaf2966a42aff1ecc2c5a6c55c3a..40c79fb1f9797e4648c94cd5a4118979420357cd 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/DurationExtension.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/durationpicker/DurationExtension.kt @@ -1,4 +1,4 @@ -package de.rki.coronawarnapp.contactdiary.ui.durationpicker +package de.rki.coronawarnapp.ui.durationpicker import org.joda.time.Duration diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/ContactDiaryDurationPickerFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/durationpicker/DurationPicker.kt similarity index 60% rename from Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/ContactDiaryDurationPickerFragment.kt rename to Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/durationpicker/DurationPicker.kt index 5e14d2498e8c64bc8a44643e14a3b528f1dc0f4f..044f141c44b8000381924604ccf13d4d7278fd88 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/ContactDiaryDurationPickerFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/durationpicker/DurationPicker.kt @@ -1,26 +1,23 @@ -package de.rki.coronawarnapp.contactdiary.ui.durationpicker +package de.rki.coronawarnapp.ui.durationpicker import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.DialogFragment -import de.rki.coronawarnapp.databinding.ContactDiaryDurationPickerDialogFragmentBinding +import de.rki.coronawarnapp.databinding.DurationPickerBinding import org.joda.time.Duration import org.joda.time.format.PeriodFormatter import org.joda.time.format.PeriodFormatterBuilder -class ContactDiaryDurationPickerFragment : DialogFragment() { +class DurationPicker : DialogFragment() { - interface OnChangeListener { + fun interface OnChangeListener { fun onChange(duration: Duration) } - val binding: Lazy<ContactDiaryDurationPickerDialogFragmentBinding> = lazy { - ContactDiaryDurationPickerDialogFragmentBinding.inflate( - layoutInflater - ) - } + private var onChangeListener: OnChangeListener? = null + private val binding: Lazy<DurationPickerBinding> = lazy { DurationPickerBinding.inflate(layoutInflater) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { return binding.value.root @@ -42,7 +39,7 @@ class ContactDiaryDurationPickerFragment : DialogFragment() { } with(binding.value) { - var duration = requireArguments().getString(DURATION_ARGUMENT_KEY)!!.split(":").toTypedArray() + var duration = requireArguments().getString(DURATION_KEY)!!.split(":").toTypedArray() if (duration.size < 2) duration = arrayOf("00", "00") hours.value = hoursArray.indexOf(duration[0]) @@ -50,15 +47,19 @@ class ContactDiaryDurationPickerFragment : DialogFragment() { cancelButton.setOnClickListener { dismiss() } okButton.setOnClickListener { - (targetFragment as? OnChangeListener)?.onChange(getDuration(hours.value, minutes.value)) + onChangeListener?.onChange(getDuration(hours.value, minutes.value)) dismiss() } } } - companion object { - const val DURATION_ARGUMENT_KEY = "duration" + fun setDurationChangeListener(onChangeListener: OnChangeListener) { + this.onChangeListener = onChangeListener + } + companion object { + private const val DURATION_KEY = "duration" + private const val TITLE_KEY = "title" val minutesArray = arrayOf("00", "15", "30", "45") val hoursArray = Array(24) { "%02d".format(it) } @@ -71,5 +72,24 @@ class ContactDiaryDurationPickerFragment : DialogFragment() { .toFormatter() return formatter.parsePeriod(durationString).toStandardDuration() } + + private fun newInstance(builder: Builder) = DurationPicker() + .apply { + arguments = Bundle().apply { + putString(DURATION_KEY, builder.duration) + putString(TITLE_KEY, builder.title) + } + } + } + + class Builder { + var title: String = "" + private set + var duration: String = "" + private set + + fun title(title: String) = apply { this.title = title } + fun duration(duration: String) = apply { this.duration = duration } + fun build() = newInstance(this) } } diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_duration_picker_dialog_fragment.xml b/Corona-Warn-App/src/main/res/layout/duration_picker.xml similarity index 98% rename from Corona-Warn-App/src/main/res/layout/contact_diary_duration_picker_dialog_fragment.xml rename to Corona-Warn-App/src/main/res/layout/duration_picker.xml index 882b3e971552b8a976f45642f1cc8cda17d39a67..3e165988d2a1197c8a113c542334a3de82c249f4 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_duration_picker_dialog_fragment.xml +++ b/Corona-Warn-App/src/main/res/layout/duration_picker.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/duration_container" android:layout_width="match_parent" + tools:context="de.rki.coronawarnapp.ui.durationpicker.DurationPicker" android:layout_height="wrap_content"> <TextView diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/ContactDiaryDurationPickerFragmentTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/ContactDiaryDurationPickerFragmentTest.kt deleted file mode 100644 index 3506e3065244d200abf8c8d573f9b267fdc83a38..0000000000000000000000000000000000000000 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/ContactDiaryDurationPickerFragmentTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -package de.rki.coronawarnapp.contactdiary.ui.durationpicker - -import io.kotest.matchers.shouldBe -import io.mockk.MockKAnnotations -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class ContactDiaryDurationPickerFragmentTest { - - @BeforeEach - fun setup() { - MockKAnnotations.init(this) - } - - @Test - fun `check hours array`() { - ContactDiaryDurationPickerFragment.hoursArray.count() shouldBe 24 - for (i in 0..9) { - ContactDiaryDurationPickerFragment.hoursArray[i] shouldBe "0$i" - } - for (i in 10..23) { - ContactDiaryDurationPickerFragment.hoursArray[i] shouldBe "$i" - } - } - - @Test - fun `check minutes array`() { - ContactDiaryDurationPickerFragment.minutesArray.count() shouldBe 4 - ContactDiaryDurationPickerFragment.minutesArray[0] shouldBe "00" - for (i in 1..3) { - ContactDiaryDurationPickerFragment.minutesArray[i] shouldBe "${i * 15}" - } - } - - @Test - fun `check duration`() { - ContactDiaryDurationPickerFragment.getDuration(0, 0).toContactDiaryFormat() shouldBe "00:00" - ContactDiaryDurationPickerFragment.getDuration(1, 0).toContactDiaryFormat() shouldBe "01:00" - ContactDiaryDurationPickerFragment.getDuration(23, 3).toContactDiaryFormat() shouldBe "23:45" - ContactDiaryDurationPickerFragment.getDuration(9, 2).toContactDiaryFormat() shouldBe "09:30" - ContactDiaryDurationPickerFragment.getDuration(10, 1).toContactDiaryFormat() shouldBe "10:15" - } -} diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt index 8e65fb16cf165c58a2429ccf987cde6fba68609d..f40a42669d9f633f50cf526f7c219e27ae27e111 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt @@ -5,6 +5,7 @@ import de.rki.coronawarnapp.appconfig.ConfigData import de.rki.coronawarnapp.datadonation.analytics.modules.exposureriskmetadata.ExposureRiskMetadataDonor import de.rki.coronawarnapp.datadonation.analytics.storage.AnalyticsSettings import de.rki.coronawarnapp.risk.RiskLevelResult +import de.rki.coronawarnapp.risk.TraceLocationCheckInRisk import de.rki.coronawarnapp.risk.result.AggregatedRiskResult import de.rki.coronawarnapp.risk.storage.RiskLevelStorage import de.rki.coronawarnapp.server.protocols.internal.ppdd.PpaData @@ -51,6 +52,8 @@ class ExposureRiskMetadataDonorTest : BaseTest() { override val exposureWindows: List<ExposureWindow>? = null override val matchedKeyCount: Int = 0 override val daysWithEncounters: Int = 0 + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // todo } private fun createInstance() = ExposureRiskMetadataDonor( diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt index 13fea4bb9f7b0a2bb24c3848256cfe2431e2ba14..7840e75c702b5a957a8c5d2689f819849551791f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt @@ -68,6 +68,8 @@ class RiskLevelChangeDetectorTest : BaseTest() { override val exposureWindows: List<ExposureWindow>? = null override val matchedKeyCount: Int = 0 override val daysWithEncounters: Int = 0 + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // TODO } private fun createInstance(scope: CoroutineScope) = RiskLevelChangeDetector( diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt index 986a67bc737f9244c8c9677b354360a77802aac8..61f5e691cadca7bdef7fd97c730fe069e7e000e4 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt @@ -22,10 +22,12 @@ class RiskLevelResultExtensionsTest : BaseTest() { override val exposureWindows: List<ExposureWindow>? = null override val matchedKeyCount: Int = 0 override val daysWithEncounters: Int = 0 + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // TODO("Not yet implemented") } @Test - fun `getLastestAndLastSuccessful on empty results`() { + fun `getLatestAndLastSuccessful on empty results`() { val emptyResults = emptyList<RiskLevelResult>() emptyResults.tryLatestResultsWithDefaults().apply { @@ -41,7 +43,7 @@ class RiskLevelResultExtensionsTest : BaseTest() { } @Test - fun `getLastestAndLastSuccessful last calculation was successful`() { + fun `getLatestAndLastSuccessful last calculation was successful`() { val results = listOf( createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH), createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH.plus(1)) @@ -54,7 +56,7 @@ class RiskLevelResultExtensionsTest : BaseTest() { } @Test - fun `getLastestAndLastSuccessful last calculation was not successful`() { + fun `getLatestAndLastSuccessful last calculation was not successful`() { val results = listOf( createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH), createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH.plus(1)), @@ -68,7 +70,7 @@ class RiskLevelResultExtensionsTest : BaseTest() { } @Test - fun `getLastestAndLastSuccessful no successful calculations yet`() { + fun `getLatestAndLastSuccessful no successful calculations yet`() { val results = listOf( createRiskLevelResult(hasResult = false, calculatedAt = Instant.EPOCH.plus(10)), createRiskLevelResult(hasResult = false, calculatedAt = Instant.EPOCH.plus(11)), diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt index b401435390b6df088edcc5d583196d34be7fc066..27e93e671d109b2534f98775894243528a0be3ed 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt @@ -20,6 +20,8 @@ class RiskLevelResultTest : BaseTest() { override val exposureWindows: List<ExposureWindow>? = null override val matchedKeyCount: Int = 0 override val daysWithEncounters: Int = 0 + override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk> + get() = emptyList() // TODO("Not yet implemented") } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/DurationExtensionKtTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/durationpicker/DurationExtensionKtTest.kt similarity index 96% rename from Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/DurationExtensionKtTest.kt rename to Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/durationpicker/DurationExtensionKtTest.kt index 84d647ea27cf50a0499fb23ca5d15a87d889d365..78d19f9fd5dbf66b383cb4d61d5801c60128e441 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/durationpicker/DurationExtensionKtTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/durationpicker/DurationExtensionKtTest.kt @@ -1,4 +1,4 @@ -package de.rki.coronawarnapp.contactdiary.ui.durationpicker +package de.rki.coronawarnapp.ui.durationpicker import io.kotest.matchers.shouldBe import org.joda.time.Duration diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/durationpicker/DurationPickerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/durationpicker/DurationPickerTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..61c1b12aec2ecc4ea6454f72fd0a4fbc91bea612 --- /dev/null +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/durationpicker/DurationPickerTest.kt @@ -0,0 +1,43 @@ +package de.rki.coronawarnapp.ui.durationpicker + +import io.kotest.matchers.shouldBe +import io.mockk.MockKAnnotations +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +class DurationPickerTest { + + @BeforeEach + fun setup() { + MockKAnnotations.init(this) + } + + @Test + fun `check hours array`() { + DurationPicker.hoursArray.count() shouldBe 24 + for (i in 0..9) { + DurationPicker.hoursArray[i] shouldBe "0$i" + } + for (i in 10..23) { + DurationPicker.hoursArray[i] shouldBe "$i" + } + } + + @Test + fun `check minutes array`() { + DurationPicker.minutesArray.count() shouldBe 4 + DurationPicker.minutesArray[0] shouldBe "00" + for (i in 1..3) { + DurationPicker.minutesArray[i] shouldBe "${i * 15}" + } + } + + @Test + fun `check duration`() { + DurationPicker.getDuration(0, 0).toContactDiaryFormat() shouldBe "00:00" + DurationPicker.getDuration(1, 0).toContactDiaryFormat() shouldBe "01:00" + DurationPicker.getDuration(23, 3).toContactDiaryFormat() shouldBe "23:45" + DurationPicker.getDuration(9, 2).toContactDiaryFormat() shouldBe "09:30" + DurationPicker.getDuration(10, 1).toContactDiaryFormat() shouldBe "10:15" + } +}