tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 217d8de8c438bad56202570a7d5ef615544c611f
parent 5e3f4c98972f3d0c820bd72900d271ef4fad5e09
Author: AndiAJ <andiaj@users.noreply.github.com>
Date:   Thu,  6 Nov 2025 14:33:58 +0000

Bug 1996852 - New UI test that verifies and interacts with the crash reports data collection options r=calu,aaronmt

As @calu requested, I've created a new UI test that verifies and interacts with the crash reports data collection options and radio buttons.

The UI test successfully passed 50x on Firebase

Differential Revision: https://phabricator.services.mozilla.com/D271398

Diffstat:
Mmobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt | 38++++++++++++++++++++++++++++++++++++++
Mmobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuDataCollectionRobot.kt | 58++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/list/ListItem.kt | 6++++++
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/datachoices/DataChoicesScreen.kt | 2+-
4 files changed, 95 insertions(+), 9 deletions(-)

diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt @@ -123,4 +123,42 @@ class SettingsPrivacyTest : TestSetup() { verifyDailyUsagePingToggle(composeTestRule, isChecked = false) } } + + // TestRail link: https://mozilla.testrail.io/index.php?/cases/view/3215044 + @Test + fun verifyTheCrashReportsOptionsTest() { + homeScreen { + }.openThreeDotMenu { + }.openSettings { + }.openSettingsSubMenuDataCollection { + verifyTheCrashReportsSection(composeTestRule) + verifyTheCrashReportOptionStates( + composeTestRule, + isAskBeforeSendingCrashReportsEnabled = true, + isAutomaticallySendCrashReportsEnabled = false, + isNeverSendCrashReportsEnabled = false, + ) + clickTheCrashReportsRadioButton(composeTestRule, "Send automatically") + verifyTheCrashReportOptionStates( + composeTestRule, + isAskBeforeSendingCrashReportsEnabled = false, + isAutomaticallySendCrashReportsEnabled = true, + isNeverSendCrashReportsEnabled = false, + ) + clickTheCrashReportsRadioButton(composeTestRule, "Never send") + verifyTheCrashReportOptionStates( + composeTestRule, + isAskBeforeSendingCrashReportsEnabled = false, + isAutomaticallySendCrashReportsEnabled = false, + isNeverSendCrashReportsEnabled = true, + ) + clickTheCrashReportsRadioButton(composeTestRule, "Ask before sending") + verifyTheCrashReportOptionStates( + composeTestRule, + isAskBeforeSendingCrashReportsEnabled = true, + isAutomaticallySendCrashReportsEnabled = false, + isNeverSendCrashReportsEnabled = false, + ) + } + } } diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuDataCollectionRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuDataCollectionRobot.kt @@ -20,11 +20,13 @@ 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.assertItemIsChecked +import org.mozilla.fenix.helpers.MatcherHelper.assertItemTextEquals import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId import org.mozilla.fenix.helpers.TestHelper.packageName +import org.mozilla.fenix.helpers.TestHelper.waitForAppWindowToBeUpdated import org.mozilla.fenix.helpers.click import mozilla.components.lib.crash.R as crashR @@ -63,12 +65,9 @@ class SettingsSubMenuDataCollectionRobot { itemContainingText(getStringResource(R.string.preferences_daily_usage_ping_title)), itemContainingText(getStringResource(R.string.preferences_daily_usage_ping_description)), itemWithDescription("Learn more about daily usage ping Links available"), - // Crash reports section - itemContainingText(getStringResource(R.string.crash_reporting_description)), - itemContainingText(getStringResource(crashR.string.crash_reporting_ask)), - itemContainingText(getStringResource(crashR.string.crash_reporting_auto)), - itemContainingText(getStringResource(crashR.string.crash_reporting_never)), ) + // Crash reports section + verifyTheCrashReportsSection(composeTestRule) // Technical Data toggle verifyUsageAndTechnicalDataToggle(composeTestRule, isSendTechnicalDataEnabled) @@ -77,9 +76,12 @@ class SettingsSubMenuDataCollectionRobot { verifyDailyUsagePingToggle(composeTestRule, isDailyUsagePingEnabled) // Crash reports radio buttons - assertItemIsChecked(itemWithResId("data.collection.Ask.radio.button"), isChecked = isAskBeforeSendingCrashReportsEnabled) - assertItemIsChecked(itemWithResId("data.collection.Auto.radio.button"), isChecked = isAutomaticallySendCrashReportsEnabled) - assertItemIsChecked(itemWithResId("data.collection.Never.radio.button"), isChecked = isNeverSendCrashReportsEnabled) + verifyTheCrashReportOptionStates( + composeTestRule, + isAskBeforeSendingCrashReportsEnabled, + isAutomaticallySendCrashReportsEnabled, + isNeverSendCrashReportsEnabled, + ) } fun verifyUsageAndTechnicalDataToggle(composeTestRule: ComposeTestRule, isChecked: Boolean) { @@ -153,6 +155,46 @@ class SettingsSubMenuDataCollectionRobot { Log.i(TAG, "clickStudiesDialogOkButton: Clicked the \"Studies\" dialog \"Ok\" button") } + fun verifyTheCrashReportsSection(composeTestRule: ComposeTestRule) { + Log.i(TAG, "verifyTheCrashReportsSection: Waiting for compose test rule to be idle") + composeTestRule.waitForIdle() + Log.i(TAG, "verifyTheCrashReportsSection: Waited for compose test rule to be idle") + + assertUIObjectExists( + itemContainingText(getStringResource(R.string.crash_reports_data_category)), + itemContainingText(getStringResource(R.string.crash_reporting_description)), + itemContainingText(getStringResource(crashR.string.crash_reporting_ask)), + itemContainingText(getStringResource(crashR.string.crash_reporting_auto)), + itemContainingText(getStringResource(crashR.string.crash_reporting_never)), + ) + } + + fun verifyTheCrashReportOptionStates( + composeTestRule: ComposeTestRule, + isAskBeforeSendingCrashReportsEnabled: Boolean = true, + isAutomaticallySendCrashReportsEnabled: Boolean = false, + isNeverSendCrashReportsEnabled: Boolean = false, + ) { + Log.i(TAG, "verifyTheCrashReportOptionStates: Waiting for compose test rule to be idle") + composeTestRule.waitForIdle() + Log.i(TAG, "verifyTheCrashReportOptionStates: Waited for compose test rule to be idle") + + // Crash reports item state + assertItemIsChecked(itemWithResId("data.collection.Ask.option"), isChecked = isAskBeforeSendingCrashReportsEnabled) + assertItemIsChecked(itemWithResId("data.collection.Auto.option"), isChecked = isAutomaticallySendCrashReportsEnabled) + assertItemIsChecked(itemWithResId("data.collection.Never.option"), isChecked = isNeverSendCrashReportsEnabled) + } + + fun clickTheCrashReportsRadioButton(composeTestRule: ComposeTestRule, crashReportsRadioButton: String) { + Log.i(TAG, "clickTheCrashReportsRadioButton: Trying to click the $crashReportsRadioButton radio button") + when (crashReportsRadioButton) { + "Ask before sending" -> composeTestRule.onNodeWithTag("Ask before sending.radio.button", useUnmergedTree = true).performClick() + "Send automatically" -> composeTestRule.onNodeWithTag("Send automatically.radio.button", useUnmergedTree = true).performClick() + "Never send" -> composeTestRule.onNodeWithTag("Never send.radio.button", useUnmergedTree = true).performClick() + } + Log.i(TAG, "clickTheCrashReportsRadioButton: Clicked the $crashReportsRadioButton radio button") + } + class Transition { fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { Log.i(TAG, "goBack: Trying to click the navigate up toolbar button") diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/list/ListItem.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/list/ListItem.kt @@ -52,6 +52,8 @@ import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.selected import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.testTag +import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.compose.ui.text.style.Hyphens import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview @@ -428,6 +430,10 @@ fun RadioButtonListItem( selected = selected, modifier = Modifier .size(ICON_SIZE) + .semantics { + testTag = "$label.radio.button" + testTagsAsResourceId = true + } .clearAndSetSemantics {}, enabled = enabled, onClick = onClick, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/datachoices/DataChoicesScreen.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/datachoices/DataChoicesScreen.kt @@ -199,7 +199,7 @@ private fun CrashReportsSection( selected = selectedOption == crashReportOption, modifier = Modifier .semantics { - testTag = "data.collection.$crashReportOption.radio.button" + testTag = "data.collection.$crashReportOption.option" testTagsAsResourceId = true }, maxLabelLines = 1,