-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[google_maps_flutter] Add a pinned-SDK web example app #11761
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
Open
stuartmorgan-g
wants to merge
9
commits into
flutter:main
Choose a base branch
from
stuartmorgan-g:maps-heatmap-test-app
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7dac490
Update README
stuartmorgan-g 08cebef
Move existing example
stuartmorgan-g 24ba697
Add an example pinning 3.64, and move heatmap tests there
stuartmorgan-g c9b191a
Add a README
stuartmorgan-g 002e914
Version bump
stuartmorgan-g 508949f
Remove comments that shouldn't have been copied over
stuartmorgan-g 44740e5
Fix READMEs
stuartmorgan-g 80beb58
Update known secrets path
stuartmorgan-g 6b468f1
Remove unnecessary example bits
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
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md
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
26 changes: 26 additions & 0 deletions
26
packages/google_maps_flutter/google_maps_flutter_web/example/3-64/README.md
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,26 @@ | ||
| # Platform Implementation Test App | ||
|
|
||
| This is a test app for manual testing and automated integration testing | ||
| of this platform implementation. It is not intended to demonstrate actual use of | ||
| this package, since the intent is that plugin clients use the app-facing | ||
| package. | ||
|
|
||
| Unless you are making changes to this implementation package, this example is | ||
| very unlikely to be relevant. | ||
|
|
||
| ## Legacy SDK | ||
|
|
||
| This test app pins the Google Maps JavaScript SDK to version 3.64, which is | ||
| the last version that supported heatmaps. It is used to run integration tests | ||
| that use heatmaps, and to test that changes to the package do not break | ||
| existing heatmap functionality. | ||
|
|
||
| ## Testing | ||
|
|
||
| This package uses `package:integration_test` to run its tests in a web browser. | ||
|
|
||
| See [Plugin Tests > Web Tests](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests) | ||
| in the Flutter documentation for instructions to set up and run the tests in this package. | ||
|
|
||
| Check [flutter.dev > Integration testing](https://docs.flutter.dev/testing/integration-tests) | ||
| for more info. |
File renamed without changes.
File renamed without changes.
205 changes: 205 additions & 0 deletions
205
...ogle_maps_flutter/google_maps_flutter_web/example/3-64/integration_test/heatmap_test.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,205 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:js_interop'; | ||
| import 'dart:ui'; | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:google_maps/google_maps.dart' as gmaps; | ||
| import 'package:google_maps/google_maps_visualization.dart' as visualization; | ||
| import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; | ||
| import 'package:google_maps_flutter_web/google_maps_flutter_web.dart'; | ||
| // ignore: implementation_imports | ||
| import 'package:google_maps_flutter_web/src/utils.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
|
|
||
| /// Test Shapes (Circle, Polygon, Polyline) | ||
|
stuartmorgan-g marked this conversation as resolved.
Outdated
|
||
| void main() { | ||
| IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| late gmaps.Map map; | ||
|
|
||
| setUp(() { | ||
| map = gmaps.Map(createDivElement()); | ||
| }); | ||
|
|
||
| group('HeatmapsController', () { | ||
| late HeatmapsController controller; | ||
|
|
||
| const heatmapPoints = <WeightedLatLng>[ | ||
| WeightedLatLng(LatLng(37.782, -122.447)), | ||
| WeightedLatLng(LatLng(37.782, -122.445)), | ||
| WeightedLatLng(LatLng(37.782, -122.443)), | ||
| WeightedLatLng(LatLng(37.782, -122.441)), | ||
| WeightedLatLng(LatLng(37.782, -122.439)), | ||
| WeightedLatLng(LatLng(37.782, -122.437)), | ||
| WeightedLatLng(LatLng(37.782, -122.435)), | ||
| WeightedLatLng(LatLng(37.785, -122.447)), | ||
| WeightedLatLng(LatLng(37.785, -122.445)), | ||
| WeightedLatLng(LatLng(37.785, -122.443)), | ||
| WeightedLatLng(LatLng(37.785, -122.441)), | ||
| WeightedLatLng(LatLng(37.785, -122.439)), | ||
| WeightedLatLng(LatLng(37.785, -122.437)), | ||
| WeightedLatLng(LatLng(37.785, -122.435)), | ||
| ]; | ||
|
|
||
| setUp(() { | ||
| controller = HeatmapsController(); | ||
| controller.bindToMap(123, map); | ||
| }); | ||
|
|
||
| testWidgets('addHeatmaps', (WidgetTester tester) async { | ||
| final heatmaps = <Heatmap>{ | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('1'), | ||
| data: heatmapPoints, | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('2'), | ||
| data: heatmapPoints, | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| }; | ||
|
|
||
| controller.addHeatmaps(heatmaps); | ||
|
|
||
| expect(controller.heatmaps.length, 2); | ||
| expect(controller.heatmaps, contains(const HeatmapId('1'))); | ||
| expect(controller.heatmaps, contains(const HeatmapId('2'))); | ||
| expect(controller.heatmaps, isNot(contains(const HeatmapId('66')))); | ||
| }); | ||
|
|
||
| testWidgets('changeHeatmaps', (WidgetTester tester) async { | ||
| final heatmaps = <Heatmap>{ | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('1'), | ||
| data: <WeightedLatLng>[], | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| }; | ||
| controller.addHeatmaps(heatmaps); | ||
|
|
||
| expect( | ||
| controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart, | ||
| hasLength(0), | ||
| ); | ||
|
|
||
| final updatedHeatmaps = <Heatmap>{ | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('1'), | ||
| data: <WeightedLatLng>[WeightedLatLng(LatLng(0, 0))], | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| }; | ||
| controller.changeHeatmaps(updatedHeatmaps); | ||
|
|
||
| expect(controller.heatmaps.length, 1); | ||
| expect( | ||
| controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart, | ||
| hasLength(1), | ||
| ); | ||
| }); | ||
|
|
||
| testWidgets('removeHeatmaps', (WidgetTester tester) async { | ||
| final heatmaps = <Heatmap>{ | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('1'), | ||
| data: heatmapPoints, | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('2'), | ||
| data: heatmapPoints, | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('3'), | ||
| data: heatmapPoints, | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| }; | ||
|
|
||
| controller.addHeatmaps(heatmaps); | ||
|
|
||
| expect(controller.heatmaps.length, 3); | ||
|
|
||
| // Remove some polylines... | ||
|
stuartmorgan-g marked this conversation as resolved.
Outdated
|
||
| final heatmapIdsToRemove = <HeatmapId>{ | ||
| const HeatmapId('1'), | ||
| const HeatmapId('3'), | ||
| }; | ||
|
|
||
| controller.removeHeatmaps(heatmapIdsToRemove); | ||
|
|
||
| expect(controller.heatmaps.length, 1); | ||
| expect(controller.heatmaps, isNot(contains(const HeatmapId('1')))); | ||
| expect(controller.heatmaps, contains(const HeatmapId('2'))); | ||
| expect(controller.heatmaps, isNot(contains(const HeatmapId('3')))); | ||
| }); | ||
|
|
||
| testWidgets('Converts colors to CSS', (WidgetTester tester) async { | ||
| final heatmaps = <Heatmap>{ | ||
| const Heatmap( | ||
| heatmapId: HeatmapId('1'), | ||
| data: heatmapPoints, | ||
| gradient: HeatmapGradient(<HeatmapGradientColor>[ | ||
| HeatmapGradientColor(Color(0xFFFABADA), 0), | ||
| ]), | ||
| radius: HeatmapRadius.fromPixels(20), | ||
| ), | ||
| }; | ||
|
|
||
| controller.addHeatmaps(heatmaps); | ||
|
|
||
| final visualization.HeatmapLayer heatmap = | ||
| controller.heatmaps.values.first.heatmap!; | ||
|
|
||
| expect( | ||
| (heatmap.get('gradient')! as JSArray<JSString>).toDart.map( | ||
| (JSString? value) => value!.toDart, | ||
| ), | ||
| <String>['rgba(250, 186, 218, 0.00)', 'rgba(250, 186, 218, 1.00)'], | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| group('headless tests (no map attachment)', () { | ||
| testWidgets('update', (WidgetTester tester) async { | ||
| final heatmap = visualization.HeatmapLayer(); | ||
|
|
||
| final controller = HeatmapController(heatmap: heatmap); | ||
| final options = visualization.HeatmapLayerOptions() | ||
| ..data = <gmaps.LatLng>[gmaps.LatLng(0, 0)].toJS; | ||
|
|
||
| expect(heatmap.data.array.toDart, hasLength(0)); | ||
|
|
||
| controller.update(options); | ||
|
|
||
| expect(heatmap.data.array.toDart, hasLength(1)); | ||
| }); | ||
|
|
||
| testWidgets('remove drops gmaps instance', (WidgetTester tester) async { | ||
| final heatmap = visualization.HeatmapLayer(); | ||
| final controller = HeatmapController(heatmap: heatmap); | ||
|
|
||
| controller.remove(); | ||
|
|
||
| expect(controller.heatmap, isNull); | ||
| }); | ||
|
|
||
| testWidgets('cannot call update after remove', (WidgetTester tester) async { | ||
| final heatmap = visualization.HeatmapLayer(); | ||
| final controller = HeatmapController(heatmap: heatmap); | ||
|
|
||
| final options = visualization.HeatmapLayerOptions()..dissipating = true; | ||
|
|
||
| controller.remove(); | ||
|
|
||
| expect(() { | ||
| controller.update(options); | ||
| }, throwsAssertionError); | ||
| }); | ||
| }); | ||
| } | ||
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
packages/google_maps_flutter/google_maps_flutter_web/example/3-64/pubspec.yaml
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,32 @@ | ||
| name: google_maps_flutter_web_integration_tests | ||
| publish_to: none | ||
|
|
||
| environment: | ||
| sdk: ^3.10.0 | ||
| flutter: ">=3.38.0" | ||
|
|
||
| dependencies: | ||
| flutter: | ||
| sdk: flutter | ||
| google_maps_flutter_platform_interface: ^2.14.0 | ||
| google_maps_flutter_web: | ||
| path: ../.. | ||
| web: ^1.0.0 | ||
|
|
||
| dev_dependencies: | ||
| build_runner: ^2.1.1 | ||
| flutter_test: | ||
| sdk: flutter | ||
| google_maps: ^8.1.0 | ||
| google_maps_flutter: ^2.2.0 # Needed for projection_test.dart | ||
| http: ^1.2.2 | ||
| integration_test: | ||
| sdk: flutter | ||
| mockito: ^5.4.4 | ||
|
stuartmorgan-g marked this conversation as resolved.
Outdated
|
||
|
|
||
| dependency_overrides: | ||
| # Override the google_maps_flutter dependency on google_maps_flutter_web. | ||
| # TODO(ditman): Unwind the circular dependency. This will create problems | ||
| # if we need to make a breaking change to google_maps_flutter_web. | ||
| google_maps_flutter_web: | ||
| path: ../.. | ||
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
packages/google_maps_flutter/google_maps_flutter_web/example/3-64/web/index.html
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,20 @@ | ||
| <!DOCTYPE HTML> | ||
| <!-- Copyright 2013 The Flutter Authors | ||
| Use of this source code is governed by a BSD-style license that can be | ||
| found in the LICENSE file. --> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>Browser Tests</title> | ||
| <!-- This API key comes from: go/flutter-maps-web-tests-api-key (GCP project: flutter-infra) --> | ||
| <script | ||
| src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAa9cRBkhuxGq3Xw3HPz8SPwaVOhRmm7kk&libraries=marker,geometry,visualization&v=3.64"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@googlemaps/markerclusterer@2.5.3/dist/index.umd.min.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <script src="flutter_bootstrap.js" async></script> | ||
| </body> | ||
|
|
||
| </html> |
24 changes: 6 additions & 18 deletions
24
packages/google_maps_flutter/google_maps_flutter_web/example/README.md
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 |
|---|---|---|
| @@ -1,19 +1,7 @@ | ||
| # Platform Implementation Test App | ||
| # Example Structure | ||
|
|
||
| This is a test app for manual testing and automated integration testing | ||
| of this platform implementation. It is not intended to demonstrate actual use of | ||
| this package, since the intent is that plugin clients use the app-facing | ||
| package. | ||
|
|
||
| Unless you are making changes to this implementation package, this example is | ||
| very unlikely to be relevant. | ||
|
|
||
| ## Testing | ||
|
|
||
| This package uses `package:integration_test` to run its tests in a web browser. | ||
|
|
||
| See [Plugin Tests > Web Tests](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests) | ||
| in the Flutter documentation for instructions to set up and run the tests in this package. | ||
|
|
||
| Check [flutter.dev > Integration testing](https://docs.flutter.dev/testing/integration-tests) | ||
| for more info. | ||
| This directory contains two example apps: | ||
| - latest/ uses an unpinned SDK load, so it will use the latest SDK version. | ||
| This follows the standard recommendation in the package's README. | ||
| - 3-64 pins the SDK to 3.64. This is used for integration tests of the | ||
| heatmap support, since heatmaps were removed from the SDK in 3.65. |
19 changes: 19 additions & 0 deletions
19
packages/google_maps_flutter/google_maps_flutter_web/example/latest/README.md
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,19 @@ | ||
| # Platform Implementation Test App | ||
|
|
||
| This is a test app for manual testing and automated integration testing | ||
| of this platform implementation. It is not intended to demonstrate actual use of | ||
| this package, since the intent is that plugin clients use the app-facing | ||
| package. | ||
|
|
||
| Unless you are making changes to this implementation package, this example is | ||
| very unlikely to be relevant. | ||
|
|
||
| ## Testing | ||
|
|
||
| This package uses `package:integration_test` to run its tests in a web browser. | ||
|
|
||
| See [Plugin Tests > Web Tests](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests) | ||
| in the Flutter documentation for instructions to set up and run the tests in this package. | ||
|
|
||
| Check [flutter.dev > Integration testing](https://docs.flutter.dev/testing/integration-tests) | ||
| for more info. |
File renamed without changes
15 changes: 15 additions & 0 deletions
15
packages/google_maps_flutter/google_maps_flutter_web/example/latest/build.excerpt.yaml
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,15 @@ | ||
| targets: | ||
| $default: | ||
| sources: | ||
| include: | ||
| - lib/** | ||
| # Some default includes that aren't really used here but will prevent | ||
| # false-negative warnings: | ||
| - $package$ | ||
| - lib/$lib$ | ||
| exclude: | ||
| - '**/.*/**' | ||
| - '**/build/**' | ||
| builders: | ||
| code_excerpter|code_excerpter: | ||
| enabled: true |
10 changes: 10 additions & 0 deletions
10
packages/google_maps_flutter/google_maps_flutter_web/example/latest/build.yaml
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,10 @@ | ||
| targets: | ||
| $default: | ||
| sources: | ||
| - integration_test/*.dart | ||
| - lib/$lib$ | ||
| - $package$ | ||
| builders: | ||
| mockito|mockBuilder: | ||
| generate_for: | ||
| - integration_test/** |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.