Commit 32493491 authored by Mugurell's avatar Mugurell
Browse files

For #17195 - Test a potential fix for the test

parent 23cc3522
......@@ -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()
}
......
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment