From 01a702ba9c723f1465604473bc1e8cc95f8d6aa3 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 17 Sep 2024 10:54:01 +1000 Subject: [PATCH] Using our updated qaTag instead of testTag --- .../securesms/preferences/SettingsActivity.kt | 11 +++++------ .../java/org/thoughtcrime/securesms/ui/Util.kt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index 50127be81d..83fca7fe7a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -45,7 +45,6 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -58,11 +57,9 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager import com.canhub.cropper.CropImageContract import com.squareup.phrase.Phrase import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.launch @@ -80,7 +77,9 @@ import org.thoughtcrime.securesms.debugmenu.DebugActivity import org.thoughtcrime.securesms.home.PathActivity import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity import org.thoughtcrime.securesms.permissions.Permissions -import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.* +import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.NoAvatar +import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.TempAvatar +import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogState.UserAvatar import org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity import org.thoughtcrime.securesms.recoverypassword.RecoveryPasswordActivity import org.thoughtcrime.securesms.ui.AlertDialog @@ -91,10 +90,10 @@ import org.thoughtcrime.securesms.ui.Divider import org.thoughtcrime.securesms.ui.GetString import org.thoughtcrime.securesms.ui.LargeItemButton import org.thoughtcrime.securesms.ui.LargeItemButtonWithDrawable -import org.thoughtcrime.securesms.ui.components.CircularProgressIndicator import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton import org.thoughtcrime.securesms.ui.components.PrimaryOutlineCopyButton import org.thoughtcrime.securesms.ui.contentDescription +import org.thoughtcrime.securesms.ui.qaTag import org.thoughtcrime.securesms.ui.setThemedContent import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.theme.LocalDimensions @@ -518,7 +517,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { ) { startAvatarSelection() } - .testTag(stringResource(R.string.AccessibilityId_avatarPicker)) + .qaTag(stringResource(R.string.AccessibilityId_avatarPicker)) .background( shape = CircleShape, color = LocalColors.current.backgroundBubbleReceived, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt index 3dec8d5a2e..de2271162d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt @@ -6,7 +6,12 @@ import android.content.ContextWrapper import android.view.View import android.view.ViewTreeObserver import androidx.compose.runtime.Composable +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.fragment.app.Fragment import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.PermissionState @@ -71,3 +76,15 @@ inline fun T.afterMeasured(crossinline block: T.() -> Unit) { } }) } + +/** + * This is used to set the test tag that the QA team can use to retrieve an element in appium + * In order to do so we need to set the testTagsAsResourceId to true, which ideally should be done only once + * in the root composable, but our app is currently made up of multiple isolated composables + * set up in the old activity/fragment view system + * As such we need to repeat it for every component that wants to use testTag, until such + * a time as we have one root composable + */ +@OptIn(ExperimentalComposeUiApi::class) +@Composable +fun Modifier.qaTag(tag: String) = semantics { testTagsAsResourceId = true }.testTag(tag) \ No newline at end of file