Skip to content

Implement animation disable mechanism for instrumentation tests#519

Open
temcguir wants to merge 14 commits into
mainfrom
temcguir/disable_animations
Open

Implement animation disable mechanism for instrumentation tests#519
temcguir wants to merge 14 commits into
mainfrom
temcguir/disable_animations

Conversation

@temcguir

Copy link
Copy Markdown
Collaborator

Problem

Continuous animations (like screen flash, focus pulse, audio amplitude) keep the Compose runtime busy, causing Espresso's idle checks to fail or time out on slow emulators.

Solution

Implemented a LocalDisableAnimations CompositionLocal to provide a flag to disable or snap animations.

  • Provided from MainActivity based on an intent extra.
  • Set in UiTestUtil via TestStorage arguments passed from the build configuration.
  • Updated various components to respect this local and snap animations or use fixed states.

Impact

Drastically reduces CPU load and Espresso timeouts by stopping background animations during tests.

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

Copy link
Copy Markdown
Contributor

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 introduces a mechanism to disable animations within the application, primarily for testing purposes. It adds a LocalDisableAnimations CompositionLocal, updates MainActivity to read a disable_animations flag from TestStorage or an intent extra, and modifies various UI components to bypass animations when this flag is active. The review feedback focuses on making the implementation more idiomatic to Jetpack Compose by using conditional transitions within AnimatedVisibility and animateFloatAsState instead of manual if-else blocks, which reduces code duplication and nesting.

Comment thread app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt Outdated
temcguir added a commit that referenced this pull request May 15, 2026
@temcguir temcguir changed the base branch from main to temcguir/gesture_sync_fixes May 22, 2026 15:53
@temcguir temcguir force-pushed the temcguir/gesture_sync_fixes branch from f690aa2 to f0645f5 Compare June 4, 2026 06:11
@temcguir temcguir force-pushed the temcguir/disable_animations branch from 6729224 to 5a8505a Compare June 8, 2026 19:40
@temcguir temcguir force-pushed the temcguir/gesture_sync_fixes branch from 7f851fe to 91972d9 Compare June 8, 2026 19:47
Base automatically changed from temcguir/gesture_sync_fixes to main June 8, 2026 21:57
@temcguir temcguir force-pushed the temcguir/disable_animations branch from e68a94a to d53a760 Compare June 8, 2026 23:37
@temcguir temcguir force-pushed the temcguir/disable_animations branch from 15c632d to 55e516e Compare June 9, 2026 00:16
@temcguir temcguir force-pushed the temcguir/disable_animations branch from 55e516e to 744111f Compare June 9, 2026 00:18
@temcguir temcguir force-pushed the temcguir/disable_animations branch from cd0685f to 88f4489 Compare June 9, 2026 00:39
@temcguir temcguir force-pushed the temcguir/disable_animations branch from 88f4489 to 69475db Compare June 9, 2026 00:40
@temcguir temcguir marked this pull request as ready for review June 9, 2026 01:41
@temcguir

temcguir commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 introduces a mechanism to disable animations during tests by adding a LocalDisableAnimations CompositionLocal and passing a KEY_DISABLE_ANIMATIONS extra through the MainActivity intent. This flag is then used across various UI components to bypass or snap animations. The review feedback suggests replacing an arbitrary delay(50) in ScreenFlashOverlay with yield() to prevent test flakiness, and using EnterTransition.None instead of fadeIn(animationSpec = snap()) in LockSwitchCaptureButtonNucleus for architectural consistency.

@temcguir temcguir requested a review from Kimblebee June 9, 2026 17:50
}

is Success -> {
// TODO(kimblebee@): add app setting to enable/disable dynamic color

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.

can get rid of this todo

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