Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #16317: resets long press delay at the end of UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath committed Feb 17, 2021
1 parent dfc5628 commit 4e4bbcc
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

/**
Expand All @@ -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() {
Expand Down

0 comments on commit 4e4bbcc

Please sign in to comment.