diff --git a/app/src/androidTest/java/org/mozilla/fenix/helpers/ext/ViewInteraction.kt b/app/src/androidTest/java/org/mozilla/fenix/helpers/ext/ViewInteraction.kt index 601c450cf..e818a0733 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/helpers/ext/ViewInteraction.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/helpers/ext/ViewInteraction.kt @@ -4,7 +4,14 @@ package org.mozilla.fenix.helpers +import android.view.InputDevice +import android.view.MotionEvent +import androidx.test.espresso.ViewAction import androidx.test.espresso.ViewInteraction +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.assertion.ViewAssertions.matches @@ -21,3 +28,21 @@ fun ViewInteraction.assertIsChecked(isChecked: Boolean): ViewInteraction { fun ViewInteraction.assertIsSelected(isSelected: Boolean): ViewInteraction { return this.check(matches(isSelected(isSelected)))!! } + +/** + * Perform a click (simulate the finger touching the View) at a specific location in the View + * rather than the default middle of the View. + * + * Useful in situations where the View we want clicked contains other Views in it's x,y middle + * and we need to simulate the touch in some other free space of the View we want clicked. + */ +fun ViewInteraction.clickAtLocationInView(locationInView: GeneralLocation): ViewAction = + ViewActions.actionWithAssertions( + GeneralClickAction( + Tap.SINGLE, + locationInView, + Press.FINGER, + InputDevice.SOURCE_UNKNOWN, + MotionEvent.BUTTON_PRIMARY + ) + ) 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 2f77988ab..0f84a9ef0 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,8 +7,6 @@ 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 @@ -17,12 +15,8 @@ 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 @@ -51,6 +45,7 @@ import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.click +import org.mozilla.fenix.helpers.clickAtLocationInView import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.helpers.idlingresource.BottomSheetBehaviorStateIdlingResource import org.mozilla.fenix.helpers.matchers.BottomSheetBehaviorHalfExpandedMaxRatioMatcher @@ -264,17 +259,7 @@ class TabDrawerRobot { fun clickTopBar(interact: TabDrawerRobot.() -> Unit): Transition { // 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 - ) - ) - ) + onView(withId(R.id.topBar)).clickAtLocationInView(GeneralLocation.TOP_RIGHT) TabDrawerRobot().interact() return Transition() } diff --git a/automation/taskcluster/androidTest/flank-x86.yml b/automation/taskcluster/androidTest/flank-x86.yml index e1b5ceee8..15e72ac14 100644 --- a/automation/taskcluster/androidTest/flank-x86.yml +++ b/automation/taskcluster/androidTest/flank-x86.yml @@ -38,9 +38,8 @@ gcloud: performance-metrics: true test-targets: - - package org.mozilla.fenix.ui.TabbedBrowsingTest#verifyTabTrayNotShowingStateHalfExpanded -# - package org.mozilla.fenix.ui -# - package org.mozilla.fenix.glean + - package org.mozilla.fenix.ui + - package org.mozilla.fenix.glean device: - model: Pixel2 @@ -53,4 +52,5 @@ 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: 50 + num-test-runs: 1 +