Fix for ambiguous tabstray_title and with text

This commit is contained in:
AndiAJ 2021-10-05 13:52:38 +03:00 committed by mergify[bot]
parent 8d7e5dd4b7
commit 66ac309d40

View File

@ -8,11 +8,9 @@ package org.mozilla.fenix.ui.robots
import android.content.Context import android.content.Context
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.UiController import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction import androidx.test.espresso.ViewAction
import androidx.test.espresso.action.GeneralLocation import androidx.test.espresso.action.GeneralLocation
@ -21,9 +19,7 @@ import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.longClick import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
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
@ -407,16 +403,23 @@ private fun assertExistingOpenTabs(title: String) {
) )
.waitForExists(waitingTime) .waitForExists(waitingTime)
tab(title).check(matches(isDisplayed())) assertTrue(
} catch (e: NoMatchingViewException) { mDevice.findObject(
onView(withId(R.id.tabsTray)).perform( UiSelector()
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>( .resourceId("$packageName:id/mozac_browser_tabstray_title")
allOf( .textContains(title)
withId(R.id.mozac_browser_tabstray_title), ).waitForExists(waitingTime)
withText(title) )
) } catch (e: AssertionError) {
) println("The tab wasn't found")
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) mDevice.findObject(UiSelector().resourceId("$packageName:id/tabsTray")).swipeUp(2)
assertTrue(
mDevice.findObject(
UiSelector()
.resourceId("$packageName:id/mozac_browser_tabstray_title")
.textContains(title)
).waitForExists(waitingTime)
)
} }
} }