Bug 1881489 - Add logs to SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot

fenix/125.0
AndiAJ 4 months ago committed by mergify[bot]
parent bb2620b9da
commit cc783b64f7

@ -4,6 +4,7 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
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
@ -13,10 +14,10 @@ import androidx.test.espresso.matcher.ViewMatchers.isChecked
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.withId
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.not import org.hamcrest.CoreMatchers.not
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
@ -26,55 +27,71 @@ import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
class SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot { class SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot {
fun verifySaveLoginsOptionsView() { fun verifySaveLoginsOptionsView() {
Log.i(TAG, "verifySaveLoginsOptionsView: Trying to verify that the \"Ask to save\" option is visible")
onView(withText("Ask to save")) onView(withText("Ask to save"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
Log.i(TAG, "verifySaveLoginsOptionsView: Verified that the \"Ask to save\" option is visible")
Log.i(TAG, "verifySaveLoginsOptionsView: Trying to verify that the \"Never save\" option is visible")
onView(withText("Never save")) onView(withText("Never save"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
Log.i(TAG, "verifySaveLoginsOptionsView: Verified that the \"Never save\" option is visible")
} }
fun verifyAskToSaveRadioButton(isChecked: Boolean) { fun verifyAskToSaveRadioButton(isChecked: Boolean) {
if (isChecked) { if (isChecked) {
Log.i(TAG, "verifyAskToSaveRadioButton: Trying to verify that the \"Ask to save\" option is checked")
onView( onView(
allOf( allOf(
withId(R.id.radio_button), withId(R.id.radio_button),
hasSibling(withText(R.string.preferences_passwords_save_logins_ask_to_save)), hasSibling(withText(R.string.preferences_passwords_save_logins_ask_to_save)),
), ),
).check(matches(isChecked())) ).check(matches(isChecked()))
Log.i(TAG, "verifyAskToSaveRadioButton: Verified that the \"Ask to save\" option is checked")
} else { } else {
Log.i(TAG, "verifyAskToSaveRadioButton: Trying to verify that the \"Ask to save\" option is not checked")
onView( onView(
allOf( allOf(
withId(R.id.radio_button), withId(R.id.radio_button),
hasSibling(withText(R.string.preferences_passwords_save_logins_ask_to_save)), hasSibling(withText(R.string.preferences_passwords_save_logins_ask_to_save)),
), ),
).check(matches(not(isChecked()))) ).check(matches(not(isChecked())))
Log.i(TAG, "verifyAskToSaveRadioButton: Verified that the \"Ask to save\" option is not checked")
} }
} }
fun verifyNeverSaveSaveRadioButton(isChecked: Boolean) { fun verifyNeverSaveSaveRadioButton(isChecked: Boolean) {
if (isChecked) { if (isChecked) {
Log.i(TAG, "verifyNeverSaveSaveRadioButton: Trying to verify that the \"Never save\" option is checked")
onView( onView(
allOf( allOf(
withId(R.id.radio_button), withId(R.id.radio_button),
hasSibling(withText(R.string.preferences_passwords_save_logins_never_save)), hasSibling(withText(R.string.preferences_passwords_save_logins_never_save)),
), ),
).check(matches(isChecked())) ).check(matches(isChecked()))
Log.i(TAG, "verifyNeverSaveSaveRadioButton: Verified that the \"Never save\" option is checked")
} else { } else {
Log.i(TAG, "verifyNeverSaveSaveRadioButton: Trying to verify that the \"Never save\" option is not checked")
onView( onView(
allOf( allOf(
withId(R.id.radio_button), withId(R.id.radio_button),
hasSibling(withText(R.string.preferences_passwords_save_logins_never_save)), hasSibling(withText(R.string.preferences_passwords_save_logins_never_save)),
), ),
).check(matches(not(isChecked()))) ).check(matches(not(isChecked())))
Log.i(TAG, "verifyNeverSaveSaveRadioButton: Verified that the \"Never save\" option is not checked")
} }
} }
fun clickNeverSaveOption() = fun clickNeverSaveOption() {
Log.i(TAG, "clickNeverSaveOption: Trying to click the \"Never save\" option")
itemContainingText(getStringResource(R.string.preferences_passwords_save_logins_never_save)).click() itemContainingText(getStringResource(R.string.preferences_passwords_save_logins_never_save)).click()
Log.i(TAG, "clickNeverSaveOption: Clicked the \"Never save\" option")
}
class Transition { class Transition {
fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition { fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.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")
SettingsSubMenuLoginsAndPasswordRobot().interact() SettingsSubMenuLoginsAndPasswordRobot().interact()
return SettingsSubMenuLoginsAndPasswordRobot.Transition() return SettingsSubMenuLoginsAndPasswordRobot.Transition()
@ -83,4 +100,4 @@ class SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot {
} }
private fun goBackButton() = private fun goBackButton() =
onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up"))) onView(allOf(ViewMatchers.withContentDescription("Navigate up")))

Loading…
Cancel
Save