Bug 1882264 - Add logs to SettingsSubMenuOpenLinksInAppsRobot

fenix/125.0
AndiAJ 4 months ago committed by mergify[bot]
parent 77b69aafd7
commit 5944b5b8bf

@ -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.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.hasSibling import androidx.test.espresso.matcher.ViewMatchers.hasSibling
@ -11,6 +12,7 @@ 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.allOf import org.hamcrest.CoreMatchers.allOf
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.assertUIObjectExists import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
@ -44,26 +46,35 @@ class SettingsSubMenuOpenLinksInAppsRobot {
verifySelectedOpenLinksInAppOption(selectedOpenLinkInAppsOption) verifySelectedOpenLinksInAppOption(selectedOpenLinkInAppsOption)
} }
fun verifySelectedOpenLinksInAppOption(openLinkInAppsOption: String) = fun verifySelectedOpenLinksInAppOption(openLinkInAppsOption: String) {
Log.i(TAG, "verifySelectedOpenLinksInAppOption: Trying to verify that the $openLinkInAppsOption option is checked")
onView( onView(
allOf( allOf(
withId(R.id.radio_button), withId(R.id.radio_button),
hasSibling(withText(openLinkInAppsOption)), hasSibling(withText(openLinkInAppsOption)),
), ),
).check(matches(isChecked(true))) ).check(matches(isChecked(true)))
Log.i(TAG, "verifySelectedOpenLinksInAppOption: Verified that the $openLinkInAppsOption option is checked")
}
fun clickOpenLinkInAppOption(openLinkInAppsOption: String) { fun clickOpenLinkInAppOption(openLinkInAppsOption: String) {
Log.i(TAG, "clickOpenLinkInAppOption: Trying to click the $openLinkInAppsOption option")
when (openLinkInAppsOption) { when (openLinkInAppsOption) {
"Always" -> alwaysOption().click() "Always" -> alwaysOption().click()
"Ask before opening" -> askBeforeOpeningOption().click() "Ask before opening" -> askBeforeOpeningOption().click()
"Never" -> neverOption().click() "Never" -> neverOption().click()
} }
Log.i(TAG, "clickOpenLinkInAppOption: Clicked the $openLinkInAppsOption option")
} }
class Transition { class Transition {
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
Log.i(TAG, "goBack: Waiting for device to be idle")
mDevice.waitForIdle() mDevice.waitForIdle()
Log.i(TAG, "goBack: Waited for device to be idle")
Log.i(TAG, "goBack: Trying to click the navigate up button")
goBackButton().click() goBackButton().click()
Log.i(TAG, "goBack: Clicked the navigate up button")
SettingsRobot().interact() SettingsRobot().interact()
return SettingsRobot.Transition() return SettingsRobot.Transition()

Loading…
Cancel
Save