Bug 1879072 - Remove redundant assertion functions from HomeScreenRobot

fenix/124.1.0
AndiAJ 4 months ago committed by mergify[bot]
parent da540d7578
commit e36e0e2313

@ -104,14 +104,27 @@ class HomeScreenRobot {
fun verifyHomePrivateBrowsingButton() = assertUIObjectExists(privateBrowsingButton()) fun verifyHomePrivateBrowsingButton() = assertUIObjectExists(privateBrowsingButton())
fun verifyHomeMenuButton() = assertUIObjectExists(menuButton) fun verifyHomeMenuButton() = assertUIObjectExists(menuButton)
fun verifyTabButton() = assertTabButton() fun verifyTabButton() =
fun verifyCollectionsHeader() = assertCollectionsHeader() onView(allOf(withId(R.id.tab_button), isDisplayed())).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyNoCollectionsText() = assertNoCollectionsText() fun verifyCollectionsHeader() =
onView(allOf(withText("Collections"))).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyNoCollectionsText() =
onView(
withText(
containsString(
"Collect the things that matter to you.\n" +
"Group together similar searches, sites, and tabs for quick access later.",
),
),
).check(matches(isDisplayed()))
fun verifyHomeWordmark() { fun verifyHomeWordmark() {
homeScreenList().scrollToBeginning(3) homeScreenList().scrollToBeginning(3)
assertUIObjectExists(homepageWordmark()) assertUIObjectExists(homepageWordmark())
} }
fun verifyHomeComponent() = assertHomeComponent() fun verifyHomeComponent() =
onView(ViewMatchers.withResourceName("sessionControlRecyclerView"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyTabCounter(numberOfOpenTabs: String) = fun verifyTabCounter(numberOfOpenTabs: String) =
assertUIObjectExists(tabCounter(numberOfOpenTabs)) assertUIObjectExists(tabCounter(numberOfOpenTabs))
@ -218,7 +231,16 @@ class HomeScreenRobot {
fun verifyExistingTopSitesList() = fun verifyExistingTopSitesList() =
assertUIObjectExists(itemWithResId("$packageName:id/top_sites_list")) assertUIObjectExists(itemWithResId("$packageName:id/top_sites_list"))
fun verifyNotExistingTopSitesList(title: String) = assertNotExistingTopSitesList(title) fun verifyNotExistingTopSitesList(title: String) {
mDevice.findObject(UiSelector().text(title)).waitUntilGone(waitingTime)
assertUIObjectExists(
itemWithResIdContainingText(
"$packageName:id/top_site_title",
title,
),
exists = false,
)
}
fun verifySponsoredShortcutDoesNotExist(sponsoredShortcutTitle: String, position: Int) = fun verifySponsoredShortcutDoesNotExist(sponsoredShortcutTitle: String, position: Int) =
assertUIObjectExists( assertUIObjectExists(
itemWithResIdAndIndex("$packageName:id/top_site_item", index = position - 1) itemWithResIdAndIndex("$packageName:id/top_site_item", index = position - 1)
@ -228,17 +250,60 @@ class HomeScreenRobot {
), ),
exists = false, exists = false,
) )
fun verifyNotExistingSponsoredTopSitesList() = assertSponsoredTopSitesNotDisplayed() fun verifyNotExistingSponsoredTopSitesList() =
assertUIObjectExists(
itemWithResIdContainingText(
"$packageName:id/top_site_subtitle",
getStringResource(R.string.top_sites_sponsored_label),
),
exists = false,
)
fun verifyExistingTopSitesTabs(title: String) { fun verifyExistingTopSitesTabs(title: String) {
homeScreenList().scrollIntoView(itemWithResId("$packageName:id/top_sites_list")) homeScreenList().scrollIntoView(itemWithResId("$packageName:id/top_sites_list"))
assertExistingTopSitesTabs(title) 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)))
} }
fun verifySponsoredShortcutDetails(sponsoredShortcutTitle: String, position: Int) { fun verifySponsoredShortcutDetails(sponsoredShortcutTitle: String, position: Int) {
assertSponsoredShortcutLogoIsDisplayed(position) assertUIObjectExists(
assertSponsoredShortcutTitle(sponsoredShortcutTitle, position) itemWithResIdAndIndex(resourceId = "$packageName:id/top_site_item", index = position - 1)
assertSponsoredSubtitleIsDisplayed(position) .getChild(
UiSelector()
.resourceId("$packageName:id/favicon_card"),
),
)
assertUIObjectExists(
itemWithResIdAndIndex(resourceId = "$packageName:id/top_site_item", index = position - 1)
.getChild(
UiSelector()
.textContains(sponsoredShortcutTitle),
),
)
assertUIObjectExists(
itemWithResIdAndIndex(resourceId = "$packageName:id/top_site_item", index = position - 1)
.getChild(
UiSelector()
.resourceId("$packageName:id/top_site_subtitle"),
),
)
}
fun verifyTopSiteContextMenuItems() {
mDevice.waitNotNull(
findObject(By.text("Open in private tab")),
waitingTime,
)
mDevice.waitNotNull(
findObject(By.text("Remove")),
waitingTime,
)
} }
fun verifyTopSiteContextMenuItems() = assertTopSiteContextMenuItems()
fun verifyJumpBackInSectionIsDisplayed() { fun verifyJumpBackInSectionIsDisplayed() {
scrollToElementByText(getStringResource(R.string.recent_tabs_header)) scrollToElementByText(getStringResource(R.string.recent_tabs_header))
@ -247,13 +312,16 @@ class HomeScreenRobot {
fun verifyJumpBackInSectionIsNotDisplayed() = fun verifyJumpBackInSectionIsNotDisplayed() =
assertUIObjectExists(itemContainingText(getStringResource(R.string.recent_tabs_header)), exists = false) assertUIObjectExists(itemContainingText(getStringResource(R.string.recent_tabs_header)), exists = false)
fun verifyJumpBackInItemTitle(testRule: ComposeTestRule, itemTitle: String) = fun verifyJumpBackInItemTitle(testRule: ComposeTestRule, itemTitle: String) =
assertJumpBackInItemTitle(testRule, itemTitle) testRule.onNodeWithTag("recent.tab.title", useUnmergedTree = true).assert(hasText(itemTitle))
fun verifyJumpBackInItemWithUrl(testRule: ComposeTestRule, itemUrl: String) = fun verifyJumpBackInItemWithUrl(testRule: ComposeTestRule, itemUrl: String) =
assertJumpBackInItemWithUrl(testRule, itemUrl) testRule.onNodeWithTag("recent.tab.url", useUnmergedTree = true).assert(hasText(itemUrl))
fun verifyJumpBackInShowAllButton() = assertJumpBackInShowAllButton() fun verifyJumpBackInShowAllButton() = assertUIObjectExists(itemContainingText(getStringResource(R.string.recent_tabs_show_all)))
fun verifyRecentlyVisitedSectionIsDisplayed(exists: Boolean) = assertRecentlyVisitedSectionIsDisplayed(exists) fun verifyRecentlyVisitedSectionIsDisplayed(exists: Boolean) =
fun verifyRecentBookmarksSectionIsDisplayed(exists: Boolean) = assertRecentBookmarksSectionIsDisplayed(exists) assertUIObjectExists(itemContainingText(getStringResource(R.string.history_metadata_header_2)), exists = exists)
fun verifyPocketSectionIsDisplayed(exists: Boolean) = assertPocketSectionIsDisplayed(exists) fun verifyRecentBookmarksSectionIsDisplayed(exists: Boolean) =
assertUIObjectExists(itemContainingText(getStringResource(R.string.recently_saved_title)), exists = exists)
fun verifyPocketSectionIsDisplayed(exists: Boolean) =
assertUIObjectExists(itemContainingText(getStringResource(R.string.pocket_stories_header_1)), exists = exists)
fun verifyRecentlyVisitedSearchGroupDisplayed(shouldBeDisplayed: Boolean, searchTerm: String, groupSize: Int) { fun verifyRecentlyVisitedSearchGroupDisplayed(shouldBeDisplayed: Boolean, searchTerm: String, groupSize: Int) {
// checks if the search group exists in the Recently visited section // checks if the search group exists in the Recently visited section
@ -820,118 +888,8 @@ private fun assertKeyboardVisibility(isExpectedToBeVisible: Boolean) =
.contains("mInputShown=true"), .contains("mInputShown=true"),
) )
private fun assertTabButton() =
onView(allOf(withId(R.id.tab_button), isDisplayed()))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertCollectionsHeader() =
onView(allOf(withText("Collections")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertNoCollectionsText() =
onView(
withText(
containsString(
"Collect the things that matter to you.\n" +
"Group together similar searches, sites, and tabs for quick access later.",
),
),
).check(matches(isDisplayed()))
private fun assertHomeComponent() =
onView(ViewMatchers.withResourceName("sessionControlRecyclerView"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun threeDotButton() = onView(allOf(withId(R.id.menuButton))) private fun threeDotButton() = onView(allOf(withId(R.id.menuButton)))
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 assertSponsoredShortcutLogoIsDisplayed(position: Int) =
assertUIObjectExists(
itemWithResIdAndIndex(resourceId = "$packageName:id/top_site_item", index = position - 1)
.getChild(
UiSelector()
.resourceId("$packageName:id/favicon_card"),
),
)
private fun assertSponsoredSubtitleIsDisplayed(position: Int) =
assertUIObjectExists(
itemWithResIdAndIndex(resourceId = "$packageName:id/top_site_item", index = position - 1)
.getChild(
UiSelector()
.resourceId("$packageName:id/top_site_subtitle"),
),
)
private fun assertSponsoredShortcutTitle(sponsoredShortcutTitle: String, position: Int) =
assertUIObjectExists(
itemWithResIdAndIndex(resourceId = "$packageName:id/top_site_item", index = position - 1)
.getChild(
UiSelector()
.textContains(sponsoredShortcutTitle),
),
)
private fun assertNotExistingTopSitesList(title: String) {
mDevice.findObject(UiSelector().text(title)).waitUntilGone(waitingTime)
assertUIObjectExists(
itemWithResIdContainingText(
"$packageName:id/top_site_title",
title,
),
exists = false,
)
}
private fun assertSponsoredTopSitesNotDisplayed() =
assertUIObjectExists(
itemWithResIdContainingText(
"$packageName:id/top_site_subtitle",
getStringResource(R.string.top_sites_sponsored_label),
),
exists = false,
)
private fun assertTopSiteContextMenuItems() {
mDevice.waitNotNull(
findObject(By.text("Open in private tab")),
waitingTime,
)
mDevice.waitNotNull(
findObject(By.text("Remove")),
waitingTime,
)
}
private fun assertJumpBackInItemTitle(testRule: ComposeTestRule, itemTitle: String) =
testRule.onNodeWithTag("recent.tab.title", useUnmergedTree = true).assert(hasText(itemTitle))
private fun assertJumpBackInItemWithUrl(testRule: ComposeTestRule, itemUrl: String) =
testRule.onNodeWithTag("recent.tab.url", useUnmergedTree = true).assert(hasText(itemUrl))
private fun assertJumpBackInShowAllButton() =
assertUIObjectExists(itemContainingText(getStringResource(R.string.recent_tabs_show_all)))
private fun assertRecentlyVisitedSectionIsDisplayed(exists: Boolean) =
assertUIObjectExists(itemContainingText(getStringResource(R.string.history_metadata_header_2)), exists = exists)
private fun assertRecentBookmarksSectionIsDisplayed(exists: Boolean) =
assertUIObjectExists(itemContainingText(getStringResource(R.string.recently_saved_title)), exists = exists)
private fun assertPocketSectionIsDisplayed(exists: Boolean) =
assertUIObjectExists(itemContainingText(getStringResource(R.string.pocket_stories_header_1)), exists = exists)
private fun saveTabsToCollectionButton() = onView(withId(R.id.add_tabs_to_collections_button)) private fun saveTabsToCollectionButton() = onView(withId(R.id.add_tabs_to_collections_button))
private fun tabsCounter() = onView(withId(R.id.tab_button)) private fun tabsCounter() = onView(withId(R.id.tab_button))

Loading…
Cancel
Save