From aa63facce4dba67dfd0400c28e5c8a262920eea5 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Fri, 10 Sep 2021 12:12:27 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/21133 fix openMainMenuSyncItemTest UI test --- .../java/org/mozilla/fenix/ui/SmokeTest.kt | 3 ++- .../fenix/ui/robots/SyncSignInRobot.kt | 20 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index 5f85ee9266..83444a26ca 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -274,9 +274,10 @@ class SmokeTest { navigationToolbar { }.enterURLAndEnterToBrowser(defaultWebPage.url) { + mDevice.waitForIdle() }.openThreeDotMenu { }.openSyncSignIn { - verifySyncSignInMenuHeader() + verifyTurnOnSyncMenu() } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SyncSignInRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SyncSignInRobot.kt index ac7132ea77..e00503bcba 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SyncSignInRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SyncSignInRobot.kt @@ -6,14 +6,18 @@ package org.mozilla.fenix.ui.robots import androidx.test.espresso.Espresso.onView import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withText -import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice +import androidx.test.uiautomator.UiSelector import org.hamcrest.CoreMatchers.allOf +import org.junit.Assert.assertTrue import org.mozilla.fenix.R +import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime +import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.click /** @@ -22,7 +26,7 @@ import org.mozilla.fenix.helpers.click class SyncSignInRobot { fun verifyAccountSettingsMenuHeader() = assertAccountSettingsMenuHeader() - fun verifySyncSignInMenuHeader() = assertSyncSignInMenuHeader() + fun verifyTurnOnSyncMenu() = assertTurnOnSyncMenu() class Transition { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!! @@ -46,7 +50,13 @@ private fun assertAccountSettingsMenuHeader() { .check((matches(withEffectiveVisibility(Visibility.VISIBLE)))) } -private fun assertSyncSignInMenuHeader() { - onView(withText(R.string.sign_in_with_camera)) - .check((matches(withEffectiveVisibility(Visibility.VISIBLE)))) +private fun assertTurnOnSyncMenu() { + mDevice.findObject(UiSelector().resourceId("$packageName:id/container")).waitForExists(waitingTime) + assertTrue( + mDevice.findObject( + UiSelector() + .resourceId("$packageName:id/signInScanButton") + .resourceId("$packageName:id/signInEmailButton") + ).waitForExists(waitingTime) + ) }