Skip to content

Conversation

@camsim99
Copy link
Contributor

@camsim99 camsim99 commented May 30, 2023

Ensures that InstanceManager is mocked (once) for all camera_android_camerax tests.

Fixes flutter/flutter#127661.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@camsim99 camsim99 marked this pull request as draft May 30, 2023 18:11
@camsim99 camsim99 changed the title [camerax] Mock InstanceManager in image capture test [camerax] Mock InstanceManager in unit tests May 30, 2023
@camsim99 camsim99 requested a review from stuartmorgan-g May 31, 2023 15:19
@camsim99 camsim99 marked this pull request as ready for review May 31, 2023 15:19
Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Can you elaborate a bit on what the issue is and how this fixes it? I'm not sure what exactly the effect of this PR is, and usually test setup being global rather than per-test causes issues

@@ -1,3 +1,7 @@
## NEXT

* Updates tests to mock `InstanceManager` to fix unit test flake.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't need a changelog change, since it's dev-only.

@camsim99
Copy link
Contributor Author

Can you elaborate a bit on what the issue is and how this fixes it? I'm not sure what exactly the effect of this PR is, and usually test setup being global rather than per-test causes issues

I think calls to an InstanceManager's method clear() is causing the flake, and by mocking for all tests, we ensure that it doesn't actually get called. An InstanceManager instance is used in essentially all the tests except for those testing detached constructors, so I think it makes sense to mock it globally, and shouldn't cause any issues.

I would defer to @bparrishMines, though. Any feedback on this?

Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

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

LGTM

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2023
@auto-submit auto-submit bot merged commit 75085ed into flutter:main Jun 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 2, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 2, 2023
flutter/packages@f0513ae...75085ed

2023-06-02 [email protected] [camerax] Mock `InstanceManager` in unit tests (flutter/packages#4121)
2023-06-01 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.core:core from 1.9.0 to 1.10.1 in /packages/image_picker/image_picker_android/android (flutter/packages#3991)
2023-06-01 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump org.jetbrains.kotlin:kotlin-bom from 1.8.10 to 1.8.21 in /packages/image_picker/image_picker_android/android (flutter/packages#4054)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: camera

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[camera] CameraX unit tests are flaky

3 participants