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 24, 2020
1 parent 673507d commit a33496a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
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

0 comments on commit a33496a

Please sign in to comment.