Skip to content

Fix intent extras merging and usage in VideoRecordingDeviceTest#516

Open
temcguir wants to merge 9 commits into
temcguir/elapsed_time_optfrom
temcguir/intent_extras_fix
Open

Fix intent extras merging and usage in VideoRecordingDeviceTest#516
temcguir wants to merge 9 commits into
temcguir/elapsed_time_optfrom
temcguir/intent_extras_fix

Conversation

@temcguir
Copy link
Copy Markdown
Collaborator

Problem

The special logic to force "SingleLensMode" on emulators via compatMainActivityExtras was being lost when tests passed custom extras, or not used at all in tests returning results.

Solution

  • Fixed runMainActivityScenarioTest in UiTestUtil.kt to properly merge compatMainActivityExtras with provided extras.
  • Updated tests in VideoRecordingDeviceTest.kt to use runMainActivityScenarioTestForResult which handles this merging.

Impact

Ensures emulators always run in single lens mode where intended, avoiding initialization timeouts.

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
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt Outdated
@temcguir temcguir marked this pull request as ready for review May 15, 2026 22:11
Comment on lines +84 to +87
val disableAnimations = args["disable_animations"]?.toBoolean() ?: false
if (disableAnimations) {
extras.putBoolean("KEY_DISABLE_ANIMATIONS", true)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this work?

) = runScenarioTest<MainActivity>(extras ?: compatMainActivityExtras, block)
) {
val activityExtras = mergeWithCompatExtras(extras)
runScenarioTest<MainActivity>(activityExtras, block)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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? {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the visibility modifier here is causing runMainActivityScenarioTest and runMainActivityScenarioTestForResult to fail.

# Conflicts:
#	app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
@temcguir temcguir changed the base branch from main to temcguir/elapsed_time_opt May 22, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants