Skip to content

Commit 3b7dfd5

Browse files
committed
address PR comments
1 parent cb89e24 commit 3b7dfd5

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

app/src/androidTest/java/com/google/jetpackcamera/utils/ComposeTestRuleExt.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ import com.google.jetpackcamera.ui.components.capture.BTN_QUICK_SETTINGS_HDR_OPT
7272
import com.google.jetpackcamera.ui.components.capture.CAPTURE_BUTTON
7373
import com.google.jetpackcamera.ui.components.capture.CAPTURE_MODE_TOGGLE_BUTTON
7474
import com.google.jetpackcamera.ui.components.capture.ELAPSED_TIME_TAG
75+
import com.google.jetpackcamera.ui.components.capture.FLIP_CAMERA_BUTTON
7576
import com.google.jetpackcamera.ui.components.capture.QUICK_SETTINGS_BOTTOM_SHEET
7677
import com.google.jetpackcamera.ui.components.capture.R as CaptureR
78+
import com.google.jetpackcamera.ui.components.capture.ROW_QUICK_SETTINGS_ASPECT_RATIO
79+
import com.google.jetpackcamera.ui.components.capture.ROW_QUICK_SETTINGS_CAPTURE_MODE
7780
import com.google.jetpackcamera.ui.components.capture.SETTINGS_BUTTON
7881
import com.google.jetpackcamera.ui.components.capture.SNACKBAR_NODE_TAG
82+
import com.google.jetpackcamera.ui.uistateadapter.capture.R
7983
import org.junit.AssumptionViolatedException
8084

8185
/**
@@ -269,7 +273,7 @@ fun ComposeTestRule.pressAndDragToLockVideoRecording(
269273
checkWhileWaiting: () -> Unit = {
270274
// If the video capture fails, there is no point to continue waiting. Assert.
271275
onNodeWithText(
272-
com.google.jetpackcamera.ui.uistateadapter.capture.R.string.toast_video_capture_failure
276+
R.string.toast_video_capture_failure
273277
).assertIsNotDisplayed()
274278
}
275279
) {
@@ -304,7 +308,7 @@ fun ComposeTestRule.longClickForVideoRecordingCheckingElapsedTime(
304308
checkWhileWaiting: () -> Unit = {
305309
// If the video capture fails, there is no point to continue waiting. Assert.
306310
onNodeWithText(
307-
com.google.jetpackcamera.ui.uistateadapter.capture.R.string.toast_video_capture_failure
311+
R.string.toast_video_capture_failure
308312
).assertIsNotDisplayed()
309313
}
310314
) {
@@ -447,7 +451,7 @@ fun ComposeTestRule.isHdrEnabled(): Boolean {
447451

448452
fun ComposeTestRule.getCurrentLensFacing(): LensFacing {
449453
onNodeWithTag(
450-
com.google.jetpackcamera.ui.components.capture.FLIP_CAMERA_BUTTON
454+
FLIP_CAMERA_BUTTON
451455
).fetchSemanticsNode(
452456
"Flip camera button is not visible on main screen."
453457
).let { node ->
@@ -486,22 +490,30 @@ fun ComposeTestRule.getCurrentFlashMode(): FlashMode = visitQuickSettings {
486490

487491
fun ComposeTestRule.getCurrentCaptureMode(): CaptureMode = visitQuickSettings {
488492
val standardRowExists = onAllNodesWithTag(
489-
com.google.jetpackcamera.ui.components.capture.ROW_QUICK_SETTINGS_CAPTURE_MODE
493+
ROW_QUICK_SETTINGS_CAPTURE_MODE
490494
).fetchSemanticsNodes().isNotEmpty()
491495

492496
if (standardRowExists) {
493497
return@visitQuickSettings CaptureMode.STANDARD
494498
}
495499

496500
val aspectRatioRowExists = onAllNodesWithTag(
497-
com.google.jetpackcamera.ui.components.capture.ROW_QUICK_SETTINGS_ASPECT_RATIO
501+
ROW_QUICK_SETTINGS_ASPECT_RATIO
498502
).fetchSemanticsNodes().isNotEmpty()
499503

500504
if (aspectRatioRowExists) {
501505
return@visitQuickSettings CaptureMode.IMAGE_ONLY
502506
}
503507

504-
return@visitQuickSettings CaptureMode.VIDEO_ONLY
508+
val videoSettingsTitleExists = onAllNodes(
509+
hasText(getResString(CaptureR.string.quick_settings_title_video_settings))
510+
).fetchSemanticsNodes().isNotEmpty()
511+
512+
if (videoSettingsTitleExists) {
513+
return@visitQuickSettings CaptureMode.VIDEO_ONLY
514+
}
515+
516+
throw AssertionError("Unable to determine capture mode from quick settings")
505517
}
506518

507519
// ////////////////////////////

0 commit comments

Comments
 (0)