-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[google_maps_flutter_platform_interface] Convert
PatternItem
and `C…
…ap` to typesafe structures. (#7703) Convert `PatternItem` and `Cap` from JSON wrappers to typesafe classes. flutter/flutter#155121 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] page, which explains my responsibilities. - [x] I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use `dart format`.) - [ ] I signed the [CLA]. - [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g. `[shared_preferences]` - [x] I [linked to at least one issue that this PR fixes] in the description above. - [x] I updated `pubspec.yaml` with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes]. - [x] I updated `CHANGELOG.md` to add a description of the change, [following repository CHANGELOG style], or this PR is [exempt from CHANGELOG changes]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [relevant style guides]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md [linked to at least one issue that this PR fixes]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [pub versioning philosophy]: https://dart.dev/tools/pub/versioning [exempt from version changes]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version [following repository CHANGELOG style]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style [exempt from CHANGELOG changes]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
- Loading branch information
1 parent
05bf1d4
commit 6ec1b43
Showing
6 changed files
with
190 additions
and
14 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md
This file contains 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 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 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 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
48 changes: 48 additions & 0 deletions
48
packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cap_test.dart
This file contains 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,48 @@ | ||
// 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:flutter_test/flutter_test.dart'; | ||
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
test('buttCap', () { | ||
const Cap cap = Cap.buttCap; | ||
expect(cap.toJson(), equals(<Object>['buttCap'])); | ||
}); | ||
|
||
test('roundCap', () { | ||
const Cap cap = Cap.roundCap; | ||
expect(cap.toJson(), equals(<Object>['roundCap'])); | ||
}); | ||
|
||
test('squareCap', () { | ||
const Cap cap = Cap.squareCap; | ||
expect(cap.toJson(), equals(<Object>['squareCap'])); | ||
}); | ||
|
||
test('customCap', () { | ||
final Cap cap = Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker); | ||
expect( | ||
cap.toJson(), | ||
equals(<Object>[ | ||
'customCap', | ||
<Object>['defaultMarker'], | ||
10.0 | ||
])); | ||
}); | ||
|
||
test('customCapWithWidth', () { | ||
final Cap cap = | ||
Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker, refWidth: 100); | ||
expect( | ||
cap.toJson(), | ||
equals(<Object>[ | ||
'customCap', | ||
<Object>['defaultMarker'], | ||
100.0 | ||
])); | ||
}); | ||
} |
27 changes: 27 additions & 0 deletions
27
...gle_maps_flutter/google_maps_flutter_platform_interface/test/types/pattern_item_test.dart
This file contains 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,27 @@ | ||
// 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:flutter_test/flutter_test.dart'; | ||
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
test('dot', () { | ||
const PatternItem item = PatternItem.dot; | ||
expect(item.toJson(), equals(<Object>['dot'])); | ||
}); | ||
|
||
test('dash', () { | ||
final PatternItem item = PatternItem.dash(10.0); | ||
expect(item, isA<VariableLengthPatternItem>()); | ||
expect(item.toJson(), equals(<Object>['dash', 10.0])); | ||
}); | ||
|
||
test('gap', () { | ||
final PatternItem item = PatternItem.gap(20.0); | ||
expect(item, isA<VariableLengthPatternItem>()); | ||
expect(item.toJson(), equals(<Object>['gap', 20.0])); | ||
}); | ||
} |