For #16615: UI smoke test firstRunScreenTest

upstream-sync
Oana Horvath 4 years ago
parent 01ec558811
commit 2d6d49324e

@ -13,7 +13,6 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.helpers.ext.waitNotNull
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.ui.robots.PRIVATE_SESSION_MESSAGE
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
/** /**
@ -54,68 +53,6 @@ class HomeScreenTest {
} }
} }
@Test
fun firstRunScreenTest() {
homeScreen {
verifyHomeScreen()
verifyNavigationToolbar()
verifyHomePrivateBrowsingButton()
verifyHomeMenu()
verifyHomeWordmark()
verifyWelcomeHeader()
// Sign in to Firefox
verifyGetTheMostHeader()
verifyAccountsSignInButton()
// Intro to other sections
verifyGetToKnowHeader()
// See What's new
// scrollToElementByText("See whats new")
// verifyWhatsNewHeader()
// verifyWhatsNewLink()
// Automatic privacy
scrollToElementByText("Automatic privacy")
verifyAutomaticPrivacyfHeader()
verifyTrackingProtectionToggle()
verifyAutomaticPrivacyText()
/* 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 @Test
fun privateModeScreenItemsTest() { fun privateModeScreenItemsTest() {
homeScreen { }.dismissOnboarding() homeScreen { }.dismissOnboarding()
@ -139,7 +76,7 @@ class HomeScreenTest {
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.
mDevice.waitNotNull(Until.gone(By.text(PRIVATE_SESSION_MESSAGE)), waitingTime) mDevice.waitNotNull(Until.gone(By.text(privateSessionMessage)), waitingTime)
verifyHomeScreen() verifyHomeScreen()
verifyNavigationToolbar() verifyNavigationToolbar()
verifyHomePrivateBrowsingButton() verifyHomePrivateBrowsingButton()

@ -44,6 +44,56 @@ class SmokeTest {
mockWebServer.shutdown() mockWebServer.shutdown()
} }
// copied over from HomeScreenTest
@Test
fun firstRunScreenTest() {
homeScreen {
verifyHomeScreen()
verifyNavigationToolbar()
verifyHomePrivateBrowsingButton()
verifyHomeMenu()
verifyHomeWordmark()
verifyWelcomeHeader()
// Sign in to Firefox
verifyStartSyncHeader()
verifyAccountsSignInButton()
// Intro to other sections
verifyGetToKnowHeader()
// Automatic privacy
scrollToElementByText("Automatic privacy")
verifyAutomaticPrivacyHeader()
verifyTrackingProtectionToggle()
verifyAutomaticPrivacyText()
// Choose your theme
verifyChooseThemeHeader()
verifyChooseThemeText()
verifyDarkThemeDescription()
verifyDarkThemeToggle()
verifyLightThemeDescription()
verifyLightThemeToggle()
// Browse privately
verifyBrowsePrivatelyHeader()
verifyBrowsePrivatelyText()
// Take a position
verifyTakePositionHeader()
verifyTakePositionElements()
// Your privacy
verifyYourPrivacyHeader()
verifyYourPrivacyText()
verifyPrivacyNoticeButton()
// Start Browsing
verifyStartBrowsingButton()
}
}
@Test @Test
fun verifyBasicNavigationToolbarFunctionality() { fun verifyBasicNavigationToolbarFunctionality() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

@ -43,7 +43,13 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
*/ */
class BookmarksRobot { class BookmarksRobot {
fun verifyBookmarksMenuView() = assertBookmarksView() fun verifyBookmarksMenuView() {
mDevice.findObject(
UiSelector().text("Bookmarks")
).waitForExists(waitingTime)
assertBookmarksView()
}
fun verifyEmptyBookmarksList() = assertEmptyBookmarksList() fun verifyEmptyBookmarksList() = assertEmptyBookmarksList()

@ -37,6 +37,7 @@ import androidx.test.uiautomator.UiScrollable
import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import androidx.test.uiautomator.Until.findObject import androidx.test.uiautomator.Until.findObject
import mozilla.components.support.ktx.android.content.appName
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.instanceOf import org.hamcrest.CoreMatchers.instanceOf
@ -47,6 +48,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.Search import org.mozilla.fenix.components.Search
import org.mozilla.fenix.helpers.TestAssetHelper 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.TestHelper.scrollToElementByText
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
import org.mozilla.fenix.helpers.matchers.hasItem import org.mozilla.fenix.helpers.matchers.hasItem
@ -56,6 +58,12 @@ import org.mozilla.fenix.helpers.withBitmapDrawable
* Implementation of Robot Pattern for the home screen menu. * Implementation of Robot Pattern for the home screen menu.
*/ */
class HomeScreenRobot { class HomeScreenRobot {
val privateSessionMessage =
"${appContext.appName} clears your search and browsing history from private tabs when you close them" +
" or quit the app. While this doesnt make you anonymous to websites or your internet" +
" service provider, it makes it easier to keep what you do online private from anyone" +
" else who uses this device."
fun verifyNavigationToolbar() = assertNavigationToolbar() fun verifyNavigationToolbar() = assertNavigationToolbar()
fun verifyFocusedNavigationToolbar() = assertFocusedNavigationToolbar() fun verifyFocusedNavigationToolbar() = assertFocusedNavigationToolbar()
fun verifyHomeScreen() = assertHomeScreen() fun verifyHomeScreen() = assertHomeScreen()
@ -75,7 +83,7 @@ class HomeScreenRobot {
// First Run elements // First Run elements
fun verifyWelcomeHeader() = assertWelcomeHeader() fun verifyWelcomeHeader() = assertWelcomeHeader()
fun verifyGetTheMostHeader() = assertGetTheMostHeader() fun verifyStartSyncHeader() = assertStartSyncHeader()
fun verifyAccountsSignInButton() = assertAccountsSignInButton() fun verifyAccountsSignInButton() = assertAccountsSignInButton()
fun verifyGetToKnowHeader() = assertGetToKnowHeader() fun verifyGetToKnowHeader() = assertGetToKnowHeader()
fun verifyChooseThemeHeader() = assertChooseThemeHeader() fun verifyChooseThemeHeader() = assertChooseThemeHeader()
@ -86,14 +94,10 @@ class HomeScreenRobot {
fun verifyDarkThemeDescription() = assertDarkThemeDescription() fun verifyDarkThemeDescription() = assertDarkThemeDescription()
fun verifyAutomaticThemeToggle() = assertAutomaticThemeToggle() fun verifyAutomaticThemeToggle() = assertAutomaticThemeToggle()
fun verifyAutomaticThemeDescription() = assertAutomaticThemeDescription() fun verifyAutomaticThemeDescription() = assertAutomaticThemeDescription()
fun verifyAutomaticPrivacyfHeader() = assertAutomaticPrivacyHeader() fun verifyAutomaticPrivacyHeader() = assertAutomaticPrivacyHeader()
fun verifyTrackingProtectionToggle() = assertTrackingProtectionToggle() fun verifyTrackingProtectionToggle() = assertTrackingProtectionToggle()
fun verifyAutomaticPrivacyText() = assertAutomaticPrivacyText() fun verifyAutomaticPrivacyText() = assertAutomaticPrivacyText()
// What's new elements
fun verifyWhatsNewHeader() = assertWhatsNewHeather()
fun verifyWhatsNewLink() = assertWhatsNewLink()
// Browse privately // Browse privately
fun verifyBrowsePrivatelyHeader() = assertBrowsePrivatelyHeader() fun verifyBrowsePrivatelyHeader() = assertBrowsePrivatelyHeader()
fun verifyBrowsePrivatelyText() = assertBrowsePrivatelyText() fun verifyBrowsePrivatelyText() = assertBrowsePrivatelyText()
@ -584,10 +588,10 @@ private fun verifySearchEngineIcon(searchEngineName: String) {
// First Run elements // First Run elements
private fun assertWelcomeHeader() = private fun assertWelcomeHeader() =
onView(allOf(withText("Welcome to Firefox Preview!"))) onView(allOf(withText("Welcome to ${appContext.appName}!")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertGetTheMostHeader() = private fun assertStartSyncHeader() =
onView(allOf(withText("Start syncing bookmarks, passwords, and more with your Firefox account."))) onView(allOf(withText("Start syncing bookmarks, passwords, and more with your Firefox account.")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
@ -596,51 +600,69 @@ private fun assertAccountsSignInButton() =
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertGetToKnowHeader() = private fun assertGetToKnowHeader() =
onView(allOf(withText("Get to know Firefox Preview"))) onView(allOf(withText("Get to know ${appContext.appName}")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertChooseThemeHeader() = private fun assertChooseThemeHeader() {
onView(allOf(withText("Choose your theme"))) scrollToElementByText("Choose your theme")
onView(withText("Choose your theme"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertChooseThemeText() = private fun assertChooseThemeText() {
scrollToElementByText("Choose your theme")
onView(allOf(withText("Save some battery and your eyesight by enabling dark mode."))) 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() {
scrollToElementByText("Choose your theme")
onView(ViewMatchers.withResourceName("theme_light_radio_button")) onView(ViewMatchers.withResourceName("theme_light_radio_button"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertLightThemeDescription() = private fun assertLightThemeDescription() {
scrollToElementByText("Choose your theme")
onView(allOf(withText("Light theme"))) onView(allOf(withText("Light theme")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertDarkThemeToggle() = private fun assertDarkThemeToggle() {
scrollToElementByText("Choose your theme")
onView(ViewMatchers.withResourceName("theme_dark_radio_button")) onView(ViewMatchers.withResourceName("theme_dark_radio_button"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertDarkThemeDescription() = private fun assertDarkThemeDescription() {
scrollToElementByText("Choose your theme")
onView(allOf(withText("Dark theme"))) onView(allOf(withText("Dark theme")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertAutomaticThemeToggle() = private fun assertAutomaticThemeToggle() {
scrollToElementByText("Choose your theme")
onView(withId(R.id.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() {
scrollToElementByText("Choose your theme")
onView(allOf(withText("Automatic"))) onView(allOf(withText("Automatic")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertAutomaticPrivacyHeader() = private fun assertAutomaticPrivacyHeader() {
scrollToElementByText("Automatic privacy")
onView(allOf(withText("Automatic privacy"))) onView(allOf(withText("Automatic privacy")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertTrackingProtectionToggle() = onView( private fun assertTrackingProtectionToggle() {
allOf(ViewMatchers.withResourceName("tracking_protection_toggle")) scrollToElementByText("Automatic privacy")
) onView(withId(R.id.tracking_protection_toggle))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertAutomaticPrivacyText() { private fun assertAutomaticPrivacyText() {
scrollToElementByText("Automatic privacy")
onView( onView(
allOf( allOf(
withText( withText(
@ -651,60 +673,65 @@ private fun assertAutomaticPrivacyText() {
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
} }
private fun assertBrowsePrivatelyHeader() = private fun assertBrowsePrivatelyHeader() {
scrollToElementByText("Browse privately")
onView(allOf(withText("Browse privately"))) onView(allOf(withText("Browse privately")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertBrowsePrivatelyText() = private fun assertBrowsePrivatelyText() {
scrollToElementByText("Browse privately")
onView(allOf(withText(containsString("Update your private browsing settings.")))) 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() {
scrollToElementByText("Your privacy")
onView(allOf(withText("Your privacy"))) onView(allOf(withText("Your privacy")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertYourPrivacyText() = private fun assertYourPrivacyText() {
scrollToElementByText("Your privacy")
onView( onView(
allOf( allOf(
withText( withText(
"Weve designed Firefox Preview to give you control over what you share online and what you share with us." "Weve designed ${appContext.appName} to give you control over what you share online and what you share with us."
) )
) )
) )
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertPrivacyNoticeButton() = private fun assertPrivacyNoticeButton() {
scrollToElementByText("Your privacy")
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 assertStartBrowsingButton() {
private fun assertWhatsNewHeather() = onView(allOf(withText("See whats new"))) scrollToElementByText("Start browsing")
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertWhatsNewLink() = onView(allOf(withText("Get answers here")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
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 // Take a position
private fun assertTakePositionheader() = onView(allOf(withText("Take a position"))) private fun assertTakePositionheader() {
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) scrollToElementByText("Take a position")
onView(allOf(withText("Take a position")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertTakePositionTopRadioButton() = private fun assertTakePositionTopRadioButton() {
scrollToElementByText("Take a position")
onView(ViewMatchers.withResourceName("toolbar_top_radio_button")) onView(ViewMatchers.withResourceName("toolbar_top_radio_button"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertTakePositionBottomRadioButton() = private fun assertTakePositionBottomRadioButton() {
scrollToElementByText("Take a position")
onView(ViewMatchers.withResourceName("toolbar_bottom_radio_button")) onView(ViewMatchers.withResourceName("toolbar_bottom_radio_button"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
const val PRIVATE_SESSION_MESSAGE =
"Firefox Preview clears your search and browsing history from private tabs when you close them" +
" or quit the app. While this doesnt make you anonymous to websites or your internet" +
" service provider, it makes it easier to keep what you do online private from anyone" +
" else who uses this device."
private fun assertPrivateSessionMessage() = private fun assertPrivateSessionMessage() =
onView(withId(R.id.private_session_description)) onView(withId(R.id.private_session_description))

Loading…
Cancel
Save