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

Commit

Permalink
Missing tracing duration on low risk detail screen (EXPOSUREAPP-5092) (
Browse files Browse the repository at this point in the history
…#2326)

* Show active tracing history in low risk detail screen

* Move isGone logic from xml layout into state object and add tests

Co-authored-by: Ralf Gehrer <ralfgehrer@users.noreply.github.com>
Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 12, 2021
1 parent a7333d8 commit 8eefd38
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ data class LowRisk(
)
}

fun isGoneOnContentLowView(context: Context) = getRiskContactLast(context) != null && !isInDetailsMode

fun getProgressColorLowRisk(context: Context) = context.getColorCompat(R.color.colorStableLight)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/row_saved_days"
gone="@{state.getRiskContactLast(context) != null}"
gone="@{state.isGoneOnContentLowView(context)}"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package de.rki.coronawarnapp.tracing.states

import android.content.Context
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.risk.RiskState
import io.kotest.matchers.shouldBe
import io.mockk.MockKAnnotations
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.joda.time.Instant
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

internal class LowRiskTest {

@MockK private lateinit var context: Context

@BeforeEach
fun setUp() {
MockKAnnotations.init(this)
every {
context.getString(
R.string.risk_card_low_risk_most_recent_body_encounter_on_single_day,
any()
)
} returns "String not relevant for this test"
}

@AfterEach
fun tearDown() {
clearAllMocks()
}

private val defaultRisk = LowRisk(
riskState = RiskState.LOW_RISK,
isInDetailsMode = false,
lastExposureDetectionTime = Instant.now(),
allowManualUpdate = false,
daysWithEncounters = 0,
activeTracingDays = 1,
lastEncounterAt = null
)

@Test
fun `Active tracing row should be visible in low risk card on the home screen when there are no encounters`() {
defaultRisk.isGoneOnContentLowView(context) shouldBe false
}

@Test
fun `Active tracing row should be gone in low risk card on the home screen when there are encounters`() {
defaultRisk
.copy(daysWithEncounters = 1, lastEncounterAt = Instant.now())
.isGoneOnContentLowView(context) shouldBe true
}

@Test
fun `Active tracing row should be shown in low risk detail screen when there are no encounters`() {
defaultRisk
.copy(isInDetailsMode = true)
.isGoneOnContentLowView(context) shouldBe false
}

@Test
fun `Active tracing row should be shown in low risk detail screen when there are encounters`() {
defaultRisk
.copy(daysWithEncounters = 1, lastEncounterAt = Instant.now(), isInDetailsMode = true)
.isGoneOnContentLowView(context) shouldBe false
}
}

0 comments on commit 8eefd38

Please sign in to comment.