-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[google_maps_flutter] Remove use of OCMock #10863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 refactors the iOS native unit tests for google_maps_flutter by eliminating the use of OCMock. It introduces new protocols (FGMAssetProvider, FGMMapEventDelegate, FGMTileProviderDelegate) and their concrete implementations to allow for dependency injection, thereby improving testability. The changes include updating controller initializers to use these new delegates/providers and replacing OCMock-based test setups with custom fakes and direct assertions. The CHANGELOG.md and pubspec.yaml have been updated to reflect these changes. The refactoring is comprehensive and aligns well with the stated objective of improving testability.
| // GMSCameraUpdate is not inspectable, so this test just ensures that the codepath | ||
| // doesn't throw. FGMGetCameraUpdateForPigeonCameraUpdate is simple enough that | ||
| // injecting a wrapper would not meaningfully improve test coverage, since the non-test | ||
| // implementation would be about as complex as the conversion function itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This set of changes is the only place where this PR actually removes test coverage. The only way to test this without the static class mock (the worst kind of OCMock mocking, so I would want to eliminate this even without OCMock being problematic for Swift migration) would be to make a factory protocol that wraps all of the static factor methods on GMSCameraUpdate.
I did seriously consider that, but the implementation being tested is almost as simple as the wrapper class we would need to write—by intentional design of FGMPlatformCameraUpdate being a direct parallel of GMSCameraUpdate. That wrapper class wouldn't be testable, so it felt like it would be improving test coverage on paper without meaningfully adding any real coverage.
If anyone feels strongly the other way, I can add the wrapper.
Eliminates usage of OCMock in the native iOS unit tests:
Unblocks flutter/flutter#119108
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3