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

Profile screenshots (EXPOSUREAPP-12673) #5093

Merged
merged 15 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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,114 @@
package de.rki.coronawarnapp.profile.ui.list

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.profile.model.Profile
import de.rki.coronawarnapp.profile.ui.list.items.ProfileCard
import de.rki.coronawarnapp.profile.ui.list.items.ProfileListItem
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.joda.time.LocalDate
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import testhelpers.BaseUITest
import testhelpers.Screenshot
import testhelpers.launchFragmentInContainer2
import testhelpers.takeScreenshot

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

@MockK lateinit var viewModel: ProfileListViewModel

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

every { viewModel.profiles } returns profileCards()

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

@After
fun teardown() {
clearAllViewModels()
}

@Test
@Screenshot
fun capture_fragment() {
launchFragmentInContainer2<ProfileListFragment>()
takeScreenshot<ProfileListFragment>("1")
}

private fun profileCards(): LiveData<List<ProfileListItem>> =
MutableLiveData(
listOf<ProfileListItem>(
ProfileCard.Item(
profile = Profile(
id = 1,
firstName = "Andrea",
lastName = "Schneider",
birthDate = LocalDate(1990, 11, 17),
city = "Potsdam",
zipCode = "14471",
street = "Lange Straße 5",
phone = "0151123456789",
email = "andreaschneider@web.de"
),
qrCode = "BEGIN:VCARD\n" +
"VERSION:4.0\n" +
"N:Schneider;Andrea;;;\n" +
"FN:Andrea Schneider\n" +
"BDAY:19690420\n" +
"EMAIL;TYPE=home:andrea.schneider@gmail.com\n" +
"TEL;TYPE=\"cell,home\":(359) 260-345\n" +
"ADR;TYPE=home:;;Long Str\\, No. 4;Liverpool;;12345\n" +
"REV:20220418T091325Z\n" +
"END:VCARD",
onClickAction = { _, _ -> }
),

ProfileCard.Item(
profile = Profile(
id = 2,
firstName = "Max",
lastName = "Mustermann",
birthDate = LocalDate(1997, 7, 24),
city = "Potsdam",
zipCode = "14471",
street = "Lange Straße 5",
phone = "0234523454545",
email = "maxmustermann@web.de"
),
qrCode = "BEGIN:VCARD\n" +
"VERSION:4.0\n" +
"N:Musterman;Max;;;\n" +
"FN:Max Musterman\n" +
"BDAY:19690420\n" +
"EMAIL;TYPE=home:max.musterman@gmail.com\n" +
"TEL;TYPE=\"cell,home\":(359) 260-345\n" +
"ADR;TYPE=home:;;Long Str\\, No. 4;Liverpool;;12345\n" +
"REV:20220418T091325Z\n" +
"END:VCARD",
onClickAction = { _, _ -> }
)
)
)
}

@Module
abstract class ProfileListFragmentTestModule {
@ContributesAndroidInjector
abstract fun profileListFragment(): ProfileListFragment
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import de.rki.coronawarnapp.familytest.ui.consent.FamilyTestConsentFragmentTestM
import de.rki.coronawarnapp.familytest.ui.selection.TestRegistrationSelectionFragmentTestModule
import de.rki.coronawarnapp.familytest.ui.testlist.FamilyTestsListFragmentTestModule
import de.rki.coronawarnapp.profile.ui.create.ProfileCreateFragmentTestModule
import de.rki.coronawarnapp.profile.ui.list.ProfileListFragmentTestModule
import de.rki.coronawarnapp.profile.ui.onboarding.ProfileOnboardingFragmentTestModule
import de.rki.coronawarnapp.qrcode.ui.QrCodeScannerFragmentTestModule
import de.rki.coronawarnapp.reyclebin.ui.RecyclerBinOverviewFragmentTestModule
Expand Down Expand Up @@ -133,6 +134,7 @@ import de.rki.coronawarnapp.ui.vaccination.CovidCertificateInfoFragmentTestModul
ProfileCreateFragmentTestModule::class,
ProfileOnboardingFragmentTestModule::class,
ProfileQrCodeFragmentTestModule::class,
ProfileListFragmentTestModule::class,

QrCodeScannerFragmentTestModule::class,

Expand Down