Skip to content

Commit

Permalink
Fix mozilla-mobile#16960 & mozilla-mobile#16959: updateSavedLoginTest…
Browse files Browse the repository at this point in the history
…, swipeToSwitchTabTest UI smoke tests
  • Loading branch information
Oana Horvath committed Dec 10, 2020
1 parent ca605d8 commit 9d5ec47
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,31 @@ import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.SessionLoadedIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull

class BrowserRobot {
private lateinit var sessionLoadedIdlingResource: SessionLoadedIdlingResource

fun verifyCurrentPrivateSession(context: Context) {
val session = context.components.core.sessionManager.selectedSession
assertTrue("Current session is private", session?.private!!)
}

fun verifyUrl(url: String) {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
sessionLoadedIdlingResource = SessionLoadedIdlingResource()

mDevice.waitNotNull(
Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")),
waitingTime
)
TestAssetHelper.waitingTime
onView(withId(R.id.mozac_browser_toolbar_url_view))
.check(matches(withText(containsString(url.replace("http://", "")))))
runWithIdleRes(sessionLoadedIdlingResource) {
onView(withId(R.id.mozac_browser_toolbar_url_view))
.check(matches(withText(containsString(url.replace("http://", "")))))
}
}

fun verifyHelpUrl() {
Expand All @@ -79,11 +84,16 @@ class BrowserRobot {
*/

fun verifyPageContent(expectedText: String) {
sessionLoadedIdlingResource = SessionLoadedIdlingResource()

mDevice.waitNotNull(
Until.findObject(By.res("org.mozilla.fenix.debug:id/engineView")),
waitingTime
)
assertTrue(mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime))

runWithIdleRes(sessionLoadedIdlingResource) {
assertTrue(mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime))
}
}

fun verifyTabCounter(expectedText: String) {
Expand Down Expand Up @@ -339,6 +349,8 @@ class BrowserRobot {
)
passwordField.waitForExists(waitingTime)
passwordField.setText(password)
// wait until the password is hidden
assertTrue(mDevice.findObject(UiSelector().text(password)).waitUntilGone(waitingTime))
}

fun clickMediaPlayerPlayButton() {
Expand Down

0 comments on commit 9d5ec47

Please sign in to comment.