Fix intent extras merging and usage in VideoRecordingDeviceTest#516
Fix intent extras merging and usage in VideoRecordingDeviceTest#516temcguir wants to merge 9 commits into
Conversation
Fixed runMainActivityScenarioTest to merge compatMainActivityExtras with provided extras instead of ignoring them when extras are present. Updated VideoRecordingDeviceTest to use runMainActivityScenarioTestForResult instead of runScenarioTestForResult<MainActivity> to ensure compatMainActivityExtras are applied. TAG=agy CONV=ede7015c-6915-452c-91bf-1734f3aecca3
There was a problem hiding this comment.
Code Review
This pull request updates test utilities to support disabling animations through TestStorage and refactors MainActivity scenario tests to merge provided extras with compatibility settings. Feedback suggests adding KDoc documentation, using more restrictive visibility modifiers, removing debug logs, and extracting the extras-merging logic into a reusable helper function to improve maintainability and adhere to the DRY principle.
| val disableAnimations = args["disable_animations"]?.toBoolean() ?: false | ||
| if (disableAnimations) { | ||
| extras.putBoolean("KEY_DISABLE_ANIMATIONS", true) | ||
| } |
| ) = runScenarioTest<MainActivity>(extras ?: compatMainActivityExtras, block) | ||
| ) { | ||
| val activityExtras = mergeWithCompatExtras(extras) | ||
| runScenarioTest<MainActivity>(activityExtras, block) |
There was a problem hiding this comment.
Public-API inline function cannot access non-public-API function.
you'll need to update the visibility modifiers of this or mergeWithCompatExtras
| * @param extras The extras to merge with the compat extras. | ||
| * @return The merged bundle, or null if there are no extras. | ||
| */ | ||
| internal fun mergeWithCompatExtras(extras: Bundle?): Bundle? { |
There was a problem hiding this comment.
the visibility modifier here is causing runMainActivityScenarioTest and runMainActivityScenarioTestForResult to fail.
# Conflicts: # app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
# Conflicts: # app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Problem
The special logic to force "SingleLensMode" on emulators via
compatMainActivityExtraswas being lost when tests passed custom extras, or not used at all in tests returning results.Solution
runMainActivityScenarioTestinUiTestUtil.ktto properly mergecompatMainActivityExtraswith provided extras.VideoRecordingDeviceTest.ktto userunMainActivityScenarioTestForResultwhich handles this merging.Impact
Ensures emulators always run in single lens mode where intended, avoiding initialization timeouts.