From 32493491fa8ddf0e2c350d303bd01d09600d3bbc Mon Sep 17 00:00:00 2001 From: Mugurell Date: Thu, 11 Feb 2021 12:42:05 +0200 Subject: [PATCH] For #17195 - Test a potential fix for the test --- .../mozilla/fenix/ui/robots/TabDrawerRobot.kt | 34 ++++++++++++++++--- .../taskcluster/androidTest/flank-x86.yml | 8 ++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt index 10bd50d4da..2f77988ab7 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt @@ -7,6 +7,8 @@ package org.mozilla.fenix.ui.robots import android.content.Context +import android.view.InputDevice +import android.view.MotionEvent import android.view.View import androidx.recyclerview.widget.RecyclerView import androidx.test.core.app.ApplicationProvider @@ -15,7 +17,12 @@ import androidx.test.espresso.Espresso.onView import androidx.test.espresso.NoMatchingViewException import androidx.test.espresso.UiController import androidx.test.espresso.ViewAction +import androidx.test.espresso.action.GeneralClickAction +import androidx.test.espresso.action.GeneralLocation +import androidx.test.espresso.action.Press +import androidx.test.espresso.action.Tap import androidx.test.espresso.action.ViewActions +import androidx.test.espresso.action.ViewActions.actionWithAssertions import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.replaceText import androidx.test.espresso.assertion.ViewAssertions.doesNotExist @@ -255,7 +262,19 @@ class TabDrawerRobot { } fun clickTopBar(interact: TabDrawerRobot.() -> Unit): Transition { - onView(withId(R.id.topBar)).click() + // The topBar contains other views. + // Don't do the default click in the middle, rather click in some free space - top right. + onView(withId(R.id.topBar)).perform( + actionWithAssertions( + GeneralClickAction( + Tap.SINGLE, + GeneralLocation.TOP_RIGHT, + Press.FINGER, + InputDevice.SOURCE_UNKNOWN, + MotionEvent.BUTTON_PRIMARY + ) + ) + ) TabDrawerRobot().interact() return Transition() } @@ -280,8 +299,11 @@ class TabDrawerRobot { } fun waitForTabTrayBehaviorToIdle(interact: TabDrawerRobot.() -> Unit): Transition { + // Need to get the behavior of tab_wrapper and wait for that to idle. var behavior: BottomSheetBehavior<*>? = null - onView(withId(R.id.tab_wrapper)).perform(object : ViewAction { + + // Null check here since it's possible that the view is already animated away from the screen. + onView(withId(R.id.tab_wrapper))?.perform(object : ViewAction { override fun getDescription(): String { return "Postpone actions to after the BottomSheetBehavior has settled" } @@ -294,9 +316,13 @@ class TabDrawerRobot { behavior = BottomSheetBehavior.from(view!!) } }) - runWithIdleRes(BottomSheetBehaviorStateIdlingResource(behavior!!)) { - TabDrawerRobot().interact() + + behavior?.let { + runWithIdleRes(BottomSheetBehaviorStateIdlingResource(it)) { + TabDrawerRobot().interact() + } } + return Transition() } diff --git a/automation/taskcluster/androidTest/flank-x86.yml b/automation/taskcluster/androidTest/flank-x86.yml index 15e72ac146..e1b5ceee8f 100644 --- a/automation/taskcluster/androidTest/flank-x86.yml +++ b/automation/taskcluster/androidTest/flank-x86.yml @@ -38,8 +38,9 @@ gcloud: performance-metrics: true test-targets: - - package org.mozilla.fenix.ui - - package org.mozilla.fenix.glean + - package org.mozilla.fenix.ui.TabbedBrowsingTest#verifyTabTrayNotShowingStateHalfExpanded +# - package org.mozilla.fenix.ui +# - package org.mozilla.fenix.glean device: - model: Pixel2 @@ -52,5 +53,4 @@ flank: max-test-shards: 50 # num-test-runs: the amount of times to run the tests. # 1 runs the tests once. 10 runs all the tests 10x - num-test-runs: 1 - + num-test-runs: 50