commit 1f74f55b43b518287525819030f372d6efbe695d
parent 7a0403fd087740a1e2c537788806c72935357edd
Author: RebecaTudor <rebecatudor273@gmail.com>
Date: Mon, 29 Dec 2025 22:14:20 +0000
Bug 1975017 - Part 3 - Fix UI tests fors settings slider. r=android-reviewers,aaronmt,gmalekpour
Differential Revision: https://phabricator.services.mozilla.com/D275973
Diffstat:
4 files changed, 164 insertions(+), 131 deletions(-)
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt
@@ -19,6 +19,7 @@ import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Assume
import org.junit.Before
+import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FenixApplication
@@ -30,13 +31,11 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AppAndSystemHelper.enableOrDisableBackGestureNavigationOnDevice
import org.mozilla.fenix.helpers.AppAndSystemHelper.grantSystemPermission
-import org.mozilla.fenix.helpers.AppAndSystemHelper.runWithAppLocaleChanged
import org.mozilla.fenix.helpers.AppAndSystemHelper.runWithCondition
import org.mozilla.fenix.helpers.AppAndSystemHelper.verifyKeyboardVisibility
import org.mozilla.fenix.helpers.DataGenerationHelper.createCustomTabIntent
import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
-import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
import org.mozilla.fenix.helpers.MockBrowserDataHelper.createBookmarkItem
import org.mozilla.fenix.helpers.MockBrowserDataHelper.createHistoryItem
@@ -50,7 +49,6 @@ import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.clickSnackbarButton
import org.mozilla.fenix.helpers.TestHelper.exitMenu
-import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.verifyDarkThemeApplied
import org.mozilla.fenix.helpers.TestHelper.verifyLightThemeApplied
import org.mozilla.fenix.helpers.TestSetup
@@ -63,7 +61,6 @@ import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.longClickPageObject
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.searchScreen
-import java.util.Locale
/**
* Tests for verifying basic functionality of browser navigation and page related interactions
@@ -216,7 +213,7 @@ class NavigationToolbarTest : TestSetup() {
}
// TestRail link: https://mozilla.testrail.io/index.php?/cases/view/3135005
- @SmokeTest
+ @Ignore("Failing, see https://bugzilla.mozilla.org/show_bug.cgi?id=2007909")
@Test
fun verifyFontSizingChangeTest() {
runWithCondition(
@@ -235,20 +232,27 @@ class NavigationToolbarTest : TestSetup() {
}.clickSettingsButton {
}.openAccessibilitySubMenu {
clickFontSizingSwitch()
- verifyEnabledMenuItems()
- changeTextSizeSlider(textSizePercentage)
- verifyTextSizePercentage(textSizePercentage)
+ verifyFontSizingMenuItems(
+ composeTestRule,
+ isTheAutomaticFontSizingToggleChecked = true,
+ isTheFontSizingSliderEnabled = false,
+ isTheZoomOnAllWbsitesToggleChecked = false,
+ )
+ clickFontSizingSwitch()
+ verifyFontSizingMenuItems(
+ composeTestRule,
+ isTheAutomaticFontSizingToggleChecked = false,
+ isTheFontSizingSliderEnabled = true,
+ isTheZoomOnAllWbsitesToggleChecked = false,
+ )
+ changeTextSizeSlider(textSizePercentage, composeTestRule)
+ verifyTextSizePercentage(textSizePercentage, composeTestRule)
}.goBack {
}.goBack(composeTestRule) {
}
navigationToolbar(composeTestRule) {
}.enterURLAndEnterToBrowser(webpage) {
checkTextSizeOnWebsite(textSizePercentage, fenixApp.components)
- }.openThreeDotMenu {
- }.clickSettingsButton {
- }.openAccessibilitySubMenu {
- clickFontSizingSwitch()
- verifyMenuItemsAreDisabled()
}
}
}
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsGeneralTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsGeneralTest.kt
@@ -83,21 +83,27 @@ class SettingsGeneralTest : TestSetup() {
}.openThreeDotMenu {
}.clickSettingsButton {
}.openAccessibilitySubMenu {
+ verifyFontSizingMenuItems(
+ composeTestRule,
+ isTheAutomaticFontSizingToggleChecked = true,
+ isTheFontSizingSliderEnabled = false,
+ isTheZoomOnAllWbsitesToggleChecked = false,
+ )
clickFontSizingSwitch()
- verifyEnabledMenuItems()
- changeTextSizeSlider(textSizePercentage)
- verifyTextSizePercentage(textSizePercentage)
+ verifyFontSizingMenuItems(
+ composeTestRule,
+ isTheAutomaticFontSizingToggleChecked = false,
+ isTheFontSizingSliderEnabled = true,
+ isTheZoomOnAllWbsitesToggleChecked = false,
+ )
+ changeTextSizeSlider(textSizePercentage, composeTestRule)
+ verifyTextSizePercentage(textSizePercentage, composeTestRule)
}.goBack {
}.goBack(composeTestRule) {
}
navigationToolbar(composeTestRule) {
}.enterURLAndEnterToBrowser(webpage) {
checkTextSizeOnWebsite(textSizePercentage, fenixApp.components)
- }.openThreeDotMenu {
- }.clickSettingsButton {
- }.openAccessibilitySubMenu {
- clickFontSizingSwitch()
- verifyMenuItemsAreDisabled()
}
}
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAccessibilityRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAccessibilityRobot.kt
@@ -7,39 +7,36 @@
package org.mozilla.fenix.ui.robots
import android.util.Log
-import android.view.KeyEvent
-import android.view.KeyEvent.ACTION_DOWN
-import android.view.KeyEvent.KEYCODE_DPAD_LEFT
-import android.view.KeyEvent.KEYCODE_DPAD_RIGHT
-import android.view.View
-import android.widget.SeekBar
-import android.widget.TextView
+import androidx.compose.ui.semantics.SemanticsActions
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.assertIsEnabled
+import androidx.compose.ui.test.assertIsNotEnabled
+import androidx.compose.ui.test.assertTextEquals
+import androidx.compose.ui.test.junit4.ComposeTestRule
+import androidx.compose.ui.test.onNodeWithTag
+import androidx.compose.ui.test.performSemanticsAction
import androidx.test.espresso.Espresso.onView
-import androidx.test.espresso.UiController
-import androidx.test.espresso.ViewAction
-import androidx.test.espresso.ViewAssertion
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility
-import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
+import androidx.test.espresso.matcher.ViewMatchers.isChecked
+import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
+import androidx.test.espresso.matcher.ViewMatchers.withClassName
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
-import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
-import androidx.test.platform.app.InstrumentationRegistry
import org.hamcrest.CoreMatchers.allOf
-import org.hamcrest.Matcher
+import org.hamcrest.CoreMatchers.endsWith
import org.junit.Assert.assertTrue
+import org.mozilla.fenix.R
import org.mozilla.fenix.components.Components
import org.mozilla.fenix.helpers.Constants.TAG
+import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
+import org.mozilla.fenix.helpers.TestHelper.hasCousin
import org.mozilla.fenix.helpers.TestHelper.mDevice
-import org.mozilla.fenix.helpers.assertIsEnabled
-import org.mozilla.fenix.helpers.isEnabled
import org.mozilla.fenix.ui.robots.SettingsSubMenuAccessibilityRobot.Companion.DECIMAL_CONVERSION
import org.mozilla.fenix.ui.robots.SettingsSubMenuAccessibilityRobot.Companion.MIN_VALUE
import org.mozilla.fenix.ui.robots.SettingsSubMenuAccessibilityRobot.Companion.STEP_SIZE
-import org.mozilla.fenix.ui.robots.SettingsSubMenuAccessibilityRobot.Companion.TEXT_SIZE
-import kotlin.math.roundToInt
/**
* Implementation of Robot Pattern for the settings Accessibility sub menu.
@@ -50,60 +47,105 @@ class SettingsSubMenuAccessibilityRobot {
const val STEP_SIZE = 5
const val MIN_VALUE = 50
const val DECIMAL_CONVERSION = 100f
- const val TEXT_SIZE = 16f
}
fun clickFontSizingSwitch() = toggleFontSizingSwitch()
- fun verifyEnabledMenuItems() {
- Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Font Size\" title is visible")
- onView(withText("Font Size")).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
- Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Font Size\" title is visible")
- Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Font Size\" title is enabled")
- onView(withText("Font Size")).check(matches(isEnabled(true)))
- Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Font Size\" title is enabled")
- Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Make text on websites larger or smaller\" summary is visible")
- onView(withText("Make text on websites larger or smaller")).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
- Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Make text on websites larger or smaller\" summary is visible")
- Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Make text on websites larger or smaller\" summary is enabled")
- onView(withText("Make text on websites larger or smaller")).check(matches(isEnabled(true)))
- Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Make text on websites larger or smaller\" summary is enabled")
- Log.i(TAG, "verifyEnabledMenuItems: Trying to verify the \"This is sample text. It is here to show how text will appear\" sample text")
- onView(withId(org.mozilla.fenix.R.id.sampleText))
- .check(matches(withText("This is sample text. It is here to show how text will appear when you increase or decrease the size with this setting.")))
- Log.i(TAG, "verifyEnabledMenuItems: Verified the \"This is sample text. It is here to show how text will appear\" sample text")
+ fun verifyFontSizingMenuItems(
+ composeTestRule: ComposeTestRule,
+ isTheAutomaticFontSizingToggleChecked: Boolean,
+ isTheFontSizingSliderEnabled: Boolean,
+ isTheZoomOnAllWbsitesToggleChecked: Boolean,
+ ) {
+ // Automatic font sizing
+ Log.i(TAG, "verifyFontSizingMenuItems: Trying to verify that the \"Automatic font sizing\" title is displayed")
+ onView(withText(getStringResource(R.string.preference_accessibility_auto_size_2))).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
+ Log.i(TAG, "verifyFontSizingMenuItems: Verified that the \"Automatic font sizing\" title is displayed")
+ Log.i(TAG, "verifyFontSizingMenuItems: Trying to verify that the \"Automatic font sizing\" summary is displayed")
+ onView(withText(getStringResource(R.string.preference_accessibility_auto_size_summary))).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
+ Log.i(TAG, "verifyFontSizingMenuItems: Verified that the \"Automatic font sizing\" summary is displayed")
+
+ // Automatic font sizing toggle assertion
+ Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Automatic font sizing\" toggle is enabled: $isTheAutomaticFontSizingToggleChecked")
+ onView(withText(R.string.preference_accessibility_auto_size_2))
+ .check(
+ matches(
+ hasCousin(
+ allOf(
+ withClassName(endsWith("Switch")),
+ if (isTheAutomaticFontSizingToggleChecked) {
+ isChecked()
+ } else {
+ isNotChecked()
+ },
+ ),
+ ),
+ ),
+ )
+ Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Automatic font sizing\" toggle is enabled: $isTheAutomaticFontSizingToggleChecked")
+
+ // Font size
+ Log.i(TAG, "verifyFontSizingMenuItems: Trying to verify that the \"Font Size\" title is displayed")
+ composeTestRule.onNodeWithTag("fontSizeTitle").assertIsDisplayed()
+ Log.i(TAG, "verifyFontSizingMenuItems: Verified that the \"Font Size\" title is displayed")
+ Log.i(TAG, "verifyFontSizingMenuItems: Trying to verify that the \"Font Size\" summary is displayed")
+ composeTestRule.onNodeWithTag("fontSizeSubtitle").assertIsDisplayed()
+ Log.i(TAG, "verifyFontSizingMenuItems: Verified that the \"Font Size\" summary is displayed")
+
+ // Font size seek bar
+ Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar is displayed")
+ composeTestRule.onNodeWithTag("fontSizeSlider").assertIsDisplayed()
+ Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar is displayed")
Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar value is set to 100%")
- onView(withId(org.mozilla.fenix.R.id.seekbar_value)).check(matches(withText("100%")))
+ composeTestRule.onNodeWithTag("fontSizeSliderValue").assertTextEquals("100 %")
Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar value is set to 100%")
- Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar is visible")
- onView(withId(org.mozilla.fenix.R.id.seekbar)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
- Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar is visible")
- }
- fun verifyMenuItemsAreDisabled() {
- Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the \"Font Size\" title is not enabled")
- onView(withText("Font Size")).assertIsEnabled(false)
- Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the \"Font Size\" title is not enabled")
- Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the \"Make text on websites larger or smaller\" summary is not enabled")
- onView(withText("Make text on websites larger or smaller")).assertIsEnabled(false)
- Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the \"Make text on websites larger or smaller\" summary is not enabled")
- Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the \"This is sample text. It is here to show how text will appear\" sample text is not enabled")
- onView(withId(org.mozilla.fenix.R.id.sampleText)).assertIsEnabled(false)
- Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the \"This is sample text. It is here to show how text will appear\" sample text is not enabled")
- Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the seek bar value is not enabled")
- onView(withId(org.mozilla.fenix.R.id.seekbar_value)).assertIsEnabled(false)
- Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the seek bar value is not enabled")
- Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the seek bar is not enabled")
- onView(withId(org.mozilla.fenix.R.id.seekbar)).assertIsEnabled(false)
- Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the seek bar is not enabled")
+ // Seek bar assertion
+ if (isTheFontSizingSliderEnabled) {
+ Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar is enabled")
+ composeTestRule.onNodeWithTag("fontSizeSlider").assertIsEnabled()
+ Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar is displayed")
+ } else {
+ Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar is not enabled")
+ composeTestRule.onNodeWithTag("fontSizeSlider").assertIsNotEnabled()
+ Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar is not enabled")
+ }
+
+ // Zoom on all websites
+ Log.i(TAG, "verifyFontSizingMenuItems: Trying to verify that the \"Zoom on all websites\" title is displayed")
+ onView(withText(getStringResource(R.string.preference_accessibility_force_enable_zoom))).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
+ Log.i(TAG, "verifyFontSizingMenuItems: Verified that the \"Zoom on all websites\" title is displayed")
+ Log.i(TAG, "verifyFontSizingMenuItems: Trying to verify that the \"Zoom on all websites\" summary is displayed")
+ onView(withText(getStringResource(R.string.preference_accessibility_force_enable_zoom_summary))).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
+ Log.i(TAG, "verifyFontSizingMenuItems: Verified that the \"Zoom on all websites\" summary is displayed")
+
+ // Zoom on all websites toggle assertion
+ Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Zoom on all websites\" toggle is enabled: $isTheZoomOnAllWbsitesToggleChecked")
+ onView(withText(R.string.preference_accessibility_force_enable_zoom))
+ .check(
+ matches(
+ hasCousin(
+ allOf(
+ withClassName(endsWith("Switch")),
+ if (isTheZoomOnAllWbsitesToggleChecked) {
+ isChecked()
+ } else {
+ isNotChecked()
+ },
+ ),
+ ),
+ ),
+ )
+ Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Zoom on all websites\" toggle is enabled: $isTheZoomOnAllWbsitesToggleChecked")
}
- fun changeTextSizeSlider(seekBarPercentage: Int) = adjustTextSizeSlider(seekBarPercentage)
+ fun changeTextSizeSlider(seekBarPercentage: Int, composeTestRule: ComposeTestRule) =
+ adjustTextSizeSlider(seekBarPercentage, composeTestRule)
- fun verifyTextSizePercentage(textSize: Int) {
+ fun verifyTextSizePercentage(textSize: Int, composeTestRule: ComposeTestRule) {
Log.i(TAG, "verifyTextSizePercentage: Trying to verify that the text size percentage is set to: $textSize")
- onView(withId(org.mozilla.fenix.R.id.sampleText))
- .check(textSizePercentageEquals(textSize))
+ composeTestRule.onNodeWithTag("fontSizeSliderValue")
+ .assertTextEquals("$textSize %")
Log.i(TAG, "verifyTextSizePercentage: Verified that the text size percentage is set to: $textSize")
}
@@ -131,60 +173,16 @@ private fun toggleFontSizingSwitch() {
Log.i(TAG, "toggleFontSizingSwitch: Clicked the \"Automatic font sizing\" toggle")
}
-private fun adjustTextSizeSlider(seekBarPercentage: Int) {
+private fun adjustTextSizeSlider(seekBarPercentage: Int, composeTestRule: ComposeTestRule) {
Log.i(TAG, "adjustTextSizeSlider: Trying to set the seek bar value to: $seekBarPercentage")
- onView(withId(org.mozilla.fenix.R.id.seekbar))
- .perform(SeekBarChangeProgressViewAction(seekBarPercentage))
+ composeTestRule.onNodeWithTag("fontSizeSlider")
+ .performSemanticsAction(SemanticsActions.SetProgress) { it(seekBarPercentage.toFloat()) }
Log.i(TAG, "adjustTextSizeSlider: Seek bar value was set to: $seekBarPercentage")
}
private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))
-class SeekBarChangeProgressViewAction(val seekBarPercentage: Int) : ViewAction {
- override fun getConstraints(): Matcher<View> {
- return isAssignableFrom(SeekBar::class.java)
- }
-
- override fun perform(uiController: UiController?, view: View?) {
- val targetStepSize = calculateStepSizeFromPercentage(seekBarPercentage)
- val seekbar = view as SeekBar
- var progress = seekbar.progress
-
- if (targetStepSize > progress) {
- for (i in progress until targetStepSize) {
- seekbar.onKeyDown(KEYCODE_DPAD_RIGHT, KeyEvent(ACTION_DOWN, KEYCODE_DPAD_RIGHT))
- }
- } else if (progress > targetStepSize) {
- for (i in progress downTo targetStepSize) {
- seekbar.onKeyDown(KEYCODE_DPAD_LEFT, KeyEvent(ACTION_DOWN, KEYCODE_DPAD_LEFT))
- }
- }
- }
-
- override fun getDescription(): String {
- return "Changes the progress on a SeekBar, based on the percentage value."
- }
-}
-
-fun textSizePercentageEquals(textSizePercentage: Int): ViewAssertion {
- return ViewAssertion { view, noViewFoundException ->
- if (noViewFoundException != null) throw noViewFoundException
-
- val textView = view as TextView
- val scaledPixels =
- textView.textSize / InstrumentationRegistry.getInstrumentation().context.resources.displayMetrics.density
- val currentTextSizePercentage = calculateTextPercentageFromTextSize(scaledPixels)
-
- if (currentTextSizePercentage != textSizePercentage) throw AssertionError("The textview has a text size percentage of $currentTextSizePercentage, and does not match $textSizePercentage")
- }
-}
-
-fun calculateTextPercentageFromTextSize(textSize: Float): Int {
- val decimal = textSize / TEXT_SIZE
- return (decimal * DECIMAL_CONVERSION).roundToInt()
-}
-
fun calculateStepSizeFromPercentage(textSizePercentage: Int): Int {
return ((textSizePercentage - MIN_VALUE) / STEP_SIZE)
}
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/FontSizeSlider.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/FontSizeSlider.kt
@@ -30,6 +30,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.testTag
+import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -70,11 +73,19 @@ fun FontSizePreference(
) {
Text(
text = stringResource(id = R.string.preference_accessibility_font_size_title),
+ modifier = Modifier.semantics {
+ testTagsAsResourceId = true
+ testTag = "fontSizeTitle"
+ },
style = MaterialTheme.typography.bodyLarge,
)
Text(
text = stringResource(id = R.string.preference_accessibility_text_size_summary),
+ modifier = Modifier.semantics {
+ testTagsAsResourceId = true
+ testTag = "fontSizeSubtitle"
+ },
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
@@ -106,6 +117,10 @@ private fun SampleText(fontSize: Float) {
) {
Text(
text = stringResource(id = R.string.accessibility_text_size_sample_text_1),
+ modifier = Modifier.semantics {
+ testTagsAsResourceId = true
+ testTag = "sampleText"
+ },
style = MaterialTheme.typography.bodyMedium,
fontSize = textSize.sp,
lineHeight = (textSize + BASE_SAMPLE_HEIGHT_LINE_DIFFERENCE).sp,
@@ -137,7 +152,12 @@ private fun FontSizeSlider(
onValueChange(newSliderValue.toFloat())
},
valueRange = start.toFloat()..end.toFloat(),
- modifier = Modifier.weight(1f),
+ modifier = Modifier
+ .weight(1f)
+ .semantics {
+ testTagsAsResourceId = true
+ testTag = "fontSizeSlider"
+ },
enabled = isEnabled,
onValueChangeFinished = onValueChangeFinished,
thumb = { Thumb(isEnabled) },
@@ -155,7 +175,12 @@ private fun FontSizeSlider(
Text(
text = "${value.toInt()} %",
- modifier = Modifier.padding(start = 8.dp),
+ modifier = Modifier
+ .padding(start = 8.dp)
+ .semantics {
+ testTagsAsResourceId = true
+ testTag = "fontSizeSliderValue"
+ },
)
}
}