Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter_web] Pass BitmapDescriptor.fromBytes size to JS SDK (2/2) #6209

Merged
merged 6 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 0.4.0+2

* Updates conversion of `BitmapDescriptor.fromBytes` marker icons to support the
new `size` parameter. Issue [#73789](https://github.com/flutter/flutter/issues/73789).
* Fixes avoid_redundant_argument_values lint warnings and minor typos.

## 0.4.0+1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Mocks generated by Mockito 5.2.0 from annotations
// Mocks generated by Mockito 5.3.0 from annotations
// in google_maps_flutter_web_integration_tests/integration_test/google_maps_controller_test.dart.
// Do not manually edit this file.

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:google_maps/google_maps.dart' as _i2;
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'
as _i4;
Expand All @@ -17,8 +18,12 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class

class _FakeGMap_0 extends _i1.Fake implements _i2.GMap {}
class _FakeGMap_0 extends _i1.SmartFake implements _i2.GMap {
_FakeGMap_0(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}

/// A class which mocks [CirclesController].
///
Expand All @@ -27,18 +32,21 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
@override
Map<_i4.CircleId, _i3.CircleController> get circles =>
(super.noSuchMethod(Invocation.getter(#circles),
returnValue: <_i4.CircleId, _i3.CircleController>{})
returnValue: <_i4.CircleId, _i3.CircleController>{},
returnValueForMissingStub: <_i4.CircleId, _i3.CircleController>{})
as Map<_i4.CircleId, _i3.CircleController>);
@override
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
returnValue: _FakeGMap_0()) as _i2.GMap);
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
returnValueForMissingStub:
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
@override
set googleMap(_i2.GMap? _googleMap) =>
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
returnValueForMissingStub: null);
@override
int get mapId =>
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
returnValue: 0, returnValueForMissingStub: 0) as int);
@override
set mapId(int? _mapId) =>
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
Expand Down Expand Up @@ -67,20 +75,23 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
class MockPolygonsController extends _i1.Mock
implements _i3.PolygonsController {
@override
Map<_i4.PolygonId, _i3.PolygonController> get polygons =>
(super.noSuchMethod(Invocation.getter(#polygons),
returnValue: <_i4.PolygonId, _i3.PolygonController>{})
as Map<_i4.PolygonId, _i3.PolygonController>);
Map<_i4.PolygonId, _i3.PolygonController> get polygons => (super.noSuchMethod(
Invocation.getter(#polygons),
returnValue: <_i4.PolygonId, _i3.PolygonController>{},
returnValueForMissingStub: <_i4.PolygonId, _i3.PolygonController>{})
as Map<_i4.PolygonId, _i3.PolygonController>);
@override
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
returnValue: _FakeGMap_0()) as _i2.GMap);
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
returnValueForMissingStub:
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
@override
set googleMap(_i2.GMap? _googleMap) =>
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
returnValueForMissingStub: null);
@override
int get mapId =>
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
returnValue: 0, returnValueForMissingStub: 0) as int);
@override
set mapId(int? _mapId) =>
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
Expand Down Expand Up @@ -109,20 +120,23 @@ class MockPolygonsController extends _i1.Mock
class MockPolylinesController extends _i1.Mock
implements _i3.PolylinesController {
@override
Map<_i4.PolylineId, _i3.PolylineController> get lines =>
(super.noSuchMethod(Invocation.getter(#lines),
returnValue: <_i4.PolylineId, _i3.PolylineController>{})
as Map<_i4.PolylineId, _i3.PolylineController>);
Map<_i4.PolylineId, _i3.PolylineController> get lines => (super.noSuchMethod(
Invocation.getter(#lines),
returnValue: <_i4.PolylineId, _i3.PolylineController>{},
returnValueForMissingStub: <_i4.PolylineId, _i3.PolylineController>{})
as Map<_i4.PolylineId, _i3.PolylineController>);
@override
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
returnValue: _FakeGMap_0()) as _i2.GMap);
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
returnValueForMissingStub:
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
@override
set googleMap(_i2.GMap? _googleMap) =>
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
returnValueForMissingStub: null);
@override
int get mapId =>
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
returnValue: 0, returnValueForMissingStub: 0) as int);
@override
set mapId(int? _mapId) =>
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
Expand Down Expand Up @@ -152,18 +166,21 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
@override
Map<_i4.MarkerId, _i3.MarkerController> get markers =>
(super.noSuchMethod(Invocation.getter(#markers),
returnValue: <_i4.MarkerId, _i3.MarkerController>{})
returnValue: <_i4.MarkerId, _i3.MarkerController>{},
returnValueForMissingStub: <_i4.MarkerId, _i3.MarkerController>{})
as Map<_i4.MarkerId, _i3.MarkerController>);
@override
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
returnValue: _FakeGMap_0()) as _i2.GMap);
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
returnValueForMissingStub:
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
@override
set googleMap(_i2.GMap? _googleMap) =>
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
returnValueForMissingStub: null);
@override
int get mapId =>
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
returnValue: 0, returnValueForMissingStub: 0) as int);
@override
set mapId(int? _mapId) =>
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
Expand Down Expand Up @@ -191,7 +208,7 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
@override
bool isInfoWindowShown(_i4.MarkerId? markerId) =>
(super.noSuchMethod(Invocation.method(#isInfoWindowShown, [markerId]),
returnValue: false) as bool);
returnValue: false, returnValueForMissingStub: false) as bool);
@override
void bindToMap(int? mapId, _i2.GMap? googleMap) =>
super.noSuchMethod(Invocation.method(#bindToMap, [mapId, googleMap]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Mocks generated by Mockito 5.2.0 from annotations
// Mocks generated by Mockito 5.3.0 from annotations
// in google_maps_flutter_web_integration_tests/integration_test/google_maps_plugin_test.dart.
// Do not manually edit this file.

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i2;

import 'package:google_maps/google_maps.dart' as _i5;
Expand All @@ -19,36 +20,53 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class

class _FakeStreamController_0<T> extends _i1.Fake
implements _i2.StreamController<T> {}
class _FakeStreamController_0<T> extends _i1.SmartFake
implements _i2.StreamController<T> {
_FakeStreamController_0(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}

class _FakeLatLngBounds_1 extends _i1.Fake implements _i3.LatLngBounds {}
class _FakeLatLngBounds_1 extends _i1.SmartFake implements _i3.LatLngBounds {
_FakeLatLngBounds_1(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}

class _FakeScreenCoordinate_2 extends _i1.Fake
implements _i3.ScreenCoordinate {}
class _FakeScreenCoordinate_2 extends _i1.SmartFake
implements _i3.ScreenCoordinate {
_FakeScreenCoordinate_2(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}

class _FakeLatLng_3 extends _i1.Fake implements _i3.LatLng {}
class _FakeLatLng_3 extends _i1.SmartFake implements _i3.LatLng {
_FakeLatLng_3(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}

/// A class which mocks [GoogleMapController].
///
/// See the documentation for Mockito's code generation for more information.
class MockGoogleMapController extends _i1.Mock
implements _i4.GoogleMapController {
@override
_i2.StreamController<_i3.MapEvent<Object?>> get stream =>
(super.noSuchMethod(Invocation.getter(#stream),
returnValue: _FakeStreamController_0<_i3.MapEvent<Object?>>())
as _i2.StreamController<_i3.MapEvent<Object?>>);
_i2.StreamController<_i3.MapEvent<Object?>> get stream => (super.noSuchMethod(
Invocation.getter(#stream),
returnValue: _FakeStreamController_0<_i3.MapEvent<Object?>>(
this, Invocation.getter(#stream)),
returnValueForMissingStub: _FakeStreamController_0<_i3.MapEvent<Object?>>(
this, Invocation.getter(#stream))) as _i2
.StreamController<_i3.MapEvent<Object?>>);
@override
_i2.Stream<_i3.MapEvent<Object?>> get events =>
(super.noSuchMethod(Invocation.getter(#events),
returnValue: Stream<_i3.MapEvent<Object?>>.empty())
as _i2.Stream<_i3.MapEvent<Object?>>);
_i2.Stream<_i3.MapEvent<Object?>> get events => (super.noSuchMethod(
Invocation.getter(#events),
returnValue: _i2.Stream<_i3.MapEvent<Object?>>.empty(),
returnValueForMissingStub: _i2.Stream<_i3.MapEvent<Object?>>.empty())
as _i2.Stream<_i3.MapEvent<Object?>>);
@override
bool get isInitialized =>
(super.noSuchMethod(Invocation.getter(#isInitialized), returnValue: false)
as bool);
(super.noSuchMethod(Invocation.getter(#isInitialized),
returnValue: false, returnValueForMissingStub: false) as bool);
@override
void debugSetOverrides(
{_i4.DebugCreateMapFunction? createMap,
Expand Down Expand Up @@ -78,29 +96,43 @@ class MockGoogleMapController extends _i1.Mock
returnValueForMissingStub: null);
@override
_i2.Future<_i3.LatLngBounds> getVisibleRegion() => (super.noSuchMethod(
Invocation.method(#getVisibleRegion, []),
returnValue: Future<_i3.LatLngBounds>.value(_FakeLatLngBounds_1()))
as _i2.Future<_i3.LatLngBounds>);
Invocation.method(#getVisibleRegion, []),
returnValue: _i2.Future<_i3.LatLngBounds>.value(
_FakeLatLngBounds_1(this, Invocation.method(#getVisibleRegion, []))),
returnValueForMissingStub: _i2.Future<_i3.LatLngBounds>.value(
_FakeLatLngBounds_1(
this, Invocation.method(#getVisibleRegion, [])))) as _i2
.Future<_i3.LatLngBounds>);
@override
_i2.Future<_i3.ScreenCoordinate> getScreenCoordinate(_i3.LatLng? latLng) =>
(super.noSuchMethod(Invocation.method(#getScreenCoordinate, [latLng]),
returnValue:
Future<_i3.ScreenCoordinate>.value(_FakeScreenCoordinate_2()))
returnValue: _i2.Future<_i3.ScreenCoordinate>.value(
_FakeScreenCoordinate_2(
this, Invocation.method(#getScreenCoordinate, [latLng]))),
returnValueForMissingStub: _i2.Future<_i3.ScreenCoordinate>.value(
_FakeScreenCoordinate_2(
this, Invocation.method(#getScreenCoordinate, [latLng]))))
as _i2.Future<_i3.ScreenCoordinate>);
@override
_i2.Future<_i3.LatLng> getLatLng(_i3.ScreenCoordinate? screenCoordinate) =>
(super.noSuchMethod(Invocation.method(#getLatLng, [screenCoordinate]),
returnValue: Future<_i3.LatLng>.value(_FakeLatLng_3()))
as _i2.Future<_i3.LatLng>);
returnValue: _i2.Future<_i3.LatLng>.value(_FakeLatLng_3(
this, Invocation.method(#getLatLng, [screenCoordinate]))),
returnValueForMissingStub: _i2.Future<_i3.LatLng>.value(_FakeLatLng_3(
this, Invocation.method(#getLatLng, [screenCoordinate])))) as _i2
.Future<_i3.LatLng>);
@override
_i2.Future<void> moveCamera(_i3.CameraUpdate? cameraUpdate) =>
(super.noSuchMethod(Invocation.method(#moveCamera, [cameraUpdate]),
returnValue: Future<void>.value(),
returnValueForMissingStub: Future<void>.value()) as _i2.Future<void>);
returnValue: _i2.Future<void>.value(),
returnValueForMissingStub: _i2.Future<void>.value())
as _i2.Future<void>);
@override
_i2.Future<double> getZoomLevel() =>
(super.noSuchMethod(Invocation.method(#getZoomLevel, []),
returnValue: Future<double>.value(0.0)) as _i2.Future<double>);
returnValue: _i2.Future<double>.value(0.0),
returnValueForMissingStub: _i2.Future<double>.value(0.0))
as _i2.Future<double>);
@override
void updateCircles(_i3.CircleUpdates? updates) =>
super.noSuchMethod(Invocation.method(#updateCircles, [updates]),
Expand Down Expand Up @@ -128,7 +160,7 @@ class MockGoogleMapController extends _i1.Mock
@override
bool isInfoWindowShown(_i3.MarkerId? markerId) =>
(super.noSuchMethod(Invocation.method(#isInfoWindowShown, [markerId]),
returnValue: false) as bool);
returnValue: false, returnValueForMissingStub: false) as bool);
@override
void dispose() => super.noSuchMethod(Invocation.method(#dispose, []),
returnValueForMissingStub: null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import 'dart:async';
import 'dart:convert';
import 'dart:html' as html;
import 'dart:js_util' show getProperty;
import 'dart:typed_data';
import 'dart:ui';

import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps/google_maps.dart' as gmaps;
Expand Down Expand Up @@ -155,22 +155,46 @@ void main() {
controller.addMarkers(markers);

expect(controller.markers.length, 1);
expect(controller.markers[const MarkerId('1')]?.marker?.icon, isNotNull);

final String blobUrl = getProperty<String>(
controller.markers[const MarkerId('1')]!.marker!.icon!,
'url',
);
final gmaps.Icon? icon =
controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?;
expect(icon, isNotNull);

final String blobUrl = icon!.url!;
expect(blobUrl, startsWith('blob:'));

final http.Response response = await http.get(Uri.parse(blobUrl));

expect(response.bodyBytes, bytes,
reason:
'Bytes from the Icon blob must match bytes used to create Marker');
});

// https://github.com/flutter/flutter/issues/73789
testWidgets('markers with custom bitmap icon pass size to sdk',
(WidgetTester tester) async {
final Uint8List bytes = const Base64Decoder().convert(iconImageBase64);
final Set<Marker> markers = <Marker>{
Marker(
markerId: const MarkerId('1'),
icon: BitmapDescriptor.fromBytes(bytes, size: const Size(20, 30)),
),
};

controller.addMarkers(markers);

expect(controller.markers.length, 1);
final gmaps.Icon? icon =
controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?;
expect(icon, isNotNull);

final gmaps.Size size = icon!.size!;
final gmaps.Size scaledSize = icon.scaledSize!;

expect(size.width, 20);
expect(size.height, 30);
expect(scaledSize.width, 20);
expect(scaledSize.height, 30);
});

// https://github.com/flutter/flutter/issues/67854
testWidgets('InfoWindow snippet can have links',
(WidgetTester tester) async {
Expand Down
Loading