Skip to content

Commit

Permalink
[google_maps_flutter_ios] Add missing tests and address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jokerttu committed Feb 5, 2025
1 parent b84b657 commit a859a4d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (void)testUpdatingGroundOverlayWithPosition {
image:bitmap
position:position
bounds:nil
anchor:nil
anchor:[FGMPlatformPoint makeWithX:0.5 y:0.5]
transparency:0.5
bearing:65.0
zIndex:2.0
Expand All @@ -103,10 +103,29 @@ - (void)testUpdatingGroundOverlayWithPosition {
screenScale:1.0];

XCTAssertNotNil(groundOverlayController.groundOverlay.icon);
XCTAssertEqual(groundOverlayController.groundOverlay.position.latitude, position.latitude);
XCTAssertEqual(groundOverlayController.groundOverlay.position.longitude, position.longitude);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.position.latitude,
position.latitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.position.longitude,
position.longitude, DBL_EPSILON);
XCTAssertEqual(groundOverlayController.groundOverlay.opacity, platformGroundOverlay.transparency);
XCTAssertEqual(groundOverlayController.groundOverlay.bearing, platformGroundOverlay.bearing);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.anchor.x, 0.5, DBL_EPSILON);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.anchor.y, 0.5, DBL_EPSILON);
XCTAssertEqual(groundOverlayController.groundOverlay.zIndex, platformGroundOverlay.zIndex);

FGMPlatformGroundOverlay *convertedPlatformGroundOverlay =
FGMGetPigeonGroundOverlay(groundOverlayController.groundOverlay, @"id_1", NO, @14.0);
XCTAssertEqualObjects(convertedPlatformGroundOverlay.groundOverlayId, @"id_1");
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.position.latitude, position.latitude,
DBL_EPSILON);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.position.longitude, position.longitude,
DBL_EPSILON);
XCTAssertEqual(convertedPlatformGroundOverlay.zoomLevel.doubleValue, 14.0);
XCTAssertEqual(convertedPlatformGroundOverlay.transparency, platformGroundOverlay.transparency);
XCTAssertEqual(convertedPlatformGroundOverlay.bearing, platformGroundOverlay.bearing);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.anchor.x, 0.5, DBL_EPSILON);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.anchor.y, 0.5, DBL_EPSILON);
XCTAssertEqual(convertedPlatformGroundOverlay.zIndex, platformGroundOverlay.zIndex);
}

- (void)testUpdatingGroundOverlayWithBounds {
Expand All @@ -127,7 +146,7 @@ - (void)testUpdatingGroundOverlayWithBounds {
image:bitmap
position:nil
bounds:bounds
anchor:nil
anchor:[FGMPlatformPoint makeWithX:0.5 y:0.5]
transparency:0.5
bearing:65.0
zIndex:2.0
Expand All @@ -140,16 +159,36 @@ - (void)testUpdatingGroundOverlayWithBounds {
screenScale:1.0];

XCTAssertNotNil(groundOverlayController.groundOverlay.icon);
XCTAssertEqual(groundOverlayController.groundOverlay.bounds.northEast.latitude,
bounds.northeast.latitude);
XCTAssertEqual(groundOverlayController.groundOverlay.bounds.northEast.longitude,
bounds.northeast.longitude);
XCTAssertEqual(groundOverlayController.groundOverlay.bounds.southWest.latitude,
bounds.southwest.latitude);
XCTAssertEqual(groundOverlayController.groundOverlay.bounds.southWest.longitude,
bounds.southwest.longitude);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.bounds.northEast.latitude,
bounds.northeast.latitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.bounds.northEast.longitude,
bounds.northeast.longitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.bounds.southWest.latitude,
bounds.southwest.latitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.bounds.southWest.longitude,
bounds.southwest.longitude, DBL_EPSILON);
XCTAssertEqual(groundOverlayController.groundOverlay.opacity, platformGroundOverlay.transparency);
XCTAssertEqual(groundOverlayController.groundOverlay.bearing, platformGroundOverlay.bearing);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.anchor.x, 0.5, DBL_EPSILON);
XCTAssertEqualWithAccuracy(groundOverlayController.groundOverlay.anchor.y, 0.5, DBL_EPSILON);
XCTAssertEqual(groundOverlayController.groundOverlay.zIndex, platformGroundOverlay.zIndex);

FGMPlatformGroundOverlay *convertedPlatformGroundOverlay =
FGMGetPigeonGroundOverlay(groundOverlayController.groundOverlay, @"id_1", YES, nil);
XCTAssertEqualObjects(convertedPlatformGroundOverlay.groundOverlayId, @"id_1");
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.bounds.northeast.latitude,
bounds.northeast.latitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.bounds.northeast.longitude,
bounds.northeast.longitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.bounds.southwest.latitude,
bounds.southwest.latitude, DBL_EPSILON);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.bounds.southwest.longitude,
bounds.southwest.longitude, DBL_EPSILON);
XCTAssertEqual(convertedPlatformGroundOverlay.transparency, platformGroundOverlay.transparency);
XCTAssertEqual(convertedPlatformGroundOverlay.bearing, platformGroundOverlay.bearing);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.anchor.x, 0.5, DBL_EPSILON);
XCTAssertEqualWithAccuracy(convertedPlatformGroundOverlay.anchor.y, 0.5, DBL_EPSILON);
XCTAssertEqual(convertedPlatformGroundOverlay.zIndex, platformGroundOverlay.zIndex);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ - (void)updateFromPlatformGroundOverlay:(FGMPlatformGroundOverlay *)groundOverla
registrar:(NSObject<FlutterPluginRegistrar> *)registrar
screenScale:(CGFloat)screenScale {
[self setConsumeTapEvents:groundOverlay.clickable];
[self setVisible:groundOverlay.visible];
[self setZIndex:(int)groundOverlay.zIndex];
[self setAnchor:CGPointMake(groundOverlay.anchor.x, groundOverlay.anchor.y)];
UIImage *image = FGMIconFromBitmap(groundOverlay.image, registrar, screenScale);
Expand All @@ -95,6 +94,7 @@ - (void)updateFromPlatformGroundOverlay:(FGMPlatformGroundOverlay *)groundOverla
[self setPositionFromCoordinates:CLLocationCoordinate2DMake(groundOverlay.position.latitude,
groundOverlay.position.longitude)];
}
[self setVisible:groundOverlay.visible];
}

@end
Expand Down Expand Up @@ -196,9 +196,6 @@ - (void)removeGroundOverlaysWithIdentifiers:(NSArray<NSString *> *)identifiers {
}

- (void)didTapGroundOverlayWithIdentifier:(NSString *)identifier {
if (!identifier) {
return;
}
FGMGroundOverlayController *controller = self.groundOverlayControllerByIdentifier[identifier];
if (!controller) {
return;
Expand Down

0 comments on commit a859a4d

Please sign in to comment.