From 6b4fbca1bbdfe1f813f5b443d6bb7f6b4bb71c0c Mon Sep 17 00:00:00 2001 From: Oana Horvath Date: Fri, 13 Nov 2020 10:25:08 +0200 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/12899: fixed UI test for ETP off --- .../java/org/mozilla/fenix/ui/SmokeTest.kt | 9 +++------ .../java/org/mozilla/fenix/ui/robots/BrowserRobot.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 12 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 cebb84683..6adcce398 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -10,7 +10,6 @@ import androidx.test.uiautomator.UiDevice import okhttp3.mockwebserver.MockWebServer import org.junit.After import org.junit.Before -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.mozilla.fenix.helpers.AndroidAssetDispatcher @@ -130,9 +129,8 @@ class SmokeTest { } } - @Ignore("Flaky test: https://github.com/mozilla-mobile/fenix/issues/12899") @Test - fun verifyETPToolbarShieldIconIsNotDisplayedIfETPIsOFFGloballyTest() { + fun verifyETPShieldNotDisplayedIfOFFGlobally() { val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) homeScreen { @@ -149,9 +147,8 @@ class SmokeTest { }.openSettings { }.openEnhancedTrackingProtectionSubMenu { clickEnhancedTrackingProtectionDefaults() - }.goBackToHomeScreen { - }.openTabDrawer { - }.openTab(defaultWebPage.title) { + }.goBack { + }.goBackToBrowser { clickEnhancedTrackingProtectionPanel() verifyEnhancedTrackingProtectionSwitch() // Turning off TP Switch results in adding the WebPage to exception list 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 8d45e5a8a..dcf84c575 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 @@ -33,6 +33,7 @@ import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.Until import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.containsString +import org.hamcrest.Matchers.not import org.junit.Assert.assertTrue import org.mozilla.fenix.R import org.mozilla.fenix.ext.components @@ -185,10 +186,10 @@ class BrowserRobot { .perform(ViewActions.pressBack()) } - fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionPanel().click() + fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionIndicator().click() fun verifyEnhancedTrackingProtectionPanelNotVisible() = - assertEnhancedTrackingProtectionPanelNotVisible() + assertEnhancedTrackingProtectionIndicatorNotVisible() fun clickContextOpenLinkInNewTab() { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) @@ -413,12 +414,11 @@ fun navURLBar() = onView(withId(R.id.mozac_browser_toolbar_url_view)) private fun assertNavURLBar() = navURLBar() .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) -fun enhancedTrackingProtectionPanel() = +fun enhancedTrackingProtectionIndicator() = onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator)) -private fun assertEnhancedTrackingProtectionPanelNotVisible() { - enhancedTrackingProtectionPanel() - .check(matches(withEffectiveVisibility(Visibility.GONE))) +private fun assertEnhancedTrackingProtectionIndicatorNotVisible() { + enhancedTrackingProtectionIndicator().check(matches(not(isDisplayed()))) } private fun assertEnhancedTrackingProtectionSwitch() {