@@ -842,6 +842,65 @@ void main() {
842
842
expect (iwVisibleStatus, false );
843
843
});
844
844
845
+ testWidgets ('updating a marker does not hide its info window' ,
846
+ (WidgetTester tester) async {
847
+ final Key key = GlobalKey ();
848
+ const Marker marker = Marker (
849
+ markerId: MarkerId ('marker' ),
850
+ infoWindow: InfoWindow (title: 'InfoWindow' ));
851
+ Set <Marker > markers = < Marker > {marker};
852
+
853
+ const ClusterManager clusterManager =
854
+ ClusterManager (clusterManagerId: ClusterManagerId ('cluster_manager' ));
855
+ final Set <ClusterManager > clusterManagers = < ClusterManager > {
856
+ clusterManager
857
+ };
858
+
859
+ final Completer <ExampleGoogleMapController > controllerCompleter =
860
+ Completer <ExampleGoogleMapController >();
861
+
862
+ await tester.pumpWidget (Directionality (
863
+ textDirection: TextDirection .ltr,
864
+ child: ExampleGoogleMap (
865
+ key: key,
866
+ initialCameraPosition: const CameraPosition (target: LatLng (10.0 , 15.0 )),
867
+ markers: markers,
868
+ clusterManagers: clusterManagers,
869
+ onMapCreated: (ExampleGoogleMapController googleMapController) {
870
+ controllerCompleter.complete (googleMapController);
871
+ },
872
+ ),
873
+ ));
874
+
875
+ final ExampleGoogleMapController controller =
876
+ await controllerCompleter.future;
877
+
878
+ await controller.showMarkerInfoWindow (marker.markerId);
879
+ bool iwVisibleStatus =
880
+ await controller.isMarkerInfoWindowShown (marker.markerId);
881
+ expect (iwVisibleStatus, true );
882
+
883
+ // Update marker and ensure the info window remains visible when added to a
884
+ // cluster manager.
885
+ final Marker updatedMarker = marker.copyWith (
886
+ alphaParam: 0.5 ,
887
+ clusterManagerIdParam: clusterManager.clusterManagerId,
888
+ );
889
+ markers = < Marker > {updatedMarker};
890
+
891
+ await tester.pumpWidget (Directionality (
892
+ textDirection: TextDirection .ltr,
893
+ child: ExampleGoogleMap (
894
+ key: key,
895
+ initialCameraPosition: _kInitialCameraPosition,
896
+ clusterManagers: clusterManagers,
897
+ markers: Set <Marker >.of (markers)),
898
+ ));
899
+
900
+ iwVisibleStatus = await controller.isMarkerInfoWindowShown (marker.markerId);
901
+ expect (iwVisibleStatus, true );
902
+ });
903
+
845
904
testWidgets ('testTakeSnapshot' , (WidgetTester tester) async {
846
905
final Completer <ExampleGoogleMapController > controllerCompleter =
847
906
Completer <ExampleGoogleMapController >();
@@ -1110,6 +1169,46 @@ void main() {
1110
1169
expect (markersAmountForClusterManager, markersPerClusterManager);
1111
1170
}
1112
1171
1172
+ // Move marker from the first cluster manager to the last.
1173
+ final MarkerId markerIdToMove = markers.entries
1174
+ .firstWhere ((MapEntry <MarkerId , Marker > entry) =>
1175
+ entry.value.clusterManagerId ==
1176
+ clusterManagers.first.clusterManagerId)
1177
+ .key;
1178
+ markers[markerIdToMove] = _copyMarkerWithClusterManagerId (
1179
+ markers[markerIdToMove]! , clusterManagers.last.clusterManagerId);
1180
+
1181
+ await tester.pumpWidget (Directionality (
1182
+ textDirection: TextDirection .ltr,
1183
+ child: ExampleGoogleMap (
1184
+ key: key,
1185
+ initialCameraPosition: _kInitialCameraPosition,
1186
+ clusterManagers: clusterManagers,
1187
+ markers: Set <Marker >.of (markers.values)),
1188
+ ));
1189
+
1190
+ {
1191
+ final List <Cluster > clusters = await inspector.getClusters (
1192
+ mapId: controller.mapId,
1193
+ clusterManagerId: clusterManagers.first.clusterManagerId);
1194
+ final int markersAmountForClusterManager = clusters
1195
+ .map <int >((Cluster cluster) => cluster.count)
1196
+ .reduce ((int value, int element) => value + element);
1197
+ //Check that first cluster manager has one less marker.
1198
+ expect (markersAmountForClusterManager, markersPerClusterManager - 1 );
1199
+ }
1200
+
1201
+ {
1202
+ final List <Cluster > clusters = await inspector.getClusters (
1203
+ mapId: controller.mapId,
1204
+ clusterManagerId: clusterManagers.last.clusterManagerId);
1205
+ final int markersAmountForClusterManager = clusters
1206
+ .map <int >((Cluster cluster) => cluster.count)
1207
+ .reduce ((int value, int element) => value + element);
1208
+ // Check that last cluster manager has one more marker.
1209
+ expect (markersAmountForClusterManager, markersPerClusterManager + 1 );
1210
+ }
1211
+
1113
1212
// Remove markers from clusterManagers and test that clusterManagers are empty.
1114
1213
for (final MapEntry <MarkerId , Marker > entry in markers.entries) {
1115
1214
markers[entry.key] = _copyMarkerWithClusterManagerId (entry.value, null );
0 commit comments