From 677a9da5eca17524c1ce4e206f90f7174f744a84 Mon Sep 17 00:00:00 2001 From: mcarare Date: Mon, 23 Mar 2020 18:48:46 +0200 Subject: [PATCH] For #8485 Update UI tests after settings reorg --- .../mozilla/fenix/ui/SettingsAdvancedTest.kt | 59 +++++++++++++++++++ .../fenix/ui/SettingsDeveloperToolsTest.kt | 1 - .../mozilla/fenix/ui/SettingsPrivacyTest.kt | 1 - .../mozilla/fenix/ui/robots/SettingsRobot.kt | 29 +++++---- 4 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt new file mode 100644 index 000000000..c0a87fe13 --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt @@ -0,0 +1,59 @@ +/* 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.Test +import org.mozilla.fenix.helpers.AndroidAssetDispatcher +import org.mozilla.fenix.helpers.HomeActivityIntentTestRule +import org.mozilla.fenix.ui.robots.homeScreen + +/** + * Tests for verifying the advanced section in Settings + * + */ + +class SettingsAdvancedTest { + /* 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 activityIntentTestRule = HomeActivityIntentTestRule() + + @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() { + // ADVANCED + homeScreen { + }.openThreeDotMenu { + }.openSettings { + // ADVANCED + verifyAdvancedHeading() + verifyAddons() + verifyRemoteDebug() + verifyLeakCanaryButton() + } + } +} diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsDeveloperToolsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsDeveloperToolsTest.kt index f60e50915..f42902c99 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsDeveloperToolsTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsDeveloperToolsTest.kt @@ -49,7 +49,6 @@ class SettingsDeveloperToolsTest { homeScreen { }.openThreeDotMenu { }.openSettings { - verifyDeveloperToolsHeading() verifyRemoteDebug() } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt index c5cf4a061..cb017834e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt @@ -111,7 +111,6 @@ class SettingsPrivacyTest { verifyDeleteBrowsingDataButton() verifyDeleteBrowsingDataOnQuitButton() verifyDataCollectionButton() - verifyLeakCanaryButton() } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt index 2c1718708..7db88955a 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt @@ -64,9 +64,9 @@ class SettingsRobot { fun verifyLeakCanaryButton() = assertLeakCanaryButton() fun verifySettingsView() = assertSettingsView() - // DEVELOPER TOOLS SECTION - fun verifyDeveloperToolsHeading() = assertDeveloperToolsHeading() - + // ADVANCED SECTION + fun verifyAdvancedHeading() = assertAdvancedHeading() + fun verifyAddons() = assertAddons() fun verifyRemoteDebug() = assertRemoteDebug() // ABOUT SECTION @@ -174,7 +174,7 @@ private fun assertSettingsView() { // verify that we are in the correct library view assertGeneralHeading() assertPrivacyHeading() - assertDeveloperToolsHeading() + assertAdvancedHeading() assertAboutHeading() } @@ -255,13 +255,22 @@ private fun assertDeleteBrowsingDataOnQuitButton() { private fun assertDataCollectionButton() = onView(withText("Data collection")) .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) -private fun assertLeakCanaryButton() = onView(withText("LeakCanary")) - .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) +private fun assertLeakCanaryButton() { + scrollToElementByText("LeakCanary") + onView(withText("LeakCanary")) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) +} + +// ADVANCED SECTION +private fun assertAdvancedHeading() { + scrollToElementByText("Advanced") + onView(withText("Advanced")) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) +} -// DEVELOPER TOOLS SECTION -private fun assertDeveloperToolsHeading() { - scrollToElementByText("Developer tools") - onView(withText("Developer tools")) +private fun assertAddons() { + scrollToElementByText("Add-ons") + onView(withText("Add-ons")) .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) }