2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] Refactor recently closed tabs UI smoke tests

This commit is contained in:
AndiAJ 2021-11-25 16:28:19 +02:00 committed by mergify[bot]
parent c9a18b8b03
commit 5959b0a309
2 changed files with 17 additions and 24 deletions

View File

@ -681,8 +681,8 @@ class SmokeTest {
} }
@Test @Test
// Verifies the Open in a new tab option from the Recently Closed Tabs overflow menu // Verifies that a recently closed item is properly opened
fun openRecentlyClosedTabsInNewTabTest() { fun openRecentlyClosedItemTest() {
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1) val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)
homeScreen { homeScreen {
@ -699,15 +699,13 @@ class SmokeTest {
IdlingRegistry.getInstance().register(recentlyClosedTabsListIdlingResource!!) IdlingRegistry.getInstance().register(recentlyClosedTabsListIdlingResource!!)
verifyRecentlyClosedTabsMenuView() verifyRecentlyClosedTabsMenuView()
IdlingRegistry.getInstance().unregister(recentlyClosedTabsListIdlingResource!!) IdlingRegistry.getInstance().unregister(recentlyClosedTabsListIdlingResource!!)
}.clickOpenInNewTab { }.clickRecentlyClosedItem("Test_Page_1") {
verifyUrl(website.url.toString()) verifyUrl(website.url.toString())
}.openTabDrawer {
verifyNormalModeSelected()
} }
} }
@Test @Test
// Verifies the delete button from the Recently Closed Tabs // Verifies that tapping the "x" button removes a recently closed item from the list
fun deleteRecentlyClosedTabsItemTest() { fun deleteRecentlyClosedTabsItemTest() {
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1) val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)

View File

@ -7,7 +7,6 @@ package org.mozilla.fenix.ui.robots
import android.net.Uri import android.net.Uri
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
@ -44,8 +43,9 @@ class RecentlyClosedTabsRobot {
fun clickDeleteRecentlyClosedTabs() = recentlyClosedTabsDeleteButton().click() fun clickDeleteRecentlyClosedTabs() = recentlyClosedTabsDeleteButton().click()
class Transition { class Transition {
fun clickOpenInNewTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickRecentlyClosedItem(title: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
recentlyClosedTabsPageTitle().click() recentlyClosedTabsPageTitle(title).click()
mDevice.waitForIdle()
BrowserRobot().interact() BrowserRobot().interact()
return BrowserRobot.Transition() return BrowserRobot.Transition()
@ -65,16 +65,16 @@ private fun assertRecentlyClosedTabsMenuView() {
) )
} }
private fun assertEmptyRecentlyClosedTabsList() = private fun assertEmptyRecentlyClosedTabsList() {
mDevice.waitForIdle()
onView( onView(
allOf( allOf(
withId(R.id.recently_closed_empty_view), withId(R.id.recently_closed_empty_view),
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE) withText(R.string.recently_closed_empty_message)
)
)
.check(
matches(withText("No recently closed tabs here"))
) )
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertPageUrl(expectedUrl: Uri) = onView( private fun assertPageUrl(expectedUrl: Uri) = onView(
allOf( allOf(
@ -88,21 +88,16 @@ private fun assertPageUrl(expectedUrl: Uri) = onView(
matches(withText(Matchers.containsString(expectedUrl.toString()))) matches(withText(Matchers.containsString(expectedUrl.toString())))
) )
private fun recentlyClosedTabsPageTitle() = onView( private fun recentlyClosedTabsPageTitle(title: String) = onView(
allOf( allOf(
withId(R.id.title), withId(R.id.title),
withText("Test_Page_1") withText(title)
) )
) )
private fun assertRecentlyClosedTabsPageTitle(title: String) { private fun assertRecentlyClosedTabsPageTitle(title: String) {
recentlyClosedTabsPageTitle() recentlyClosedTabsPageTitle(title)
.check( .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
matches(withEffectiveVisibility(Visibility.VISIBLE))
)
.check(
matches(withText(title))
)
} }
private fun recentlyClosedTabsDeleteButton() = private fun recentlyClosedTabsDeleteButton() =