Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/google_maps_flutter/example/ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ - (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
// Provide the GoogleMaps API key.
NSString* mapsApiKey = [[NSProcessInfo processInfo] environment][@"MAPS_API_KEY"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be confusing for users, what do you think about still using the key "YOUR KEY HERE" if the env variable is not set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of making it so that in the future for local runs we require the api key to be set via env var. That way we do not need to edit these files, and flutter run will automatically pick them up. But for short term, i'm cool with making this be "YOUR KEY HERE".

if ([mapsApiKey length] == 0) {
mapsApiKey = @"YOUR KEY HERE";
}
[GMSServices provideAPIKey:mapsApiKey];

// Register Flutter plugins.
Expand Down
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dev_dependencies:
path: ../
flutter_driver:
sdk: flutter
test: any
test: ^1.6.0

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import 'package:flutter/services.dart';

class GoogleMapTestController {
GoogleMapTestController(this._channel);
class GoogleMapInspector {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a doc comment explaining the role of this class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about why this is its own class. Why not put methods on the GoogleMapController?

GoogleMapInspector(this._channel);

final MethodChannel _channel;

Expand Down
19 changes: 9 additions & 10 deletions packages/google_maps_flutter/example/test_driver/google_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

import 'google_maps_test_controller.dart';
import 'google_map_inspector.dart';
import 'test_widgets.dart';

const CameraPosition _kInitialCameraPosition =
Expand All @@ -22,26 +22,25 @@ void main() {
tearDownAll(() => allTestsCompleter.complete(null));

test('testCompassToggle', () async {
final Completer<GoogleMapTestController> controllerCompleter =
Completer<GoogleMapTestController>();
final Completer<GoogleMapInspector> inspectorCompleter =
Completer<GoogleMapInspector>();

await pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
initialCameraPosition: _kInitialCameraPosition,
compassEnabled: false,
onMapCreated: (GoogleMapController controller) {
final GoogleMapTestController testController =
final GoogleMapInspector inspector =
// ignore: invalid_use_of_visible_for_testing_member
GoogleMapTestController(controller.channel);
controllerCompleter.complete(testController);
GoogleMapInspector(controller.channel);
inspectorCompleter.complete(inspector);
},
),
));

final GoogleMapTestController testController =
await controllerCompleter.future;
bool compassEnabled = await testController.isCompassEnabled();
final GoogleMapInspector inspector = await inspectorCompleter.future;
bool compassEnabled = await inspector.isCompassEnabled();
expect(compassEnabled, false);

await pumpWidget(Directionality(
Expand All @@ -55,7 +54,7 @@ void main() {
),
));

compassEnabled = await testController.isCompassEnabled();
compassEnabled = await inspector.isCompassEnabled();
expect(compassEnabled, true);
});
}
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dev_dependencies:
# https://github.com/dart-lang/pub/issues/2101 is resolved.
flutter_driver:
sdk: flutter
test: any
test: ^1.6.0

flutter:
plugin:
Expand Down