From cc783b64f76c96a1242b41c53b189ce1f913e54b Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Wed, 21 Feb 2024 17:20:49 +0200 Subject: [PATCH] Bug 1881489 - Add logs to SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot --- ...MenuLoginsAndPasswordOptionsToSaveRobot.kt | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.kt index d424ee845d..f107104f9d 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.kt @@ -4,6 +4,7 @@ package org.mozilla.fenix.ui.robots +import android.util.Log import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions 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.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import org.hamcrest.CoreMatchers import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.not import org.mozilla.fenix.R +import org.mozilla.fenix.helpers.Constants.TAG import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText @@ -26,55 +27,71 @@ import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText class SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot { fun verifySaveLoginsOptionsView() { + Log.i(TAG, "verifySaveLoginsOptionsView: Trying to verify that the \"Ask to save\" option is visible") onView(withText("Ask to save")) .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")) .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + Log.i(TAG, "verifySaveLoginsOptionsView: Verified that the \"Never save\" option is visible") } fun verifyAskToSaveRadioButton(isChecked: Boolean) { if (isChecked) { + Log.i(TAG, "verifyAskToSaveRadioButton: Trying to verify that the \"Ask to save\" option is checked") onView( allOf( withId(R.id.radio_button), hasSibling(withText(R.string.preferences_passwords_save_logins_ask_to_save)), ), ).check(matches(isChecked())) + Log.i(TAG, "verifyAskToSaveRadioButton: Verified that the \"Ask to save\" option is checked") } else { + Log.i(TAG, "verifyAskToSaveRadioButton: Trying to verify that the \"Ask to save\" option is not checked") onView( allOf( withId(R.id.radio_button), hasSibling(withText(R.string.preferences_passwords_save_logins_ask_to_save)), ), ).check(matches(not(isChecked()))) + Log.i(TAG, "verifyAskToSaveRadioButton: Verified that the \"Ask to save\" option is not checked") } } fun verifyNeverSaveSaveRadioButton(isChecked: Boolean) { if (isChecked) { + Log.i(TAG, "verifyNeverSaveSaveRadioButton: Trying to verify that the \"Never save\" option is checked") onView( allOf( withId(R.id.radio_button), hasSibling(withText(R.string.preferences_passwords_save_logins_never_save)), ), ).check(matches(isChecked())) + Log.i(TAG, "verifyNeverSaveSaveRadioButton: Verified that the \"Never save\" option is checked") } else { + Log.i(TAG, "verifyNeverSaveSaveRadioButton: Trying to verify that the \"Never save\" option is not checked") onView( allOf( withId(R.id.radio_button), hasSibling(withText(R.string.preferences_passwords_save_logins_never_save)), ), ).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() + Log.i(TAG, "clickNeverSaveOption: Clicked the \"Never save\" option") + } class Transition { fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition { + Log.i(TAG, "goBack: Trying to click the navigate up button") goBackButton().perform(ViewActions.click()) + Log.i(TAG, "goBack: Clicked the navigate up button") SettingsSubMenuLoginsAndPasswordRobot().interact() return SettingsSubMenuLoginsAndPasswordRobot.Transition() @@ -83,4 +100,4 @@ class SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot { } private fun goBackButton() = - onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up"))) + onView(allOf(ViewMatchers.withContentDescription("Navigate up")))