From 7ea855bda865fcd11af1a1ac36e928edefe57862 Mon Sep 17 00:00:00 2001 From: Richard Pappalardo Date: Wed, 7 Aug 2019 09:54:38 -0700 Subject: [PATCH] [fenix] Stub out tabs tests (https://github.com/mozilla-mobile/fenix/pull/4573) --- .../org/mozilla/fenix/ui/HomeScreenTest.kt | 2 + .../java/org/mozilla/fenix/ui/TabsTest.kt | 122 ++++++++++++++++++ .../org/mozilla/fenix/ui/robots/TabsRobot.kt | 23 ++++ 3 files changed, 147 insertions(+) create mode 100644 app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt create mode 100644 app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabsRobot.kt diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt index 694fa48079..2ee6600521 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt @@ -15,6 +15,8 @@ import org.mozilla.fenix.ui.robots.homeScreen /** * Tests for verifying the presence of home screen and first-run homescreen elements * + * Note: For private browsing, navigation bar and tabs see separate test class + * */ class HomeScreenTest { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt new file mode 100644 index 0000000000..d8607363cf --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt @@ -0,0 +1,122 @@ +/* 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.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.Before +import org.junit.After +import org.mozilla.fenix.helpers.AndroidAssetDispatcher +import org.mozilla.fenix.helpers.HomeActivityTestRule +import org.mozilla.fenix.helpers.TestAssetHelper +import org.mozilla.fenix.ui.robots.homeScreen +import org.mozilla.fenix.ui.robots.navigationToolbar + +/** + * Tests for verifying basic functionality of tabs + * + */ + +class TabsTest { + /* 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() + } + + @Ignore("This is a stub test, ignore for now") + @Test + fun tabsItemsTest() { + homeScreen { }.dismissOnboarding() + + // Setup browser so that tabs are visible in UI + // Verify all tabs elements are visible: + // "open tabs header, + button, etc. + // Verify tabs 3-dot menu elements + } + + @Ignore("This is a stub test, ignore for now") + @Test + fun noTabsInCacheTest() { + // Verify open tabs header and text exists (when no previous browsing) + // Verify + button redirects to navigation bar UI + // Verify "Collections" header exists + // Verify "No collections" text (when no previous browsing) + } + + @Ignore("This is a stub test, ignore for now") + @Test + fun browsingWithTabsTest() { + // Setup: + // - Verify + button redirects to navigation bar UI + // - Enter mock website via navigation bar + // Verify "Open tabs" header exits + // Verify Collections header exits + // Verify that tabs counter is augmented by 1 count + // Click on tabs counter + // Verify that new page is listed in "Open tabs" + // Repeat for several sites + + } + + @Ignore("This is a stub test, ignore for now") + @Test + fun tabsThreeDotMenuTest() { + // short 3-dot menu setup: + // - create multiple tabs (using mock web server) for the following... + // Verify tabs 3-dot menu functions: + // 1. "Close all tabs" + // 2. "Share tabs" - opens share sub-menu + // 3. "Save to collection" - verify saved to collection + + // NOTE: extended 3 dot menu test is verified in a separate class + } + + @Ignore("This is a stub test, ignore for now") + @Test + fun collectionsTest() { + // Setup: + // - create multiple tabs (using mock web server) for the following... + // Verify collections header exits + // Verify multiple collections can be saved, named + // Verify "Select tabs to save" + // Verify collections dropdown toggle + // Verify send and share button works - opens share menu + + // Verify collections 3-dot menu functions: + // 1. Delete collection + // 2. Rename collection + // 3. Open tabs + } + + @Ignore("This is a sample test, ignore") + @Test + fun sampleTest() { + val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) + + navigationToolbar { + }.enterURLAndEnterToBrowser(defaultWebPage.url) { + } + } +} diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabsRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabsRobot.kt new file mode 100644 index 0000000000..35dd43d105 --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabsRobot.kt @@ -0,0 +1,23 @@ +/* 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/. */ + +@file:Suppress("TooManyFunctions") + +package org.mozilla.fenix.ui.robots + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice + +class TabsRobot { + + // Tabs functions here + + class Transition { + private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + + // Transition functions here + } +} + +// Locaters here