2019-08-19 20:05:10 +02:00
|
|
|
/* 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
|
|
|
|
|
2019-10-29 10:36:19 +01:00
|
|
|
import android.content.Context
|
|
|
|
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
2019-08-19 20:05:10 +02:00
|
|
|
import okhttp3.mockwebserver.MockWebServer
|
|
|
|
import org.junit.After
|
|
|
|
import org.junit.Before
|
2019-11-04 18:44:44 +01:00
|
|
|
import org.junit.Ignore
|
2019-08-19 20:05:10 +02:00
|
|
|
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
|
2019-10-29 10:36:19 +01:00
|
|
|
import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
|
2019-12-03 11:44:54 +01:00
|
|
|
import org.mozilla.fenix.ui.robots.historyMenu
|
2019-08-19 20:05:10 +02:00
|
|
|
import org.mozilla.fenix.ui.robots.homeScreen
|
2019-10-29 10:36:19 +01:00
|
|
|
import org.mozilla.fenix.ui.robots.multipleSelectionToolbar
|
2019-08-19 20:05:10 +02:00
|
|
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests for verifying basic functionality of history
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class HistoryTest {
|
|
|
|
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
|
|
|
|
private lateinit var mockWebServer: MockWebServer
|
|
|
|
|
|
|
|
@get:Rule
|
|
|
|
val activityTestRule = HomeActivityTestRule()
|
|
|
|
|
|
|
|
@Before
|
|
|
|
fun setUp() {
|
|
|
|
mockWebServer = MockWebServer().apply {
|
|
|
|
setDispatcher(AndroidAssetDispatcher())
|
|
|
|
start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
fun tearDown() {
|
|
|
|
mockWebServer.shutdown()
|
2019-10-29 10:36:19 +01:00
|
|
|
// Clearing all history data after each test to avoid overlapping data
|
|
|
|
val applicationContext: Context = activityTestRule.activity.applicationContext
|
|
|
|
val historyStorage = PlacesHistoryStorage(applicationContext)
|
|
|
|
runBlocking {
|
|
|
|
historyStorage.deleteEverything()
|
|
|
|
}
|
2019-08-19 20:05:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun noHistoryItemsInCacheTest() {
|
2019-10-29 10:36:19 +01:00
|
|
|
homeScreen {
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
verifyHistoryButton()
|
|
|
|
}.openHistory {
|
|
|
|
verifyHistoryMenuView()
|
|
|
|
verifyEmptyHistoryView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-11-05 00:25:29 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun visitedUrlHistoryTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
verifyHistoryMenuView()
|
|
|
|
verifyVisitedTimeTitle()
|
|
|
|
verifyFirstTestPageTitle("Test_Page_1")
|
|
|
|
verifyTestPageUrl(firstWebPage.url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-11-05 00:25:29 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun deleteHistoryItemTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
openOverflowMenu()
|
|
|
|
clickThreeDotMenuDelete()
|
|
|
|
verifyEmptyHistoryView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-12-02 01:53:55 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun deleteAllHistoryTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
clickDeleteHistoryButton()
|
|
|
|
verifyDeleteConfirmationMessage()
|
|
|
|
confirmDeleteAllHistory()
|
|
|
|
verifyEmptyHistoryView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-11-05 00:25:29 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun multiSelectionToolbarItemsTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
longTapSelectItem(firstWebPage.url)
|
|
|
|
}
|
|
|
|
|
|
|
|
multipleSelectionToolbar {
|
|
|
|
verifyMultiSelectionCheckmark()
|
|
|
|
verifyMultiSelectionCounter()
|
2019-12-03 11:44:54 +01:00
|
|
|
verifyShareHistoryButton()
|
2019-10-29 10:36:19 +01:00
|
|
|
verifyCloseToolbarButton()
|
|
|
|
}.closeToolbarReturnToHistory {
|
|
|
|
verifyHistoryMenuView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-11-05 00:25:29 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun openHistoryInNewTabTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openHomeScreen {
|
|
|
|
closeTab()
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
}.openHistory {
|
|
|
|
longTapSelectItem(firstWebPage.url)
|
2019-12-02 01:53:55 +01:00
|
|
|
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
|
2019-10-29 10:36:19 +01:00
|
|
|
}
|
2019-08-19 20:05:10 +02:00
|
|
|
|
2019-10-29 10:36:19 +01:00
|
|
|
multipleSelectionToolbar {
|
|
|
|
}.clickOpenNewTab {
|
|
|
|
verifyExistingTabList()
|
|
|
|
verifyOpenTabsHeader()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-11-05 00:25:29 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun openHistoryInPrivateTabTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
longTapSelectItem(firstWebPage.url)
|
2019-12-02 01:53:55 +01:00
|
|
|
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
|
2019-10-29 10:36:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
multipleSelectionToolbar {
|
|
|
|
}.clickOpenPrivateTab {
|
|
|
|
verifyExistingTabList()
|
|
|
|
verifyPrivateSessionHeader()
|
|
|
|
}
|
2019-08-19 20:05:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-12-02 01:53:55 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun deleteMultipleSelectionTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
|
|
|
val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
|
|
|
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openHomeScreen {}
|
|
|
|
|
|
|
|
navigationToolbar {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.enterURLAndEnterToBrowser(secondWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
longTapSelectItem(firstWebPage.url)
|
|
|
|
longTapSelectItem(secondWebPage.url)
|
2019-12-02 01:53:55 +01:00
|
|
|
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
|
2019-10-29 10:36:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
multipleSelectionToolbar {
|
2019-12-03 11:44:54 +01:00
|
|
|
clickMultiSelectionDelete()
|
|
|
|
}
|
|
|
|
|
|
|
|
historyMenu {
|
2019-10-29 10:36:19 +01:00
|
|
|
verifyEmptyHistoryView()
|
|
|
|
}
|
2019-08-19 20:05:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-11-05 17:53:07 +01:00
|
|
|
@Ignore("Temp disable flakey test - see: https://github.com/mozilla-mobile/fenix/issues/5462")
|
2019-10-29 10:36:19 +01:00
|
|
|
fun shareButtonTest() {
|
|
|
|
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
2019-08-19 20:05:10 +02:00
|
|
|
|
|
|
|
navigationToolbar {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.enterURLAndEnterToBrowser(firstWebPage.url) {
|
|
|
|
}.openThreeDotMenu {
|
2019-11-19 10:29:35 +01:00
|
|
|
}.openLibrary {
|
2019-10-29 10:36:19 +01:00
|
|
|
}.openHistory {
|
|
|
|
longTapSelectItem(firstWebPage.url)
|
|
|
|
}
|
|
|
|
|
|
|
|
multipleSelectionToolbar {
|
2019-12-03 11:44:54 +01:00
|
|
|
clickShareHistoryButton()
|
2019-10-29 10:36:19 +01:00
|
|
|
verifyShareOverlay()
|
|
|
|
verifyShareTabFavicon()
|
|
|
|
verifyShareTabTitle()
|
|
|
|
verifyShareTabUrl()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun verifyBackNavigation() {
|
|
|
|
homeScreen {
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
}.openHistory {
|
|
|
|
}.goBack {
|
2019-10-29 14:36:37 +01:00
|
|
|
verifyHomeScreen()
|
2019-10-29 10:36:19 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-19 20:05:10 +02:00
|
|
|
}
|