Bug 1882272 - Remove redundant assertion functions from SettingsSubMenuPrivateBrowsingRobot

fenix/125.0
AndiAJ 3 months ago committed by mergify[bot]
parent 5944b5b8bf
commit 39f1f91d93

@ -9,18 +9,14 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
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.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By
import androidx.test.uiautomator.By.text
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers
import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResId
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
@ -35,17 +31,37 @@ import org.mozilla.fenix.helpers.isEnabled
class SettingsSubMenuPrivateBrowsingRobot {
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
fun verifyOpenLinksInPrivateTab() = assertOpenLinksInPrivateTab()
fun verifyOpenLinksInPrivateTab() {
openLinksInPrivateTabSwitch()
.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()
@ -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() =
onView(withText("Open links in a private tab"))
@ -119,34 +125,3 @@ private fun cancelShortcutAdditionButton() =
mDevice.findObject(UiSelector().textContains("CANCEL"))
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")))
}

Loading…
Cancel
Save