diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenStepper.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenStepper.kt index cc891ae28..cbb0eb0b4 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenStepper.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenStepper.kt @@ -3,6 +3,8 @@ package com.x8bit.bitwarden.ui.platform.components import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.testTag import androidx.compose.ui.text.input.KeyboardType import com.x8bit.bitwarden.R import com.x8bit.bitwarden.ui.platform.base.util.ZERO_WIDTH_CHARACTER @@ -24,6 +26,7 @@ import com.x8bit.bitwarden.ui.platform.components.model.IconResource * @param textFieldReadOnly whether or not the text field should be read only. The stepper * increment and decrement buttons function regardless of this value. */ +@Suppress("LongMethod") @Composable fun BitwardenStepper( label: String, @@ -34,6 +37,8 @@ fun BitwardenStepper( isIncrementEnabled: Boolean = true, isDecrementEnabled: Boolean = true, textFieldReadOnly: Boolean = true, + increaseButtonTestTag: String? = null, + decreaseButtonTestTag: String? = null, ) { val clampedValue = value?.coerceIn(range) if (clampedValue != value && clampedValue != null) { @@ -59,6 +64,11 @@ fun BitwardenStepper( } }, isEnabled = isDecrementEnabled, + modifier = Modifier.semantics { + if (decreaseButtonTestTag != null) { + testTag = decreaseButtonTestTag + } + }, ) BitwardenIconButtonWithResource( iconRes = IconResource( @@ -72,6 +82,11 @@ fun BitwardenStepper( } }, isEnabled = isIncrementEnabled, + modifier = Modifier.semantics { + if (increaseButtonTestTag != null) { + testTag = increaseButtonTestTag + } + }, ) }, readOnly = textFieldReadOnly, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreen.kt index 5d3ad85b2..59f3358fb 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreen.kt @@ -257,6 +257,7 @@ private fun DefaultAppBar( OverflowMenuItemData( text = stringResource(id = R.string.password_history), onClick = onPasswordHistoryClick, + testTag = "Options", ), ), ) @@ -779,7 +780,11 @@ private fun PassphraseNumWordsCounterItem( value = numWords, range = PASSPHRASE_MIN_NUMBER_OF_WORDS..PASSPHRASE_MAX_NUMBER_OF_WORDS, onValueChange = onPassphraseNumWordsCounterChange, - modifier = Modifier.padding(horizontal = 16.dp), + increaseButtonTestTag = "NumberOfWordsIncreaseButton", + decreaseButtonTestTag = "NumberOfWordsDecreaseButton", + modifier = Modifier + .semantics { testTag = "NumberOfWordsLabel" } + .padding(horizontal = 16.dp), ) } @@ -795,6 +800,7 @@ private fun PassphraseWordSeparatorInputItem( onPassphraseWordSeparatorChange(it.toCharArray().firstOrNull()) }, modifier = Modifier + .semantics { testTag = "WordSeparatorEntry" } .width(267.dp) .padding(horizontal = 16.dp), ) @@ -810,6 +816,7 @@ private fun PassphraseCapitalizeToggleItem( isChecked = capitalize, onCheckedChange = onPassphraseCapitalizeToggleChange, modifier = Modifier + .semantics { testTag = "CapitalizePassphraseToggle" } .fillMaxWidth() .padding(horizontal = 16.dp), ) @@ -825,6 +832,7 @@ private fun PassphraseIncludeNumberToggleItem( isChecked = includeNumber, onCheckedChange = onPassphraseIncludeNumberToggleChange, modifier = Modifier + .semantics { testTag = "IncludeNumbersToggle" } .fillMaxWidth() .padding(horizontal = 16.dp), )