From fe0165a84644b8667bec3475204ed038a731e500 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Fri, 24 Jun 2022 12:12:05 +0300 Subject: [PATCH] For #25726 fix failing testStrictVisitSheetDetails UI test --- .../StrictEnhancedTrackingProtectionTest.kt | 5 ++-- .../mozilla/fenix/ui/robots/BrowserRobot.kt | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt index 7045370b03..5229f8692b 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt @@ -161,7 +161,6 @@ class StrictEnhancedTrackingProtectionTest { } } - @Ignore("Failing, see: https://github.com/mozilla-mobile/fenix/issues/25726") @Test fun testStrictVisitSheetDetails() { val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) @@ -176,7 +175,9 @@ class StrictEnhancedTrackingProtectionTest { } navigationToolbar { - }.enterURLAndEnterToBrowser(trackingProtectionTest.url) {} + }.enterURLAndEnterToBrowser(trackingProtectionTest.url) { + verifyTrackingProtectionWebContent("blocked") + } enhancedTrackingProtection { }.openEnhancedTrackingProtectionSheet { verifyEnhancedTrackingProtectionSheetStatus("ON", true) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index 18ddb028fa..45f34958c3 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -41,6 +41,7 @@ import org.junit.Assert.fail import org.mozilla.fenix.R import org.mozilla.fenix.ext.components import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION +import org.mozilla.fenix.helpers.Constants.RETRY_COUNT import org.mozilla.fenix.helpers.SessionLoadedIdlingResource import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong @@ -682,6 +683,31 @@ class BrowserRobot { ) } + fun verifyTrackingProtectionWebContent(state: String) { + for (i in 1..RETRY_COUNT) { + try { + assertTrue( + mDevice.findObject( + UiSelector().textContains(state) + ).waitForExists(waitingTimeLong) + ) + + break + } catch (e: AssertionError) { + if (i == RETRY_COUNT) { + throw e + } else { + Log.e("TestLog", "On try $i, trackers are not: $state") + + navigationToolbar { + }.openThreeDotMenu { + }.refreshPage { + } + } + } + } + } + class Transition { private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) private fun threeDotButton() = onView(