Remove tab tray feature flag (#11176)
* For #11171 - Removes feature flag for the new tab tray * For #11171 - Removes all tab references from homeFragment * For #11171 - Fixes unit tests * For #11171 - Gets UI tests to compile and HomeScreenTest to pass * For #11171 - Fixes `deleteMultipleSelectionTest` * For #11171 - Fixes `openHistoryItemInNewPrivateTabTest` * For #11171 - Fixes `openHistoryInPrivateTabTest` * For #11171 - Fixes `openHistoryInNewTabTest` * For #11171 - Fixes `openNewPrivateTabTest` * For #11171 - Fixes tabbedBrowsingTests * For #11171 - Fixes SettingsPrivacyTest * For #11171 - Fixes TopSitesTest * For #11171 - Fixes lint errors * Ignorefennec/production
parent
4b3230a118
commit
52c2fdb310
@ -1,362 +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
|
|
||||||
fun verifyCreateFirstCollectionFlowItems() {
|
|
||||||
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
||||||
|
|
||||||
navigationToolbar {
|
|
||||||
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
||||||
}.openHomeScreen {
|
|
||||||
}.openNavigationToolbar {
|
|
||||||
}.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
||||||
}.openHomeScreen {
|
|
||||||
clickSaveCollectionButton()
|
|
||||||
verifySelectTabsView()
|
|
||||||
selectAllTabsForCollection()
|
|
||||||
verifyTabsSelectedCounterText(2)
|
|
||||||
deselectAllTabsForCollection()
|
|
||||||
verifyTabsSelectedCounterText(0)
|
|
||||||
selectTabForCollection(firstWebPage.title)
|
|
||||||
verifyTabsSelectedCounterText(1)
|
|
||||||
selectAllTabsForCollection()
|
|
||||||
saveTabsSelectedForCollection()
|
|
||||||
verifyNameCollectionView()
|
|
||||||
verifyDefaultCollectionName("Collection 1")
|
|
||||||
typeCollectionName(firstCollectionName)
|
|
||||||
verifySnackBarText("Tabs saved!")
|
|
||||||
verifyExistingOpenTabs(firstWebPage.title)
|
|
||||||
verifyExistingOpenTabs(secondWebPage.title)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 collectionMenuOpenAllTabsTest() {
|
|
||||||
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
|
|
||||||
createCollection(firstCollectionName)
|
|
||||||
|
|
||||||
homeScreen {
|
|
||||||
closeTab()
|
|
||||||
expandCollection(firstCollectionName)
|
|
||||||
clickCollectionThreeDotButton()
|
|
||||||
selectOpenTabs()
|
|
||||||
verifyExistingOpenTabs(firstWebPage.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 deleteCollectionTest() {
|
|
||||||
createCollection(firstCollectionName)
|
|
||||||
|
|
||||||
homeScreen {
|
|
||||||
expandCollection(firstCollectionName)
|
|
||||||
clickCollectionThreeDotButton()
|
|
||||||
selectDeleteCollection()
|
|
||||||
confirmDeleteCollection()
|
|
||||||
verifyNoCollectionsHeader()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
@Test
|
|
||||||
fun createCollectionFromTabTest() {
|
|
||||||
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
|
|
||||||
createCollection(firstCollectionName)
|
|
||||||
homeScreen {
|
|
||||||
// swipe to bottom until the collections are shown
|
|
||||||
verifyExistingOpenTabs(firstWebPage.title)
|
|
||||||
try {
|
|
||||||
verifyCollectionIsDisplayed(firstCollectionName)
|
|
||||||
} catch (e: NoMatchingViewException) {
|
|
||||||
scrollToElementByText(firstCollectionName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
@Test
|
|
||||||
fun verifyExpandedCollectionItemsTest() {
|
|
||||||
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
||||||
|
|
||||||
createCollection(firstCollectionName)
|
|
||||||
|
|
||||||
homeScreen {
|
|
||||||
verifyCollectionIsDisplayed(firstCollectionName)
|
|
||||||
verifyCollectionIcon()
|
|
||||||
expandCollection(firstCollectionName)
|
|
||||||
verifyItemInCollectionExists(firstWebPage.title)
|
|
||||||
verifyCollectionItemLogo()
|
|
||||||
verifyCollectionItemUrl()
|
|
||||||
verifyShareCollectionButtonIsVisible(true)
|
|
||||||
verifyCollectionMenuIsVisible(true)
|
|
||||||
verifyCollectionItemRemoveButtonIsVisible(firstWebPage.title, true)
|
|
||||||
collapseCollection(firstCollectionName)
|
|
||||||
verifyItemInCollectionExists(firstWebPage.title, false)
|
|
||||||
verifyShareCollectionButtonIsVisible(false)
|
|
||||||
verifyCollectionMenuIsVisible(false)
|
|
||||||
verifyCollectionItemRemoveButtonIsVisible(firstWebPage.title, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
|
||||||
@Test
|
|
||||||
fun shareCollectionTest() {
|
|
||||||
createCollection(firstCollectionName)
|
|
||||||
homeScreen {
|
|
||||||
expandCollection(firstCollectionName)
|
|
||||||
clickShareCollectionButton()
|
|
||||||
verifyShareTabsOverlay()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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,367 @@
|
|||||||
|
///* 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
|
||||||
|
// fun verifyCreateFirstCollectionFlowItems() {
|
||||||
|
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
// val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
||||||
|
//
|
||||||
|
// navigationToolbar {
|
||||||
|
// }.enterURLAndEnterToBrowser(firstWebPage.url) {
|
||||||
|
// }.openHomeScreen {
|
||||||
|
// }.openNavigationToolbar {
|
||||||
|
// }.enterURLAndEnterToBrowser(secondWebPage.url) {
|
||||||
|
// }.openTabDrawer {
|
||||||
|
// }.openTabsListThreeDotMenu {
|
||||||
|
// verifySaveCollection()
|
||||||
|
// }.clickOpenTabsMenuSaveCollection {
|
||||||
|
// clickSaveCollectionButton()
|
||||||
|
// verifySelectTabsView()
|
||||||
|
// selectAllTabsForCollection()
|
||||||
|
// verifyTabsSelectedCounterText(2)
|
||||||
|
// deselectAllTabsForCollection()
|
||||||
|
// verifyTabsSelectedCounterText(0)
|
||||||
|
// selectTabForCollection(firstWebPage.title)
|
||||||
|
// verifyTabsSelectedCounterText(1)
|
||||||
|
// selectAllTabsForCollection()
|
||||||
|
// saveTabsSelectedForCollection()
|
||||||
|
// verifyNameCollectionView()
|
||||||
|
// verifyDefaultCollectionName("Collection 1")
|
||||||
|
// typeCollectionName(firstCollectionName)
|
||||||
|
// verifySnackBarText("Tabs saved!")
|
||||||
|
//// verifyExistingOpenTabs(firstWebPage.title)
|
||||||
|
//// verifyExistingOpenTabs(secondWebPage.title)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @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 collectionMenuOpenAllTabsTest() {
|
||||||
|
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
//
|
||||||
|
// createCollection(firstCollectionName)
|
||||||
|
//
|
||||||
|
// homeScreen {
|
||||||
|
// closeTab()
|
||||||
|
// expandCollection(firstCollectionName)
|
||||||
|
// clickCollectionThreeDotButton()
|
||||||
|
// selectOpenTabs()
|
||||||
|
// }.openTabDrawer {
|
||||||
|
// verifyExistingOpenTabs(firstWebPage.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 deleteCollectionTest() {
|
||||||
|
// createCollection(firstCollectionName)
|
||||||
|
//
|
||||||
|
// homeScreen {
|
||||||
|
// expandCollection(firstCollectionName)
|
||||||
|
// clickCollectionThreeDotButton()
|
||||||
|
// selectDeleteCollection()
|
||||||
|
// confirmDeleteCollection()
|
||||||
|
// verifyNoCollectionsHeader()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @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 verifyExpandedCollectionItemsTest() {
|
||||||
|
// val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
//
|
||||||
|
// createCollection(firstCollectionName)
|
||||||
|
//
|
||||||
|
// homeScreen {
|
||||||
|
// verifyCollectionIsDisplayed(firstCollectionName)
|
||||||
|
// verifyCollectionIcon()
|
||||||
|
// expandCollection(firstCollectionName)
|
||||||
|
// verifyItemInCollectionExists(firstWebPage.title)
|
||||||
|
// verifyCollectionItemLogo()
|
||||||
|
// verifyCollectionItemUrl()
|
||||||
|
// verifyShareCollectionButtonIsVisible(true)
|
||||||
|
// verifyCollectionMenuIsVisible(true)
|
||||||
|
// verifyCollectionItemRemoveButtonIsVisible(firstWebPage.title, true)
|
||||||
|
// collapseCollection(firstCollectionName)
|
||||||
|
// verifyItemInCollectionExists(firstWebPage.title, false)
|
||||||
|
// verifyShareCollectionButtonIsVisible(false)
|
||||||
|
// verifyCollectionMenuIsVisible(false)
|
||||||
|
// verifyCollectionItemRemoveButtonIsVisible(firstWebPage.title, false)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Ignore("Intermittent failures, see: https://github.com/mozilla-mobile/fenix/issues/10587")
|
||||||
|
// @Test
|
||||||
|
// fun shareCollectionTest() {
|
||||||
|
// createCollection(firstCollectionName)
|
||||||
|
// homeScreen {
|
||||||
|
// expandCollection(firstCollectionName)
|
||||||
|
// clickShareCollectionButton()
|
||||||
|
// verifyShareTabsOverlay()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @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,198 @@
|
|||||||
|
/* 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 android.content.Context
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import androidx.test.espresso.Espresso
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.NoMatchingViewException
|
||||||
|
import androidx.test.espresso.action.ViewActions
|
||||||
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.uiautomator.By
|
||||||
|
import androidx.test.uiautomator.By.text
|
||||||
|
import androidx.test.uiautomator.UiDevice
|
||||||
|
import androidx.test.uiautomator.Until.findObject
|
||||||
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||||
|
import org.mozilla.fenix.helpers.click
|
||||||
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of Robot Pattern for the home screen menu.
|
||||||
|
*/
|
||||||
|
class TabDrawerRobot {
|
||||||
|
fun verifyExistingOpenTabs(title: String) = assertExistingOpenTabs(title)
|
||||||
|
fun verifyCloseTabsButton(title: String) = assertCloseTabsButton(title)
|
||||||
|
|
||||||
|
fun verifyExistingTabList() = assertExistingTabList()
|
||||||
|
|
||||||
|
fun verifyNoTabsOpened() = assertNoTabsOpenedText()
|
||||||
|
fun verifyPrivateModeSelected() = assertPrivateModeSelected()
|
||||||
|
fun verifyNormalModeSelected() = assertNormalModeSelected()
|
||||||
|
|
||||||
|
fun closeTab() {
|
||||||
|
closeTabButton().click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun swipeTabRight(title: String) =
|
||||||
|
tab(title).perform(ViewActions.swipeRight())
|
||||||
|
|
||||||
|
fun swipeTabLeft(title: String) =
|
||||||
|
tab(title).perform(ViewActions.swipeLeft())
|
||||||
|
|
||||||
|
fun closeTabViaXButton(title: String) {
|
||||||
|
val closeButton = onView(
|
||||||
|
allOf(
|
||||||
|
withId(R.id.mozac_browser_tabstray_close),
|
||||||
|
withContentDescription("Close tab $title")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
closeButton.perform(click())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifySnackBarText(expectedText: String) {
|
||||||
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
mDevice.waitNotNull(findObject(By.text(expectedText)), TestAssetHelper.waitingTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun snackBarButtonClick(expectedText: String) {
|
||||||
|
onView(allOf(withId(R.id.snackbar_btn), withText(expectedText))).check(
|
||||||
|
matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
|
||||||
|
).perform(click())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyTabMediaControlButtonState(action: String) {
|
||||||
|
mDevice.waitNotNull(
|
||||||
|
findObject(
|
||||||
|
By
|
||||||
|
.res("org.mozilla.fenix.debug:id/play_pause_button")
|
||||||
|
.desc(action)
|
||||||
|
),
|
||||||
|
waitingTime
|
||||||
|
)
|
||||||
|
|
||||||
|
tabMediaControlButton().check(matches(withContentDescription(action)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clickTabMediaControlButton() = tabMediaControlButton().click()
|
||||||
|
|
||||||
|
class Transition {
|
||||||
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
|
||||||
|
fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
|
||||||
|
mDevice.waitForIdle()
|
||||||
|
|
||||||
|
Espresso.openActionBarOverflowOrOptionsMenu(ApplicationProvider.getApplicationContext<Context>())
|
||||||
|
ThreeDotMenuMainRobot().interact()
|
||||||
|
return ThreeDotMenuMainRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||||
|
mDevice.waitForIdle()
|
||||||
|
|
||||||
|
newTabButton().perform(click())
|
||||||
|
HomeScreenRobot().interact()
|
||||||
|
return HomeScreenRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggleToNormalTabs(interact: TabDrawerRobot.() -> Unit): Transition {
|
||||||
|
normalBrowsingButton().perform(click())
|
||||||
|
TabDrawerRobot().interact()
|
||||||
|
return Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggleToPrivateTabs(interact: TabDrawerRobot.() -> Unit): Transition {
|
||||||
|
privateBrowsingButton().perform(click())
|
||||||
|
TabDrawerRobot().interact()
|
||||||
|
return Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openTabsListThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
|
||||||
|
threeDotMenu().perform(click())
|
||||||
|
|
||||||
|
ThreeDotMenuMainRobot().interact()
|
||||||
|
return ThreeDotMenuMainRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openTab(title: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
mDevice.waitNotNull(findObject(text(title)))
|
||||||
|
tab(title).click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun tabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
|
||||||
|
TabDrawerRobot().interact()
|
||||||
|
return TabDrawerRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun tabMediaControlButton() = onView(withId(R.id.play_pause_button))
|
||||||
|
|
||||||
|
private fun closeTabButton() = onView(withId(R.id.mozac_browser_tabstray_close))
|
||||||
|
private fun assertCloseTabsButton(title: String) =
|
||||||
|
onView(allOf(withId(R.id.mozac_browser_tabstray_close), withContentDescription("Close tab $title")))
|
||||||
|
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
|
|
||||||
|
private fun normalBrowsingButton() = onView(withContentDescription("Open tabs"))
|
||||||
|
private fun privateBrowsingButton() = onView(withContentDescription("Private tabs"))
|
||||||
|
private fun newTabButton() = onView(withId(R.id.new_tab_button))
|
||||||
|
private fun threeDotMenu() = onView(withId(R.id.tab_tray_overflow))
|
||||||
|
|
||||||
|
private fun assertExistingOpenTabs(title: String) {
|
||||||
|
try {
|
||||||
|
tab(title).check(matches(isDisplayed()))
|
||||||
|
} catch (e: NoMatchingViewException) {
|
||||||
|
onView(withId(R.id.tabsTray)).perform(
|
||||||
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||||
|
allOf(
|
||||||
|
withId(R.id.mozac_browser_tabstray_title),
|
||||||
|
withText(title)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun assertExistingTabList() =
|
||||||
|
onView(allOf(withId(R.id.tab_item)))
|
||||||
|
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
|
|
||||||
|
private fun assertNoTabsOpenedText() =
|
||||||
|
onView(withId(R.id.tab_tray_empty_view))
|
||||||
|
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
|
|
||||||
|
private fun assertNormalModeSelected() =
|
||||||
|
normalBrowsingButton()
|
||||||
|
.check(matches(ViewMatchers.isSelected()))
|
||||||
|
|
||||||
|
private fun assertPrivateModeSelected() =
|
||||||
|
privateBrowsingButton()
|
||||||
|
.check(matches(ViewMatchers.isSelected()))
|
||||||
|
|
||||||
|
private fun tab(title: String) =
|
||||||
|
onView(
|
||||||
|
allOf(
|
||||||
|
withId(R.id.mozac_browser_tabstray_title),
|
||||||
|
withText(title)
|
||||||
|
)
|
||||||
|
)
|
@ -1,71 +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.components
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.Application
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import org.mozilla.fenix.ext.settings
|
|
||||||
|
|
||||||
class PendingSessionDeletionManager(application: Application) :
|
|
||||||
Application.ActivityLifecycleCallbacks {
|
|
||||||
|
|
||||||
private val sessionIdsPendingDeletion = mutableSetOf<String>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
application.registerActivityLifecycleCallbacks(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addSession(sessionId: String) {
|
|
||||||
sessionIdsPendingDeletion.add(sessionId)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun removeSession(sessionId: String) {
|
|
||||||
sessionIdsPendingDeletion.remove(sessionId)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getSessionsToDelete(context: Context): Set<String> {
|
|
||||||
return context.settings().preferences.getStringSet(
|
|
||||||
PREF_KEY,
|
|
||||||
setOf()
|
|
||||||
) ?: setOf()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityPaused(activity: Activity?) {
|
|
||||||
activity?.settings()?.preferences?.edit()?.putStringSet(
|
|
||||||
PREF_KEY,
|
|
||||||
sessionIdsPendingDeletion
|
|
||||||
)?.apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResumed(p0: Activity?) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityStarted(p0: Activity?) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityDestroyed(p0: Activity?) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivitySaveInstanceState(p0: Activity?, p1: Bundle?) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityStopped(p0: Activity?) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityCreated(p0: Activity?, p1: Bundle?) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val PREF_KEY = "pref_key_session_id_set_to_delete"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +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.home.sessioncontrol.viewholders
|
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import androidx.annotation.DrawableRes
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import kotlinx.android.synthetic.main.no_content_message_with_action.*
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
|
|
||||||
class NoContentMessageWithActionViewHolder(view: View) : NoContentMessageViewHolder(view) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param header ID of string resource for title text.
|
|
||||||
* @param description ID of string resource for description text.
|
|
||||||
* @param buttonIcon Optional ID of drawable resource for button icon.
|
|
||||||
* @param buttonText Optional ID of string resource for button text.
|
|
||||||
* @param listener Optional Callback to be invoked when the button is clicked.
|
|
||||||
*/
|
|
||||||
@Suppress("LongParameterList")
|
|
||||||
fun bind(
|
|
||||||
@StringRes header: Int,
|
|
||||||
@StringRes description: Int,
|
|
||||||
@DrawableRes buttonIcon: Int = 0,
|
|
||||||
@StringRes buttonText: Int = 0,
|
|
||||||
listener: (() -> Unit)? = null
|
|
||||||
) {
|
|
||||||
super.bind(header, description)
|
|
||||||
with(itemView.context) {
|
|
||||||
|
|
||||||
if (buttonIcon != 0 || buttonText != 0) {
|
|
||||||
add_new_tab_button.apply {
|
|
||||||
isVisible = true
|
|
||||||
icon = getDrawable(buttonIcon)
|
|
||||||
text = getString(buttonText)
|
|
||||||
setOnClickListener {
|
|
||||||
listener?.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val LAYOUT_ID = R.layout.no_content_message_with_action
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +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.home.sessioncontrol.viewholders
|
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import kotlinx.android.synthetic.main.save_to_collection_button.view.*
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
import org.mozilla.fenix.home.sessioncontrol.TabSessionInteractor
|
|
||||||
|
|
||||||
class SaveTabGroupViewHolder(
|
|
||||||
view: View,
|
|
||||||
private val interactor: TabSessionInteractor
|
|
||||||
) : RecyclerView.ViewHolder(view) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
view.save_tab_group_button.setOnClickListener {
|
|
||||||
view.context.components.analytics.metrics
|
|
||||||
.track(Event.CollectionSaveButtonPressed(TELEMETRY_HOME_IDENTIFIER))
|
|
||||||
interactor.onSaveToCollection(sessionId = null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TELEMETRY_HOME_IDENTIFIER = "home"
|
|
||||||
const val LAYOUT_ID = R.layout.save_to_collection_button
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +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.home.sessioncontrol.viewholders
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.PopupWindow
|
|
||||||
import androidx.core.view.isInvisible
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import kotlinx.android.synthetic.main.tab_header.*
|
|
||||||
import mozilla.components.browser.menu.BrowserMenu
|
|
||||||
import mozilla.components.browser.menu.BrowserMenuBuilder
|
|
||||||
import mozilla.components.browser.menu.item.SimpleBrowserMenuItem
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.ext.ViewHolder
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
import org.mozilla.fenix.home.sessioncontrol.SessionControlInteractor
|
|
||||||
|
|
||||||
class TabHeaderViewHolder(
|
|
||||||
view: View,
|
|
||||||
private val interactor: SessionControlInteractor
|
|
||||||
) : ViewHolder(view) {
|
|
||||||
private var isPrivate = false
|
|
||||||
private var tabsMenu: TabHeaderMenu
|
|
||||||
|
|
||||||
init {
|
|
||||||
tabsMenu = TabHeaderMenu(view.context, isPrivate) {
|
|
||||||
when (it) {
|
|
||||||
is TabHeaderMenu.Item.Share -> interactor.onShareTabs()
|
|
||||||
is TabHeaderMenu.Item.CloseAll -> interactor.onCloseAllTabs(isPrivate)
|
|
||||||
is TabHeaderMenu.Item.SaveToCollection -> {
|
|
||||||
interactor.onSaveToCollection(null)
|
|
||||||
view.context.components.analytics.metrics
|
|
||||||
.track(Event.CollectionSaveButtonPressed(TELEMETRY_HOME_MENU_IDENITIFIER))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
share_tabs_button.setOnClickListener {
|
|
||||||
interactor.onShareTabs()
|
|
||||||
}
|
|
||||||
|
|
||||||
close_tabs_button.setOnClickListener {
|
|
||||||
it.context.components.analytics.metrics.track(Event.PrivateBrowsingGarbageIconTapped)
|
|
||||||
interactor.onCloseAllTabs(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
tabs_overflow_button.run {
|
|
||||||
var menu: PopupWindow? = null
|
|
||||||
setOnClickListener {
|
|
||||||
if (menu == null) {
|
|
||||||
menu = tabsMenu.menuBuilder
|
|
||||||
.build(it.context)
|
|
||||||
.show(
|
|
||||||
anchor = it,
|
|
||||||
orientation = BrowserMenu.Orientation.DOWN,
|
|
||||||
onDismiss = { menu = null }
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
menu?.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bind(isPrivate: Boolean, hasTabs: Boolean) {
|
|
||||||
this.isPrivate = isPrivate
|
|
||||||
tabsMenu.isPrivate = isPrivate
|
|
||||||
|
|
||||||
val headerTextResourceId =
|
|
||||||
if (isPrivate) R.string.tabs_header_private_tabs_title else R.string.tab_header_label
|
|
||||||
header_text.text = itemView.context.getString(headerTextResourceId)
|
|
||||||
share_tabs_button.isInvisible = !isPrivate || !hasTabs
|
|
||||||
close_tabs_button.isInvisible = !isPrivate || !hasTabs
|
|
||||||
tabs_overflow_button.isVisible = !isPrivate && hasTabs
|
|
||||||
}
|
|
||||||
|
|
||||||
class TabHeaderMenu(
|
|
||||||
private val context: Context,
|
|
||||||
var isPrivate: Boolean,
|
|
||||||
private val onItemTapped: (Item) -> Unit = {}
|
|
||||||
) {
|
|
||||||
sealed class Item {
|
|
||||||
object CloseAll : Item()
|
|
||||||
object Share : Item()
|
|
||||||
object SaveToCollection : Item()
|
|
||||||
}
|
|
||||||
|
|
||||||
val menuBuilder by lazy { BrowserMenuBuilder(menuItems) }
|
|
||||||
|
|
||||||
private val menuItems by lazy {
|
|
||||||
listOf(
|
|
||||||
SimpleBrowserMenuItem(
|
|
||||||
context.getString(R.string.tabs_menu_close_all_tabs)
|
|
||||||
) {
|
|
||||||
onItemTapped.invoke(Item.CloseAll)
|
|
||||||
},
|
|
||||||
SimpleBrowserMenuItem(
|
|
||||||
context.getString(R.string.tabs_menu_share_tabs)
|
|
||||||
) {
|
|
||||||
onItemTapped.invoke(Item.Share)
|
|
||||||
},
|
|
||||||
SimpleBrowserMenuItem(
|
|
||||||
context.getString(R.string.tabs_menu_save_to_collection)
|
|
||||||
) {
|
|
||||||
onItemTapped.invoke(Item.SaveToCollection)
|
|
||||||
}.apply { visible = { !isPrivate } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TELEMETRY_HOME_MENU_IDENITIFIER = "homeMenu"
|
|
||||||
const val LAYOUT_ID = R.layout.tab_header
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +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.home.sessioncontrol.viewholders
|
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.Outline
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewOutlineProvider
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
|
||||||
import kotlinx.android.synthetic.main.tab_list_row.*
|
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
|
||||||
import mozilla.components.support.ktx.android.util.dpToFloat
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.ext.ViewHolder
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
import org.mozilla.fenix.ext.increaseTapArea
|
|
||||||
import org.mozilla.fenix.ext.loadIntoView
|
|
||||||
import org.mozilla.fenix.ext.removeAndDisable
|
|
||||||
import org.mozilla.fenix.ext.removeTouchDelegate
|
|
||||||
import org.mozilla.fenix.ext.showAndEnable
|
|
||||||
import org.mozilla.fenix.home.Tab
|
|
||||||
import org.mozilla.fenix.home.sessioncontrol.TabSessionInteractor
|
|
||||||
|
|
||||||
class TabViewHolder(
|
|
||||||
view: View,
|
|
||||||
interactor: TabSessionInteractor
|
|
||||||
) : ViewHolder(view) {
|
|
||||||
|
|
||||||
internal var tab: Tab? = null
|
|
||||||
|
|
||||||
init {
|
|
||||||
item_tab.setOnClickListener {
|
|
||||||
interactor.onSelectTab(it, tab?.sessionId!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
item_tab.setOnLongClickListener {
|
|
||||||
view.context.components.analytics.metrics.track(Event.CollectionTabLongPressed)
|
|
||||||
interactor.onSaveToCollection(tab?.sessionId!!)
|
|
||||||
return@setOnLongClickListener true
|
|
||||||
}
|
|
||||||
|
|
||||||
close_tab_button.setOnClickListener {
|
|
||||||
interactor.onCloseTab(tab?.sessionId!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
play_pause_button.setOnClickListener {
|
|
||||||
when (tab?.mediaState) {
|
|
||||||
MediaState.State.PLAYING -> {
|
|
||||||
it.context.components.analytics.metrics.track(Event.TabMediaPause)
|
|
||||||
interactor.onPauseMediaClicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaState.State.PAUSED -> {
|
|
||||||
it.context.components.analytics.metrics.track(Event.TabMediaPlay)
|
|
||||||
interactor.onPlayMediaClicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaState.State.NONE -> throw AssertionError(
|
|
||||||
"Play/Pause button clicked without play/pause state."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
favicon_image.clipToOutline = true
|
|
||||||
favicon_image.outlineProvider = object : ViewOutlineProvider() {
|
|
||||||
override fun getOutline(view: View?, outline: Outline?) {
|
|
||||||
outline?.setRoundRect(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
view!!.width,
|
|
||||||
view.height,
|
|
||||||
favIconBorderRadiusInPx.dpToFloat(view.context.resources.displayMetrics)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun bindSession(tab: Tab) {
|
|
||||||
updateTab(tab)
|
|
||||||
updateTitle(tab.title)
|
|
||||||
// Truncate to MAX_URI_LENGTH to prevent the UI from locking up for
|
|
||||||
// extremely large URLs such as data URIs or bookmarklets. The same
|
|
||||||
// is done in the toolbar and awesomebar:
|
|
||||||
// https://github.com/mozilla-mobile/fenix/issues/1824
|
|
||||||
// https://github.com/mozilla-mobile/android-components/issues/6985
|
|
||||||
updateHostname(tab.hostname.take(MAX_URI_LENGTH))
|
|
||||||
updateFavIcon(tab.url, tab.icon)
|
|
||||||
updateSelected(tab.selected ?: false)
|
|
||||||
updatePlayPauseButton(tab.mediaState)
|
|
||||||
item_tab.transitionName = "$TAB_ITEM_TRANSITION_NAME${tab.sessionId}"
|
|
||||||
updateCloseButtonDescription(tab.title)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updatePlayPauseButton(mediaState: MediaState.State) {
|
|
||||||
with(play_pause_button) {
|
|
||||||
invalidate()
|
|
||||||
when (mediaState) {
|
|
||||||
MediaState.State.PAUSED -> {
|
|
||||||
showAndEnable()
|
|
||||||
play_pause_button.increaseTapArea(PLAY_PAUSE_BUTTON_EXTRA_DPS)
|
|
||||||
contentDescription =
|
|
||||||
context.getString(R.string.mozac_feature_media_notification_action_play)
|
|
||||||
setImageDrawable(
|
|
||||||
AppCompatResources.getDrawable(
|
|
||||||
context,
|
|
||||||
R.drawable.play_with_background
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaState.State.PLAYING -> {
|
|
||||||
showAndEnable()
|
|
||||||
play_pause_button.increaseTapArea(PLAY_PAUSE_BUTTON_EXTRA_DPS)
|
|
||||||
contentDescription =
|
|
||||||
context.getString(R.string.mozac_feature_media_notification_action_pause)
|
|
||||||
setImageDrawable(
|
|
||||||
AppCompatResources.getDrawable(
|
|
||||||
context,
|
|
||||||
R.drawable.pause_with_background
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaState.State.NONE -> {
|
|
||||||
removeTouchDelegate()
|
|
||||||
removeAndDisable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updateTab(tab: Tab) {
|
|
||||||
this.tab = tab
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updateTitle(text: String) {
|
|
||||||
tab_title.text = text
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updateHostname(text: String) {
|
|
||||||
hostname.text = text
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updateFavIcon(url: String, icon: Bitmap?) {
|
|
||||||
if (icon == null) {
|
|
||||||
favicon_image.context.components.core.icons.loadIntoView(favicon_image, url)
|
|
||||||
} else {
|
|
||||||
favicon_image.setImageBitmap(icon)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updateSelected(selected: Boolean) {
|
|
||||||
selected_border.visibility = if (selected) View.VISIBLE else View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun updateCloseButtonDescription(title: String) {
|
|
||||||
close_tab_button.contentDescription =
|
|
||||||
close_tab_button.context.getString(R.string.close_tab_title, title)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAB_ITEM_TRANSITION_NAME = "tab_item"
|
|
||||||
private const val PLAY_PAUSE_BUTTON_EXTRA_DPS = 24
|
|
||||||
const val LAYOUT_ID = R.layout.tab_list_row
|
|
||||||
const val favIconBorderRadiusInPx = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +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.home
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import io.mockk.mockk
|
|
||||||
import kotlinx.android.synthetic.main.tab_list_row.view.*
|
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
|
||||||
import org.mozilla.fenix.home.sessioncontrol.TabSessionInteractor
|
|
||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.TabViewHolder
|
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
|
||||||
class TabViewHolderTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `extremely long URLs are truncated to prevent slowing down the UI`() {
|
|
||||||
val view = LayoutInflater.from(testContext).inflate(
|
|
||||||
R.layout.tab_list_row, null, false)
|
|
||||||
|
|
||||||
val interactor: TabSessionInteractor = mockk()
|
|
||||||
val tabViewHolder = TabViewHolder(view, interactor)
|
|
||||||
|
|
||||||
val extremelyLongUrl = "m".repeat(MAX_URI_LENGTH + 1)
|
|
||||||
val tab = Tab(
|
|
||||||
sessionId = "123",
|
|
||||||
url = extremelyLongUrl,
|
|
||||||
hostname = extremelyLongUrl,
|
|
||||||
title = "test",
|
|
||||||
mediaState = MediaState.State.NONE)
|
|
||||||
tabViewHolder.bindSession(tab)
|
|
||||||
|
|
||||||
assertEquals("m".repeat(MAX_URI_LENGTH), view.hostname.text)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue