|
|
|
@ -43,168 +43,9 @@ class SettingsSubMenuHomepageRobot {
|
|
|
|
|
pocketSwitchEnabled: Boolean = true,
|
|
|
|
|
sponsoredStoriesCheckBox: Boolean = true,
|
|
|
|
|
) {
|
|
|
|
|
assertShortcutsButton()
|
|
|
|
|
assertShortcutsSwitchState(shortcutsSwitchEnabled)
|
|
|
|
|
assertSponsoredShortcutsButton()
|
|
|
|
|
assertSponsoredShortcutsCheckBox(sponsoredShortcutsCheckBox)
|
|
|
|
|
assertJumpBackInButton()
|
|
|
|
|
assertJumpBackInSwitchState(jumpBackInSwitchEnabled)
|
|
|
|
|
assertRecentBookmarksButton()
|
|
|
|
|
assertRecentBookmarksSwitchState(recentBookmarksSwitchEnabled)
|
|
|
|
|
assertRecentlyVisitedButton()
|
|
|
|
|
assertRecentlyVisitedSwitchState(recentlyVisitedSwitchEnabled)
|
|
|
|
|
assertPocketButton()
|
|
|
|
|
assertPocketSwitchState(pocketSwitchEnabled)
|
|
|
|
|
assertSponsoredStoriesButton()
|
|
|
|
|
assertSponsoredStoriesCheckBox(sponsoredStoriesCheckBox)
|
|
|
|
|
assertOpeningScreenHeading()
|
|
|
|
|
assertHomepageButton()
|
|
|
|
|
assertLastTabButton()
|
|
|
|
|
assertHomepageAfterFourHoursButton()
|
|
|
|
|
Log.i(Constants.TAG, "verifyHomePageView: Verified the home page elements")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySelectedOpeningScreenOption(openingScreenOption: String) =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.radio_button),
|
|
|
|
|
hasSibling(withText(openingScreenOption)),
|
|
|
|
|
),
|
|
|
|
|
).check(matches(isChecked(true)))
|
|
|
|
|
|
|
|
|
|
fun clickShortcutsButton() = shortcutsButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickSponsoredShortcuts() = sponsoredShortcutsButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickJumpBackInButton() = jumpBackInButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentlyVisited() = recentlyVisitedButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentBookmarksButton() = recentBookmarksButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentSearchesButton() = recentlyVisitedButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickPocketButton() = pocketButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickOpeningScreenOption(openingScreenOption: String) {
|
|
|
|
|
when (openingScreenOption) {
|
|
|
|
|
"Homepage" -> homepageButton().click()
|
|
|
|
|
"Last tab" -> lastTabButton().click()
|
|
|
|
|
"Homepage after four hours of inactivity" -> homepageAfterFourHoursButton().click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun openWallpapersMenu() = wallpapersMenuButton.click()
|
|
|
|
|
|
|
|
|
|
fun selectWallpaper(wallpaperName: String) =
|
|
|
|
|
mDevice.findObject(UiSelector().description(wallpaperName)).click()
|
|
|
|
|
|
|
|
|
|
fun verifySponsoredShortcutsCheckBox(checked: Boolean) = assertSponsoredShortcutsCheckBox(checked)
|
|
|
|
|
|
|
|
|
|
class Transition {
|
|
|
|
|
|
|
|
|
|
fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
|
|
|
|
goBackButton().click()
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
|
|
|
|
goBackButton().click()
|
|
|
|
|
|
|
|
|
|
SettingsRobot().interact()
|
|
|
|
|
return SettingsRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickSnackBarViewButton(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
|
|
|
|
val snackBarButton = mDevice.findObject(UiSelector().text("VIEW"))
|
|
|
|
|
snackBarButton.waitForExists(waitingTimeShort)
|
|
|
|
|
snackBarButton.click()
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun shortcutsButton() =
|
|
|
|
|
onView(allOf(withText(R.string.top_sites_toggle_top_recent_sites_4)))
|
|
|
|
|
|
|
|
|
|
private fun sponsoredShortcutsButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_contile)))
|
|
|
|
|
|
|
|
|
|
private fun jumpBackInButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_jump_back_in)))
|
|
|
|
|
|
|
|
|
|
private fun recentBookmarksButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_recent_bookmarks)))
|
|
|
|
|
|
|
|
|
|
private fun recentlyVisitedButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_recently_visited)))
|
|
|
|
|
|
|
|
|
|
private fun pocketButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_pocket_2)))
|
|
|
|
|
|
|
|
|
|
private fun sponsoredStoriesButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_pocket_sponsored)))
|
|
|
|
|
|
|
|
|
|
private fun openingScreenHeading() = onView(withText(R.string.preferences_opening_screen))
|
|
|
|
|
|
|
|
|
|
private fun homepageButton() =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.title),
|
|
|
|
|
withText(R.string.opening_screen_homepage),
|
|
|
|
|
hasSibling(withId(R.id.radio_button)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun lastTabButton() =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.title),
|
|
|
|
|
withText(R.string.opening_screen_last_tab),
|
|
|
|
|
hasSibling(withId(R.id.radio_button)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun homepageAfterFourHoursButton() =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.title),
|
|
|
|
|
withText(R.string.opening_screen_after_four_hours_of_inactivity),
|
|
|
|
|
hasSibling(withId(R.id.radio_button)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun goBackButton() = onView(allOf(withContentDescription(R.string.action_bar_up_description)))
|
|
|
|
|
|
|
|
|
|
private fun assertShortcutsButton() =
|
|
|
|
|
shortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertSponsoredShortcutsButton() =
|
|
|
|
|
sponsoredShortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertJumpBackInButton() =
|
|
|
|
|
jumpBackInButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertRecentBookmarksButton() =
|
|
|
|
|
recentBookmarksButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertRecentlyVisitedButton() =
|
|
|
|
|
recentlyVisitedButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertPocketButton() =
|
|
|
|
|
pocketButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertSponsoredStoriesButton() =
|
|
|
|
|
sponsoredStoriesButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertOpeningScreenHeading() =
|
|
|
|
|
openingScreenHeading().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertHomepageButton() =
|
|
|
|
|
homepageButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertLastTabButton() =
|
|
|
|
|
lastTabButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun assertHomepageAfterFourHoursButton() =
|
|
|
|
|
homepageAfterFourHoursButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
fun assertShortcutsSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
if (shortcutsSwitchEnabled) {
|
|
|
|
|
shortcutsButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -229,10 +70,10 @@ fun assertShortcutsSwitchState(enabled: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertSponsoredShortcutsCheckBox(checked: Boolean) {
|
|
|
|
|
if (checked) {
|
|
|
|
|
sponsoredShortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
if (sponsoredShortcutsCheckBox) {
|
|
|
|
|
sponsoredShortcutsButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -261,10 +102,10 @@ fun assertSponsoredShortcutsCheckBox(checked: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertJumpBackInSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
jumpBackInButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
if (jumpBackInSwitchEnabled) {
|
|
|
|
|
jumpBackInButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -289,10 +130,10 @@ fun assertJumpBackInSwitchState(enabled: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertRecentBookmarksSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
recentBookmarksButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
if (recentBookmarksSwitchEnabled) {
|
|
|
|
|
recentBookmarksButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -317,10 +158,10 @@ fun assertRecentBookmarksSwitchState(enabled: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertRecentlyVisitedSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
recentlyVisitedButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
if (recentlyVisitedSwitchEnabled) {
|
|
|
|
|
recentlyVisitedButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -345,10 +186,10 @@ fun assertRecentlyVisitedSwitchState(enabled: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertPocketSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
pocketButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
if (pocketSwitchEnabled) {
|
|
|
|
|
pocketButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -373,10 +214,10 @@ fun assertPocketSwitchState(enabled: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertSponsoredStoriesCheckBox(checked: Boolean) {
|
|
|
|
|
if (checked) {
|
|
|
|
|
sponsoredStoriesButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
if (sponsoredStoriesCheckBox) {
|
|
|
|
|
sponsoredStoriesButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -405,6 +246,162 @@ fun assertSponsoredStoriesCheckBox(checked: Boolean) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openingScreenHeading().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
homepageButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
lastTabButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
homepageAfterFourHoursButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
Log.i(Constants.TAG, "verifyHomePageView: Verified the home page elements")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySelectedOpeningScreenOption(openingScreenOption: String) =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.radio_button),
|
|
|
|
|
hasSibling(withText(openingScreenOption)),
|
|
|
|
|
),
|
|
|
|
|
).check(matches(isChecked(true)))
|
|
|
|
|
|
|
|
|
|
fun clickShortcutsButton() = shortcutsButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickSponsoredShortcuts() = sponsoredShortcutsButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickJumpBackInButton() = jumpBackInButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentlyVisited() = recentlyVisitedButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentBookmarksButton() = recentBookmarksButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentSearchesButton() = recentlyVisitedButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickPocketButton() = pocketButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickOpeningScreenOption(openingScreenOption: String) {
|
|
|
|
|
when (openingScreenOption) {
|
|
|
|
|
"Homepage" -> homepageButton().click()
|
|
|
|
|
"Last tab" -> lastTabButton().click()
|
|
|
|
|
"Homepage after four hours of inactivity" -> homepageAfterFourHoursButton().click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun openWallpapersMenu() = wallpapersMenuButton().click()
|
|
|
|
|
|
|
|
|
|
fun selectWallpaper(wallpaperName: String) =
|
|
|
|
|
mDevice.findObject(UiSelector().description(wallpaperName)).click()
|
|
|
|
|
|
|
|
|
|
fun verifySponsoredShortcutsCheckBox(checked: Boolean) {
|
|
|
|
|
if (checked) {
|
|
|
|
|
sponsoredShortcutsButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
hasSibling(
|
|
|
|
|
ViewMatchers.withChild(
|
|
|
|
|
allOf(
|
|
|
|
|
withClassName(CoreMatchers.endsWith("CheckBox")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
sponsoredShortcutsButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
hasSibling(
|
|
|
|
|
ViewMatchers.withChild(
|
|
|
|
|
allOf(
|
|
|
|
|
withClassName(CoreMatchers.endsWith("CheckBox")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Transition {
|
|
|
|
|
|
|
|
|
|
fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
|
|
|
|
goBackButton().click()
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
|
|
|
|
goBackButton().click()
|
|
|
|
|
|
|
|
|
|
SettingsRobot().interact()
|
|
|
|
|
return SettingsRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickSnackBarViewButton(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
|
|
|
|
val snackBarButton = mDevice.findObject(UiSelector().text("VIEW"))
|
|
|
|
|
snackBarButton.waitForExists(waitingTimeShort)
|
|
|
|
|
snackBarButton.click()
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun shortcutsButton() =
|
|
|
|
|
onView(allOf(withText(R.string.top_sites_toggle_top_recent_sites_4)))
|
|
|
|
|
|
|
|
|
|
private fun sponsoredShortcutsButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_contile)))
|
|
|
|
|
|
|
|
|
|
private fun jumpBackInButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_jump_back_in)))
|
|
|
|
|
|
|
|
|
|
private fun recentBookmarksButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_recent_bookmarks)))
|
|
|
|
|
|
|
|
|
|
private fun recentlyVisitedButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_recently_visited)))
|
|
|
|
|
|
|
|
|
|
private fun pocketButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_pocket_2)))
|
|
|
|
|
|
|
|
|
|
private fun sponsoredStoriesButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_pocket_sponsored)))
|
|
|
|
|
|
|
|
|
|
private fun openingScreenHeading() = onView(withText(R.string.preferences_opening_screen))
|
|
|
|
|
|
|
|
|
|
private fun homepageButton() =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.title),
|
|
|
|
|
withText(R.string.opening_screen_homepage),
|
|
|
|
|
hasSibling(withId(R.id.radio_button)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun lastTabButton() =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.title),
|
|
|
|
|
withText(R.string.opening_screen_last_tab),
|
|
|
|
|
hasSibling(withId(R.id.radio_button)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun homepageAfterFourHoursButton() =
|
|
|
|
|
onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withId(R.id.title),
|
|
|
|
|
withText(R.string.opening_screen_after_four_hours_of_inactivity),
|
|
|
|
|
hasSibling(withId(R.id.radio_button)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun goBackButton() = onView(allOf(withContentDescription(R.string.action_bar_up_description)))
|
|
|
|
|
|
|
|
|
|
private val wallpapersMenuButton = onView(withText("Wallpapers"))
|
|
|
|
|
private fun wallpapersMenuButton() = onView(withText("Wallpapers"))
|
|
|
|
|