Skip to content

Comments

parameterize capture tests#478

Open
Kimblebee wants to merge 4 commits intomainfrom
kim/parameterize-capture-tests
Open

parameterize capture tests#478
Kimblebee wants to merge 4 commits intomainfrom
kim/parameterize-capture-tests

Conversation

@Kimblebee
Copy link
Collaborator

Parameterize Image/Video capture tests to support both immediate and cache capture flows, reducing significant code duplication.

- separate concern for exiting postcapture screen. That is now checked in PostCaptureTest.kt
- centralized duplicate CacheParam util
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Kimblebee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the image and video capture end-to-end tests to leverage parameterization. By introducing the TestParameterInjector library, the tests can now cover both immediate and cached capture scenarios within a single test suite, eliminating redundant code and streamlining the testing process for different capture behaviors. This change improves test maintainability and ensures consistent validation across various capture modes.

Highlights

  • Test Parameterization: Image and video capture tests have been parameterized using TestParameterInjector to support both immediate and cached capture flows, significantly reducing code duplication across test cases.
  • Test File Consolidation: Dedicated test files for cached image and video capture (CachedImageCaptureDeviceTest.kt, CachedVideoRecordingDeviceTest.kt) were removed, as their functionality is now integrated into the main ImageCaptureDeviceTest.kt and VideoRecordingDeviceTest.kt through parameterization.
  • Build Dependency Update: The testParameterInjector library was added to the app/build.gradle.kts and gradle/libs.versions.toml files to enable the new parameterized testing approach.
  • Post-Capture Test Enhancement: A new test case was added to PostCaptureTest.kt to verify the ability to exit the post-capture screen after an image capture, ensuring proper flow and media handling.
  • Utility Functionality: A CacheParam enum and an expectedNumFiles extension function were introduced in UiTestUtil.kt to manage test parameters and dynamically adjust expected file counts based on the capture flow (cached vs. non-cached).

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • app/build.gradle.kts
    • Added testParameterInjector as an androidTestImplementation dependency.
  • app/src/androidTest/java/com/google/jetpackcamera/CachedImageCaptureDeviceTest.kt
    • Removed the file, as its tests were merged into ImageCaptureDeviceTest.kt.
  • app/src/androidTest/java/com/google/jetpackcamera/CachedVideoRecordingDeviceTest.kt
    • Removed the file, as its tests were merged into VideoRecordingDeviceTest.kt.
  • app/src/androidTest/java/com/google/jetpackcamera/ImageCaptureDeviceTest.kt
    • Updated the test runner from AndroidJUnit4 to TestParameterInjector.
    • Introduced a cacheParam test parameter to differentiate between cached and non-cached capture flows.
    • Modified existing image capture tests to use cacheParam for conditional logic related to post-capture navigation or success tag visibility.
    • Updated runMainActivityScenarioTestForResult calls to pass cacheParam.extras.
  • app/src/androidTest/java/com/google/jetpackcamera/PostCaptureTest.kt
    • Added a new test captureImage_navigatesPostcapture_canExit to verify exiting the post-capture screen.
  • app/src/androidTest/java/com/google/jetpackcamera/VideoRecordingDeviceTest.kt
    • Updated the test runner from AndroidJUnit4 to TestParameterInjector.
    • Introduced a cacheParam test parameter to differentiate between cached and non-cached video recording flows.
    • Modified existing video recording tests to use cacheParam for conditional logic related to post-capture navigation or success tag visibility.
    • Updated runScenarioTestForResult calls to pass cacheParam.activityExtras.
  • app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
    • Added CacheParam enum to represent cache states and their associated Bundle extras.
    • Implemented expectedNumFiles() extension function for CacheParam to return the expected number of files.
    • Adjusted runMainActivityMediaStoreAutoDeleteScenarioTest to conditionally collect media store entries only when expectedNumFiles is greater than zero.
  • gradle/libs.versions.toml
    • Added testParameterInjector version definition.
    • Added testParameterInjector library mapping.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 is a great refactoring that successfully parameterizes the image and video capture tests using TestParameterInjector. This has significantly reduced code duplication by allowing the removal of CachedImageCaptureDeviceTest.kt and CachedVideoRecordingDeviceTest.kt. My feedback focuses on further improving maintainability by extracting some newly duplicated verification logic within the parameterized tests into helper functions, in line with the project's style guide.

@Kimblebee Kimblebee marked this pull request as ready for review February 18, 2026 18:51
@davidjiagoogle
Copy link
Collaborator

drag_to_lock_pressed_video_capture[WITH_CACHE] is failing on Pixel2

@davidjiagoogle
Copy link
Collaborator

The test failure should be fixed by the removal of MultipleEventCutter. Please pull and try again

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