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

Commit

Permalink
Fixes #11764: re-try single-click on openTabDrawer if a long-tap is made
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath committed Jun 23, 2020
1 parent dc36c9a commit e9c4747
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
Expand Down Expand Up @@ -43,7 +42,8 @@ class ThreeDotMenuMainTest {
mockWebServer.shutdown()
}

@Ignore("Instrumentation crash: https://github.com/mozilla-mobile/fenix/issues/11642")
// @Ignore("Instrumentation crash: https://github.com/mozilla-mobile/fenix/issues/11642")

@Test
fun threeDotMenuItemsTest() {
homeScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ package org.mozilla.fenix.ui.robots
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.View
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
Expand All @@ -31,6 +34,7 @@ import androidx.test.uiautomator.Until
import androidx.test.uiautomator.Until.hasObject
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.Matcher
import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
Expand Down Expand Up @@ -370,7 +374,26 @@ class BrowserRobot {

fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
mDevice.waitForIdle(waitingTime)
tabsCounter().click()
tabsCounter().perform(
ViewActions.click(
/* no-op rollback action for when clicks randomly perform a long click, Espresso should attempt to click again
https://issuetracker.google.com/issues/37078920#comment9
*/
object : ViewAction {
override fun getDescription(): String {
return "Handle tap->longclick."
}

override fun getConstraints(): Matcher<View> {
return ViewMatchers.isAssignableFrom(View::class.java)
}

override fun perform(uiController: UiController?, view: View?) {
// do nothing
}
}
)
)

mDevice.waitNotNull(
Until.findObject(By.res("org.mozilla.fenix.debug:id/tab_layout")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions automation/taskcluster/androidTest/flank-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ gcloud:
performance-metrics: true

test-targets:
- package org.mozilla.fenix.ui
- package org.mozilla.fenix.glean
- package org.mozilla.fenix.ui.ThreeDotMenuMainTest#threeDotMenuItemsTest
# - package org.mozilla.fenix.glean

device:
- model: Pixel2
Expand All @@ -52,5 +52,5 @@ 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: 30

0 comments on commit e9c4747

Please sign in to comment.