diff --git a/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt b/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt index 71f7456690..52e9838f10 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt @@ -11,6 +11,11 @@ import android.net.Uri import android.os.Build import android.preference.PreferenceManager import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.ViewAction +import androidx.test.espresso.action.CoordinatesProvider +import androidx.test.espresso.action.GeneralClickAction +import androidx.test.espresso.action.Press +import androidx.test.espresso.action.Tap import androidx.test.espresso.action.ViewActions.longClick import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -89,4 +94,20 @@ object TestHelper { context.startActivity(intent) } } + + fun sendSingleTapToScreen(x: Int, y: Int): ViewAction? { + return GeneralClickAction( + Tap.SINGLE, + CoordinatesProvider { view -> + val screenPos = IntArray(2) + view.getLocationOnScreen(screenPos) + val screenX = screenPos[0] + x.toFloat() + val screenY = screenPos[1] + y.toFloat() + floatArrayOf(screenX, screenY) + }, + Press.FINGER, + 0, + 0 + ) + } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt index 094ddc7a9b..5e2aa903f6 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt @@ -17,6 +17,7 @@ import org.junit.Test import org.mozilla.fenix.helpers.AndroidAssetDispatcher import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.TestAssetHelper +import org.mozilla.fenix.helpers.TestHelper.sendSingleTapToScreen import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.navigationToolbar @@ -267,7 +268,9 @@ class TabbedBrowsingTest { notificationShade { verifyPrivateTabsNotification() }.clickClosePrivateTabsNotification { - verifyPrivateSessionMessage() + // Tap an empty spot on the app homescreen to make sure it's into focus + sendSingleTapToScreen(20, 20) + verifyPrivateSessionMessage(visible = true) } } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index 16d0521e31..227b2123a3 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -559,7 +559,7 @@ const val PRIVATE_SESSION_MESSAGE = " else who uses this device." private fun assertPrivateSessionMessage(visible: Boolean) = - onView(allOf(withText(PRIVATE_SESSION_MESSAGE))) + onView(withId(R.id.private_session_description)) .check( if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else doesNotExist() )