2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

ui-tests-homescreen-fix-to-enable (#9050)

This commit is contained in:
isabelrios 2020-03-13 16:16:47 +01:00 committed by GitHub
parent dd38f1df0a
commit 74433ba27a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 29 deletions

View File

@ -7,7 +7,6 @@ package org.mozilla.fenix.ui
import androidx.test.uiautomator.UiDevice
import org.junit.Rule
import org.junit.Test
import org.junit.Ignore
import org.mozilla.fenix.helpers.HomeActivityTestRule
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
@ -51,12 +50,17 @@ class HomeScreenTest {
verifyNoCollectionsTextIsNotShown()
verifyHomeToolbar()
verifyHomeComponent()
// Verify Top Sites
verifyExistingTopSitesList()
verifyExistingTopSitesTabs("Wikipedia")
verifyExistingTopSitesTabs("YouTube")
verifyExistingTopSitesTabs("Top Articles")
}
}
@Test
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
fun firstRunHomeScreenItemsTest() {
fun firstRunScreenTest() {
homeScreen {
verifyHomeScreen()
verifyNavigationToolbar()
@ -65,39 +69,59 @@ class HomeScreenTest {
verifyHomeWordmark()
verifyWelcomeHeader()
// Sign in to Firefox
verifyGetTheMostHeader()
verifyAccountsSignInButton()
// Intro to other sections
verifyGetToKnowHeader()
swipeUpToDismissFirstRun()
verifyChooseThemeHeader()
verifyChooseThemeText()
verifyLightThemeToggle()
verifyLightThemeDescription()
verifyDarkThemeToggle()
verifyDarkThemeDescription()
verifyAutomaticThemeToggle()
verifyAutomaticThemeDescription()
// See What's new
scrollToElementByText("See whats new")
verifyWhatsNewHeader()
verifyWhatsNewLink()
// Protect yourself
scrollToElementByText("Protect yourself")
verifyProtectYourselfHeader()
verifyTrackingProtectionToggle()
verifyProtectYourselfText()
/* Check disable due to Firebase failures on Pixel 2 API 28
// Choose your theme
verifyChooseThemeHeader()
verifyChooseThemeText()
verifyDarkThemeDescription()
verifyDarkThemeToggle()
verifyLightThemeDescription()
verifyLightThemeToggle()
// Browse privately
scrollToElementByText("Open Settings")
verifyBrowsePrivatelyHeader()
verifyBrowsePrivatelyText()
*/
swipeToBottom()
// Take a position
scrollToElementByText("Take a position")
verifyTakePositionHeader()
verifyTakePositionElements()
// Your privacy
scrollToElementByText("Your privacy")
verifyYourPrivacyHeader()
verifyYourPrivacyText()
verifyPrivacyNoticeButton()
// Start Browsing
swipeToBottom()
verifyStartBrowsingButton()
}
}
@Test
@Ignore("Temp disable broken test - see: https://github.com/mozilla-mobile/fenix/issues/5050")
fun privateModeScreenItemsTest() {
homeScreen { }.dismissOnboarding()
homeScreen { }.togglePrivateBrowsingMode()
@ -114,10 +138,11 @@ class HomeScreenTest {
verifyPrivateSessionMessage(visible = true)
verifyHomeToolbar()
verifyHomeComponent()
}.openCommonMythsLink {
verifyUrl("common-myths-about-private-browsing")
mDevice.pressBack()
}
homeScreen { }.addNewTab()
homeScreen {
// To deal with the race condition where multiple "add tab" buttons are present,
// we need to wait until previous HomeFragment View objects are gone.

View File

@ -32,6 +32,7 @@ import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.Constants.LongClickDuration
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull
@ -54,8 +55,9 @@ class BrowserRobot {
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))))
.check(matches(withText(containsString(url))))
}
fun verifyHelpUrl() {

View File

@ -82,14 +82,27 @@ class HomeScreenRobot {
fun verifyTrackingProtectionToggle() = assertTrackingProtectionToggle()
fun verifyProtectYourselfText() = assertProtectYourselfText()
// What's new elements
fun verifyWhatsNewHeader() = assertWhatsNewHeather()
fun verifyWhatsNewLink() = assertWhatsNewLink()
// Browse privately
fun verifyBrowsePrivatelyHeader() = assertBrowsePrivatelyHeader()
fun verifyBrowsePrivatelyText() = assertBrowsePrivatelyText()
// Take a position
fun verifyTakePositionHeader() = assertTakePositionheader()
fun verifyTakePositionElements() {
assertTakePositionBottomRadioButton()
assertTakePositionTopRadioButton()
}
// Your privacy
fun verifyYourPrivacyHeader() = assertYourPrivacyHeader()
fun verifyYourPrivacyText() = assertYourPrivacyText()
fun verifyPrivacyNoticeButton() = assertPrivacyNoticeButton()
fun verifyStartBrowsingButton() = assertStartBrowsingButton()
// Private mode elements
fun verifyPrivateSessionHeader() = assertPrivateSessionHeader()
fun verifyPrivateSessionMessage(visible: Boolean = true) = assertPrivateSessionMessage(visible)
@ -153,7 +166,7 @@ class HomeScreenRobot {
.perform(click())
}
fun swipeToBottom() = onView(withId(R.id.sessionControlRecyclerView)).perform(ViewActions.swipeUp())
fun swipeToBottom() = onView(withId(R.id.homeLayout)).perform(ViewActions.swipeUp())
fun swipeToTop() = onView(withId(R.id.sessionControlRecyclerView)).perform(ViewActions.swipeDown())
@ -264,6 +277,14 @@ class HomeScreenRobot {
BrowserRobot().interact()
return BrowserRobot.Transition()
}
fun openCommonMythsLink(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
onView(withId(R.id.private_session_common_myths))
.perform(click())
BrowserRobot().interact()
return BrowserRobot.Transition()
}
}
}
@ -389,7 +410,7 @@ private fun assertChooseThemeHeader() =
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertChooseThemeText() =
onView(allOf(withText("Try dark theme: easier on your battery and your eyes.")))
onView(allOf(withText("Save some battery and your eyesight by enabling dark mode.")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertLightThemeToggle() =
@ -409,7 +430,7 @@ private fun assertDarkThemeDescription() =
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertAutomaticThemeToggle() =
onView(ViewMatchers.withResourceName("theme_automatic_radio_button"))
onView(withId(R.id.theme_automatic_radio_button))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertAutomaticThemeDescription() =
@ -429,7 +450,7 @@ private fun assertProtectYourselfText() {
onView(
allOf(
withText(
"Firefox Preview blocks ad trackers that follow you around the web."
"Firefox Preview helps stop websites from tracking you online."
)
)
)
@ -441,7 +462,7 @@ private fun assertBrowsePrivatelyHeader() =
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertBrowsePrivatelyText() =
onView(allOf(withText(containsString("private browsing is just a tap away."))))
onView(allOf(withText(containsString("Update your private browsing settings."))))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertYourPrivacyHeader() =
@ -462,10 +483,27 @@ private fun assertPrivacyNoticeButton() =
onView(allOf(withText("Read our privacy notice")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
// What's new elements
private fun assertWhatsNewHeather() = onView(allOf(withText("See whats new")))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertWhatsNewLink() = onView(allOf(withText("Get answers here")))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertStartBrowsingButton() =
onView(allOf(withText("Start browsing")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
// Take a position
private fun assertTakePositionheader() = onView(allOf(withText("Take a position")))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertTakePositionTopRadioButton() = onView(ViewMatchers.withResourceName("toolbar_top_radio_button"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertTakePositionBottomRadioButton() = onView(ViewMatchers.withResourceName("toolbar_bottom_radio_button"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
// Private mode elements
private fun assertPrivateSessionHeader() =
onView(allOf(withText("Private tabs")))
@ -482,9 +520,10 @@ private fun assertPrivateSessionMessage(visible: Boolean) =
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else doesNotExist()
)
private fun assertShareTabsButton(visible: Boolean) =
onView(allOf(withId(R.id.share_tabs_button), isDisplayed()))
.check(matches(withEffectiveVisibility(visibleOrGone(visible))))
private fun assertShareTabsButton(visible: Boolean) = onView(allOf(withId(R.id.share_tabs_button)))
.check(
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else matches(withEffectiveVisibility(Visibility.INVISIBLE))
)
private fun assertCloseTabsButton(title: String) =
onView(allOf(withId(R.id.close_tab_button), withContentDescription("Close tab $title")))