Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Merge #6059
Browse files Browse the repository at this point in the history
6059: Add verify items tests for settings menus r=kglazko a=rpappalax

Also closes #6006

All UI tests are passing with the exception of 1 which was just uncovered by a new test in this PR.  Issue here:
#6053



Co-authored-by: Richard Pappalardo <rpappalax@gmail.com>
  • Loading branch information
MozLando and rpappalax committed Oct 21, 2019
2 parents d575c25 + 744d177 commit fed0c88
Show file tree
Hide file tree
Showing 19 changed files with 673 additions and 46 deletions.
16 changes: 16 additions & 0 deletions app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt
@@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.fenix.helpers

import androidx.test.uiautomator.UiScrollable
import androidx.test.uiautomator.UiSelector

object TestHelper {
fun scrollToElementByText(text: String): UiScrollable {
val appView = UiScrollable(UiSelector().scrollable(true))
appView.scrollTextIntoView(text)
return appView
}
}
93 changes: 93 additions & 0 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAboutTest.kt
@@ -0,0 +1,93 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.fenix.ui

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.Rule
import org.junit.Before
import org.junit.After
import org.junit.Ignore
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen

/**
* Tests for verifying the main three dot menu options
*
*/

class SettingsAboutTest {
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.

private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var mockWebServer: MockWebServer

@get:Rule
val activityTestRule = HomeActivityTestRule()

@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
start()
}
}

@After
fun tearDown() {
mockWebServer.shutdown()
}

@Test
// Walks through settings menu and sub-menus to ensure all items are present
fun settingsAboutItemsTest() {
// ABOUT
homeScreen {
}.openThreeDotMenu {
}.openSettings {
// ABOUT
verifyAboutHeading()
verifyHelp()
verifyRateOnGooglePlay()
verifyAboutFirefoxPreview()
}
}

// ABOUT
@Ignore("This is a stub test, ignore for now")
@Test
fun verifyHelpRedirect() {
// Open 3dot (main) menu
// Select settings
// Click on "Help"
// Verify redirect to: https://support.mozilla.org/
}

@Ignore("This is a stub test, ignore for now")
@Test
fun verifyRateOnGooglePlayRedirect() {
// Open 3dot (main) menu
// Select settings
// Click on "Rate on Google Play"
// Verify Android "Open with Google Play Store" sub menu
}

@Ignore("This is a stub test, ignore for now")
@Test
fun verifyAboutFirefoxPreview() {
// Open 3dot (main) menu
// Select settings
// Click on "Verify About Firefox Preview"
// Verify about page contains....
// Build #
// Version #
// "Firefox Preview is produced by Mozilla"
// Day, Date, timestamp
// "Open source libraries we use"
}
}
49 changes: 28 additions & 21 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt
Expand Up @@ -14,6 +14,7 @@ import org.junit.Ignore
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen

/**
* Tests for verifying the main three dot menu options
Expand Down Expand Up @@ -42,29 +43,35 @@ class SettingsBasicsTest {
mockWebServer.shutdown()
}

@Ignore("This is a stub test, ignore for now")
@Test
// Walks through settings menu and sub-menus to ensure all items are present
fun settingsMenuBasicsItemsTests() {
// Open 3dot (main) menu
// Select settings

// Verify header: "Basics"

// Verify item: "Search Engine" and default value: "Google"
// Open 3dot (main) menu
// Select settings
// Verify default search engine (Google)
// Select "Search engine" to change
// Verify menu choices: Google, Amazon.com, Bing, DuckDuckGo, Twitter, Wikipedia
// Verify label: "Show search suggestions"
// Verify search suggestions toggle, set to 'on' by default
// Verify label: "Show visited sites and bookmarks"
// Verify visited sites and bookmarks toggle, set to 'on' by default

// Verify item: "Theme" and default value: "Light"
// Verify item: "Accessibility"
// Verify item: "Set as default browser" and default toggle value: "off"
// Verify item: "Search Engine" and default value: "Google"
homeScreen {
}.openThreeDotMenu {
}.openSettings {
verifyBasicsHeading()
verifySearchEngineButton()
// drill down to submenu
}.openSearchSubMenu {
verifyDefaultSearchEngineHeader()
verifySearchEngineList()
verifyShowSearchSuggestions()
verifyShowClipboardSuggestions()
verifySearchBrowsingHistory()
verifySearchBookmarks()
}.goBack {
}.openThemeSubMenu {
verifyThemes()
}.goBack {
}.openAccessibilitySubMenu {
verifyAutomaticFontSizing()
}.goBack {
// drill down to submenu
}.openDefaultBrowserSubMenu {
// verify item: set as default browser (duplicates, verify child of recyclerview)
// Verify label: Open links in private tab
}.goBack {
}
}

@Ignore("This is a stub test, ignore for now")
Expand Down
@@ -0,0 +1,102 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.fenix.ui

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.Rule
import org.junit.Before
import org.junit.After
import org.junit.Ignore
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen

/**
* Tests for verifying the main three dot menu options
*
*/

class SettingsDeveloperToolsTest {
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.

private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var mockWebServer: MockWebServer

@get:Rule
val activityTestRule = HomeActivityTestRule()

@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
start()
}
}

