mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Add and remove most visited top sites UI test
This commit is contained in:
parent
1441115c0c
commit
12a861dc47
@ -11,10 +11,12 @@ import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.FeatureSettingsHelper
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.ui.robots.browserScreen
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
|
||||
@ -183,4 +185,29 @@ class TopSitesTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun addAndRemoveMostViewedTopSiteTest() {
|
||||
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
||||
for (i in 0..1) {
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
mDevice.waitForIdle()
|
||||
waitForPageToLoad()
|
||||
}
|
||||
}
|
||||
|
||||
browserScreen {
|
||||
}.goToHomescreen {
|
||||
verifyExistingTopSitesList()
|
||||
verifyExistingTopSitesTabs(defaultWebPage.title)
|
||||
}.openContextMenuOnTopSitesWithTitle(defaultWebPage.title) {
|
||||
}.deleteTopSiteFromHistory {
|
||||
}.openThreeDotMenu {
|
||||
}.openHistory {
|
||||
verifyEmptyHistoryView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem
|
||||
import androidx.test.espresso.matcher.RootMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
@ -297,6 +298,16 @@ class HomeScreenRobot {
|
||||
return Transition()
|
||||
}
|
||||
|
||||
fun deleteTopSiteFromHistory(interact: HomeScreenRobot.() -> Unit): Transition {
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("$packageName:id/simple_text")
|
||||
).waitForExists(waitingTime)
|
||||
deleteFromHistory.click()
|
||||
|
||||
HomeScreenRobot().interact()
|
||||
return Transition()
|
||||
}
|
||||
|
||||
fun openTopSiteInPrivateTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
onView(withText("Open in private tab"))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
@ -561,10 +572,17 @@ private fun assertExistingTopSitesList() =
|
||||
onView(allOf(withId(R.id.top_sites_list)))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
|
||||
private fun assertExistingTopSitesTabs(title: String) =
|
||||
private fun assertExistingTopSitesTabs(title: String) {
|
||||
mDevice.findObject(
|
||||
UiSelector()
|
||||
.resourceId("$packageName:id/top_site_title")
|
||||
.textContains(title)
|
||||
).waitForExists(waitingTime)
|
||||
|
||||
onView(allOf(withId(R.id.top_sites_list)))
|
||||
.check(matches(hasDescendant(withText(title))))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertNotExistingTopSitesList(title: String) =
|
||||
onView(allOf(withId(R.id.top_sites_list)))
|
||||
@ -623,3 +641,11 @@ private fun startBrowsingButton(): UiObject {
|
||||
.ensureFullyVisible(startBrowsingButton)
|
||||
return startBrowsingButton
|
||||
}
|
||||
|
||||
val deleteFromHistory =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.simple_text),
|
||||
withText(R.string.delete_from_history)
|
||||
)
|
||||
).inRoot(RootMatchers.isPlatformPopup())
|
||||
|
Loading…
Reference in New Issue
Block a user