diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..0cbbed399eb73d7d1df17380e4bf13d0b2d42283 --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt @@ -0,0 +1,184 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import androidx.lifecycle.MutableLiveData +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.ext.junit.runners.AndroidJUnit4 +import dagger.Module +import dagger.android.ContributesAndroidInjector +import de.rki.coronawarnapp.R +import de.rki.coronawarnapp.contactdiary.model.ContactDiaryLocation +import de.rki.coronawarnapp.contactdiary.model.ContactDiaryPerson +import de.rki.coronawarnapp.contactdiary.storage.repo.ContactDiaryRepository +import de.rki.coronawarnapp.contactdiary.ui.day.ContactDiaryDayFragment +import de.rki.coronawarnapp.contactdiary.ui.day.ContactDiaryDayFragmentArgs +import de.rki.coronawarnapp.contactdiary.ui.day.ContactDiaryDayViewModel +import de.rki.coronawarnapp.contactdiary.ui.day.tabs.location.ContactDiaryLocationListFragment +import de.rki.coronawarnapp.contactdiary.ui.day.tabs.location.ContactDiaryLocationListViewModel +import de.rki.coronawarnapp.contactdiary.ui.day.tabs.person.ContactDiaryPersonListFragment +import de.rki.coronawarnapp.contactdiary.ui.day.tabs.person.ContactDiaryPersonListViewModel +import de.rki.coronawarnapp.contactdiary.util.SelectableItem +import de.rki.coronawarnapp.contactdiary.util.toFormattedDay +import de.rki.coronawarnapp.ui.contactdiary.DiaryData.LOCATIONS +import de.rki.coronawarnapp.ui.contactdiary.DiaryData.PERSONS +import io.mockk.MockKAnnotations +import io.mockk.every +import io.mockk.impl.annotations.MockK +import io.mockk.spyk +import org.joda.time.LocalDate +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 testhelpers.selectTabAtPosition +import tools.fastlane.screengrab.Screengrab +import tools.fastlane.screengrab.locale.LocaleTestRule +import tools.fastlane.screengrab.locale.LocaleUtil +import java.util.Locale + +@RunWith(AndroidJUnit4::class) +class ContactDiaryDayFragmentTest : BaseUITest() { + + @Rule + @JvmField + val localeTestRule = LocaleTestRule() + + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + + @MockK lateinit var contactDiaryRepository: ContactDiaryRepository + + private lateinit var viewModel: ContactDiaryDayViewModel + private lateinit var personListViewModel: ContactDiaryPersonListViewModel + private lateinit var locationListViewModel: ContactDiaryLocationListViewModel + + private val selectedDay = LocalDate.now().toString() + private val fragmentArgs = ContactDiaryDayFragmentArgs(selectedDay = selectedDay).toBundle() + + @Before + fun setup() { + MockKAnnotations.init(this, relaxed = true) + setupViewModels() + + every { viewModel.uiState } returns MutableLiveData( + ContactDiaryDayViewModel.UIState( + dayText = { LocalDate.now().toFormattedDay(LocaleUtil.getTestLocale() ?: Locale.getDefault()) }, + dayTextContentDescription = { "Description" } + ) + ) + } + + @After + fun teardown() { + clearAllViewModels() + } + + @Test + fun launch_fragment() { + launchFragment2<ContactDiaryDayFragment>( + fragmentArgs = fragmentArgs, + themeResId = R.style.AppTheme_ContactDiary + ) + } + + @Screenshot + @Test + fun capture_screenshot_no_data() { + captureScreen(listOf(), listOf(), "no_data") + } + + @Screenshot + @Test + fun capture_screenshot_data() { + captureScreen(PERSONS, LOCATIONS, "data") + } + + private fun captureScreen( + persons: List<SelectableItem<ContactDiaryPerson>>, + locations: List<SelectableItem<ContactDiaryLocation>>, + suffix: String + ) { + every { personListViewModel.uiList } returns MutableLiveData(persons) + every { locationListViewModel.uiList } returns MutableLiveData(locations) + + launchFragmentInContainer2<ContactDiaryDayFragment>( + fragmentArgs = fragmentArgs, + themeResId = R.style.AppTheme_ContactDiary + ) + Thread.sleep(SCREENSHOT_DELAY_TIME) + Screengrab.screenshot(ContactDiaryDayFragment::class.simpleName.plus("_$suffix")) + + onView(withId(R.id.contact_diary_day_tab_layout)).perform(selectTabAtPosition(1)) + Thread.sleep(SCREENSHOT_DELAY_TIME) + Screengrab.screenshot(ContactDiaryDayFragment::class.simpleName.plus("_${suffix}_2")) + } + + private fun setupViewModels() { + viewModel = spyk( + ContactDiaryDayViewModel( + TestDispatcherProvider, + selectedDay + ) + ) + + personListViewModel = spyk( + ContactDiaryPersonListViewModel( + TestDispatcherProvider, + selectedDay, + contactDiaryRepository + ) + ) + + locationListViewModel = spyk( + ContactDiaryLocationListViewModel( + TestDispatcherProvider, + selectedDay, + contactDiaryRepository + ) + ) + + setupMockViewModel( + object : ContactDiaryDayViewModel.Factory { + override fun create(selectedDay: String): ContactDiaryDayViewModel = viewModel + } + ) + + setupMockViewModel( + object : ContactDiaryPersonListViewModel.Factory { + override fun create(selectedDay: String): ContactDiaryPersonListViewModel = personListViewModel + } + ) + + setupMockViewModel( + object : ContactDiaryLocationListViewModel.Factory { + override fun create(selectedDay: String): ContactDiaryLocationListViewModel = locationListViewModel + } + ) + } +} + +@Module +abstract class ContactDiaryDayFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactDiaryDayFragment(): ContactDiaryDayFragment +} + +@Module +abstract class ContactDiaryPersonListFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactDiaryPersonListFragment(): ContactDiaryPersonListFragment +} + +@Module +abstract class ContactDiaryLocationListFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactDiaryLocationListFragment(): ContactDiaryLocationListFragment +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..3bdfbe3449baf012e34e691b379fdf332046e4e8 --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt @@ -0,0 +1,84 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import androidx.lifecycle.MutableLiveData +import androidx.test.ext.junit.runners.AndroidJUnit4 +import dagger.Module +import dagger.android.ContributesAndroidInjector +import de.rki.coronawarnapp.contactdiary.storage.repo.ContactDiaryRepository +import de.rki.coronawarnapp.contactdiary.ui.edit.ContactDiaryEditLocationsFragment +import de.rki.coronawarnapp.contactdiary.ui.edit.ContactDiaryEditLocationsViewModel +import de.rki.coronawarnapp.ui.contactdiary.DiaryData.LOCATIONS_EDIT_LIST +import io.mockk.MockKAnnotations +import io.mockk.every +import io.mockk.impl.annotations.MockK +import io.mockk.spyk +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 ContactDiaryEditLocationsFragmentTest : BaseUITest() { + + @Rule + @JvmField + val localeTestRule = LocaleTestRule() + + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + + @MockK lateinit var contactDiaryRepository: ContactDiaryRepository + private lateinit var viewModel: ContactDiaryEditLocationsViewModel + + @Before + fun setUp() { + MockKAnnotations.init(this, relaxed = true) + viewModel = spyk( + ContactDiaryEditLocationsViewModel( + contactDiaryRepository, + TestDispatcherProvider + ) + ) + setupMockViewModel( + object : ContactDiaryEditLocationsViewModel.Factory { + override fun create(): ContactDiaryEditLocationsViewModel = viewModel + } + ) + } + + @After + fun tearDown() { + clearAllViewModels() + } + + @Test + fun launch_fragment() { + launchFragment2<ContactDiaryEditLocationsFragment>() + } + + @Screenshot + @Test + fun capture_screenshot() { + every { viewModel.locationsLiveData } returns MutableLiveData(LOCATIONS_EDIT_LIST) + launchFragmentInContainer2<ContactDiaryEditLocationsFragment>() + Thread.sleep(SCREENSHOT_DELAY_TIME) + + Screengrab.screenshot(ContactDiaryEditLocationsFragment::class.simpleName) + } +} + +@Module +abstract class ContactDiaryEditLocationsFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactDiaryEditLocationsFragment(): ContactDiaryEditLocationsFragment +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..91b359f039c8ff905ac4a05bcf05b7b66ec90c28 --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt @@ -0,0 +1,83 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import androidx.lifecycle.MutableLiveData +import androidx.test.ext.junit.runners.AndroidJUnit4 +import dagger.Module +import dagger.android.ContributesAndroidInjector +import de.rki.coronawarnapp.contactdiary.storage.repo.ContactDiaryRepository +import de.rki.coronawarnapp.contactdiary.ui.edit.ContactDiaryEditPersonsFragment +import de.rki.coronawarnapp.contactdiary.ui.edit.ContactDiaryEditPersonsViewModel +import de.rki.coronawarnapp.ui.contactdiary.DiaryData.PERSONS_EDIT_LIST +import io.mockk.MockKAnnotations +import io.mockk.every +import io.mockk.impl.annotations.MockK +import io.mockk.spyk +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 ContactDiaryEditPersonsFragmentTest : BaseUITest() { + + @Rule + @JvmField + val localeTestRule = LocaleTestRule() + + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + + @MockK lateinit var contactDiaryRepository: ContactDiaryRepository + private lateinit var viewModel: ContactDiaryEditPersonsViewModel + + @Before + fun setUp() { + MockKAnnotations.init(this, relaxed = true) + viewModel = spyk( + ContactDiaryEditPersonsViewModel( + contactDiaryRepository, + TestDispatcherProvider + ) + ) + setupMockViewModel( + object : ContactDiaryEditPersonsViewModel.Factory { + override fun create(): ContactDiaryEditPersonsViewModel = viewModel + } + ) + } + + @After + fun tearDown() { + clearAllViewModels() + } + + @Test + fun launch_fragment() { + launchFragment2<ContactDiaryEditPersonsFragment>() + } + + @Screenshot + @Test + fun capture_screenshot() { + every { viewModel.personsLiveData } returns MutableLiveData(PERSONS_EDIT_LIST) + launchFragmentInContainer2<ContactDiaryEditPersonsFragment>() + Thread.sleep(SCREENSHOT_DELAY_TIME) + Screengrab.screenshot(ContactDiaryEditPersonsFragment::class.simpleName) + } +} + +@Module +abstract class ContactDiaryEditPersonsFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactDiaryEditPersonsFragment(): ContactDiaryEditPersonsFragment +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..bcf8c04e2bb7e36e8b95817dd94fc37b1b3ae1a5 --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt @@ -0,0 +1,37 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import de.rki.coronawarnapp.ui.information.InformationPrivacyFragment +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import testhelpers.SCREENSHOT_DELAY_TIME +import testhelpers.Screenshot +import testhelpers.SystemUIDemoModeRule +import testhelpers.launchFragment2 +import testhelpers.launchFragmentInContainer2 +import tools.fastlane.screengrab.Screengrab +import tools.fastlane.screengrab.locale.LocaleTestRule + +@RunWith(AndroidJUnit4::class) +class ContactDiaryInformationPrivacyFragmentTest { + @Rule + @JvmField + val localeTestRule = LocaleTestRule() + + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + + @Test + fun launch_fragment() { + launchFragment2<InformationPrivacyFragment>() + } + + @Screenshot + @Test + fun capture_screenshot() { + launchFragmentInContainer2<InformationPrivacyFragment>() + Thread.sleep(SCREENSHOT_DELAY_TIME) + Screengrab.screenshot(InformationPrivacyFragment::class.simpleName) + } +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..497cde8da62349162e9e07cba441bef872664627 --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt @@ -0,0 +1,67 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import dagger.Module +import dagger.android.ContributesAndroidInjector +import de.rki.coronawarnapp.contactdiary.ui.onboarding.ContactDiaryOnboardingFragment +import de.rki.coronawarnapp.contactdiary.ui.onboarding.ContactDiaryOnboardingFragmentViewModel +import io.mockk.MockKAnnotations +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.launchFragment2 +import testhelpers.launchFragmentInContainer2 +import tools.fastlane.screengrab.Screengrab +import tools.fastlane.screengrab.locale.LocaleTestRule + +@RunWith(AndroidJUnit4::class) +class ContactDiaryOnboardingFragmentTest : BaseUITest() { + @Rule + @JvmField + val localeTestRule = LocaleTestRule() + + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + + @Before + fun setup() { + MockKAnnotations.init(this, relaxed = true) + + setupMockViewModel( + object : ContactDiaryOnboardingFragmentViewModel.Factory { + override fun create(): ContactDiaryOnboardingFragmentViewModel = + ContactDiaryOnboardingFragmentViewModel() + } + ) + } + + @After + fun teardown() { + clearAllViewModels() + } + + @Test + fun launch_fragment() { + launchFragment2<ContactDiaryOnboardingFragment>() + } + + @Screenshot + @Test + fun capture_screenshot() { + launchFragmentInContainer2<ContactDiaryOnboardingFragment>() + Thread.sleep(SCREENSHOT_DELAY_TIME) + Screengrab.screenshot(ContactDiaryOnboardingFragment::class.simpleName) + } +} + +@Module +abstract class ContactDiaryOnboardingFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactDiaryOnboardingFragment(): ContactDiaryOnboardingFragment +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..18b7685674dff75d244a1effe35b83d59e5a10a9 --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt @@ -0,0 +1,101 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.test.ext.junit.runners.AndroidJUnit4 +import dagger.Module +import dagger.android.ContributesAndroidInjector +import de.rki.coronawarnapp.contactdiary.storage.repo.ContactDiaryRepository +import de.rki.coronawarnapp.contactdiary.ui.overview.ContactDiaryOverviewFragment +import de.rki.coronawarnapp.contactdiary.ui.overview.ContactDiaryOverviewViewModel +import de.rki.coronawarnapp.contactdiary.ui.overview.adapter.ListItem +import de.rki.coronawarnapp.task.TaskController +import de.rki.coronawarnapp.ui.contactdiary.DiaryData.LIST_ITEMS +import io.mockk.MockKAnnotations +import io.mockk.every +import io.mockk.impl.annotations.MockK +import io.mockk.spyk +import org.joda.time.LocalDate +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 ContactDiaryOverviewFragmentTest : BaseUITest() { + @Rule + @JvmField + val localeTestRule = LocaleTestRule() + + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + + @MockK lateinit var taskController: TaskController + @MockK lateinit var contactDiaryRepository: ContactDiaryRepository + + private lateinit var viewModel: ContactDiaryOverviewViewModel + + @Before + fun setup() { + MockKAnnotations.init(this, relaxed = true) + viewModel = spyk( + ContactDiaryOverviewViewModel( + taskController = taskController, + dispatcherProvider = TestDispatcherProvider, + contactDiaryRepository = contactDiaryRepository + ) + ) + + setupMockViewModel( + object : ContactDiaryOverviewViewModel.Factory { + override fun create(): ContactDiaryOverviewViewModel = viewModel + } + ) + } + + @After + fun teardown() { + clearAllViewModels() + } + + @Test + fun launch_fragment() { + launchFragment2<ContactDiaryOverviewFragment>() + } + + @Screenshot + @Test + fun capture_screenshot() { + every { viewModel.listItems } returns itemLiveData() + launchFragmentInContainer2<ContactDiaryOverviewFragment>() + Thread.sleep(SCREENSHOT_DELAY_TIME) + Screengrab.screenshot(ContactDiaryOverviewFragment::class.simpleName) + } + + private fun itemLiveData(): LiveData<List<ListItem>> = + MutableLiveData( + (0 until ContactDiaryOverviewViewModel.DAY_COUNT) + .map { LocalDate.now().minusDays(it) } + .map { + ListItem(it).apply { + data.apply { addAll(LIST_ITEMS) } + } + } + ) +} + +@Module +abstract class ContactDiaryOverviewFragmentTestModule { + @ContributesAndroidInjector + abstract fun contactContactDiaryOverviewFragment(): ContactDiaryOverviewFragment +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/DiaryData.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/DiaryData.kt new file mode 100644 index 0000000000000000000000000000000000000000..767da20af5015aaaa451a2c27e9fda0033fe4c7a --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/DiaryData.kt @@ -0,0 +1,101 @@ +package de.rki.coronawarnapp.ui.contactdiary + +import de.rki.coronawarnapp.R +import de.rki.coronawarnapp.contactdiary.model.ContactDiaryLocation +import de.rki.coronawarnapp.contactdiary.model.ContactDiaryPerson +import de.rki.coronawarnapp.contactdiary.model.DefaultContactDiaryLocation +import de.rki.coronawarnapp.contactdiary.model.DefaultContactDiaryPerson +import de.rki.coronawarnapp.contactdiary.ui.overview.adapter.ListItem +import de.rki.coronawarnapp.contactdiary.util.SelectableItem +import de.rki.coronawarnapp.util.ui.toLazyString + +object DiaryData { + + val LIST_ITEMS = listOf( + ListItem.Data( + R.drawable.ic_contact_diary_person_item, + "Max Mustermann" + ), + + ListItem.Data( + R.drawable.ic_contact_diary_person_item, + "Erika Mustermann" + ), + + ListItem.Data( + R.drawable.ic_contact_diary_location, + "Fitnessstudio" + ), + + ListItem.Data( + R.drawable.ic_contact_diary_location, + "Supermarket" + ) + ) + + val LOCATIONS: List<SelectableItem<ContactDiaryLocation>> = listOf( + SelectableItem( + selected = true, + item = DefaultContactDiaryLocation(locationName = "Sport"), + contentDescription = "".toLazyString(), + onClickDescription = "".toLazyString(), + clickLabel = R.string.accessibility_location, + onClickLabel = R.string.accessibility_location + ), + SelectableItem( + selected = true, + item = DefaultContactDiaryLocation(locationName = "Büro"), + contentDescription = "".toLazyString(), + onClickDescription = "".toLazyString(), + clickLabel = R.string.accessibility_location, + onClickLabel = R.string.accessibility_location + ), + SelectableItem( + selected = false, + item = DefaultContactDiaryLocation(locationName = "Supermarkt"), + contentDescription = "".toLazyString(), + onClickDescription = "".toLazyString(), + clickLabel = R.string.accessibility_location, + onClickLabel = R.string.accessibility_location + ) + ) + + val PERSONS: List<SelectableItem<ContactDiaryPerson>> = listOf( + SelectableItem( + selected = true, + item = DefaultContactDiaryPerson(fullName = "Erika Mustermann"), + contentDescription = "".toLazyString(), + onClickDescription = "".toLazyString(), + clickLabel = R.string.accessibility_person, + onClickLabel = R.string.accessibility_person + ), + SelectableItem( + selected = true, + item = DefaultContactDiaryPerson(fullName = "Max Mustermann"), + contentDescription = "".toLazyString(), + onClickDescription = "".toLazyString(), + clickLabel = R.string.accessibility_person, + onClickLabel = R.string.accessibility_person + ), + SelectableItem( + selected = false, + item = DefaultContactDiaryPerson(fullName = "John Doe"), + contentDescription = "".toLazyString(), + onClickDescription = "".toLazyString(), + clickLabel = R.string.accessibility_person, + onClickLabel = R.string.accessibility_person + ) + ) + + val LOCATIONS_EDIT_LIST: List<ContactDiaryLocation> = listOf( + DefaultContactDiaryLocation(locationName = "Sport"), + DefaultContactDiaryLocation(locationName = "Büro"), + DefaultContactDiaryLocation(locationName = "Supermarkt") + ) + + val PERSONS_EDIT_LIST: List<ContactDiaryPerson> = listOf( + DefaultContactDiaryPerson(fullName = "Max Mustermann"), + DefaultContactDiaryPerson(fullName = "Erika Mustermann"), + DefaultContactDiaryPerson(fullName = "John Doe") + ) +} diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt index 16407e5e50e445b5842185f8f702af4e0910b221..c2a342df7c6a458246ff5d99dd3aab976f7e4d61 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt @@ -1,6 +1,5 @@ package de.rki.coronawarnapp.ui.main.home -import androidx.fragment.app.testing.launchFragment import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.test.espresso.Espresso.onView @@ -44,6 +43,7 @@ import testhelpers.SCREENSHOT_DELAY_TIME import testhelpers.Screenshot import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider +import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.recyclerScrollTo import timber.log.Timber @@ -99,8 +99,7 @@ class HomeFragmentTest : BaseUITest() { @Test fun onResumeCallsRefresh() { - // AppTheme is required here to prevent xml inflation crash - launchFragment<HomeFragment>(themeResId = R.style.AppTheme) + launchFragment2<HomeFragment>() verify(exactly = 1) { viewModel.refreshRequiredData() } } diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt index 4244122bcf89a71a3b9a183d0b19b9de1e182cc5..06c73b23105dfd4bfcc89ae6fb14d25ba5d0739e 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt @@ -2,7 +2,6 @@ package de.rki.coronawarnapp.ui.onboarding import androidx.fragment.app.testing.launchFragment import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.scrollTo import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -56,7 +55,7 @@ class OnboardingFragmentTest : BaseUITest() { Thread.sleep(SCREENSHOT_DELAY_TIME) Screengrab.screenshot(OnboardingFragment::class.simpleName) - onView(withId(R.id.onboarding_easy_language)).perform(scrollTo(), click()) + onView(withId(R.id.onboarding_easy_language)).perform(scrollTo()) Screengrab.screenshot(OnboardingFragment::class.simpleName.plus("2")) } } diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt index 0a108488676739c69d7527a0f6676dd6cf002d93..e221717278a169fd8809a12c291aa0ccaee0a3b1 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt @@ -25,6 +25,7 @@ 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 @@ -120,7 +121,7 @@ class TracingDetailsFragmentTest : BaseUITest() { private fun captureScreenshot(nameSuffix: String) { val name = TracingDetailsFragment::class.simpleName + "_" + nameSuffix launchFragmentInContainer2<TracingDetailsFragment>() - Thread.sleep(2000) // TODO use constant when EXPOSUREAPP-2950 is merged + Thread.sleep(SCREENSHOT_DELAY_TIME) Screengrab.screenshot(name) } } diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt index ba8f5e736abc16dd8681efc2df4e29ed8d6b0a0d..78cd370143da2c6b67556d515be9b0d2848bdc24 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt @@ -1,6 +1,13 @@ package testhelpers import dagger.Module +import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryDayFragmentTestModule +import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryEditLocationsFragmentTestModule +import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryEditPersonsFragmentTestModule +import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryLocationListFragmentTestModule +import de.rki.coronawarnapp.ui.contactdiary.ContactDiaryOnboardingFragmentTestModule +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.OnboardingDeltaInteroperabilityFragmentTestModule import de.rki.coronawarnapp.ui.onboarding.OnboardingFragmentTestModule @@ -47,8 +54,17 @@ import de.rki.coronawarnapp.ui.tracing.TracingDetailsFragmentTestTestModule SubmissionConsentFragmentTestModule::class, SubmissionYourConsentFragmentTestModule::class, SubmissionSymptomCalendarFragmentTestModule::class, + SubmissionQRScanFragmentModule::class, // Tracing - TracingDetailsFragmentTestTestModule::class + TracingDetailsFragmentTestTestModule::class, + // Contact Diary + ContactDiaryOnboardingFragmentTestModule::class, + ContactDiaryOverviewFragmentTestModule::class, + ContactDiaryDayFragmentTestModule::class, + ContactDiaryPersonListFragmentTestModule::class, + ContactDiaryLocationListFragmentTestModule::class, + ContactDiaryEditLocationsFragmentTestModule::class, + ContactDiaryEditPersonsFragmentTestModule::class ] ) class FragmentTestModuleRegistrar diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/SystemUIDemoModeRule.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/SystemUIDemoModeRule.kt index 158611344334b74309426c41b2b1f6a2c3aa2432..d6e01b92a42804bc35f7a116abf8a76d754dcd10 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/SystemUIDemoModeRule.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/SystemUIDemoModeRule.kt @@ -15,13 +15,9 @@ class SystemUIDemoModeRule : TestRule { override fun apply(base: Statement, description: Description): Statement = object : Statement() { override fun evaluate() { - try { - helper.enter() - base.evaluate() - helper.exit() - } catch (e: Exception) { - e.printStackTrace() - } + helper.enter() + base.evaluate() + helper.exit() } } } diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/TestAndroidModule.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/TestAndroidModule.kt new file mode 100644 index 0000000000000000000000000000000000000000..81093b7a7d4055e8562c823a34318640ac6b7c5b --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/TestAndroidModule.kt @@ -0,0 +1,16 @@ +package testhelpers + +import android.content.Context +import androidx.test.platform.app.InstrumentationRegistry +import dagger.Module +import dagger.Provides +import de.rki.coronawarnapp.util.di.AppContext +import javax.inject.Singleton + +@Module +class TestAndroidModule { + @Provides + @Singleton + @AppContext + fun context(): Context = InstrumentationRegistry.getInstrumentation().targetContext +} diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/TestAppComponent.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/TestAppComponent.kt index 53c3c747ce83f218775dd3176b7479f25ed127b7..adc3a10ace099a3f9d7770d8b94605bced233747 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/TestAppComponent.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/TestAppComponent.kt @@ -11,7 +11,8 @@ import javax.inject.Singleton modules = [ AndroidSupportInjectionModule::class, MockViewModelModule::class, - FragmentTestModuleRegistrar::class + FragmentTestModuleRegistrar::class, + TestAndroidModule::class ] ) @Singleton diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/TestExtensions.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/TestExtensions.kt index 303faa4aade55d47c1e39c3b7b7359f0a23012d9..1c2e282f7327ea6bf3c58c9dd49803369167b8e0 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/TestExtensions.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/TestExtensions.kt @@ -39,3 +39,14 @@ inline fun <reified F : Fragment> captureScreenshot( Thread.sleep(SCREENSHOT_DELAY_TIME) Screengrab.screenshot(name) } + +/** + * Launches Fragment in Activity. + * Same as [androidx.fragment.app.testing.launchFragment] except that it defaults + * the theme to [R.style.AppTheme]. + */ +inline fun <reified F : Fragment> launchFragment2( + fragmentArgs: Bundle? = null, + @StyleRes themeResId: Int = R.style.AppTheme, + factory: FragmentFactory? = null +) = FragmentScenario.launch(F::class.java, fragmentArgs, themeResId, factory) diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/RecyclerViewScrollAction.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/ViewActions.kt similarity index 60% rename from Corona-Warn-App/src/androidTest/java/testhelpers/RecyclerViewScrollAction.kt rename to Corona-Warn-App/src/androidTest/java/testhelpers/ViewActions.kt index f28f3560013c6fcb960333ce14b5164e4cf8cca7..0e2f02d6f7fd700682c40c490fc19d97f559a757 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/RecyclerViewScrollAction.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/ViewActions.kt @@ -2,10 +2,12 @@ package testhelpers import android.view.View import androidx.recyclerview.widget.RecyclerView +import androidx.test.espresso.PerformException import androidx.test.espresso.UiController import androidx.test.espresso.ViewAction import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import com.google.android.material.tabs.TabLayout import org.hamcrest.CoreMatchers.allOf import org.hamcrest.Matcher @@ -28,3 +30,21 @@ private class RecyclerViewScrollAction(private val position: Int? = null) : View uiController?.loopMainThreadUntilIdle() } } + +fun selectTabAtPosition(tabIndex: Int): ViewAction { + return object : ViewAction { + override fun getDescription() = "with tab at index $tabIndex" + + override fun getConstraints() = allOf(isDisplayed(), isAssignableFrom(TabLayout::class.java)) + + override fun perform(uiController: UiController, view: View) { + val tabLayout = view as TabLayout + val tabAtIndex: TabLayout.Tab = tabLayout.getTabAt(tabIndex) + ?: throw PerformException.Builder() + .withCause(Throwable("No tab at index $tabIndex")) + .build() + + tabAtIndex.select() + } + } +} diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_edit_list_item.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_edit_list_item.xml index e09401533bd6e6b6cccfecb8fc1c1a831a3143b0..172335e1c41f698ca0d0ef66628dfec44aecc814 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_edit_list_item.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_edit_list_item.xml @@ -21,7 +21,7 @@ app:layout_constraintEnd_toStartOf="@id/edit_icon" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - tools:text="Julia Maria" /> + tools:text="@tools:sample/full_names" /> <ImageView android:id="@+id/edit_icon" diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_edit_locations_fragment.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_edit_locations_fragment.xml index bed59ef6f3d6d45baa64e32ecd228223bf9c17d2..6b4dfda9f11e6a6428e6f83e2796b8f76f2f0fac 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_edit_locations_fragment.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_edit_locations_fragment.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/content_container" @@ -9,14 +10,14 @@ <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" + style="@style/CWAToolbar.Close" android:layout_width="0dp" android:layout_height="wrap_content" + android:contentDescription="@string/contact_diary_edit_locations_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - style="@style/CWAToolbar.Close" - app:title="@string/contact_diary_edit_locations_title" - android:contentDescription="@string/contact_diary_edit_locations_title"/> + app:title="@string/contact_diary_edit_locations_title" /> <androidx.constraintlayout.widget.Group android:id="@+id/contact_diary_location_list_no_items_group" @@ -62,7 +63,8 @@ app:layout_constraintBottom_toTopOf="@id/delete_button" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/toolbar" /> + app:layout_constraintTop_toBottomOf="@id/toolbar" + tools:listitem="@layout/contact_diary_edit_list_item" /> <android.widget.Button android:id="@+id/delete_button" diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_edit_persons_fragment.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_edit_persons_fragment.xml index f30bf67dbf408028f65ae4929504e6f25c5b9da5..e4916ab148d90a9681dc8426b003c152d4cbc508 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_edit_persons_fragment.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_edit_persons_fragment.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/content_container" @@ -62,6 +63,7 @@ app:layout_constraintBottom_toTopOf="@id/delete_button" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" + tools:listitem="@layout/contact_diary_edit_list_item" app:layout_constraintTop_toBottomOf="@id/toolbar" /> <android.widget.Button diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_fragment.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_fragment.xml index f1030bc19bdf1cf00aeebfe29608478bfdc190f1..2012c69ee0d623005da0179a5392be15b5af59f6 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_fragment.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_fragment.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" @@ -16,7 +17,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:listitem="@layout/contact_diary_location_list_item" /> <androidx.constraintlayout.widget.Group android:id="@+id/contact_diary_location_list_no_items_group" @@ -25,7 +27,7 @@ android:visibility="gone" app:constraint_referenced_ids="contact_diary_location_list_no_items_image,contact_diary_location_list_no_items_title,contact_diary_location_list_no_items_subtitle" /> - <ImageView + <androidx.appcompat.widget.AppCompatImageView android:id="@+id/contact_diary_location_list_no_items_image" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_item.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_item.xml index 7ba3076e4a29661eb1a38a2b0a7a0dec74a8062b..4a07d8eb7bfea1df946364dab5ace744ed508b88 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_item.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_location_list_item.xml @@ -30,7 +30,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/contact_diary_location_list_item_icon" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:text="@tools:sample/cities" /> </androidx.constraintlayout.widget.ConstraintLayout> </layout> diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_overview_list_item.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_overview_list_item.xml index ee92e9c05860e7877f5bf1a9ccdfc6ffeff0dba3..eb730acfbfe14ee89383c591c9f77bb44bbe8e64 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_overview_list_item.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_overview_list_item.xml @@ -75,7 +75,9 @@ android:paddingVertical="@dimen/spacing_tiny" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintTop_toBottomOf="@id/contact_diary_overview_element_divider" /> + app:layout_constraintTop_toBottomOf="@id/contact_diary_overview_element_divider" + tools:itemCount="2" + tools:listitem="@layout/contact_diary_person_list_item" /> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_fragment.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_fragment.xml index 761caef6d9622af80b25c6ab571832e84c83beea..40e60389eea8314d30aed4b8f74edc2dc70ffb75 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_fragment.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_fragment.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" @@ -16,7 +17,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:listitem="@layout/contact_diary_person_list_item" /> <androidx.constraintlayout.widget.Group android:id="@+id/contact_diary_person_list_no_items_group" @@ -25,7 +27,7 @@ android:visibility="gone" app:constraint_referenced_ids="contact_diary_person_list_no_items_image,contact_diary_person_list_no_items_title,contact_diary_person_list_no_items_subtitle" /> - <ImageView + <androidx.appcompat.widget.AppCompatImageView android:id="@+id/contact_diary_person_list_no_items_image" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_item.xml b/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_item.xml index d81299dac4415f12f7f8c7f43b9de8ca41e02e16..1b4da486f70f01340c52b402921f1ec591b890ff 100644 --- a/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_item.xml +++ b/Corona-Warn-App/src/main/res/layout/contact_diary_person_list_item.xml @@ -4,8 +4,8 @@ xmlns:tools="http://schemas.android.com/tools"> <androidx.constraintlayout.widget.ConstraintLayout - style="@style/contactDiaryCardRipple" android:id="@+id/contact_diary_person_list_item" + style="@style/contactDiaryCardRipple" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="@dimen/spacing_huge"> @@ -30,7 +30,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/contact_diary_person_list_item_icon" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:text="@tools:sample/full_names" /> </androidx.constraintlayout.widget.ConstraintLayout> </layout> diff --git a/Corona-Warn-App/src/main/res/layout/include_information_details.xml b/Corona-Warn-App/src/main/res/layout/include_information_details.xml index bb0bba0bee41a905f4b5357a66d53bbe6038d125..a0b0a3084fd8a0383183a3aab6d98f9bf793f6cc 100644 --- a/Corona-Warn-App/src/main/res/layout/include_information_details.xml +++ b/Corona-Warn-App/src/main/res/layout/include_information_details.xml @@ -34,9 +34,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="true" - android:scaleType="centerCrop" android:paddingTop="@dimen/spacing_small" android:paddingBottom="@dimen/spacing_small" + android:scaleType="centerCrop" android:src="@{illustration}" bind:cwaContentDescription="@{illustrationDescription}" tools:ignore="ContentDescription" @@ -47,8 +47,8 @@ style="@style/headline6" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/spacing_small" android:layout_marginStart="@dimen/spacing_normal" + android:layout_marginTop="@dimen/spacing_small" android:layout_marginEnd="@dimen/spacing_normal" android:accessibilityHeading="true" android:focusable="true" @@ -69,7 +69,7 @@ android:text="@{body}" android:textColorLink="@color/colorTextTint" android:visibility="@{FormatterHelper.formatVisibilityText(body)}" - tools:text="@string/settings_title" /> + tools:text="@tools:sample/lorem/random" /> </LinearLayout> diff --git a/Corona-Warn-App/src/main/res/navigation/contact_diary_nav_graph.xml b/Corona-Warn-App/src/main/res/navigation/contact_diary_nav_graph.xml index bbb93fbb3773dde89720ad52bc8205360a16a3be..06e81152ec917051b4cd2c76330b5ea1afe75444 100644 --- a/Corona-Warn-App/src/main/res/navigation/contact_diary_nav_graph.xml +++ b/Corona-Warn-App/src/main/res/navigation/contact_diary_nav_graph.xml @@ -7,7 +7,8 @@ <fragment android:id="@+id/contactDiaryDayFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.day.ContactDiaryDayFragment" - android:label="ContactDiaryDayFragment"> + android:label="ContactDiaryDayFragment" + tools:layout="@layout/contact_diary_day_fragment"> <argument android:name="selectedDay" android:defaultValue="2020-03-25" @@ -22,7 +23,8 @@ <fragment android:id="@+id/contactDiaryPersonListFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.day.tabs.person.ContactDiaryPersonListFragment" - android:label="ContactDiaryPersonListFragment"> + android:label="ContactDiaryPersonListFragment" + tools:layout="@layout/contact_diary_person_list_fragment"> <argument android:name="selectedDay" app:argType="string" /> @@ -30,7 +32,8 @@ <fragment android:id="@+id/contactDiaryPlaceListFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.day.tabs.location.ContactDiaryLocationListFragment" - android:label="ContactDiaryPlaceListFragment"> + android:label="ContactDiaryPlaceListFragment" + tools:layout="@layout/contact_diary_location_list_fragment"> <argument android:name="selectedDay" app:argType="string" /> @@ -38,12 +41,13 @@ <dialog android:id="@+id/contactDiaryPersonBottomSheetDialogFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.sheets.person.ContactDiaryPersonBottomSheetDialogFragment" - android:label="ContactDiaryPersonBottomSheetDialogFragment"> + android:label="ContactDiaryPersonBottomSheetDialogFragment" + tools:layout="@layout/contact_diary_person_bottom_sheet_fragment"> <argument android:name="selectedPerson" - app:nullable="true" android:defaultValue="@null" - app:argType="de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryPersonEntity" /> + app:argType="de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryPersonEntity" + app:nullable="true" /> <argument android:name="addedAt" android:defaultValue="@null" @@ -53,12 +57,13 @@ <dialog android:id="@+id/contactDiaryLocationBottomSheetDialogFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.sheets.location.ContactDiaryLocationBottomSheetDialogFragment" - android:label="ContactDiaryLocationBottomSheetDialogFragment"> + android:label="ContactDiaryLocationBottomSheetDialogFragment" + tools:layout="@layout/contact_diary_location_bottom_sheet_fragment"> <argument android:name="selectedLocation" - app:nullable="true" android:defaultValue="@null" - app:argType="de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationEntity" /> + app:argType="de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryLocationEntity" + app:nullable="true" /> <argument android:name="addedAt" android:defaultValue="@null" @@ -68,7 +73,8 @@ <fragment android:id="@+id/contactDiaryOnboardingFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.onboarding.ContactDiaryOnboardingFragment" - android:label="ContactDiaryOnboardingFragment"> + android:label="ContactDiaryOnboardingFragment" + tools:layout="@layout/contact_diary_onboarding_fragment"> <action android:id="@+id/action_contactDiaryOnboardingFragment_to_contactDiaryInformationPrivacyFragment" app:destination="@id/contactDiaryInformationPrivacyFragment" /> @@ -76,12 +82,13 @@ android:id="@+id/action_contactDiaryOnboardingFragment_to_contactDiaryOverviewFragment" app:destination="@id/contactDiaryOverviewFragment" app:popUpTo="@id/contact_diary_nav_graph" - app:popUpToInclusive="true"/> + app:popUpToInclusive="true" /> </fragment> <fragment android:id="@+id/contactDiaryInformationPrivacyFragment" android:name="de.rki.coronawarnapp.ui.information.InformationPrivacyFragment" - android:label="InformationPrivacyFragment" /> + android:label="InformationPrivacyFragment" + tools:layout="@layout/fragment_information_privacy" /> <fragment android:id="@+id/contactDiaryOverviewFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.overview.ContactDiaryOverviewFragment" @@ -103,7 +110,8 @@ <fragment android:id="@+id/contactDiaryEditLocationsFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.edit.ContactDiaryEditLocationsFragment" - android:label="ContactDiaryEditLocationsFragment"> + android:label="ContactDiaryEditLocationsFragment" + tools:layout="@layout/contact_diary_edit_locations_fragment"> <action android:id="@+id/action_contactDiaryEditLocationsFragment_to_contactDiaryLocationBottomSheetDialogFragment" app:destination="@id/contactDiaryLocationBottomSheetDialogFragment" /> @@ -111,7 +119,8 @@ <fragment android:id="@+id/contactDiaryEditPersonsFragment" android:name="de.rki.coronawarnapp.contactdiary.ui.edit.ContactDiaryEditPersonsFragment" - android:label="ContactDiaryEditPersonsFragment" > + android:label="ContactDiaryEditPersonsFragment" + tools:layout="@layout/contact_diary_edit_persons_fragment"> <action android:id="@+id/action_contactDiaryEditPersonsFragment_to_contactDiaryPersonBottomSheetDialogFragment" app:destination="@id/contactDiaryPersonBottomSheetDialogFragment" />