Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.compose.ui.platform

import androidx.compose.ui.Modifier

/**
* Applies the test tag in debug builds.
*/
fun Modifier.debugTestTag(tag: String): Modifier = this.testTag(tag)
Comment thread
davidjiagoogle marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.debugTestTag
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
Expand Down Expand Up @@ -128,7 +129,7 @@ fun PermissionTemplate(
modifier = Modifier
.height(IntrinsicSize.Min)
.align(Alignment.CenterHorizontally)
.testTag(testTag),
.debugTestTag(testTag),
painter = painter,
accessibilityText = iconAccessibilityText
)
Expand All @@ -144,7 +145,7 @@ fun PermissionTemplate(
// permission button section
PermissionButtonSection(
modifier = Modifier
.testTag(REQUEST_PERMISSION_BUTTON)
.debugTestTag(REQUEST_PERMISSION_BUTTON)
.fillMaxWidth()
.align(Alignment.CenterHorizontally)
.height(IntrinsicSize.Min),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.compose.ui.platform

import androidx.compose.ui.Modifier

/**
* No-op in release builds (inlined to prevent execution and string overhead).
*/
inline fun Modifier.debugTestTag(tag: String): Modifier = this
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.compose.ui.platform

import androidx.compose.ui.Modifier

/**
* Applies the test tag in debug builds.
*/
fun Modifier.debugTestTag(tag: String): Modifier = this.testTag(tag)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.debugTestTag
import androidx.compose.ui.platform.testTag
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.media3.common.util.UnstableApi
Expand Down Expand Up @@ -142,7 +143,7 @@ fun PostCaptureComponent(
if (snackBarData != null) {
snackBarController?.let {
TestableSnackbar(
modifier = modifier.testTag(snackBarData.testTag),
modifier = modifier.debugTestTag(snackBarData.testTag),
snackbarToShow = snackBarData,
snackbarHostState = snackbarHostState,
snackBarController = snackBarController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.platform.debugTestTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -82,7 +82,7 @@ fun ImageFromBitmap(modifier: Modifier, bitmap: Bitmap) {
Image(
bitmap = bitmap.asImageBitmap(),
contentDescription = stringResource(R.string.post_capture_image_description),
modifier = modifier.testTag(VIEWER_POST_CAPTURE_IMAGE)
modifier = modifier.debugTestTag(VIEWER_POST_CAPTURE_IMAGE)
)
}

Expand All @@ -92,7 +92,7 @@ fun VideoPlayer(modifier: Modifier, player: Player?) {
val presentationState = rememberPresentationState(player)
ContentFrame(
modifier = modifier
.testTag(VIEWER_POST_CAPTURE_VIDEO)
.debugTestTag(VIEWER_POST_CAPTURE_VIDEO)
.resizeWithContentScale(
ContentScale.Fit,
presentationState.videoSizeDp
Expand All @@ -111,7 +111,7 @@ fun VideoPlayer(modifier: Modifier, player: Player?) {
fun ExitPostCaptureButton(onExitPostCapture: () -> Unit, modifier: Modifier = Modifier) {
PostCaptureIconButton(
modifier = modifier
.testTag(BUTTON_POST_CAPTURE_EXIT),
.debugTestTag(BUTTON_POST_CAPTURE_EXIT),
onClick = onExitPostCapture
) {
Icon(
Expand All @@ -134,7 +134,7 @@ fun ShareCurrentMediaButton(
PostCaptureIconButton(
onClick = onClick,
modifier = modifier
.testTag(BUTTON_POST_CAPTURE_SHARE),
.debugTestTag(BUTTON_POST_CAPTURE_SHARE),
enabled = enabled

) {
Expand All @@ -158,7 +158,7 @@ fun ShareCurrentMediaButton(
fun SaveCurrentMediaButton(onClick: () -> Unit, modifier: Modifier = Modifier) {
PostCaptureIconButton(
modifier = modifier
.testTag(BUTTON_POST_CAPTURE_SAVE),
.debugTestTag(BUTTON_POST_CAPTURE_SAVE),
onClick = onClick
) {
Icon(
Expand All @@ -177,7 +177,7 @@ fun DeleteCurrentMediaButton(
enabled: Boolean = true
) {
PostCaptureIconButton(
modifier = modifier.testTag(BUTTON_POST_CAPTURE_DELETE),
modifier = modifier.debugTestTag(BUTTON_POST_CAPTURE_DELETE),
onClick = onClick,
enabled = enabled
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.compose.ui.platform

import androidx.compose.ui.Modifier

/**
* No-op in release builds (inlined to prevent execution and string overhead).
*/
inline fun Modifier.debugTestTag(tag: String): Modifier = this
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.debugTestTag
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -394,7 +395,7 @@ private fun ContentScreen(
videoQualityIndicator = {
VideoQualityIcon(
captureUiState.videoQuality,
Modifier.testTag(VIDEO_QUALITY_TAG)
Modifier.debugTestTag(VIDEO_QUALITY_TAG)
)
},
stabilizationIndicator = {
Expand Down Expand Up @@ -453,7 +454,7 @@ private fun ContentScreen(
},
flipCameraButton = {
FlipCameraButton(
modifier = Modifier.testTag(FLIP_CAMERA_BUTTON),
modifier = Modifier.debugTestTag(FLIP_CAMERA_BUTTON),
onClick = onFlipCamera,
flipLensUiState = captureUiState.flipLensUiState,
// enable only when phone has front and rear camera
Expand All @@ -480,7 +481,7 @@ private fun ContentScreen(
exit = fadeOut(animationSpec = tween(delayMillis = 1_500))
) {
ElapsedTimeText(
modifier = Modifier.testTag(ELAPSED_TIME_TAG),
modifier = Modifier.debugTestTag(ELAPSED_TIME_TAG),
elapsedTimeUiState = captureUiState.elapsedTimeUiState
)
}
Expand Down Expand Up @@ -519,7 +520,7 @@ private fun ContentScreen(

quickSettingsController = quickSettingsController,
snackBarController = snackBarController,
modifier = it.testTag(CAPTURE_MODE_TOGGLE_BUTTON)
modifier = it.debugTestTag(CAPTURE_MODE_TOGGLE_BUTTON)
)
}
},
Expand Down Expand Up @@ -576,7 +577,7 @@ private fun ContentScreen(
if (snackBarData != null) {
snackBarController?.let { snackBarController ->
TestableSnackbar(
modifier = modifier.testTag(snackBarData.testTag),
modifier = modifier.debugTestTag(snackBarData.testTag),
snackbarToShow = snackBarData,
snackbarHostState = snackbarHostState,
snackBarController = snackBarController
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.compose.ui.platform

import androidx.compose.ui.Modifier

/**
* Applies the test tag in debug builds.
*/
fun Modifier.debugTestTag(tag: String): Modifier = this.testTag(tag)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.platform.debugTestTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -130,7 +130,7 @@ private fun SettingsScreen(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
SettingsPageHeader(
modifier = Modifier.testTag(SETTINGS_TITLE),
modifier = Modifier.debugTestTag(SETTINGS_TITLE),
title = stringResource(id = R.string.settings_title),
navBack = onNavigateBack,
scrollBehavior = scrollBehavior
Expand Down
Loading
Loading