[fenix] For https://github.com/mozilla-mobile/fenix/issues/16317: resets long press delay at the end of UI tests

pull/600/head
Oana Horvath 3 years ago
parent ca84828a66
commit 9caaa08732

@ -27,9 +27,14 @@ class HomeActivityTestRule(
ActivityTestRule<HomeActivity>(HomeActivity::class.java, initialTouchMode, launchActivity) {
override fun beforeActivityLaunched() {
super.beforeActivityLaunched()
setLongTapTimeout()
setLongTapTimeout("3000")
if (skipOnboarding) { skipOnboardingBeforeLaunch() }
}
override fun afterActivityFinished() {
super.afterActivityFinished()
setLongTapTimeout("400")
}
}
/**
@ -48,15 +53,20 @@ class HomeActivityIntentTestRule(
IntentsTestRule<HomeActivity>(HomeActivity::class.java, initialTouchMode, launchActivity) {
override fun beforeActivityLaunched() {
super.beforeActivityLaunched()
setLongTapTimeout()
setLongTapTimeout("3000")
if (skipOnboarding) { skipOnboardingBeforeLaunch() }
}
override fun afterActivityFinished() {
super.afterActivityFinished()
setLongTapTimeout("400")
}
}
// changing the device preference for Touch and Hold delay, to avoid long-clicks instead of a single-click
fun setLongTapTimeout() {
fun setLongTapTimeout(delay: String) {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.executeShellCommand("settings put secure long_press_timeout 3000")
mDevice.executeShellCommand("settings put secure long_press_timeout $delay")
}
private fun skipOnboardingBeforeLaunch() {

Loading…
Cancel
Save