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

fennec/beta
isabelrios 4 years ago committed by GitHub
parent dd38f1df0a
commit 74433ba27a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -32,6 +32,7 @@ import org.junit.Assert.assertTrue
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.Constants.LongClickDuration 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.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.helpers.ext.waitNotNull
@ -54,6 +55,7 @@ class BrowserRobot {
Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")), Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")),
waitingTime waitingTime
) )
TestAssetHelper.waitingTime
onView(withId(R.id.mozac_browser_toolbar_url_view)) onView(withId(R.id.mozac_browser_toolbar_url_view))
.check(matches(withText(containsString(url)))) .check(matches(withText(containsString(url))))
} }

@ -82,14 +82,27 @@ class HomeScreenRobot {
fun verifyTrackingProtectionToggle() = assertTrackingProtectionToggle() fun verifyTrackingProtectionToggle() = assertTrackingProtectionToggle()
fun verifyProtectYourselfText() = assertProtectYourselfText() fun verifyProtectYourselfText() = assertProtectYourselfText()
// What's new elements
fun verifyWhatsNewHeader() = assertWhatsNewHeather()
fun verifyWhatsNewLink() = assertWhatsNewLink()
// Browse privately
fun verifyBrowsePrivatelyHeader() = assertBrowsePrivatelyHeader() fun verifyBrowsePrivatelyHeader() = assertBrowsePrivatelyHeader()
fun verifyBrowsePrivatelyText() = assertBrowsePrivatelyText() fun verifyBrowsePrivatelyText() = assertBrowsePrivatelyText()
// Take a position
fun verifyTakePositionHeader() = assertTakePositionheader()
fun verifyTakePositionElements() {
assertTakePositionBottomRadioButton()
assertTakePositionTopRadioButton()
}
// Your privacy
fun verifyYourPrivacyHeader() = assertYourPrivacyHeader() fun verifyYourPrivacyHeader() = assertYourPrivacyHeader()
fun verifyYourPrivacyText() = assertYourPrivacyText() fun verifyYourPrivacyText() = assertYourPrivacyText()
fun verifyPrivacyNoticeButton() = assertPrivacyNoticeButton() fun verifyPrivacyNoticeButton() = assertPrivacyNoticeButton()
fun verifyStartBrowsingButton() = assertStartBrowsingButton() fun verifyStartBrowsingButton() = assertStartBrowsingButton()
// Private mode elements
fun verifyPrivateSessionHeader() = assertPrivateSessionHeader() fun verifyPrivateSessionHeader() = assertPrivateSessionHeader()
fun verifyPrivateSessionMessage(visible: Boolean = true) = assertPrivateSessionMessage(visible) fun verifyPrivateSessionMessage(visible: Boolean = true) = assertPrivateSessionMessage(visible)
@ -153,7 +166,7 @@ class HomeScreenRobot {
.perform(click()) .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()) fun swipeToTop() = onView(withId(R.id.sessionControlRecyclerView)).perform(ViewActions.swipeDown())
@ -264,6 +277,14 @@ class HomeScreenRobot {
BrowserRobot().interact() BrowserRobot().interact()
return BrowserRobot.Transition() 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))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertChooseThemeText() = 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))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertLightThemeToggle() = private fun assertLightThemeToggle() =
@ -409,7 +430,7 @@ private fun assertDarkThemeDescription() =
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertAutomaticThemeToggle() = private fun assertAutomaticThemeToggle() =
onView(ViewMatchers.withResourceName("theme_automatic_radio_button")) onView(withId(R.id.theme_automatic_radio_button))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertAutomaticThemeDescription() = private fun assertAutomaticThemeDescription() =
@ -429,7 +450,7 @@ private fun assertProtectYourselfText() {
onView( onView(
allOf( allOf(
withText( 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))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertBrowsePrivatelyText() = 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))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertYourPrivacyHeader() = private fun assertYourPrivacyHeader() =
@ -462,10 +483,27 @@ private fun assertPrivacyNoticeButton() =
onView(allOf(withText("Read our privacy notice"))) onView(allOf(withText("Read our privacy notice")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .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() = private fun assertStartBrowsingButton() =
onView(allOf(withText("Start browsing"))) onView(allOf(withText("Start browsing")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .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 mode elements
private fun assertPrivateSessionHeader() = private fun assertPrivateSessionHeader() =
onView(allOf(withText("Private tabs"))) onView(allOf(withText("Private tabs")))
@ -482,9 +520,10 @@ private fun assertPrivateSessionMessage(visible: Boolean) =
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else doesNotExist() if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else doesNotExist()
) )
private fun assertShareTabsButton(visible: Boolean) = private fun assertShareTabsButton(visible: Boolean) = onView(allOf(withId(R.id.share_tabs_button)))
onView(allOf(withId(R.id.share_tabs_button), isDisplayed())) .check(
.check(matches(withEffectiveVisibility(visibleOrGone(visible)))) if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else matches(withEffectiveVisibility(Visibility.INVISIBLE))
)
private fun assertCloseTabsButton(title: String) = private fun assertCloseTabsButton(title: String) =
onView(allOf(withId(R.id.close_tab_button), withContentDescription("Close tab $title"))) onView(allOf(withId(R.id.close_tab_button), withContentDescription("Close tab $title")))

Loading…
Cancel
Save