[fenix] For https://github.com/mozilla-mobile/fenix/issues/10587: Fix and re-enable old CollectionTest.kt
parent
d819ebc81d
commit
76e4acdb54
@ -0,0 +1,259 @@
|
|||||||
|
/* 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.After
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||||
|
import org.mozilla.fenix.ui.robots.browserScreen
|
||||||
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||||||
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||||
|
import org.mozilla.fenix.ui.robots.tabDrawer
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for verifying basic functionality of tab collections
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CollectionTest {
|
||||||
|
/* ktlint-disable no-blank-line-before-rbrace */
|
||||||
|
// This imposes unreadable grouping.
|
||||||
|
|
||||||
|
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
private lateinit var mockWebServer: MockWebServer
|
||||||
|
private val firstCollectionName = "testcollection_1"
|
||||||
|
private val secondCollectionName = "testcollection_2"
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val activityTestRule = HomeActivityTestRule()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
mockWebServer = MockWebServer().apply {
|
||||||
|
dispatcher = AndroidAssetDispatcher()
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun tearDown() {
|
||||||
|
mockWebServer.shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
// open a webpage, and add currently opened tab to existing collection
|
||||||
|
fun mainMenuSaveToExistingCollection() {
|
||||||
|
val firstWebPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
val secondWebPage = getGenericAsset(mockWebServer, 2)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(firstWebPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
}.closeTabDrawer {}
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(secondWebPage.url) {
|
||||||
|
verifyPageContent(secondWebPage.content)
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSaveToCollection {
|
||||||
|
}.selectExistingCollection(firstCollectionName) {
|
||||||
|
verifySnackBarText("Tab saved!")
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.expandCollection(firstCollectionName) {
|
||||||
|
verifyTabSavedInCollection(firstWebPage.title)
|
||||||
|
verifyTabSavedInCollection(secondWebPage.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyAddTabButtonOfCollectionMenu() {
|
||||||
|
val firstWebPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
val secondWebPage = getGenericAsset(mockWebServer, 2)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(firstWebPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
}.closeTabDrawer {}
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(secondWebPage.url) {
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.expandCollection(firstCollectionName) {
|
||||||
|
clickCollectionThreeDotButton()
|
||||||
|
selectAddTabToCollection()
|
||||||
|
verifyTabsSelectedCounterText(1)
|
||||||
|
saveTabsSelectedForCollection()
|
||||||
|
verifySnackBarText("Tab saved!")
|
||||||
|
verifyTabSavedInCollection(secondWebPage.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun renameCollectionTest() {
|
||||||
|
val webPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(webPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(webPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
}.closeTabDrawer {
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.expandCollection(firstCollectionName) {
|
||||||
|
clickCollectionThreeDotButton()
|
||||||
|
selectRenameCollection()
|
||||||
|
}.typeCollectionNameAndSave("renamed_collection") {}
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
verifyCollectionIsDisplayed("renamed_collection")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun createSecondCollectionTest() {
|
||||||
|
val webPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(webPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(webPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
createCollection(webPage.title, secondCollectionName, false)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
}.closeTabDrawer {
|
||||||
|
}.goToHomescreen {}
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
verifyCollectionIsDisplayed(firstCollectionName)
|
||||||
|
verifyCollectionIsDisplayed(secondCollectionName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun removeTabFromCollectionTest() {
|
||||||
|
val webPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(webPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(webPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
}.closeTabDrawer {
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.expandCollection(firstCollectionName) {
|
||||||
|
removeTabFromCollection(webPage.title)
|
||||||
|
verifyTabSavedInCollection(webPage.title, false)
|
||||||
|
}
|
||||||
|
// To add this step when https://github.com/mozilla-mobile/fenix/issues/13177 is fixed
|
||||||
|
// homeScreen {
|
||||||
|
// verifyCollectionIsDisplayed(firstCollectionName, false)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun swipeToRemoveTabFromCollectionTest() {
|
||||||
|
val firstWebPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
val secondWebPage = getGenericAsset(mockWebServer, 2)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(firstWebPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
closeTab()
|
||||||
|
}
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(secondWebPage.url) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSaveToCollection {
|
||||||
|
}.selectExistingCollection(firstCollectionName) {
|
||||||
|
}.goToHomescreen {}
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.expandCollection(firstCollectionName) {
|
||||||
|
swipeCollectionItemLeft(firstWebPage.title)
|
||||||
|
verifyTabSavedInCollection(firstWebPage.title, false)
|
||||||
|
swipeCollectionItemRight(secondWebPage.title)
|
||||||
|
verifyTabSavedInCollection(secondWebPage.title, false)
|
||||||
|
}
|
||||||
|
// To add this step when https://github.com/mozilla-mobile/fenix/issues/13177 is fixed
|
||||||
|
// homeScreen {
|
||||||
|
// verifyCollectionIsDisplayed(firstCollectionName, false)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun selectTabOnLongTapTest() {
|
||||||
|
val firstWebPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
val secondWebPage = getGenericAsset(mockWebServer, 2)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openNewTab {
|
||||||
|
}.submitQuery(secondWebPage.url.toString()) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
longClickTab(firstWebPage.title)
|
||||||
|
verifyTabsMultiSelectionCounter(1)
|
||||||
|
selectTab(secondWebPage.title)
|
||||||
|
verifyTabsMultiSelectionCounter(2)
|
||||||
|
}.clickSaveCollection {
|
||||||
|
typeCollectionNameAndSave(firstCollectionName)
|
||||||
|
verifySnackBarText("Tabs saved!")
|
||||||
|
}
|
||||||
|
|
||||||
|
tabDrawer {
|
||||||
|
}.closeTabDrawer {
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.expandCollection(firstCollectionName) {
|
||||||
|
verifyTabSavedInCollection(firstWebPage.title)
|
||||||
|
verifyTabSavedInCollection(secondWebPage.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun navigateBackInCollectionFlowTest() {
|
||||||
|
val webPage = getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(webPage.url) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
createCollection(webPage.title, firstCollectionName)
|
||||||
|
verifySnackBarText("Collection saved!")
|
||||||
|
}.closeTabDrawer {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSaveToCollection {
|
||||||
|
verifySelectCollectionScreen()
|
||||||
|
goBackInCollectionFlow()
|
||||||
|
}
|
||||||
|
|
||||||
|
browserScreen {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSaveToCollection {
|
||||||
|
verifySelectCollectionScreen()
|
||||||
|
clickAddNewCollection()
|
||||||
|
verifyCollectionNameTextField()
|
||||||
|
goBackInCollectionFlow()
|
||||||
|
verifySelectCollectionScreen()
|
||||||
|
goBackInCollectionFlow()
|
||||||
|
}
|
||||||
|
// verify the browser layout is visible
|
||||||
|
browserScreen {
|
||||||
|
verifyMenuButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,266 +0,0 @@
|
|||||||
///* 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.espresso.NoMatchingViewException
|
|
||||||
//import androidx.test.platform.app.InstrumentationRegistry
|
|
||||||
//import androidx.test.uiautomator.By
|
|
||||||
//import androidx.test.uiautomator.UiDevice
|
|
||||||
//import androidx.test.uiautomator.Until
|
|
||||||
//import okhttp3.mockwebserver.MockWebServer
|
|
||||||
//import org.junit.After
|
|
||||||
//import org.junit.Before
|
|
||||||
//import org.junit.Ignore
|
|
||||||
//import org.junit.Rule
|
|
||||||
//import org.junit.Test
|
|
||||||
//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 tab collection
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
//class CollectionTest {
|
|
||||||
// /* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
|
|
||||||
//
|
|
||||||
// private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
||||||
// private lateinit var mockWebServer: MockWebServer
|
|
||||||
// private val firstCollectionName = "testcollection_1"
|
|
||||||
// private val secondCollectionName = "testcollection_2"
|
|
||||||
//
|
|
||||||
// @get:Rule
|
|
||||||
// val activityTestRule = HomeActivityTestRule()
|
|
||||||
//
|
|
||||||
// @Before
|
|
||||||
// fun setUp() {
|
|
||||||
// mockWebServer = MockWebServer().apply {
|
|
||||||
// setDispatcher(AndroidAssetDispatcher())
|
|
||||||
// start()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @After
|
|
||||||
// fun tearDown() {
|
|
||||||
// mockWebServer.shutdown()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// // open a webpage, and add currently opened tab to existing collection
|
|
||||||
// fun addTabToExistingCollectionTest() {
|
|
||||||
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
//
|
|
||||||
// homeScreen {
|
|
||||||
//// verifyExistingTabList()
|
|
||||||
// closeTab()
|
|
||||||
// }.openNavigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
||||||
// verifyPageContent(secondWebPage.content)
|
|
||||||
// }.openThreeDotMenu {
|
|
||||||
// clickBrowserViewSaveCollectionButton()
|
|
||||||
// }.selectExistingCollection(firstCollectionName) {
|
|
||||||
// verifySnackBarText("Tab saved!")
|
|
||||||
// }.openHomeScreen {
|
|
||||||
//// verifyExistingTabList()
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// verifyItemInCollectionExists(firstWebPage.title)
|
|
||||||
// verifyItemInCollectionExists(secondWebPage.title)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun collectionMenuAddTabButtonTest() {
|
|
||||||
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
//
|
|
||||||
// homeScreen {
|
|
||||||
// closeTab()
|
|
||||||
// }.openNavigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// clickCollectionThreeDotButton()
|
|
||||||
// selectAddTabToCollection()
|
|
||||||
// verifyTabsSelectedCounterText(1)
|
|
||||||
// saveTabsSelectedForCollection()
|
|
||||||
// verifySnackBarText("Tab saved!")
|
|
||||||
// verifyItemInCollectionExists(secondWebPage.title)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun renameCollectionTest() {
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
//
|
|
||||||
// homeScreen {
|
|
||||||
// // On homeview, tap the 3-dot button to expand, select rename, rename collection
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// clickCollectionThreeDotButton()
|
|
||||||
// selectRenameCollection()
|
|
||||||
// typeCollectionName("renamed_collection")
|
|
||||||
// verifyCollectionIsDisplayed("renamed_collection")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun createCollectionFromTabTest() {
|
|
||||||
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
// homeScreen {
|
|
||||||
// }.openTabDrawer {
|
|
||||||
// verifyExistingOpenTabs(firstWebPage.title)
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// try {
|
|
||||||
// verifyCollectionIsDisplayed(firstCollectionName)
|
|
||||||
// } catch (e: NoMatchingViewException) {
|
|
||||||
// scrollToElementByText(firstCollectionName)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun removeTabFromCollectionTest() {
|
|
||||||
// val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
// homeScreen {
|
|
||||||
// closeTab()
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// removeTabFromCollection(webPage.title)
|
|
||||||
// verifyItemInCollectionExists(webPage.title, false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
// homeScreen {
|
|
||||||
// closeTab()
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// swipeCollectionItemLeft(webPage.title)
|
|
||||||
// verifyItemInCollectionExists(webPage.title, false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
// homeScreen {
|
|
||||||
// closeTab()
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// swipeCollectionItemRight(webPage.title)
|
|
||||||
// verifyItemInCollectionExists(webPage.title, false)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun selectTabOnLongTapTest() {
|
|
||||||
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
||||||
//
|
|
||||||
// navigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// }.openNavigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// longTapSelectTab(firstWebPage.title)
|
|
||||||
// verifySelectTabsView()
|
|
||||||
// verifyTabsSelectedCounterText(1)
|
|
||||||
// selectTabForCollection(secondWebPage.title)
|
|
||||||
// verifyTabsSelectedCounterText(2)
|
|
||||||
// saveTabsSelectedForCollection()
|
|
||||||
// typeCollectionName(firstCollectionName)
|
|
||||||
// verifySnackBarText("Tabs saved!")
|
|
||||||
//// closeTabViaXButton(firstWebPage.title)
|
|
||||||
//// closeTabViaXButton(secondWebPage.title)
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// verifyItemInCollectionExists(firstWebPage.title)
|
|
||||||
// verifyItemInCollectionExists(secondWebPage.title)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun tabsOverflowMenuSaveCollectionTest() {
|
|
||||||
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
||||||
//
|
|
||||||
// navigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// }.openNavigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// }.openTabsListThreeDotMenu {
|
|
||||||
// verifySaveCollection()
|
|
||||||
// }.clickOpenTabsMenuSaveCollection {
|
|
||||||
// verifySelectTabsView()
|
|
||||||
// verifyTabsSelectedCounterText(0)
|
|
||||||
// selectAllTabsForCollection()
|
|
||||||
// verifyTabsSelectedCounterText(2)
|
|
||||||
// saveTabsSelectedForCollection()
|
|
||||||
// typeCollectionName(firstCollectionName)
|
|
||||||
//// closeTabViaXButton(firstWebPage.title)
|
|
||||||
//// closeTabViaXButton(secondWebPage.title)
|
|
||||||
// expandCollection(firstCollectionName)
|
|
||||||
// verifyItemInCollectionExists(firstWebPage.title)
|
|
||||||
// verifyItemInCollectionExists(secondWebPage.title)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
// @Test
|
|
||||||
// fun navigateBackInCollectionFlowTest() {
|
|
||||||
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
||||||
//
|
|
||||||
// createCollection(firstCollectionName)
|
|
||||||
// navigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// longTapSelectTab(secondWebPage.title)
|
|
||||||
// verifySelectTabsView()
|
|
||||||
// saveTabsSelectedForCollection()
|
|
||||||
// verifySelectCollectionView()
|
|
||||||
// clickAddNewCollection()
|
|
||||||
// verifyNameCollectionView()
|
|
||||||
// goBackCollectionFlow()
|
|
||||||
// verifySelectCollectionView()
|
|
||||||
// goBackCollectionFlow()
|
|
||||||
// verifySelectTabsView()
|
|
||||||
// goBackCollectionFlow()
|
|
||||||
// verifyHomeComponent()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun createCollection(collectionName: String, firstCollection: Boolean = true) {
|
|
||||||
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
//
|
|
||||||
// navigationToolbar {
|
|
||||||
// }.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
||||||
// verifyPageContent(firstWebPage.content)
|
|
||||||
// }.openThreeDotMenu {
|
|
||||||
// clickBrowserViewSaveCollectionButton()
|
|
||||||
// if (!firstCollection)
|
|
||||||
// clickAddNewCollection()
|
|
||||||
//
|
|
||||||
// }.typeCollectionName(collectionName) {
|
|
||||||
// verifySnackBarText("Tab saved!")
|
|
||||||
// }.openHomeScreen {
|
|
||||||
// mDevice.wait(
|
|
||||||
// Until.findObject(By.text(collectionName)),
|
|
||||||
// TestAssetHelper.waitingTime
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -0,0 +1,265 @@
|
|||||||
|
package org.mozilla.fenix.ui.robots
|
||||||
|
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.NoMatchingViewException
|
||||||
|
import androidx.test.espresso.action.ViewActions
|
||||||
|
import androidx.test.espresso.action.ViewActions.pressImeActionButton
|
||||||
|
import androidx.test.espresso.action.ViewActions.replaceText
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
|
import androidx.test.uiautomator.By
|
||||||
|
import androidx.test.uiautomator.UiSelector
|
||||||
|
import androidx.test.uiautomator.Until
|
||||||
|
import org.hamcrest.Matchers.allOf
|
||||||
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||||
|
import org.mozilla.fenix.helpers.TestHelper.packageName
|
||||||
|
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
|
||||||
|
import org.mozilla.fenix.helpers.click
|
||||||
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
|
|
||||||
|
class CollectionRobot {
|
||||||
|
|
||||||
|
fun verifySelectCollectionScreen() {
|
||||||
|
onView(withText("Select collection"))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
|
||||||
|
onView(withId(R.id.collections_list))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
|
||||||
|
onView(withText("Add new collection"))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clickAddNewCollection() = addNewCollectionButton().click()
|
||||||
|
|
||||||
|
fun selectTabForCollection(title: String) {
|
||||||
|
onView(withText(title))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyCollectionNameTextField() {
|
||||||
|
mainMenuEditCollectionNameField().check(matches(isDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
|
// names a collection saved from tab drawer
|
||||||
|
fun typeCollectionNameAndSave(collectionName: String) {
|
||||||
|
collectionNameTextField().perform(replaceText(collectionName))
|
||||||
|
mDevice.findObject(UiSelector().textContains("OK")).click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyTabsSelectedCounterText(numOfTabs: Int) {
|
||||||
|
mDevice.findObject(UiSelector().text("Select tabs to save"))
|
||||||
|
.waitUntilGone(waitingTime)
|
||||||
|
|
||||||
|
val tabsCounter = onView(withId(R.id.bottom_bar_text))
|
||||||
|
when (numOfTabs) {
|
||||||
|
1 -> tabsCounter.check(matches(withText("$numOfTabs tab selected")))
|
||||||
|
2 -> tabsCounter.check(matches(withText("$numOfTabs tabs selected")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveTabsSelectedForCollection() {
|
||||||
|
onView(withId(R.id.save_button)).click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyTabSavedInCollection(title: String, visible: Boolean = true) {
|
||||||
|
try {
|
||||||
|
collectionItem(title)
|
||||||
|
.check(
|
||||||
|
if (visible) matches(isDisplayed()) else doesNotExist()
|
||||||
|
)
|
||||||
|
} catch (e: NoMatchingViewException) {
|
||||||
|
scrollToElementByText(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyCollectionTabUrl() {
|
||||||
|
onView(withId(R.id.caption)).check(matches(isDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyCollectionTabLogo() {
|
||||||
|
onView(withId(R.id.favicon)).check(matches(isDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyShareCollectionButtonIsVisible(visible: Boolean) {
|
||||||
|
shareCollectionButton()
|
||||||
|
.check(
|
||||||
|
if (visible) matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
|
||||||
|
else matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clickShareCollectionButton() = onView(withId(R.id.collection_share_button)).click()
|
||||||
|
|
||||||
|
fun verifyCollectionMenuIsVisible(visible: Boolean) {
|
||||||
|
collectionThreeDotButton()
|
||||||
|
.check(
|
||||||
|
if (visible) matches(
|
||||||
|
withEffectiveVisibility(
|
||||||
|
ViewMatchers.Visibility.VISIBLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clickCollectionThreeDotButton() {
|
||||||
|
collectionThreeDotButton().click()
|
||||||
|
mDevice.waitNotNull(
|
||||||
|
Until.findObject(By.text("Delete collection")),
|
||||||
|
waitingTime
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selectOpenTabs() {
|
||||||
|
onView(withText("Open tabs")).click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selectRenameCollection() {
|
||||||
|
onView(withText("Rename collection")).click()
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.text("Rename collection")))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selectAddTabToCollection() {
|
||||||
|
onView(withText("Add tab")).click()
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.text("Select Tabs")))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selectDeleteCollection() {
|
||||||
|
onView(withText("Delete collection")).click()
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.res("android:id/message")), waitingTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun confirmDeleteCollection() {
|
||||||
|
onView(withText("DELETE")).click()
|
||||||
|
mDevice.waitNotNull(
|
||||||
|
Until.findObject(By.res("$packageName:id/no_collections_header")),
|
||||||
|
waitingTime
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyCollectionItemRemoveButtonIsVisible(title: String, visible: Boolean) {
|
||||||
|
removeTabFromCollectionButton(title)
|
||||||
|
.check(
|
||||||
|
if (visible) matches(
|
||||||
|
withEffectiveVisibility(
|
||||||
|
ViewMatchers.Visibility.VISIBLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else doesNotExist()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeTabFromCollection(title: String) = removeTabFromCollectionButton(title).click()
|
||||||
|
|
||||||
|
fun swipeCollectionItemRight(title: String) {
|
||||||
|
try {
|
||||||
|
collectionItem(title).perform(ViewActions.swipeRight())
|
||||||
|
} catch (e: NoMatchingViewException) {
|
||||||
|
scrollToElementByText(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun swipeCollectionItemLeft(title: String) {
|
||||||
|
try {
|
||||||
|
collectionItem(title).perform(ViewActions.swipeLeft())
|
||||||
|
} catch (e: NoMatchingViewException) {
|
||||||
|
scrollToElementByText(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifySnackBarText(expectedText: String) {
|
||||||
|
mDevice.findObject(UiSelector().text(expectedText)).waitForExists(waitingTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun goBackInCollectionFlow() = backButton().click()
|
||||||
|
|
||||||
|
class Transition {
|
||||||
|
fun collapseCollection(
|
||||||
|
title: String,
|
||||||
|
interact: HomeScreenRobot.() -> Unit
|
||||||
|
): HomeScreenRobot.Transition {
|
||||||
|
try {
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.text(title)), waitingTime)
|
||||||
|
onView(allOf(withId(R.id.chevron), hasSibling(withText(title)))).click()
|
||||||
|
} catch (e: NoMatchingViewException) {
|
||||||
|
scrollToElementByText(title)
|
||||||
|
}
|
||||||
|
|
||||||
|
HomeScreenRobot().interact()
|
||||||
|
return HomeScreenRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
// names a collection saved from the 3dot menu
|
||||||
|
fun typeCollectionNameAndSave(
|
||||||
|
name: String,
|
||||||
|
interact: BrowserRobot.() -> Unit
|
||||||
|
): BrowserRobot.Transition {
|
||||||
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/name_collection_edittext"))
|
||||||
|
.waitForExists(waitingTime)
|
||||||
|
|
||||||
|
mainMenuEditCollectionNameField().perform(
|
||||||
|
replaceText(name),
|
||||||
|
pressImeActionButton()
|
||||||
|
)
|
||||||
|
|
||||||
|
// wait for the collection creation wrapper to be dismissed
|
||||||
|
mDevice.waitNotNull(Until.gone(By.res("$packageName:id/createCollectionWrapper")))
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selectExistingCollection(
|
||||||
|
title: String,
|
||||||
|
interact: BrowserRobot.() -> Unit
|
||||||
|
): BrowserRobot.Transition {
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.text(title)), waitingTime)
|
||||||
|
onView(withText(title)).click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectionRobot(interact: CollectionRobot.() -> Unit): CollectionRobot.Transition {
|
||||||
|
CollectionRobot().interact()
|
||||||
|
return CollectionRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun collectionThreeDotButton() =
|
||||||
|
onView(withId(R.id.collection_overflow_button))
|
||||||
|
|
||||||
|
private fun collectionItem(title: String) =
|
||||||
|
onView(allOf(withId(R.id.label), withText(title)))
|
||||||
|
|
||||||
|
private fun shareCollectionButton() = onView(withId(R.id.collection_share_button))
|
||||||
|
|
||||||
|
private fun removeTabFromCollectionButton(title: String) =
|
||||||
|
onView(
|
||||||
|
allOf(
|
||||||
|
withId(R.id.secondary_button),
|
||||||
|
hasSibling(withText(title))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
// collection name text field, opened from tab drawer
|
||||||
|
private fun collectionNameTextField() = onView(withId(R.id.collection_name))
|
||||||
|
|
||||||
|
// collection name text field, opened from main menu
|
||||||
|
private fun mainMenuEditCollectionNameField() =
|
||||||
|
onView(withId(R.id.name_collection_edittext))
|
||||||
|
|
||||||
|
private fun addNewCollectionButton() = onView(withText("Add new collection"))
|
||||||
|
|
||||||
|
private fun backButton() =
|
||||||
|
onView(withId(R.id.back_button))
|
Loading…
Reference in New Issue