2023-02-28 05:54:07 -08:00
|
|
|
@file:Suppress("TooManyFunctions")
|
|
|
|
|
2022-10-18 06:08:36 -07:00
|
|
|
package co.electroniccoin.zcash.ui.screenshot
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
import android.content.Context
|
|
|
|
import android.os.Build
|
|
|
|
import android.os.LocaleList
|
2023-03-21 12:04:16 -07:00
|
|
|
import androidx.activity.viewModels
|
2022-01-31 13:42:22 -08:00
|
|
|
import androidx.compose.ui.test.assertCountEquals
|
2023-03-21 12:04:16 -07:00
|
|
|
import androidx.compose.ui.test.assertIsEnabled
|
2022-01-31 13:42:22 -08:00
|
|
|
import androidx.compose.ui.test.hasContentDescription
|
|
|
|
import androidx.compose.ui.test.hasTestTag
|
|
|
|
import androidx.compose.ui.test.hasText
|
|
|
|
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
|
|
|
import androidx.compose.ui.test.junit4.ComposeTestRule
|
|
|
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
|
|
|
import androidx.compose.ui.test.onAllNodesWithTag
|
|
|
|
import androidx.compose.ui.test.onChildren
|
|
|
|
import androidx.compose.ui.test.onNodeWithTag
|
|
|
|
import androidx.compose.ui.test.onNodeWithText
|
|
|
|
import androidx.compose.ui.test.performClick
|
2022-04-19 18:28:49 -07:00
|
|
|
import androidx.compose.ui.test.performScrollTo
|
2022-01-31 13:42:22 -08:00
|
|
|
import androidx.compose.ui.test.performTextInput
|
2022-03-16 12:26:39 -07:00
|
|
|
import androidx.test.core.app.ApplicationProvider
|
2022-06-02 08:09:02 -07:00
|
|
|
import androidx.test.core.graphics.writeToTestStorage
|
2023-03-26 23:25:36 -07:00
|
|
|
import androidx.test.espresso.Espresso
|
2022-06-02 08:09:02 -07:00
|
|
|
import androidx.test.espresso.Espresso.onView
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
|
|
|
import androidx.test.espresso.screenshot.captureToBitmap
|
2022-01-31 13:42:22 -08:00
|
|
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
2022-06-08 07:22:09 -07:00
|
|
|
import androidx.test.filters.LargeTest
|
|
|
|
import androidx.test.filters.MediumTest
|
|
|
|
import androidx.test.filters.SdkSuppress
|
2023-02-17 03:05:23 -08:00
|
|
|
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
|
|
|
|
import cash.z.ecc.android.sdk.model.MonetarySeparators
|
2023-03-21 12:04:16 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.SeedPhrase
|
2023-03-26 23:25:36 -07:00
|
|
|
import cash.z.ecc.sdk.fixture.MemoFixture
|
2022-01-31 13:42:22 -08:00
|
|
|
import cash.z.ecc.sdk.fixture.SeedPhraseFixture
|
2023-02-20 10:46:23 -08:00
|
|
|
import co.electriccoin.zcash.configuration.model.map.StringConfiguration
|
2022-03-16 12:26:39 -07:00
|
|
|
import co.electriccoin.zcash.spackle.FirebaseTestLabUtil
|
2022-05-02 12:49:49 -07:00
|
|
|
import co.electriccoin.zcash.test.UiTestPrerequisites
|
2022-03-08 11:05:03 -08:00
|
|
|
import co.electriccoin.zcash.ui.MainActivity
|
2022-08-09 12:23:38 -07:00
|
|
|
import co.electriccoin.zcash.ui.NavigationTargets
|
2022-03-08 11:05:03 -08:00
|
|
|
import co.electriccoin.zcash.ui.R
|
2023-02-20 10:46:23 -08:00
|
|
|
import co.electriccoin.zcash.ui.configuration.ConfigurationEntries
|
2022-06-08 07:22:09 -07:00
|
|
|
import co.electriccoin.zcash.ui.design.component.ConfigurationOverride
|
|
|
|
import co.electriccoin.zcash.ui.design.component.UiMode
|
2022-03-08 11:05:03 -08:00
|
|
|
import co.electriccoin.zcash.ui.screen.backup.BackupTag
|
|
|
|
import co.electriccoin.zcash.ui.screen.home.viewmodel.SecretState
|
|
|
|
import co.electriccoin.zcash.ui.screen.restore.RestoreTag
|
2023-03-21 12:04:16 -07:00
|
|
|
import co.electriccoin.zcash.ui.screen.restore.viewmodel.RestoreViewModel
|
2023-02-20 10:46:23 -08:00
|
|
|
import kotlinx.collections.immutable.persistentMapOf
|
2022-01-31 13:42:22 -08:00
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
import kotlinx.coroutines.withContext
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
2023-03-21 12:04:16 -07:00
|
|
|
import kotlin.time.Duration.Companion.seconds
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-01-26 11:12:44 -08:00
|
|
|
private const val DEFAULT_TIMEOUT_MILLISECONDS = 10_000L
|
2023-01-17 23:31:06 -08:00
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
/*
|
|
|
|
* This screenshot implementation does not change the system-wide configuration, but rather
|
|
|
|
* injects a Context with a modified Configuration to change the uiMode and Locale.
|
|
|
|
*
|
|
|
|
* This works by:
|
|
|
|
* 1. Main Activity wraps the Composable with an Override
|
|
|
|
* 2. Main Activity exposes a Flow where a ConfigurationOverride can be set
|
|
|
|
* 3. We use an altered resContext in the tests instead of Application Context in order to load
|
|
|
|
* the right resources for comparison.
|
|
|
|
*
|
|
|
|
* Benefits of this implementation are that we do not modify system-wide values and don't require
|
|
|
|
* additional permissions to run these tests.
|
|
|
|
*
|
|
|
|
* Limitations of this implementation are that any views outside of Compose will not be updated, which
|
|
|
|
* can include the on-screen keyboard, system dialogs (like permissions), or other UI elements.
|
|
|
|
*
|
|
|
|
* An alternative implementation would be to use AppCompatActivity as the parent class for MainActivity,
|
|
|
|
* then rely on the AppCompat APIs for changing uiMode and Locale. This doesn't bring much benefit over
|
|
|
|
* our approach (it still has the problem with system dialogs and the keyboard), and it requires that
|
|
|
|
* we pull in the appcompat library.
|
|
|
|
*/
|
2022-05-02 12:49:49 -07:00
|
|
|
class ScreenshotTest : UiTestPrerequisites() {
|
2022-01-31 13:42:22 -08:00
|
|
|
|
|
|
|
companion object {
|
2022-06-08 07:22:09 -07:00
|
|
|
fun takeScreenshot(tag: String, screenshotName: String) {
|
2022-06-02 08:09:02 -07:00
|
|
|
onView(isRoot())
|
|
|
|
.captureToBitmap()
|
2022-06-08 07:22:09 -07:00
|
|
|
.writeToTestStorage("$screenshotName - $tag")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@get:Rule
|
2022-06-02 08:09:02 -07:00
|
|
|
val composeTestRule = createAndroidComposeRule(MainActivity::class.java)
|
2022-01-31 13:42:22 -08:00
|
|
|
|
|
|
|
private fun navigateTo(route: String) = runBlocking {
|
|
|
|
withContext(Dispatchers.Main) {
|
|
|
|
composeTestRule.activity.navControllerForTesting.navigate(route)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun runWith(uiMode: UiMode, locale: String, action: (Context, String) -> Unit) {
|
|
|
|
val configurationOverride = ConfigurationOverride(uiMode, LocaleList.forLanguageTags(locale))
|
|
|
|
composeTestRule.activity.configurationOverrideFlow.value = configurationOverride
|
|
|
|
|
|
|
|
val applicationContext = ApplicationProvider.getApplicationContext<Context>()
|
|
|
|
val configuration = configurationOverride.newConfiguration(applicationContext.resources.configuration)
|
|
|
|
val resContext = applicationContext.createConfigurationContext(configuration)
|
|
|
|
|
|
|
|
action(resContext, "$uiMode-$locale")
|
|
|
|
}
|
|
|
|
|
2022-01-31 13:42:22 -08:00
|
|
|
@Test
|
2022-06-08 07:22:09 -07:00
|
|
|
@MediumTest
|
|
|
|
fun take_screenshots_for_restore_wallet_light_en_XA() {
|
|
|
|
runWith(UiMode.Light, "en-XA") { context, tag ->
|
|
|
|
take_screenshots_for_restore_wallet(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
|
|
|
fun take_screenshots_for_restore_wallet_light_ar_XB() {
|
|
|
|
runWith(UiMode.Light, "ar-XB") { context, tag ->
|
|
|
|
take_screenshots_for_restore_wallet(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
|
|
|
fun take_screenshots_for_restore_wallet_light_en_US() {
|
|
|
|
runWith(UiMode.Light, "en-US") { context, tag ->
|
|
|
|
take_screenshots_for_restore_wallet(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dark mode was introduced in Android Q
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
|
|
|
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q)
|
|
|
|
fun take_screenshots_for_restore_wallet_dark_en_US() {
|
|
|
|
runWith(UiMode.Dark, "en-US") { context, tag ->
|
|
|
|
take_screenshots_for_restore_wallet(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-22 12:05:19 -07:00
|
|
|
// TODO [#859]: Screenshot tests fail on Firebase Test Lab
|
|
|
|
// https://github.com/zcash/secant-android-wallet/issues/859
|
|
|
|
// Some of the restore screenshots broke with the Compose 1.4 update and we don't yet know why.
|
|
|
|
private val isRestoreScreenshotsEnabled = false
|
|
|
|
|
|
|
|
@Suppress("LongMethod", "FunctionNaming", "CyclomaticComplexMethod")
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun take_screenshots_for_restore_wallet(resContext: Context, tag: String) {
|
2022-03-16 12:26:39 -07:00
|
|
|
// TODO [#286]: Screenshot tests fail on Firebase Test Lab
|
2022-10-18 06:08:36 -07:00
|
|
|
// TODO [#286]: https://github.com/zcash/secant-android-wallet/issues/286
|
2022-03-16 12:26:39 -07:00
|
|
|
if (FirebaseTestLabUtil.isFirebaseTestLab(ApplicationProvider.getApplicationContext())) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-01-17 23:31:06 -08:00
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.None }
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
if (ConfigurationEntries.IS_SHORT_ONBOARDING_UX.getValue(emptyConfiguration)) {
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_short_import_existing_wallet)).also {
|
|
|
|
it.assertExists()
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
} else {
|
2023-02-21 10:28:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_1_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-21 10:28:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_skip)).also {
|
|
|
|
it.assertExists()
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_4_import_existing_wallet)).also {
|
|
|
|
it.assertExists()
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
|
2022-12-01 03:31:02 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.restore_title)).also {
|
2022-01-31 13:42:22 -08:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
takeScreenshot(tag, "Import 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
|
|
|
val seedPhraseSplitLength = SeedPhraseFixture.new().split.size
|
|
|
|
SeedPhraseFixture.new().split.forEachIndexed { index, string ->
|
|
|
|
composeTestRule.onNodeWithTag(RestoreTag.SEED_WORD_TEXT_FIELD).also {
|
|
|
|
it.performTextInput(string)
|
|
|
|
|
|
|
|
// Take a screenshot half-way through filling in the seed phrase
|
|
|
|
if (index == seedPhraseSplitLength / 2) {
|
2022-06-08 07:22:09 -07:00
|
|
|
takeScreenshot(tag, "Import 2")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-21 12:04:16 -07:00
|
|
|
composeTestRule.waitUntil {
|
|
|
|
composeTestRule.activity.viewModels<RestoreViewModel>().value.userWordList.current.value.size == SeedPhrase.SEED_PHRASE_SIZE
|
|
|
|
}
|
|
|
|
|
2023-03-22 12:05:19 -07:00
|
|
|
if (isRestoreScreenshotsEnabled.not()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-21 12:04:16 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.restore_seed_button_restore)).also {
|
|
|
|
it.performScrollTo()
|
|
|
|
|
|
|
|
// Even with waiting for the word list in the view model, there's some latency before the button is enabled
|
|
|
|
composeTestRule.waitUntil(5.seconds.inWholeMilliseconds) {
|
2023-03-22 12:05:19 -07:00
|
|
|
runCatching { it.assertIsEnabled() }.isSuccess
|
2023-03-21 12:04:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.restore_birthday_button_restore)).also {
|
|
|
|
composeTestRule.waitUntil(5.seconds.inWholeMilliseconds) {
|
|
|
|
kotlin.runCatching { it.assertExists() }.isSuccess
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
takeScreenshot(tag, "Import 3")
|
|
|
|
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.restore_birthday_button_skip)).also {
|
|
|
|
it.performScrollTo()
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.restore_complete_header)).also {
|
2022-01-31 13:42:22 -08:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2023-03-21 12:04:16 -07:00
|
|
|
takeScreenshot(tag, "Import 4")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2022-06-08 07:22:09 -07:00
|
|
|
@LargeTest
|
|
|
|
fun take_screenshots_for_new_wallet_and_rest_of_app_light_en_XA() {
|
|
|
|
runWith(UiMode.Light, "en-XA") { context, tag ->
|
|
|
|
take_screenshots_for_new_wallet_and_rest_of_app(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@LargeTest
|
|
|
|
fun take_screenshots_for_new_wallet_and_rest_of_app_light_ar_XB() {
|
|
|
|
runWith(UiMode.Light, "ar-XB") { context, tag ->
|
|
|
|
take_screenshots_for_new_wallet_and_rest_of_app(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@LargeTest
|
|
|
|
fun take_screenshots_for_new_wallet_and_rest_of_app_light_en_US() {
|
|
|
|
runWith(UiMode.Light, "en-US") { context, tag ->
|
|
|
|
take_screenshots_for_new_wallet_and_rest_of_app(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dark mode was introduced in Android Q
|
|
|
|
@Test
|
|
|
|
@LargeTest
|
|
|
|
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q)
|
|
|
|
fun take_screenshots_for_new_wallet_and_rest_of_app_dark_en_US() {
|
|
|
|
runWith(UiMode.Dark, "en-US") { context, tag ->
|
|
|
|
take_screenshots_for_new_wallet_and_rest_of_app(context, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String) {
|
2022-03-16 12:26:39 -07:00
|
|
|
// TODO [#286]: Screenshot tests fail on Firebase Test Lab
|
2022-10-18 06:08:36 -07:00
|
|
|
// TODO [#286]: https://github.com/zcash/secant-android-wallet/issues/286
|
2022-03-16 12:26:39 -07:00
|
|
|
if (FirebaseTestLabUtil.isFirebaseTestLab(ApplicationProvider.getApplicationContext())) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
onboardingScreenshots(resContext, tag, composeTestRule)
|
|
|
|
backupScreenshots(resContext, tag, composeTestRule)
|
|
|
|
homeScreenshots(resContext, tag, composeTestRule)
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
// These are the buttons on the home screen
|
|
|
|
navigateTo(NavigationTargets.SEND)
|
|
|
|
sendZecScreenshots(resContext, tag, composeTestRule)
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
navigateTo(NavigationTargets.RECEIVE)
|
|
|
|
receiveZecScreenshots(resContext, tag, composeTestRule)
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
// These are the hamburger menu items
|
|
|
|
// We could manually click on each one, which is a better integration test but a worse screenshot test
|
|
|
|
navigateTo(NavigationTargets.SEED)
|
|
|
|
seedScreenshots(resContext, tag, composeTestRule)
|
2022-02-17 05:08:06 -08:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
navigateTo(NavigationTargets.SETTINGS)
|
|
|
|
settingsScreenshots(resContext, tag, composeTestRule)
|
2022-04-19 18:28:49 -07:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
navigateTo(NavigationTargets.SUPPORT)
|
2022-06-08 07:22:09 -07:00
|
|
|
supportScreenshots(resContext, tag, composeTestRule)
|
2022-04-19 18:28:49 -07:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
navigateTo(NavigationTargets.ABOUT)
|
2022-06-08 07:22:09 -07:00
|
|
|
aboutScreenshots(resContext, tag, composeTestRule)
|
2022-04-25 05:35:30 -07:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
navigateTo(NavigationTargets.WALLET_ADDRESS_DETAILS)
|
|
|
|
addressDetailsScreenshots(resContext, tag, composeTestRule)
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-21 10:28:03 -08:00
|
|
|
private val emptyConfiguration = StringConfiguration(persistentMapOf(), null)
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun onboardingScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) {
|
2023-01-17 23:31:06 -08:00
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.None }
|
2023-03-03 05:06:03 -08:00
|
|
|
if (ConfigurationEntries.IS_SHORT_ONBOARDING_UX.getValue(emptyConfiguration)) {
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_short_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Onboarding 1")
|
|
|
|
}
|
|
|
|
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_short_create_new_wallet)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
} else {
|
2023-02-21 10:28:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_1_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Onboarding 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-21 10:28:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_next)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-21 10:28:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_2_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Onboarding 2")
|
|
|
|
}
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_next)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-02-21 10:28:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_3_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Onboarding 3")
|
|
|
|
}
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_next)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_4_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Onboarding 4")
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.onboarding_4_create_new_wallet)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun backupScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) {
|
2023-01-17 23:31:06 -08:00
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.NeedsBackup }
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
if (ConfigurationEntries.IS_SHORT_ONBOARDING_UX.getValue(emptyConfiguration)) {
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_short_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_short_button_finished)).also {
|
|
|
|
it.assertExists()
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_1_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_1_button)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_2_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup 2")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_2_button)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_3_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup 3")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_3_button_finished)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_4_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup 4")
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
// Fail test first
|
|
|
|
composeTestRule.onAllNodesWithTag(BackupTag.DROPDOWN_CHIP).also {
|
|
|
|
it[0].performScrollTo()
|
|
|
|
it[0].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[0].performClick()
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[1].performScrollTo()
|
|
|
|
it[1].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[1].performClick()
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[2].performScrollTo()
|
|
|
|
it[2].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[2].performClick()
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[3].performScrollTo()
|
|
|
|
it[3].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[3].performClick()
|
|
|
|
}
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_4_header_ouch)).also {
|
|
|
|
it.assertExists()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup Fail")
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.new_wallet_4_button_retry))).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_3_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_3_button_finished)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.new_wallet_4_header)).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onAllNodesWithTag(BackupTag.DROPDOWN_CHIP).also {
|
|
|
|
it.assertCountEquals(4)
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[0].performScrollTo()
|
|
|
|
it[0].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[1].performClick()
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[1].performScrollTo()
|
|
|
|
it[1].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[0].performClick()
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[2].performScrollTo()
|
|
|
|
it[2].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[3].performClick()
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
it[3].performScrollTo()
|
|
|
|
it[3].performClick()
|
|
|
|
composeTestRule.onNode(hasTestTag(BackupTag.DROPDOWN_MENU)).onChildren()[2].performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.new_wallet_5_body))).also {
|
|
|
|
it.assertExists()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Backup 5")
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2023-03-03 05:06:03 -08:00
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.new_wallet_5_button_finished))).also {
|
|
|
|
it.assertExists()
|
|
|
|
it.performClick()
|
|
|
|
}
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun homeScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) {
|
2023-01-17 23:31:06 -08:00
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.Ready }
|
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.walletSnapshot.value != null }
|
2022-01-31 13:42:22 -08:00
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.home_button_send))).also {
|
2022-01-31 13:42:22 -08:00
|
|
|
it.assertExists()
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "Home 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
composeTestRule.onNode(hasContentDescription(resContext.getString(R.string.home_menu_content_description))).also {
|
2022-01-31 13:42:22 -08:00
|
|
|
it.assertExists()
|
2023-02-28 05:54:07 -08:00
|
|
|
it.performClick()
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Home 2 - Menu")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun settingsScreenshots(resContext: Context, tag: String, composeTestRule: ComposeTestRule) {
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.settings_header))).also {
|
2022-01-31 13:42:22 -08:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "Settings 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun addressDetailsScreenshots(resContext: Context, tag: String, composeTestRule: ComposeTestRule) {
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.wallet_address_title))).also {
|
2022-01-31 13:42:22 -08:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "Addresses 1")
|
2022-01-31 13:42:22 -08:00
|
|
|
}
|
2022-02-17 05:08:06 -08:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
// This screen is not currently navigable from the app
|
|
|
|
@Suppress("UnusedPrivateMember")
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun requestZecScreenshots(resContext: Context, tag: String, composeTestRule: ComposeTestRule) {
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.request_title))).also {
|
2022-02-17 05:08:06 -08:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "Request 1")
|
2022-02-17 05:08:06 -08:00
|
|
|
}
|
2022-03-01 05:11:23 -08:00
|
|
|
|
2023-02-28 05:54:07 -08:00
|
|
|
private fun receiveZecScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) {
|
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.addresses.value != null }
|
|
|
|
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.receive_title))).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Receive 1")
|
|
|
|
|
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.receive_see_address_details)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
composeTestRule.waitForIdle()
|
|
|
|
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Address details")
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun sendZecScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) {
|
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.synchronizer.value != null }
|
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.spendingKey.value != null }
|
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.walletSnapshot.value != null }
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.send_title))).also {
|
2022-03-01 05:11:23 -08:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2023-03-26 23:25:36 -07:00
|
|
|
// Screenshot: Empty form
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "Send 1")
|
2022-03-01 05:11:23 -08:00
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.send_amount)).also {
|
2022-03-01 05:11:23 -08:00
|
|
|
val separators = MonetarySeparators.current()
|
|
|
|
|
2023-03-26 23:25:36 -07:00
|
|
|
it.performTextInput("0${separators.decimal}123")
|
2022-03-01 05:11:23 -08:00
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.send_to)).also {
|
2022-03-01 05:11:23 -08:00
|
|
|
it.performTextInput(WalletAddressFixture.UNIFIED_ADDRESS_STRING)
|
|
|
|
}
|
|
|
|
|
2023-03-26 23:25:36 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.send_memo)).also {
|
|
|
|
it.performTextInput(MemoFixture.MEMO_STRING)
|
|
|
|
}
|
|
|
|
|
|
|
|
// To close soft keyboard to reveal the send button
|
|
|
|
Espresso.closeSoftKeyboard()
|
|
|
|
|
|
|
|
// Screenshot: Fulfilled form
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Send 2")
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.send_create)).also {
|
2022-03-01 05:11:23 -08:00
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
2023-03-26 23:25:36 -07:00
|
|
|
/*
|
|
|
|
TODO [#817]: Screenshot test on Send with pseudolocales problem
|
|
|
|
TODO [#817]: https://github.com/zcash/secant-android-wallet/issues/817
|
|
|
|
// Screenshot: Confirmation
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Send 3")
|
2022-03-01 05:11:23 -08:00
|
|
|
|
2023-03-26 23:25:36 -07:00
|
|
|
composeTestRule.onNodeWithText(resContext.getString(R.string.send_confirmation_button)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Screenshot: Sending
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Send 4")
|
|
|
|
|
|
|
|
// Note: this is potentially a long running waiting for the transaction submit result
|
|
|
|
// Remove this last section of taking screenshot if it turns out to be problematic
|
|
|
|
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) {
|
|
|
|
composeTestRule.onAllNodesWithText(resContext.getString(R.string.send_in_progress_wait))
|
|
|
|
.fetchSemanticsNodes().isEmpty()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Screenshot: Result
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Send 5")
|
|
|
|
*/
|
2022-03-01 05:11:23 -08:00
|
|
|
}
|
2022-04-19 18:28:49 -07:00
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun supportScreenshots(resContext: Context, tag: String, composeTestRule: ComposeTestRule) {
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.support_header))).also {
|
2022-04-19 18:28:49 -07:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "Support 1")
|
2022-04-19 18:28:49 -07:00
|
|
|
}
|
2022-04-25 05:35:30 -07:00
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
private fun aboutScreenshots(resContext: Context, tag: String, composeTestRule: ComposeTestRule) {
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.about_title))).also {
|
2022-04-25 05:35:30 -07:00
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
2022-06-08 07:22:09 -07:00
|
|
|
ScreenshotTest.takeScreenshot(tag, "About 1")
|
2022-04-25 05:35:30 -07:00
|
|
|
}
|
2023-02-28 05:54:07 -08:00
|
|
|
|
|
|
|
private fun seedScreenshots(resContext: Context, tag: String, composeTestRule: ComposeTestRule) {
|
|
|
|
composeTestRule.onNode(hasText(resContext.getString(R.string.seed_title))).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
|
|
|
|
|
|
|
ScreenshotTest.takeScreenshot(tag, "Seed 1")
|
|
|
|
}
|