Bug 1882272 - Add logs to SettingsSubMenuPrivateBrowsingRobot

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

@ -5,6 +5,7 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import android.os.Build import android.os.Build
import android.util.Log
import androidx.test.espresso.Espresso.onView 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
@ -17,6 +18,7 @@ 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.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.mozilla.fenix.helpers.Constants.TAG
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
@ -32,21 +34,29 @@ import org.mozilla.fenix.helpers.isEnabled
class SettingsSubMenuPrivateBrowsingRobot { class SettingsSubMenuPrivateBrowsingRobot {
fun verifyOpenLinksInPrivateTab() { fun verifyOpenLinksInPrivateTab() {
Log.i(TAG, "verifyOpenLinksInPrivateTab: Trying to verify that the \"Open links in a private tab\" option is visible")
openLinksInPrivateTabSwitch() openLinksInPrivateTabSwitch()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyOpenLinksInPrivateTab: Verified that the \"Open links in a private tab\" option is visible")
} }
fun verifyAddPrivateBrowsingShortcutButton() { fun verifyAddPrivateBrowsingShortcutButton() {
Log.i(TAG, "verifyAddPrivateBrowsingShortcutButton: Waiting for $waitingTime ms until finding the \"Add private browsing shortcut\" button")
mDevice.wait( mDevice.wait(
Until.findObject(text("Add private browsing shortcut")), Until.findObject(text("Add private browsing shortcut")),
waitingTime, waitingTime,
) )
Log.i(TAG, "verifyAddPrivateBrowsingShortcutButton: Waited for $waitingTime ms until the \"Add private browsing shortcut\" button was found")
Log.i(TAG, "verifyAddPrivateBrowsingShortcutButton: Trying to verify that the \"Add private browsing shortcut\" button is visible")
addPrivateBrowsingShortcutButton() addPrivateBrowsingShortcutButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAddPrivateBrowsingShortcutButton: Verified that the \"Add private browsing shortcut\" button is visible")
} }
fun verifyOpenLinksInPrivateTabEnabled() { fun verifyOpenLinksInPrivateTabEnabled() {
Log.i(TAG, "verifyOpenLinksInPrivateTabEnabled: Trying to verify that the \"Open links in a private tab\" toggle is enabled")
openLinksInPrivateTabSwitch().check(matches(isEnabled(true))) openLinksInPrivateTabSwitch().check(matches(isEnabled(true)))
Log.i(TAG, "verifyOpenLinksInPrivateTabEnabled: Verified that the \"Open links in a private tab\" toggle is enabled")
} }
fun verifyOpenLinksInPrivateTabOff() { fun verifyOpenLinksInPrivateTabOff() {
@ -54,53 +64,87 @@ class SettingsSubMenuPrivateBrowsingRobot {
checkedItemWithResId("android:id/switch_widget", isChecked = true), checkedItemWithResId("android:id/switch_widget", isChecked = true),
exists = false, exists = false,
) )
Log.i(TAG, "verifyOpenLinksInPrivateTabOff: Trying to verify that the \"Open links in a private tab\" toggle is visible")
openLinksInPrivateTabSwitch() openLinksInPrivateTabSwitch()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyOpenLinksInPrivateTabOff: Verified that the \"Open links in a private tab\" toggle is visible")
} }
fun verifyPrivateBrowsingShortcutIcon() { fun verifyPrivateBrowsingShortcutIcon() {
Log.i(TAG, "verifyPrivateBrowsingShortcutIcon: Waiting for $waitingTime ms until finding the \"Private $appName\" shortcut icon")
mDevice.wait(Until.findObject(text("Private $appName")), waitingTime) mDevice.wait(Until.findObject(text("Private $appName")), waitingTime)
assertTrue(mDevice.hasObject(text("Private $appName"))) Log.i(TAG, "verifyPrivateBrowsingShortcutIcon: Waited for $waitingTime ms until the \"Private $appName\" shortcut icon was found")
Log.i(TAG, "verifyPrivateBrowsingShortcutIcon: Trying to verify the \"Private $appName\" shortcut icon")
assertTrue("\"Private $appName\" shortcut icon wasn't verified", mDevice.hasObject(text("Private $appName")))
Log.i(TAG, "verifyPrivateBrowsingShortcutIcon: Verified the \"Private $appName\" shortcut icon")
} }
fun clickPrivateModeScreenshotsSwitch() = screenshotsInPrivateModeSwitch().click() fun clickPrivateModeScreenshotsSwitch() {
Log.i(TAG, "clickPrivateModeScreenshotsSwitch: Trying to click the \"Allow screenshots in private browsing\" toggle")
screenshotsInPrivateModeSwitch().click()
Log.i(TAG, "clickPrivateModeScreenshotsSwitch: Clicked the \"Allow screenshots in private browsing\" toggle")
}
fun clickOpenLinksInPrivateTabSwitch() = openLinksInPrivateTabSwitch().click() fun clickOpenLinksInPrivateTabSwitch() {
Log.i(TAG, "clickOpenLinksInPrivateTabSwitch: Trying to click the \"Open links in a private tab\" toggle")
openLinksInPrivateTabSwitch().click()
Log.i(TAG, "clickOpenLinksInPrivateTabSwitch: Clicked the \"Open links in a private tab\" toggle")
}
fun cancelPrivateShortcutAddition() { fun cancelPrivateShortcutAddition() {
Log.i(TAG, "cancelPrivateShortcutAddition: Waiting for $waitingTime ms until finding the \"Add private browsing shortcut\" button")
mDevice.wait( mDevice.wait(
Until.findObject(text("Add private browsing shortcut")), Until.findObject(text("Add private browsing shortcut")),
waitingTime, waitingTime,
) )
Log.i(TAG, "cancelPrivateShortcutAddition: Waited for $waitingTime ms until the \"Add private browsing shortcut\" button was found")
Log.i(TAG, "cancelPrivateShortcutAddition: Trying to click the \"Add private browsing shortcut\" button")
addPrivateBrowsingShortcutButton().click() addPrivateBrowsingShortcutButton().click()
Log.i(TAG, "cancelPrivateShortcutAddition: Clicked the \"Add private browsing shortcut\" button")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Log.i(TAG, "cancelPrivateShortcutAddition: Waiting for $waitingTime ms until finding the \"Cancel\" button")
mDevice.wait(Until.findObject(By.textContains("CANCEL")), waitingTime) mDevice.wait(Until.findObject(By.textContains("CANCEL")), waitingTime)
Log.i(TAG, "cancelPrivateShortcutAddition: Waited for $waitingTime ms until the \"Cancel\" button was found")
Log.i(TAG, "cancelPrivateShortcutAddition: Trying to click the \"Cancel\" button")
cancelShortcutAdditionButton().click() cancelShortcutAdditionButton().click()
Log.i(TAG, "cancelPrivateShortcutAddition: Clicked the \"Cancel\" button")
} }
} }
fun addPrivateShortcutToHomescreen() { fun addPrivateShortcutToHomescreen() {
Log.i(TAG, "addPrivateShortcutToHomescreen: Waiting for $waitingTime ms until finding the \"Add private browsing shortcut\" button")
mDevice.wait( mDevice.wait(
Until.findObject(text("Add private browsing shortcut")), Until.findObject(text("Add private browsing shortcut")),
waitingTime, waitingTime,
) )
Log.i(TAG, "addPrivateShortcutToHomescreen: Waited for $waitingTime ms until the \"Add private browsing shortcut\" button was found")
Log.i(TAG, "addPrivateShortcutToHomescreen: Trying to click the \"Add private browsing shortcut\" button")
addPrivateBrowsingShortcutButton().click() addPrivateBrowsingShortcutButton().click()
Log.i(TAG, "addPrivateShortcutToHomescreen: Clicked the \"Add private browsing shortcut\" button")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Log.i(TAG, "addPrivateShortcutToHomescreen: Waiting for $waitingTime ms until finding the \"Add automatically\" button")
mDevice.wait(Until.findObject(By.textContains("add automatically")), waitingTime) mDevice.wait(Until.findObject(By.textContains("add automatically")), waitingTime)
Log.i(TAG, "addPrivateShortcutToHomescreen: Waited for $waitingTime ms until the \"Add automatically\" button was found")
Log.i(TAG, "addPrivateShortcutToHomescreen: Trying to click the \"Add automatically\" button")
addAutomaticallyButton().click() addAutomaticallyButton().click()
Log.i(TAG, "addPrivateShortcutToHomescreen: Clicked the \"Add automatically\" button")
} }
} }
class Transition { class Transition {
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
Log.i(TAG, "goBack: Trying to click the navigate up button")
goBackButton().perform(ViewActions.click()) goBackButton().perform(ViewActions.click())
Log.i(TAG, "goBack: Clicked the navigate up button")
SettingsRobot().interact() SettingsRobot().interact()
return SettingsRobot.Transition() return SettingsRobot.Transition()
} }
fun openPrivateBrowsingShortcut(interact: SearchRobot.() -> Unit): SearchRobot.Transition { fun openPrivateBrowsingShortcut(interact: SearchRobot.() -> Unit): SearchRobot.Transition {
Log.i(TAG, "openPrivateBrowsingShortcut: Trying to click the \"Private $appName\" shortcut icon")
privateBrowsingShortcutIcon().click() privateBrowsingShortcutIcon().click()
Log.i(TAG, "openPrivateBrowsingShortcut: Clicked the \"Private $appName\" shortcut icon")
SearchRobot().interact() SearchRobot().interact()
return SearchRobot.Transition() return SearchRobot.Transition()

Loading…
Cancel
Save