|
|
@ -9,18 +9,14 @@ import androidx.test.espresso.Espresso.onView
|
|
|
|
import androidx.test.espresso.action.ViewActions
|
|
|
|
import androidx.test.espresso.action.ViewActions
|
|
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
|
|
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
|
|
|
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.withText
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
|
|
|
import androidx.test.uiautomator.By
|
|
|
|
import androidx.test.uiautomator.By
|
|
|
|
import androidx.test.uiautomator.By.text
|
|
|
|
import androidx.test.uiautomator.By.text
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
|
|
|
import androidx.test.uiautomator.Until
|
|
|
|
import androidx.test.uiautomator.Until
|
|
|
|
import org.hamcrest.CoreMatchers
|
|
|
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
|
|
|
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
|
|
|
|
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
|
|
|
|
import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResId
|
|
|
|
import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResId
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
|
|
@ -35,17 +31,37 @@ import org.mozilla.fenix.helpers.isEnabled
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsSubMenuPrivateBrowsingRobot {
|
|
|
|
class SettingsSubMenuPrivateBrowsingRobot {
|
|
|
|
|
|
|
|
|
|
|
|
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
|
|
|
fun verifyOpenLinksInPrivateTab() {
|
|
|
|
|
|
|
|
openLinksInPrivateTabSwitch()
|
|
|
|
fun verifyOpenLinksInPrivateTab() = assertOpenLinksInPrivateTab()
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun verifyAddPrivateBrowsingShortcutButton() = assertAddPrivateBrowsingShortcutButton()
|
|
|
|
fun verifyAddPrivateBrowsingShortcutButton() {
|
|
|
|
|
|
|
|
mDevice.wait(
|
|
|
|
|
|
|
|
Until.findObject(text("Add private browsing shortcut")),
|
|
|
|
|
|
|
|
waitingTime,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
addPrivateBrowsingShortcutButton()
|
|
|
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun verifyOpenLinksInPrivateTabEnabled() = assertOpenLinksInPrivateTabEnabled()
|
|
|
|
fun verifyOpenLinksInPrivateTabEnabled() {
|
|
|
|
|
|
|
|
openLinksInPrivateTabSwitch().check(matches(isEnabled(true)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun verifyOpenLinksInPrivateTabOff() = assertOpenLinksInPrivateTabOff()
|
|
|
|
fun verifyOpenLinksInPrivateTabOff() {
|
|
|
|
|
|
|
|
assertUIObjectExists(
|
|
|
|
|
|
|
|
checkedItemWithResId("android:id/switch_widget", isChecked = true),
|
|
|
|
|
|
|
|
exists = false,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
openLinksInPrivateTabSwitch()
|
|
|
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun verifyPrivateBrowsingShortcutIcon() = assertPrivateBrowsingShortcutIcon()
|
|
|
|
fun verifyPrivateBrowsingShortcutIcon() {
|
|
|
|
|
|
|
|
mDevice.wait(Until.findObject(text("Private $appName")), waitingTime)
|
|
|
|
|
|
|
|
assertTrue(mDevice.hasObject(text("Private $appName")))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun clickPrivateModeScreenshotsSwitch() = screenshotsInPrivateModeSwitch().click()
|
|
|
|
fun clickPrivateModeScreenshotsSwitch() = screenshotsInPrivateModeSwitch().click()
|
|
|
|
|
|
|
|
|
|
|
@ -92,16 +108,6 @@ class SettingsSubMenuPrivateBrowsingRobot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun assertNavigationToolBarHeader() {
|
|
|
|
|
|
|
|
onView(
|
|
|
|
|
|
|
|
CoreMatchers.allOf(
|
|
|
|
|
|
|
|
withId(R.id.navigationToolbar),
|
|
|
|
|
|
|
|
withChild(withText(R.string.preferences_private_browsing_options)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun openLinksInPrivateTabSwitch() =
|
|
|
|
private fun openLinksInPrivateTabSwitch() =
|
|
|
|
onView(withText("Open links in a private tab"))
|
|
|
|
onView(withText("Open links in a private tab"))
|
|
|
|
|
|
|
|
|
|
|
@ -119,34 +125,3 @@ private fun cancelShortcutAdditionButton() =
|
|
|
|
mDevice.findObject(UiSelector().textContains("CANCEL"))
|
|
|
|
mDevice.findObject(UiSelector().textContains("CANCEL"))
|
|
|
|
|
|
|
|
|
|
|
|
private fun privateBrowsingShortcutIcon() = mDevice.findObject(text("Private $appName"))
|
|
|
|
private fun privateBrowsingShortcutIcon() = mDevice.findObject(text("Private $appName"))
|
|
|
|
|
|
|
|
|
|
|
|
private fun assertAddPrivateBrowsingShortcutButton() {
|
|
|
|
|
|
|
|
mDevice.wait(
|
|
|
|
|
|
|
|
Until.findObject(text("Add private browsing shortcut")),
|
|
|
|
|
|
|
|
waitingTime,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
addPrivateBrowsingShortcutButton()
|
|
|
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun assertOpenLinksInPrivateTab() {
|
|
|
|
|
|
|
|
openLinksInPrivateTabSwitch()
|
|
|
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun assertOpenLinksInPrivateTabEnabled() =
|
|
|
|
|
|
|
|
openLinksInPrivateTabSwitch().check(matches(isEnabled(true)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun assertOpenLinksInPrivateTabOff() {
|
|
|
|
|
|
|
|
assertUIObjectExists(
|
|
|
|
|
|
|
|
checkedItemWithResId("android:id/switch_widget", isChecked = true),
|
|
|
|
|
|
|
|
exists = false,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
openLinksInPrivateTabSwitch()
|
|
|
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun assertPrivateBrowsingShortcutIcon() {
|
|
|
|
|
|
|
|
mDevice.wait(Until.findObject(text("Private $appName")), waitingTime)
|
|
|
|
|
|
|
|
assertTrue(mDevice.hasObject(text("Private $appName")))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|