[google_maps_flutter] Use structured Pigeon data on iOS#8142
[google_maps_flutter] Use structured Pigeon data on iOS#8142auto-submit[bot] merged 16 commits intoflutter:mainfrom
Conversation
| expect((await stream.next).value.value, equals(objectId)); | ||
| }); | ||
|
|
||
| test('moveCamera calls through with expected newCameraPosition', () async { |
There was a problem hiding this comment.
There didn't used to be any camera update Dart unit testing; it was added during the Android update, and I brought them over here.
| XCTAssertEqual(resultImage.size.width, 15.0); | ||
| XCTAssertEqual(resultImage.size.height, 45.0); | ||
| XCTAssertEqual(resultImage.size.width, width); | ||
| XCTAssertEqual(resultImage.size.height, height); |
There was a problem hiding this comment.
I didn't do it everywhere since it would have been a pretty deep rabbit hole, but I did a bit of opportunistic updating from "tests use repeated magic values" to "tests use named constants for things that should match in multiple places".
There was a problem hiding this comment.
Commented above before I got to this comment, but thank you. Much nicer.
| visible:YES | ||
| zIndex:1 | ||
| markerId:markerId2 | ||
| clusterManagerId:clusterManagerId]; |
There was a problem hiding this comment.
Some of the test setup (not just in this file) got a lot more verbose because they used to rely on the code tolerating missing JSON entries that weren't really supposed to be missing.
| XCTAssertNotNil(polylineController.polyline.spans); | ||
| } | ||
|
|
||
| - (void)testStrokeStylesFromPatterns { |
There was a problem hiding this comment.
This test moved to the (increasingly poorly named; we can rename it as the final step after heatmaps are converted) JSON conversion test file, since that's where the code it is testing lives. I'm not sure why it was here, especially since it's companion length-extraction-method test was already there.
| + (NSArray<NSArray<CLLocation *> *> *)holesFromPointsArray:(NSArray *)data; | ||
| + (nullable GMSCameraPosition *)cameraPostionFromDictionary:(nullable NSDictionary *)channelValue; | ||
| + (GMSCoordinateBounds *)coordinateBoundsFromLatLongs:(NSArray *)latlongs; | ||
| + (nullable GMSCameraUpdate *)cameraUpdateFromArray:(NSArray *)channelValue; |
There was a problem hiding this comment.
The reason these are moved instead of just renamed is that I'm chipping away at the functions-as-bag-of-static-methods-on-a-fake-class approach that the JSON conversion methods used, to the IMO-cleaner functions-as-functions approach. Once the conversion is complete this class will be gone.
| return self.tileOverlayIdentifierToController[identifier]; | ||
| } | ||
|
|
||
| + (NSString *)identifierForTileOverlay:(NSDictionary *)tileOverlay { |
There was a problem hiding this comment.
I got rid of these helpers in a bunch of files because with structured classes they became trivial.
| NSArray *pointArray = polygon[@"points"]; | ||
| NSArray<CLLocation *> *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:pointArray]; | ||
| GMSMutablePath *path = [GMSMutablePath path]; | ||
| for (CLLocation *location in points) { |
There was a problem hiding this comment.
This array conversion logic was duplicated in several places, so I consolidated it to the new FGMGetPathFromPoints.
| /// | ||
| /// @param polyline The polyline instance for which path is calculated. | ||
| /// @return An instance of GMSMutablePath. | ||
| + (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; |
There was a problem hiding this comment.
This is one of the things replaced by FGMGetPathFromPoints, so is tested that way instead.
| @"imagePixelRatio" : @1, | ||
| @"width" : @15.0 | ||
| }; // Target height | ||
| const CGFloat width = 15.0; |
| [FGMPlatformPatternItem makeWithType:FGMPlatformPatternItemTypeGap length:@(1)], | ||
| [FGMPlatformPatternItem makeWithType:FGMPlatformPatternItemTypeDash length:@(1)] | ||
| ]; | ||
| UIColor *strokeColor = [UIColor redColor]; |
There was a problem hiding this comment.
Totally optional: Opportunistic UIColor.redColor here? And maybe patternStrokeStyle.count below? 😉
There was a problem hiding this comment.
Done. I also found all the other UIColor fixed colors and updated them to the new style.
| return [UIColor colorWithRed:((float)((rgba & 0xFF0000) >> 16)) / 255.0 | ||
| green:((float)((rgba & 0xFF00) >> 8)) / 255.0 | ||
| blue:((float)(rgba & 0xFF)) / 255.0 | ||
| alpha:((float)((rgba & 0xFF000000) >> 24)) / 255.0]; |
There was a problem hiding this comment.
I realise this is just moving but... technically (CGFloat) though in the end entirely the same thing.
There was a problem hiding this comment.
Fixed. It's technically not the same since CGFloat is double on all supported devices now, so we were pointlessly losing some precision (although probably not enough to actually matter in a color).
| _layer = tileLayer; | ||
| _mapView = mapView; | ||
| [self interpretTileOverlayOptions:optionsData]; | ||
| // TODO(stuartmorgan: Refactor to avoid this call to an instance method in init. |
| registrar:(NSObject<FlutterPluginRegistrar> *)registrar | ||
| screenScale:(CGFloat)screenScale { | ||
| NSAssert(screenScale > 0, @"Screen scale must be greater than 0"); | ||
| // See comment in messages.dart for why this is so loosely typed. |
There was a problem hiding this comment.
Maybe add the issue link for searchability? flutter/flutter#117819
| } | ||
| } | ||
|
|
||
| /// Convert [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. |
There was a problem hiding this comment.
Here and (a couple times, but not all times) below: ultra pedantic nit:
| /// Convert [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. | |
| /// Converts [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. |
There was a problem hiding this comment.
It's a nit I usually leave, so I'm happy to fix it :) I didn't notice when I pasted these in from Android.
| /// camera update, and each holds a different set of data, preventing the | ||
| /// use of a single unified class. | ||
| // Pigeon does not support inheritance, which prevents a more strict type | ||
| // bound. See https://github.com/flutter/flutter/issues/117819. |
There was a problem hiding this comment.
I'll take this TODO over the one above any day. 🙂
cbracken
left a comment
There was a problem hiding this comment.
LGTM modulo some pedantic nits. Much cleaner!
* main: (64 commits) [quick_actions_plaform_interface] add localizedSubtitle (flutter#8112) [tools] Don't check license of generated Swift package (flutter#8137) Roll Flutter from 8536b96 to 93d772c (37 revisions) (flutter#8147) [go_router] Fix: Consistent PopScope Handling on Root Routes issue #140869 (flutter#8045) [in_app_purchase_storekit] fix price displayed with wrong precision (flutter#8127) [pigeon] Removes the `@protected` annotation from the InstanceManager field of the `PigeonInternalProxyApiBaseClass` (flutter#8125) [google_maps_flutter] Use structured Pigeon data on iOS (flutter#8142) [vector_graphics] handle errors from bytes loader (flutter#8080) [flutter_svg] Fix SvgNetworkLoader not closing internal http client (flutter#8126) [video_player_avfoundation] send video load failure even when eventsink was initialized late (flutter#7194) [flutter_markdown] enable Wasm support (flutter#8120) Reverts "[url_launcher] Add Swift Package Manager integration to example app (flutter#8128)" (flutter#8136) [url_launcher] Add Swift Package Manager integration to example app (flutter#8128) [pigeon] Enable example app build in CI (flutter#8119) [in_app_purchase_storekit] disallow ios versions lower than supported from enabling storekit (flutter#8110) [interactive_media_ads]: Bump com.google.ads.interactivemedia.v3:interactivemedia from 3.35.1 to 3.36.0 in /packages/interactive_media_ads/android (flutter#8046) [interactive_media_ads]: Bump androidx.annotation:annotation from 1.8.2 to 1.9.1 in /packages/interactive_media_ads/android (flutter#7980) [webview_flutter_android] Updates plugin to use `ProxyApis`s (flutter#7794) [interactive_media_ads] Adds support to define parameters that control the rendering of ads (flutter#8057) Roll Flutter from b3818f6 to 8536b96 (22 revisions) (flutter#8124) ... # Conflicts: # packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md
flutter/packages@913b99e...9203213 2024-11-22 737941+loic-sharma@users.noreply.github.com Reland "[url_launcher] Add Swift Package Manager integration to example app" (flutter/packages#8148) 2024-11-22 meliksahcakirr@gmail.com [webview_flutter_wkwebview] Webkit webview controller multiple registration fix (flutter/packages#8078) 2024-11-22 1341156974@qq.com [quick_actions_plaform_interface] add localizedSubtitle (flutter/packages#8112) 2024-11-22 737941+loic-sharma@users.noreply.github.com [tools] Don't check license of generated Swift package (flutter/packages#8137) 2024-11-21 engine-flutter-autoroll@skia.org Roll Flutter from 8536b96 to 93d772c (37 revisions) (flutter/packages#8147) 2024-11-21 omar_hanafy@icloud.com [go_router] Fix: Consistent PopScope Handling on Root Routes issue #140869 (flutter/packages#8045) 2024-11-21 louisehsu@google.com [in_app_purchase_storekit] fix price displayed with wrong precision (flutter/packages#8127) 2024-11-21 10687576+bparrishMines@users.noreply.github.com [pigeon] Removes the `@protected` annotation from the InstanceManager field of the `PigeonInternalProxyApiBaseClass` (flutter/packages#8125) 2024-11-21 stuartmorgan@google.com [google_maps_flutter] Use structured Pigeon data on iOS (flutter/packages#8142) 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
Fixes a regression introduced during the migration to structured Pigeon data (#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Fixes a regression introduced during the migration to structured Pigeon data (flutter#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Fixes a regression introduced during the migration to structured Pigeon data (flutter/packages#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Fixes a regression introduced during the migration to structured Pigeon data (flutter/packages#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Fixes a regression introduced during the migration to structured Pigeon data (flutter#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Fixes a regression introduced during the migration to structured Pigeon data (flutter#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Fixes a regression introduced during the migration to structured Pigeon data (flutter#8142), where the info window data was not passed through to the underlying SDK marker object. This wasn't caught because there was apparently no native unit testing of marker properties, and this level of info window detail isn't inspected in integration tests. Adds missing tests, and backfills tests for other marker properties as well. Fixes flutter/flutter#159471 ## 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.
Converts most of the maps objects that were still using pre-Pigeon JSON serializations to use structured Pigeon classes instead, mirroring the recent work in the Android implementation:
In addition to adding type safety, this mostly finishes addressing technical debt dating back to the initial federation of the plugin, where native code in the implementation package is relying on the JSON serialization of objects that is implemented in the platform interface package, meaning that the stringly-typed data had to match across packages in addition to languages.
This also backports some Dart unit test improvements to the Android implementation. While bringing the test code over I noticed that the expectations were based on running the Pigeon serialization and then asserting things about the results, which I missed in review. That approach is very fragile because the Pigeon serialization is an internal implementation detail of Pigeon and subject to change at any time. Instead the tests should be using the object directly.
Part of flutter/flutter#117907
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///).