-
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
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.
...es/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerTests/TestMapEventHandler.h
Outdated
Show resolved
Hide resolved
...er_ios/Sources/google_maps_flutter_ios/include/google_maps_flutter_ios/FGMMapEventDelegate.h
Show resolved
Hide resolved
| zoomLevel:nil] | ||
| withMapView:[GoogleMapsGroundOverlayControllerTests mapView] | ||
| registrar:nil | ||
| assetProvider:[[TestAssetProvider alloc] init] |
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.
Why is this not nil?
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.
It's supposed to be a non-nullable parameter (IIRC I fix all the missing NS_ASSUME_NONNULL_BEGIN in test headers in a follow-up PR I have ready; I didn't notice them in this one).
Historically we have a lot of places where we play fast and loose in tests with passing nil in places that are (explicitly declared or just assumed in implementations) non-nullable, which generally works because Obj-C, but it makes Swift migrations more painful. So I tried to provide stubs instead of taking shortcuts.
...ps_flutter/google_maps_flutter_ios/example/ios/RunnerTests/GoogleMapsMarkerControllerTests.m
Show resolved
Hide resolved
vashworth
left a comment
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.
LGTM with a couple small comments
flutter/packages@5b1bea8...3bddf2c 2026-02-04 ivan-vanyusho@yandex-team.ru [camera_avfoundation] ios saving path (flutter/packages#10832) 2026-02-04 stuartmorgan@google.com [video_player] Remove OCMock (flutter/packages#10932) 2026-02-04 stuartmorgan@google.com [google_maps_flutter] Remove use of OCMock (flutter/packages#10863) 2026-02-04 32538273+ValentinVignal@users.noreply.github.com [go_router_builder] Add support for `@TypedGoRouteParameter` to customize parameter names (flutter/packages#10793) 2026-02-03 engine-flutter-autoroll@skia.org Roll Flutter from c305f1f to bf701fe (9 revisions) (flutter/packages#10957) 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 flutter-ecosystem@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#181918) flutter/packages@5b1bea8...3bddf2c 2026-02-04 ivan-vanyusho@yandex-team.ru [camera_avfoundation] ios saving path (flutter/packages#10832) 2026-02-04 stuartmorgan@google.com [video_player] Remove OCMock (flutter/packages#10932) 2026-02-04 stuartmorgan@google.com [google_maps_flutter] Remove use of OCMock (flutter/packages#10863) 2026-02-04 32538273+ValentinVignal@users.noreply.github.com [go_router_builder] Add support for `@TypedGoRouteParameter` to customize parameter names (flutter/packages#10793) 2026-02-03 engine-flutter-autoroll@skia.org Roll Flutter from c305f1f to bf701fe (9 revisions) (flutter/packages#10957) 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 flutter-ecosystem@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
In #10863 I intermediated asset loading through an asset loader, so that individual controllers weren't using the plugin registrar directly. In doing that, I just updated the types of the ivars, but—incorrectly—not their memory models. Registrar references are generally `weak` to avoid possible cycles (the registrar may internally be the same thing in the engine that owns the plugin instance), so the result was a weak reference to the new wrapper object. However, unlike the registrar, which has an externally enforced lifetime longer than the plugin, the wrapper was just an object created locally during map controller initialization, so was invalidated almost as soon as it was passed in. This fixes the controllers to keep strong references to the wrapper (which doesn't own anything, and has a weak registrar pointer, so can't create any cycles). Fixes flutter/flutter#182149 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
…r#181918) flutter/packages@5b1bea8...3bddf2c 2026-02-04 ivan-vanyusho@yandex-team.ru [camera_avfoundation] ios saving path (flutter/packages#10832) 2026-02-04 stuartmorgan@google.com [video_player] Remove OCMock (flutter/packages#10932) 2026-02-04 stuartmorgan@google.com [google_maps_flutter] Remove use of OCMock (flutter/packages#10863) 2026-02-04 32538273+ValentinVignal@users.noreply.github.com [go_router_builder] Add support for `@TypedGoRouteParameter` to customize parameter names (flutter/packages#10793) 2026-02-03 engine-flutter-autoroll@skia.org Roll Flutter from c305f1f to bf701fe (9 revisions) (flutter/packages#10957) 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 flutter-ecosystem@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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