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

PPA onboarding screen (EXPOSUREAPP-4815) #2299

Merged
merged 24 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2ce9048
Strings for onboarding
AlexanderAlferov Feb 2, 2021
ec36f8a
view and image
AlexanderAlferov Feb 2, 2021
4e817a4
View attached to onboarding process
AlexanderAlferov Feb 3, 2021
0be135b
Merge remote-tracking branch 'origin/feature/4321-ppa-main' into feat…
AlexanderAlferov Feb 3, 2021
2e0b35b
Complete onboarding screen
AlexanderAlferov Feb 5, 2021
efddbb0
Tests and screen capture
AlexanderAlferov Feb 5, 2021
4316b9a
Accessibility
AlexanderAlferov Feb 5, 2021
73feed7
Reformatting
AlexanderAlferov Feb 5, 2021
50955c5
New screen with additional info
AlexanderAlferov Feb 8, 2021
6d51d69
New screen with routing
AlexanderAlferov Feb 9, 2021
800642d
Small change in legal text
AlexanderAlferov Feb 9, 2021
da7129e
Merge remote-tracking branch 'origin/release/1.13.x' into feature/481…
AlexanderAlferov Feb 9, 2021
ebded2f
Missing sentence in description of contact journal (EXPOSUREAPP-4941)…
janetback Feb 9, 2021
c306f7a
Change statistics overview header to 'bundesweite' Statistiken (EXPOS…
janetback Feb 9, 2021
c8fd5a1
Show normal behavior box when tracing disabled (EXPOSUREAPP-4768) #2306
chiljamgossow Feb 9, 2021
5b3cd15
Merge remote-tracking branch 'origin/release/1.13.x' into feature/481…
AlexanderAlferov Feb 9, 2021
f051997
Delta onboarding analytics screen
AlexanderAlferov Feb 9, 2021
e6f0520
Delta onboarding navigation
AlexanderAlferov Feb 9, 2021
dd6bbb5
Strings fix
AlexanderAlferov Feb 9, 2021
adc3d3e
Comment for Kolya
AlexanderAlferov Feb 9, 2021
f4893fd
Layout, nav grav and fragments refactoring
AlexanderAlferov Feb 9, 2021
169431f
Merge remote-tracking branch 'origin/feature/4321-ppa-main' into feat…
AlexanderAlferov Feb 9, 2021
104db50
Merge conflicts and formatting
AlexanderAlferov Feb 9, 2021
76d377d
Add missing tools:layout and format the file
mtwalli Feb 10, 2021
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
@@ -0,0 +1,103 @@
package de.rki.coronawarnapp.ui.onboarding

import androidx.lifecycle.asLiveData
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.datadonation.analytics.AnalyticsSettings
import de.rki.coronawarnapp.datadonation.analytics.common.Districts
import de.rki.coronawarnapp.server.protocols.internal.ppdd.PpaData
import io.mockk.MockKAnnotations
import io.mockk.coEvery
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.spyk
import io.mockk.unmockkAll
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import testhelpers.BaseUITest
import testhelpers.SCREENSHOT_DELAY_TIME
import testhelpers.Screenshot
import testhelpers.SystemUIDemoModeRule
import testhelpers.TestDispatcherProvider
import testhelpers.launchFragment2
import testhelpers.launchFragmentInContainer2
import tools.fastlane.screengrab.Screengrab
import tools.fastlane.screengrab.locale.LocaleTestRule

@RunWith(AndroidJUnit4::class)
class OnboardingAnalyticsFragmentTest : BaseUITest() {

@MockK lateinit var settings: AnalyticsSettings
@MockK lateinit var districts: Districts

private lateinit var viewModel: OnboardingAnalyticsViewModel

@Rule
@JvmField
val localeTestRule = LocaleTestRule()

@get:Rule
val systemUIDemoModeRule = SystemUIDemoModeRule()

@Before
fun setup() {
MockKAnnotations.init(this, relaxed = true)

coEvery { districts.loadDistricts() } returns listOf(Districts.District(
districtId = 11011004,
districtName = "SK Berlin Charlottenburg-Wilmersdorf"
))

viewModel = onboardingAnalyticsViewModelSpy()
with(viewModel) {
every { ageGroup } returns flowOf(PpaData.PPAAgeGroup.AGE_GROUP_0_TO_29).asLiveData()
every { federalState } returns flowOf(PpaData.PPAFederalState.FEDERAL_STATE_BE).asLiveData()
every { district } returns flow { emit(districts.loadDistricts().first()) }.asLiveData()
}

setupMockViewModel(
object : OnboardingAnalyticsViewModel.Factory {
override fun create(): OnboardingAnalyticsViewModel = viewModel
}
)
}

private fun onboardingAnalyticsViewModelSpy() = spyk(
OnboardingAnalyticsViewModel(
settings = settings,
districts = districts,
dispatcherProvider = TestDispatcherProvider()
)
)

@After
fun teardown() {
clearAllViewModels()
unmockkAll()
}

@Test
fun launch_fragment() {
launchFragment2<OnboardingAnalyticsFragment>()
}

@Screenshot
@Test
fun capture_screenshot() {
launchFragmentInContainer2<OnboardingAnalyticsFragment>()
Thread.sleep(SCREENSHOT_DELAY_TIME)
Screengrab.screenshot(OnboardingAnalyticsFragment::class.simpleName)
mtwalli marked this conversation as resolved.
Show resolved Hide resolved
}
}

@Module
abstract class OnboardingAnalyticsFragmentTestModule {
@ContributesAndroidInjector
abstract fun onboardingAnalyticsFragment(): OnboardingAnalyticsFragment
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryOnboardingFragmentTestMo
import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryOverviewFragmentTestModule
import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryPersonListFragmentTestModule
import de.rki.coronawarnapp.ui.main.home.HomeFragmentTestModule
import de.rki.coronawarnapp.ui.onboarding.OnboardingAnalyticsFragmentTestModule
import de.rki.coronawarnapp.ui.onboarding.OnboardingDeltaInteroperabilityFragmentTestModule
import de.rki.coronawarnapp.ui.onboarding.OnboardingFragmentTestModule
import de.rki.coronawarnapp.ui.onboarding.OnboardingNotificationsTestModule
Expand Down Expand Up @@ -41,6 +42,7 @@ import de.rki.coronawarnapp.ui.tracing.TracingDetailsFragmentTestTestModule
OnboardingPrivacyTestModule::class,
OnboardingTestFragmentModule::class,
OnboardingTracingFragmentTestModule::class,
OnboardingAnalyticsFragmentTestModule::class,
// Submission
SubmissionDispatcherTestModule::class,
SubmissionTanTestModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.rki.coronawarnapp.test.contactdiary.ui.ContactDiaryTestFragment
import de.rki.coronawarnapp.test.crash.ui.SettingsCrashReportFragment
import de.rki.coronawarnapp.test.debugoptions.ui.DebugOptionsFragment
import de.rki.coronawarnapp.test.keydownload.ui.KeyDownloadTestFragment
import de.rki.coronawarnapp.test.playground.ui.PlaygroundFragment
import de.rki.coronawarnapp.test.risklevel.ui.TestRiskLevelCalculationFragment
import de.rki.coronawarnapp.test.submission.ui.SubmissionTestFragment
import de.rki.coronawarnapp.test.tasks.ui.TestTaskControllerFragment
Expand All @@ -28,7 +29,8 @@ class TestMenuFragmentViewModel @AssistedInject constructor() : CWAViewModel() {
SubmissionTestFragment.MENU_ITEM,
SettingsCrashReportFragment.MENU_ITEM,
MiscInfoFragment.MENU_ITEM,
ContactDiaryTestFragment.MENU_ITEM
ContactDiaryTestFragment.MENU_ITEM,
PlaygroundFragment.MENU_ITEM
).let { MutableLiveData(it) }
}
val showTestScreenEvent = SingleLiveEvent<TestMenuItem>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package de.rki.coronawarnapp.test.playground.ui

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.databinding.FragmentTestPlaygroundBinding
import de.rki.coronawarnapp.datadonation.analytics.ui.input.AnalyticsUserInputFragment
import de.rki.coronawarnapp.datadonation.analytics.ui.input.AnalyticsUserInputFragmentArgs
import de.rki.coronawarnapp.test.menu.ui.TestMenuItem
import de.rki.coronawarnapp.util.di.AutoInject
import de.rki.coronawarnapp.util.ui.viewBindingLazy
import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactoryProvider
import de.rki.coronawarnapp.util.viewmodel.cwaViewModels
import javax.inject.Inject

@SuppressLint("SetTextI18n")
class PlaygroundFragment : Fragment(R.layout.fragment_test_playground), AutoInject {

@Inject lateinit var viewModelFactory: CWAViewModelFactoryProvider.Factory

private val vm: PlaygroundViewModel by cwaViewModels { viewModelFactory }
private val binding: FragmentTestPlaygroundBinding by viewBindingLazy()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.apply {
dataDonationUserinfoAgegroup.setOnClickListener {
findNavController().navigate(
R.id.analyticsUserInputFragment,
AnalyticsUserInputFragmentArgs(AnalyticsUserInputFragment.InputType.AGE_GROUP).toBundle()
)
}
dataDonationUserinfoFederalstate.setOnClickListener {
findNavController().navigate(
R.id.analyticsUserInputFragment,
AnalyticsUserInputFragmentArgs(AnalyticsUserInputFragment.InputType.FEDERAL_STATE).toBundle()
)
}
dataDonationUserinfoDistrict.setOnClickListener {
findNavController().navigate(
R.id.analyticsUserInputFragment,
AnalyticsUserInputFragmentArgs(AnalyticsUserInputFragment.InputType.DISTRICT).toBundle()
)
}
}
}

companion object {
val TAG: String = PlaygroundFragment::class.simpleName!!
val MENU_ITEM = TestMenuItem(
title = "Playground",
description = "Random options for not integrated features",
targetId = R.id.playgroundFragment
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.rki.coronawarnapp.test.playground.ui

import dagger.Binds
import dagger.Module
import dagger.multibindings.IntoMap
import de.rki.coronawarnapp.util.viewmodel.CWAViewModel
import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactory
import de.rki.coronawarnapp.util.viewmodel.CWAViewModelKey

@Module
abstract class PlaygroundModule {
@Binds
@IntoMap
@CWAViewModelKey(PlaygroundViewModel::class)
abstract fun playground(factory: PlaygroundViewModel.Factory): CWAViewModelFactory<out CWAViewModel>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package de.rki.coronawarnapp.test.playground.ui

import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import de.rki.coronawarnapp.util.viewmodel.CWAViewModel
import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory

class PlaygroundViewModel @AssistedInject constructor() : CWAViewModel() {

@AssistedFactory
interface Factory : SimpleCWAViewModelFactory<PlaygroundViewModel>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import de.rki.coronawarnapp.test.keydownload.ui.KeyDownloadTestFragment
import de.rki.coronawarnapp.test.keydownload.ui.KeyDownloadTestFragmentModule
import de.rki.coronawarnapp.test.menu.ui.TestMenuFragment
import de.rki.coronawarnapp.test.menu.ui.TestMenuFragmentModule
import de.rki.coronawarnapp.test.playground.ui.PlaygroundFragment
import de.rki.coronawarnapp.test.playground.ui.PlaygroundModule
import de.rki.coronawarnapp.test.risklevel.ui.TestRiskLevelCalculationFragment
import de.rki.coronawarnapp.test.risklevel.ui.TestRiskLevelCalculationFragmentModule
import de.rki.coronawarnapp.test.submission.ui.SubmissionTestFragment
Expand Down Expand Up @@ -50,4 +52,7 @@ abstract class MainActivityTestModule {

@ContributesAndroidInjector(modules = [ContactDiaryTestFragmentModule::class])
abstract fun contactDiaryTest(): ContactDiaryTestFragment

@ContributesAndroidInjector(modules = [PlaygroundModule::class])
abstract fun playground(): PlaygroundFragment
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="HardcodedText">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:orientation="vertical">
<Button
android:id="@+id/data_donation_userinfo_agegroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data Donation: Age Group" />
<Button
android:id="@+id/data_donation_userinfo_federalstate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data Donation: Federal State" />
<Button
android:id="@+id/data_donation_userinfo_district"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data Donation: District" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<action
android:id="@+id/action_test_menu_fragment_to_contactDiaryTestFragment"
app:destination="@id/test_contact_diary_fragment" />
<action
android:id="@+id/action_test_menu_fragment_to_playgroundFragment"
app:destination="@id/playgroundFragment" />
</fragment>

<fragment
Expand Down Expand Up @@ -100,5 +103,10 @@
android:name="de.rki.coronawarnapp.test.contactdiary.ui.ContactDiaryTestFragment"
android:label="ContactDiaryTestFragment"
tools:layout="@layout/fragment_test_contact_diary" />
<fragment
android:id="@+id/playgroundFragment"
android:name="de.rki.coronawarnapp.test.playground.ui.PlaygroundFragment"
tools:layout="@layout/fragment_test_playground"
android:label="PlaygroundFragment" />

</navigation>
Loading