Skip to content

Commit 471bfd3

Browse files
[google_maps_flutter] Remove legacy renderer tests (#9517)
Removes the copy of the integration tests that attempted to run against the legacy renderer, as the legacy renderer is no longer available. The tests are now just duplicating integration tests (the slowest and flakiest tests, generally), and the test that asserts that it's testing the legacy renderer is now failing (requiring a recent change to skip it). Since we no longer need to run the same set of tests in two different modes, I combined `latest_renderer_tests.dart` into `google_maps_test.dart` (renamed so it's picked up as an integration test entry point). Also removes the README discussion of the renderer option, since it's no longer useful to clients. Part of flutter/flutter#171338 Fixes flutter/flutter#171306 ## 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.
1 parent 28dbb4c commit 471bfd3

File tree

6 files changed

+40
-123
lines changed

6 files changed

+40
-123
lines changed

packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.16.2
2+
3+
* Removes documentation related to the map renderer selection API, as the
4+
legacy renderer is no longer available, so requesting it is a no-op.
5+
16
## 2.16.1
27

38
* Removes obsolete code related to supporting SDK <21.

packages/google_maps_flutter/google_maps_flutter_android/README.md

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,11 @@ This mode is more performant than Hybrid Composition and we recommend that you u
4646

4747
This mode is available for backwards compatability and corresponds to `useAndroidViewSurface = true`.
4848
We do not recommend its use as it is less performant than Texture Layer Hybrid Composition and
49-
certain flutter rendering effects are not supported.
49+
certain flutter rendering effects are not supported.
5050

5151
If you require this mode for correctness, please file a bug so we can investigate and fix
5252
the issue in the TLHC mode.
5353

54-
## Map renderer
55-
56-
This plugin supports the option to request a specific [map renderer][5].
57-
58-
The renderer must be requested before creating GoogleMap instances, as the renderer can be initialized only once per application context.
59-
60-
<?code-excerpt "readme_excerpts.dart (MapRenderer)"?>
61-
```dart
62-
AndroidMapRenderer mapRenderer = AndroidMapRenderer.platformDefault;
63-
// ···
64-
final GoogleMapsFlutterPlatform mapsImplementation =
65-
GoogleMapsFlutterPlatform.instance;
66-
if (mapsImplementation is GoogleMapsFlutterAndroid) {
67-
WidgetsFlutterBinding.ensureInitialized();
68-
mapRenderer = await mapsImplementation
69-
.initializeWithRenderer(AndroidMapRenderer.latest);
70-
}
71-
```
72-
73-
`AndroidMapRenderer.platformDefault` corresponds to `AndroidMapRenderer.latest`.
74-
75-
You are not guaranteed to get the requested renderer. For example, on emulators without
76-
Google Play the latest renderer will not be available and the legacy renderer will always be used.
77-
78-
WARNING: `AndroidMapRenderer.legacy` is known to crash apps and is no longer supported by the Google Maps team
79-
and therefore cannot be supported by the Flutter team.
80-
81-
### Cloud-based map styling
82-
83-
Cloud-based map styling is not supported with the `AndroidMapRenderer.legacy` renderer.
84-
8554
## Supported Heatmap Options
8655

8756
| Field | Supported |
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
import 'dart:async';
66
import 'dart:convert';
7-
import 'dart:typed_data';
87
import 'dart:ui' as ui;
98

109
import 'package:flutter/material.dart';
10+
import 'package:flutter/services.dart';
1111
import 'package:flutter_test/flutter_test.dart';
1212
import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
1313
import 'package:google_maps_flutter_example/example_google_map.dart';
1414
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
15+
import 'package:integration_test/integration_test.dart';
1516

1617
import 'resources/icon_image_base64.dart';
1718

@@ -42,9 +43,39 @@ final LatLngBounds _testCameraBounds = LatLngBounds(
4243
final ValueVariant<CameraUpdateType> _cameraUpdateTypeVariants =
4344
ValueVariant<CameraUpdateType>(CameraUpdateType.values.toSet());
4445

45-
void googleMapsTests() {
46+
void main() {
47+
late AndroidMapRenderer initializedRenderer;
48+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
4649
GoogleMapsFlutterPlatform.instance.enableDebugInspection();
4750

51+
setUpAll(() async {
52+
final GoogleMapsFlutterAndroid instance =
53+
GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid;
54+
initializedRenderer =
55+
await instance.initializeWithRenderer(AndroidMapRenderer.latest);
56+
});
57+
58+
testWidgets('initialized with latest renderer', (WidgetTester _) async {
59+
// There is no guarantee that the server will return the latest renderer
60+
// even when requested, so there's no way to deterministically test that.
61+
// Instead, just test that the request succeeded and returned a valid
62+
// value.
63+
expect(
64+
initializedRenderer == AndroidMapRenderer.latest ||
65+
initializedRenderer == AndroidMapRenderer.legacy,
66+
true);
67+
});
68+
69+
testWidgets('throws PlatformException on multiple renderer initializations',
70+
(WidgetTester _) async {
71+
final GoogleMapsFlutterAndroid instance =
72+
GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid;
73+
expect(
74+
() async => instance.initializeWithRenderer(AndroidMapRenderer.latest),
75+
throwsA(isA<PlatformException>().having((PlatformException e) => e.code,
76+
'code', 'Renderer already initialized')));
77+
});
78+
4879
// Repeatedly checks an asynchronous value against a test condition, waiting
4980
// on frame between each check, returing the value if it passes the predicate
5081
// before [maxTries] is reached.

packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/latest_renderer_test.dart

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/legacy_renderer_test.dart

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter_android
22
description: Android implementation of the google_maps_flutter plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 2.16.1
5+
version: 2.16.2
66

77
environment:
88
sdk: ^3.6.0

0 commit comments

Comments
 (0)