|
|
|
@ -6,22 +6,24 @@ package org.mozilla.fenix.ui.robots
|
|
|
|
|
|
|
|
|
|
import androidx.test.espresso.Espresso.onView
|
|
|
|
|
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.hasSibling
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withClassName
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
|
|
|
|
import org.hamcrest.CoreMatchers
|
|
|
|
|
import org.hamcrest.CoreMatchers.allOf
|
|
|
|
|
import org.hamcrest.CoreMatchers.endsWith
|
|
|
|
|
import org.hamcrest.Matchers
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
|
|
|
|
import org.mozilla.fenix.helpers.click
|
|
|
|
|
|
|
|
|
@ -30,25 +32,46 @@ import org.mozilla.fenix.helpers.click
|
|
|
|
|
*/
|
|
|
|
|
class SettingsSubMenuHomepageRobot {
|
|
|
|
|
|
|
|
|
|
fun verifyHomePageView() {
|
|
|
|
|
assertMostVisitedTopSitesButton()
|
|
|
|
|
fun verifyHomePageView(
|
|
|
|
|
shortcutsSwitchEnabled: Boolean = true,
|
|
|
|
|
sponsoredShortcutsCheckBox: Boolean = true,
|
|
|
|
|
jumpBackInSwitchEnabled: Boolean = true,
|
|
|
|
|
recentBookmarksSwitchEnabled: Boolean = true,
|
|
|
|
|
recentlyVisitedSwitchEnabled: Boolean = true,
|
|
|
|
|
pocketSwitchEnabled: Boolean = true,
|
|
|
|
|
sponsoredStoriesCheckBox: Boolean = true,
|
|
|
|
|
) {
|
|
|
|
|
assertShortcutsButton()
|
|
|
|
|
assertShortcutsSwitchState(shortcutsSwitchEnabled)
|
|
|
|
|
assertSponsoredShortcutsButton()
|
|
|
|
|
assertSponsoredShortcutsCheckBox(sponsoredShortcutsCheckBox)
|
|
|
|
|
assertJumpBackInButton()
|
|
|
|
|
assertJumpBackInSwitchState(jumpBackInSwitchEnabled)
|
|
|
|
|
assertRecentBookmarksButton()
|
|
|
|
|
assertRecentSearchesButton()
|
|
|
|
|
assertRecentBookmarksSwitchState(recentBookmarksSwitchEnabled)
|
|
|
|
|
assertRecentlyVisitedButton()
|
|
|
|
|
assertRecentlyVisitedSwitchState(recentlyVisitedSwitchEnabled)
|
|
|
|
|
assertPocketButton()
|
|
|
|
|
assertPocketSwitchState(pocketSwitchEnabled)
|
|
|
|
|
assertSponsoredStoriesButton()
|
|
|
|
|
assertSponsoredStoriesCheckBox(sponsoredStoriesCheckBox)
|
|
|
|
|
assertOpeningScreenHeading()
|
|
|
|
|
assertHomepageButton()
|
|
|
|
|
assertLastTabButton()
|
|
|
|
|
assertHomepageAfterFourHoursButton()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickSponsoredShortcuts() = sponsoredShortcuts().click()
|
|
|
|
|
fun clickShortcutsButton() = shortcutsButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickSponsoredShortcuts() = sponsoredShortcutsButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickJumpBackInButton() = jumpBackInButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentlyVisited() = recentlyVisitedButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentBookmarksButton() = recentBookmarksButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickRecentSearchesButton() = recentSearchesButton().click()
|
|
|
|
|
fun clickRecentSearchesButton() = recentlyVisitedButton().click()
|
|
|
|
|
|
|
|
|
|
fun clickPocketButton() = pocketButton().click()
|
|
|
|
|
|
|
|
|
@ -69,37 +92,7 @@ class SettingsSubMenuHomepageRobot {
|
|
|
|
|
).waitForExists(waitingTimeShort),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fun verifySponsoredShortcutsCheckBox(checked: Boolean) {
|
|
|
|
|
if (checked) {
|
|
|
|
|
sponsoredShortcuts()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
hasSibling(
|
|
|
|
|
withChild(
|
|
|
|
|
allOf(
|
|
|
|
|
withClassName(endsWith("CheckBox")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
sponsoredShortcuts()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
hasSibling(
|
|
|
|
|
withChild(
|
|
|
|
|
allOf(
|
|
|
|
|
withClassName(endsWith("CheckBox")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fun verifySponsoredShortcutsCheckBox(checked: Boolean) = assertSponsoredShortcutsCheckBox(checked)
|
|
|
|
|
|
|
|
|
|
class Transition {
|
|
|
|
|
|
|
|
|
@ -121,10 +114,10 @@ class SettingsSubMenuHomepageRobot {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun mostVisitedTopSitesButton() =
|
|
|
|
|
private fun shortcutsButton() =
|
|
|
|
|
onView(allOf(withText(R.string.top_sites_toggle_top_recent_sites_4)))
|
|
|
|
|
|
|
|
|
|
private fun sponsoredShortcuts() =
|
|
|
|
|
private fun sponsoredShortcutsButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_contile)))
|
|
|
|
|
|
|
|
|
|
private fun jumpBackInButton() =
|
|
|
|
@ -133,12 +126,15 @@ private fun jumpBackInButton() =
|
|
|
|
|
private fun recentBookmarksButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_recent_bookmarks)))
|
|
|
|
|
|
|
|
|
|
private fun recentSearchesButton() =
|
|
|
|
|
private fun recentlyVisitedButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_recently_visited)))
|
|
|
|
|
|
|
|
|
|
private fun pocketButton() =
|
|
|
|
|
onView(allOf(withText(R.string.customize_toggle_pocket)))
|
|
|
|
|
|
|
|
|
|
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() =
|
|
|
|
@ -170,16 +166,20 @@ private fun homepageAfterFourHoursButton() =
|
|
|
|
|
|
|
|
|
|
private fun goBackButton() = onView(allOf(withContentDescription(R.string.action_bar_up_description)))
|
|
|
|
|
|
|
|
|
|
private fun assertMostVisitedTopSitesButton() =
|
|
|
|
|
mostVisitedTopSitesButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
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 assertRecentSearchesButton() =
|
|
|
|
|
recentSearchesButton().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() =
|
|
|
|
@ -189,4 +189,208 @@ private fun assertLastTabButton() =
|
|
|
|
|
private fun assertHomepageAfterFourHoursButton() =
|
|
|
|
|
homepageAfterFourHoursButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
|
|
fun assertShortcutsSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
shortcutsButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
shortcutsButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertSponsoredShortcutsCheckBox(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(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertJumpBackInSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
jumpBackInButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
jumpBackInButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertRecentBookmarksSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
recentBookmarksButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
recentBookmarksButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertRecentlyVisitedSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
recentlyVisitedButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
recentlyVisitedButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertPocketSwitchState(enabled: Boolean) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
pocketButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
pocketButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
TestHelper.hasCousin(
|
|
|
|
|
Matchers.allOf(
|
|
|
|
|
withClassName(Matchers.endsWith("Switch")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun assertSponsoredStoriesCheckBox(checked: Boolean) {
|
|
|
|
|
if (checked) {
|
|
|
|
|
sponsoredStoriesButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
hasSibling(
|
|
|
|
|
ViewMatchers.withChild(
|
|
|
|
|
allOf(
|
|
|
|
|
withClassName(CoreMatchers.endsWith("CheckBox")),
|
|
|
|
|
isChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
sponsoredStoriesButton()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
|
hasSibling(
|
|
|
|
|
ViewMatchers.withChild(
|
|
|
|
|
allOf(
|
|
|
|
|
withClassName(CoreMatchers.endsWith("CheckBox")),
|
|
|
|
|
isNotChecked(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val wallpapersMenuButton = onView(withText("Wallpapers"))
|
|
|
|
|