This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Use an interface for test inspection #6116
Merged
auto-submit
merged 8 commits into
flutter:main
from
stuartmorgan-g:maps-inpector-interface
Jul 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
75beb20
Initial interface
stuartmorgan-g c82129c
Temp path-based dependencies
stuartmorgan-g 26e5ce6
Rewrite inspector implementation, and update tests
stuartmorgan-g b7be796
override oops
stuartmorgan-g a7790ab
Add version bumps
stuartmorgan-g 1011970
Merge branch 'main' into maps-inpector-interface
stuartmorgan-g 776f981
Remove overrides
stuartmorgan-g bc34a74
Analyzer fix
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Initial interface
- Loading branch information
commit 75beb20ae2d9d67abdc2692bd1202ecf1548b4fb
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; | ||
| import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | ||
|
|
||
| /// The interface that platform-specific implementations of | ||
| /// `google_maps_flutter` can extend to support state inpsection in tests. | ||
| /// | ||
| /// Avoid `implements` of this interface. Using `implements` makes adding any | ||
| /// new methods here a breaking change for end users of your platform! | ||
| /// | ||
| /// Do `extends GoogleMapsInspectorPlatform` instead, so new methods | ||
| /// added here are inherited in your code with the default implementation (that | ||
| /// throws at runtime), rather than breaking your users at compile time. | ||
| abstract class GoogleMapsInspectorPlatform extends PlatformInterface { | ||
| /// Constructs a GoogleMapsFlutterPlatform. | ||
| GoogleMapsInspectorPlatform() : super(token: _token); | ||
ditman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static final Object _token = Object(); | ||
|
|
||
| static GoogleMapsInspectorPlatform? _instance; | ||
|
|
||
| /// The instance of [GoogleMapsInspectorPlatform], if any. | ||
| /// | ||
| /// This is usually populated by calling | ||
| /// [GoogleMapsFlutterPlatform.enableDebugInspection]. | ||
| static GoogleMapsInspectorPlatform? get instance => _instance; | ||
|
|
||
| /// Platform-specific plugins should set this with their own platform-specific | ||
| /// class that extends [GoogleMapsInspectorPlatform] in their | ||
| /// implementation of [GoogleMapsFlutterPlatform.enableDebugInspection]. | ||
| static set instance(GoogleMapsInspectorPlatform? instance) { | ||
| if (instance != null) { | ||
| PlatformInterface.verify(instance, _token); | ||
| } | ||
| _instance = instance; | ||
| } | ||
|
|
||
| /// Returns the minimum and maxmimum zoom level settings. | ||
| Future<MinMaxZoomPreference> getMinMaxZoomLevels({required int mapId}) { | ||
| throw UnimplementedError('getMinMaxZoomLevels() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if the compass is enabled. | ||
| Future<bool> isCompassEnabled({required int mapId}) { | ||
| throw UnimplementedError('isCompassEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if lite mode is enabled. | ||
| Future<bool> isLiteModeEnabled({required int mapId}) { | ||
| throw UnimplementedError('isLiteModeEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if the map toolbar is enabled. | ||
| Future<bool> isMapToolbarEnabled({required int mapId}) { | ||
| throw UnimplementedError('isMapToolbarEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if the "my location" button is enabled. | ||
| Future<bool> isMyLocationButtonEnabled({required int mapId}) { | ||
| throw UnimplementedError( | ||
| 'isMyLocationButtonEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if the traffic overlay is enabled. | ||
| Future<bool> isTrafficEnabled({required int mapId}) { | ||
| throw UnimplementedError('isTrafficEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if the building layer is enabled. | ||
| Future<bool> areBuildingsEnabled({required int mapId}) { | ||
| throw UnimplementedError('areBuildingsEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if rotate gestures are enabled. | ||
| Future<bool> areRotateGesturesEnabled({required int mapId}) { | ||
| throw UnimplementedError( | ||
| 'areRotateGesturesEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if scroll gestures are enabled. | ||
| Future<bool> areScrollGesturesEnabled({required int mapId}) { | ||
| throw UnimplementedError( | ||
| 'areScrollGesturesEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if tilt gestures are enabled. | ||
| Future<bool> areTiltGesturesEnabled({required int mapId}) { | ||
| throw UnimplementedError( | ||
| 'areTiltGesturesEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if zoom controls are enabled. | ||
| Future<bool> areZoomControlsEnabled({required int mapId}) { | ||
| throw UnimplementedError( | ||
| 'areZoomControlsEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns true if zoom gestures are enabled. | ||
| Future<bool> areZoomGesturesEnabled({required int mapId}) { | ||
| throw UnimplementedError( | ||
| 'areZoomGesturesEnabled() has not been implemented.'); | ||
| } | ||
|
|
||
| /// Returns information about the tile overlay with the given ID. | ||
| /// | ||
| /// The returned object will be synthesized from platform data, so will not | ||
| /// be the same Dart object as the original [TileOverlay] provided to the | ||
| /// platform interface with that ID, and not all fields (e.g., | ||
| /// [TileOverlay.tileProvider]) will be populated. | ||
| Future<TileOverlay?> getTileOverlayInfo(TileOverlayId tileOverlayId, | ||
| {required int mapId}) { | ||
| throw UnimplementedError('getTileOverlayInfo() has not been implemented.'); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@ditman Does this structure address flutter/flutter#80688 (comment)?
My thought was that by having the population controlled from here, you should be able to do whatever bridging is necessary between the private data you mentioned and the web implementation of the inspector. E.g., its constructor could take a reference to the "very private" data you mentioned, or if that's too much access, maybe to a provider object that can access pieces of it via lambas?
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.
I think this should be enough. The end goal is to "leak" this
_googleMapobject to whateverextends GoogleMapsInspectorPlatformwe created for the web:https://github.com/flutter/plugins/blob/main/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart#L86
Which is wrapped by a Controller object that is indexed by mapId here:
https://github.com/flutter/plugins/blob/main/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_flutter_web.dart#L17
(Maybe this method can just enable a boolean that lets us user a _googleMap getter?)