Fix cross-test interference in SingleLensModeTest#481
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Added CameraXResetRule to ensure CameraX is shut down before and after tests that require specific configuration (e.g. SingleLensModeTest). This prevents failures where a previous test initializes CameraX, causing subsequent calls to ProcessCameraProvider.configureInstance to be ignored, and ensures SingleLensModeTest doesn't pollute the state for subsequent tests. This allows the test to be run in a non-orchestrator environment without affecting other tests. The rule uses ProcessCameraProvider.shutdownAsync() to perform the reset with a 10-second timeout to prevent indefinite hanging while allowing sufficient time for resource release. To ensure this method is available at runtime in the test process, androidx.camera:camera-lifecycle was added as a test dependency.
6a8feaf to
4fcf83d
Compare
Collaborator
Author
|
/gemini review |
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a CameraXResetRule to prevent test interference by resetting CameraX state between tests. This is a great addition for improving test stability. The implementation is solid, adding the necessary dependency and applying the rule where needed. I've suggested one improvement to the CameraXResetRule implementation to simplify it by using a more direct static API from CameraX, which makes the utility more robust and easier to read.
davidjiagoogle
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added CameraXResetRule to ensure CameraX is shut down before and after
tests that require specific configuration (e.g. SingleLensModeTest).
This prevents failures where a previous test initializes CameraX, causing
subsequent calls to ProcessCameraProvider.configureInstance to be
ignored, and ensures SingleLensModeTest doesn't pollute the state for
subsequent tests. This allows the test to be run in a non-orchestrator
environment without affecting other tests.
The rule uses ProcessCameraProvider.shutdownAsync() to perform the reset
with a 10-second timeout to prevent indefinite hanging while allowing
sufficient time for resource release. To ensure this method is available
at runtime in the test process, androidx.camera:camera-lifecycle was
added as a test dependency.