From cf69058ce8260d83eadc5027f00e00d1af9323f8 Mon Sep 17 00:00:00 2001 From: Oana Horvath Date: Mon, 7 Sep 2020 17:29:28 +0300 Subject: [PATCH] Closes #12645: Re-enable mediaSystemNotificationInPrivateModeTest --- .../mozilla/fenix/ui/MediaNotificationTest.kt | 4 ++-- .../mozilla/fenix/ui/robots/BrowserRobot.kt | 18 ++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/MediaNotificationTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/MediaNotificationTest.kt index 14d463209..8069ccb38 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/MediaNotificationTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/MediaNotificationTest.kt @@ -8,7 +8,6 @@ import androidx.test.uiautomator.UiSelector 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 @@ -61,6 +60,7 @@ class MediaNotificationTest { }.enterURLAndEnterToBrowser(videoTestPage.url) { mDevice.waitForIdle() clickMediaPlayerPlayButton() + waitForPlaybackToStart() }.openNotificationShade { verifySystemNotificationExists(videoTestPage.title) clickMediaSystemNotificationControlButton("Pause") @@ -136,7 +136,6 @@ class MediaNotificationTest { } } - @Ignore("Flaky test, temp disabled: https://github.com/mozilla-mobile/fenix/issues/12645") @Test fun mediaSystemNotificationInPrivateModeTest() { val audioTestPage = TestAssetHelper.getAudioPageAsset(mockWebServer) @@ -160,6 +159,7 @@ class MediaNotificationTest { verifyMediaIsPaused() }.openTabDrawer { closeTab() + verifySnackBarText("Private tab closed") } mDevice.openNotification() 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 e07d7ba8c..771b4fddf 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 @@ -12,14 +12,12 @@ import android.net.Uri import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.action.ViewActions -import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.intent.Intents import androidx.test.espresso.intent.matcher.BundleMatchers import androidx.test.espresso.intent.matcher.IntentMatchers import androidx.test.espresso.matcher.RootMatchers.isDialog import androidx.test.espresso.matcher.ViewMatchers -import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed @@ -33,7 +31,6 @@ import androidx.test.uiautomator.By.text import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.Until -import androidx.test.uiautomator.Until.hasObject import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.containsString import org.junit.Assert.assertTrue @@ -328,14 +325,7 @@ class BrowserRobot { } fun clickMediaPlayerPlayButton() { - mDevice.waitNotNull( - hasObject( - By - .clazz("android.widget.Button") - .textContains("Play") - ), - waitingTime - ) + mediaPlayerPlayButton().waitForExists(waitingTime) mediaPlayerPlayButton().click() } @@ -459,9 +449,9 @@ private fun tabsCounter() = onView(withId(R.id.counter_box)) private fun mediaPlayerPlayButton() = mDevice.findObject( - By - .clazz("android.widget.Button") - .textContains("Play") + UiSelector() + .className("android.widget.Button") + .text("Play") ) private fun assertBlueDot() {