Commit a98b4089 authored by Oana Horvath's avatar Oana Horvath
Browse files

For #15259 UI test: waits for home screen to be visible

parent e31b4f49
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -12,11 +12,6 @@ import android.os.Build
import android.os.Environment
import androidx.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.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers.withId
@@ -108,22 +103,6 @@ object TestHelper {
        }
    }

    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
        )
    }

    // Remove test file from the device Downloads folder
    @Suppress("Deprecation")
    fun deleteDownloadFromStorage(fileName: String) {
+0 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ 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.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
@@ -254,8 +253,6 @@ class TabbedBrowsingTest {
        notificationShade {
            verifyPrivateTabsNotification()
        }.clickClosePrivateTabsNotification {
            // Tap an empty spot on the app homescreen to make sure it's into focus
            sendSingleTapToScreen(20, 20)
            verifyHomeScreen()
        }
    }
+4 −1
Original line number Diff line number Diff line
@@ -486,8 +486,11 @@ private fun assertFocusedNavigationToolbar() =
    onView(allOf(withHint("Search or enter address")))
        .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))

private fun assertHomeScreen() = onView(ViewMatchers.withResourceName("homeLayout"))
private fun assertHomeScreen() {
    mDevice.findObject(UiSelector().resourceId("$packageName:id/homeLayout")).waitForExists(waitingTime)
    onView(ViewMatchers.withResourceName("homeLayout"))
    .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

private fun assertHomeMenu() = onView(ViewMatchers.withResourceName("menuButton"))
    .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class NotificationRobot {

        fun clickClosePrivateTabsNotification(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
            NotificationRobot().verifySystemNotificationExists("Close private tabs")
            closePrivateTabsNotification().clickAndWaitForNewWindow()
            closePrivateTabsNotification().click()

            HomeScreenRobot().interact()
            return HomeScreenRobot.Transition()