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 okhttp3.mockwebserver.MockWebServer
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.BeforeClass
import org.junit.Ignore import org.junit.Ignore
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -24,7 +25,6 @@ import org.mozilla.fenix.ui.robots.homeScreen
class ThreeDotMenuMainTest { class ThreeDotMenuMainTest {
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping. /* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var mockWebServer: MockWebServer private lateinit var mockWebServer: MockWebServer
@get:Rule @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 @After
fun tearDown() { fun tearDown() {
mockWebServer.shutdown() 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
import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant 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.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
@ -369,19 +368,19 @@ private fun assertLeakCanaryButton() {
private fun assertAboutHeading(): ViewInteraction { private fun assertAboutHeading(): ViewInteraction {
scrollToElementByText("About") scrollToElementByText("About")
return onView(withText("About")) return onView(withText("About"))
.check(matches(isCompletelyDisplayed())) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
} }
private fun assertRateOnGooglePlay(): ViewInteraction { private fun assertRateOnGooglePlay(): ViewInteraction {
scrollToElementByText("About Firefox Preview") scrollToElementByText("About Firefox Preview")
return onView(withText("Rate on Google Play")) return onView(withText("Rate on Google Play"))
.check(matches(isCompletelyDisplayed())) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
} }
private fun assertAboutFirefoxPreview(): ViewInteraction { private fun assertAboutFirefoxPreview(): ViewInteraction {
scrollToElementByText("About Firefox Preview") scrollToElementByText("About Firefox Preview")
return onView(withText("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()) fun swipeToBottom() = onView(withId(R.id.recycler_view)).perform(ViewActions.swipeUp())