1
0
Fork 0

For #11764: delay single-click duration to avoid long-clicks (#11949)

master
Oana Horvath 2020-06-25 21:21:51 +03:00 committed by GitHub
parent 665fb8d60c
commit 45bc42f92d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
@ -24,7 +25,6 @@ import org.mozilla.fenix.ui.robots.homeScreen
class ThreeDotMenuMainTest {
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var mockWebServer: MockWebServer
@get:Rule
@ -38,6 +38,16 @@ class ThreeDotMenuMainTest {
}
}
// changing the device preference for Touch and Hold delay, to avoid long-clicks instead of a single-click
companion object {
@BeforeClass
@JvmStatic
fun setDevicePreference() {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.executeShellCommand("settings put secure long_press_timeout 1500")
}
}
@After
fun tearDown() {
mockWebServer.shutdown()

View File

@ -19,7 +19,6 @@ import androidx.test.espresso.intent.matcher.IntentMatchers.toPackage
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
@ -369,19 +368,19 @@ private fun assertLeakCanaryButton() {
private fun assertAboutHeading(): ViewInteraction {
scrollToElementByText("About")
return onView(withText("About"))
.check(matches(isCompletelyDisplayed()))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertRateOnGooglePlay(): ViewInteraction {
scrollToElementByText("About Firefox Preview")
return onView(withText("Rate on Google Play"))
.check(matches(isCompletelyDisplayed()))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertAboutFirefoxPreview(): ViewInteraction {
scrollToElementByText("About Firefox Preview")
return onView(withText("About Firefox Preview"))
.check(matches(isCompletelyDisplayed()))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
fun swipeToBottom() = onView(withId(R.id.recycler_view)).perform(ViewActions.swipeUp())