Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[google_maps_flutter_platform_interface] cloud-based map styling tests
  • Loading branch information
jokerttu committed Jun 21, 2023
commit 72a0f20ef1504d668ead06ede9bfad3ec877d4a9
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ Map<String, Object> jsonForMapConfiguration(MapConfiguration config) {
if (config.trafficEnabled != null) 'trafficEnabled': config.trafficEnabled!,
if (config.buildingsEnabled != null)
'buildingsEnabled': config.buildingsEnabled!,
if (config.cloudMapId != null)
'cloudMapId': config.cloudMapId!,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

const String _kCloudMapId = '000000000000000'; // Dummy map ID.

void main() {
group('diffs', () {
// A options instance with every field set, to test diffs against.
Expand Down Expand Up @@ -53,6 +55,7 @@ void main() {
expect(updated.liteModeEnabled, isNot(null));
expect(updated.padding, isNot(null));
expect(updated.trafficEnabled, isNot(null));
expect(updated.cloudMapId, null);
});

test('handle compassEnabled', () async {
Expand Down Expand Up @@ -281,6 +284,18 @@ void main() {
// A diff applied to non-empty options should update that field.
expect(updated.buildingsEnabled, true);
});

test('handle cloudMapId', () async {
const MapConfiguration diff = MapConfiguration(cloudMapId: _kCloudMapId);

const MapConfiguration empty = MapConfiguration();
final MapConfiguration updated = diffBase.applyDiff(diff);

// A diff applied to empty options should be the diff itself.
expect(empty.applyDiff(diff), diff);
// A diff applied to non-empty options should update that field.
expect(updated.cloudMapId, _kCloudMapId);
});
});

group('isEmpty', () {
Expand Down Expand Up @@ -408,5 +423,11 @@ void main() {

expect(diff.isEmpty, false);
});

test('is false with cloudMapId', () async {
const MapConfiguration diff = MapConfiguration(cloudMapId: _kCloudMapId);

expect(diff.isEmpty, false);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:google_maps_flutter_platform_interface/src/types/utils/map_configuration_serialization.dart';

const String _kCloudMapId = '000000000000000'; // Dummy map ID.

void main() {
test('empty serialization', () async {
const MapConfiguration config = MapConfiguration();
Expand Down Expand Up @@ -37,6 +39,7 @@ void main() {
indoorViewEnabled: false,
trafficEnabled: false,
buildingsEnabled: false,
cloudMapId: _kCloudMapId
);

final Map<String, Object> json = jsonForMapConfiguration(config);
Expand Down Expand Up @@ -69,7 +72,8 @@ void main() {
'padding': <double>[5.0, 5.0, 5.0, 5.0],
'indoorEnabled': false,
'trafficEnabled': false,
'buildingsEnabled': false
'buildingsEnabled': false,
'cloudMapId': _kCloudMapId
});
});
}