@After
fun tearDown() {
mockWebServer.shutdown()
}

@Test
// Walks through settings developer tools menu and sub-menus to ensure all items are present
fun settingsDeveloperToolsItemsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
verifyDeveloperToolsHeading()
verifyRemoteDebug()
}
}

// DEVELOPER TOOLS
@Ignore("This is a stub test, ignore for now")
@Test
fun turnOnRemoteDebuggingViaUsb() {
// Open terminal
// Verify USB debugging is off
// Open 3dot (main) menu
// Select settings
// Toggle Remote debugging via USB to 'on'
// Open terminal
// Verify USB debugging is on
}

// ABOUT
@Ignore("This is a stub test, ignore for now")
@Test
fun verifyHelpRedirect() {
// Open 3dot (main) menu
// Select settings
// Click on "Help"
// Verify redirect to: https://support.mozilla.org/
}

@Ignore("This is a stub test, ignore for now")
@Test
fun verifyRateOnGooglePlayRedirect() {
// Open 3dot (main) menu
// Select settings
// Click on "Rate on Google Play"
// Verify Android "Open with Google Play Store" sub menu
}

@Ignore("This is a stub test, ignore for now")
@Test
fun verifyAboutFirefoxPreview() {
// Open 3dot (main) menu
// Select settings
// Click on "Verify About Firefox Preview"
// Verify about page contains....
// Build #
// Version #
// "Firefox Preview is produced by Mozilla"
// Day, Date, timestamp
// "Open source libraries we use"
}
}
Expand Up @@ -14,6 +14,7 @@ import org.junit.Ignore
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen

/**
* Tests for verifying the main three dot menu options
Expand Down Expand Up @@ -42,8 +43,8 @@ class SettingsPrivacyTest {
mockWebServer.shutdown()
}

@Ignore("This is a stub test, ignore for now")
@Test
// Walks through settings privacy menu and sub-menus to ensure all items are present
fun settingsPrivacyItemsTest() {
// Open 3dot (main) menu
// Select settings
Expand Down Expand Up @@ -83,6 +84,24 @@ class SettingsPrivacyTest {
// Verify item: "Privacy notice"
// Verify item: "Leak Canary" and default toggle value: "Off"

homeScreen {
}.openThreeDotMenu {
}.openSettings {

// PRIVACY
verifyPrivacyHeading()
verifyEnhancedTrackingProtectionButton()
verifyEnhancedTrackingProtectionValue()
// drill down to submenu
verifyAddPrivateBrowsingShortcutButton()
verifySitePermissionsButton()
// drill down on search
verifyDeleteBrowsingDataButton()
verifyDeleteBrowsingDataOnQuitButton()
verifyDataCollectionButton()
verifyPrivacyNoticeButton()
verifyLeakCanaryButton()
}
}

@Ignore("This is a stub test, ignore for now")
Expand Down
Expand Up @@ -44,15 +44,14 @@ class SettingsSyncTest {

@Ignore("This is a stub test, ignore for now")
@Test
// Walks through settings menu and sub-menus to ensure all items are present
fun settingsSyncMenusItemsTest() {
// Walks through settings sync menu and sub-menus to ensure all items are present
fun settingsSyncItemsTest() {
// SYNC

// Open 3dot (main) menu
// Select settings
// Verify header: "Turn on Sync"
// Verify description: "Sync bookmarks, history, and more with your Firefox Account"

}

// SYNC
Expand Down
Expand Up @@ -77,11 +77,11 @@ class BookmarksRobot {
return LibraryRobot.Transition()
}

fun openThreeDotMenu(interact: ThreeDotMenuBookmarks.() -> Unit): ThreeDotMenuBookmarks.Transition {
fun openThreeDotMenu(interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition {
threeDotMenu().click()

ThreeDotMenuBookmarks().interact()
return ThreeDotMenuBookmarks.Transition()
ThreeDotMenuBookmarksRobot().interact()
return ThreeDotMenuBookmarksRobot.Transition()
}
}
}
Expand Down
Expand Up @@ -88,12 +88,12 @@ class HomeScreenRobot {
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())

fun openThreeDotMenu(interact: ThreeDotMenuRobot.() -> Unit): ThreeDotMenuRobot.Transition {
fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
mDevice.waitForIdle()
threeDotButton().perform(click())

ThreeDotMenuRobot().interact()
return ThreeDotMenuRobot.Transition()
ThreeDotMenuMainRobot().interact()
return ThreeDotMenuMainRobot.Transition()
}

fun openSearch(interact: SearchRobot.() -> Unit): SearchRobot.Transition {
Expand All @@ -117,12 +117,12 @@ class HomeScreenRobot {
.perform(click())
}

fun openTabsListThreeDotMenu(interact: ThreeDotMenuRobot.() -> Unit): ThreeDotMenuRobot.Transition {
fun openTabsListThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
mDevice.waitForIdle()
tabsListThreeDotButton().perform(click())

ThreeDotMenuRobot().interact()
return ThreeDotMenuRobot.Transition()
ThreeDotMenuMainRobot().interact()
return ThreeDotMenuMainRobot.Transition()
}
}
}
Expand Down

0 comments on commit fed0c88

Please sign in to comment.