From 6e1b1836f472dee2a57cf11766eb1a04a11ad40a Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 13 Oct 2015 17:53:13 -0700 Subject: fixes #2611: iOS test app long press drops debug marker --- test/ios/MapViewTests.m | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/ios') diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index 1de31c6ccd..71e73054f4 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -33,6 +33,8 @@ tester.mapView.scrollEnabled = YES; tester.mapView.rotateEnabled = YES; + [tester.mapView removeAnnotations:tester.mapView.annotations]; + tester.viewController.navigationController.navigationBarHidden = YES; tester.viewController.navigationController.toolbarHidden = YES; @@ -331,6 +333,44 @@ @"setting zoom should take effect"); } +- (void)testMarkerSelection { + CGPoint point = CGPointMake(100, 100); + MGLPointAnnotation *marker = [MGLPointAnnotation new]; + marker.coordinate = [tester.mapView convertPoint:point toCoordinateFromView:tester.mapView]; + marker.title = @"test"; // title required for callout + [tester.mapView addAnnotation:marker]; + + XCTAssertEqual(tester.mapView.selectedAnnotations.count, 0); + + [tester.mapView selectAnnotation:marker animated:NO]; + XCTAssertEqualObjects(tester.mapView.selectedAnnotations.firstObject, marker); + + [tester.mapView deselectAnnotation:marker animated:NO]; + XCTAssertEqual(tester.mapView.selectedAnnotations.count, 0); +} + +- (void)testMarkerAddWithoutDelegate { + XCTAssertFalse([tester.viewController respondsToSelector:@selector(mapView:imageForAnnotation:)]); + + MGLPointAnnotation *marker = [MGLPointAnnotation new]; + marker.coordinate = tester.mapView.centerCoordinate; + [tester.mapView addAnnotation:marker]; + + [tester.mapView selectAnnotation:marker animated:NO]; + XCTAssertEqualObjects(tester.mapView.selectedAnnotations.firstObject, marker); + XCTAssertEqual([[tester.mapView subviewsWithClassNamePrefix:@"SM"] count], 0); // no callout for no title + + [tester.mapView deselectAnnotation:marker animated:NO]; + marker.title = @"test"; + [tester.mapView selectAnnotation:marker animated:NO]; + XCTAssertEqualObjects(tester.mapView.selectedAnnotations.firstObject, marker); + XCTAssertGreaterThan([[tester.mapView subviewsWithClassNamePrefix:@"SM"] count], 0); +} + +- (BOOL)mapView:(MGLMapView *)mapView annotationCanShowCallout:(id)annotation { + return YES; +} + - (void)testTopLayoutGuide { CGRect statusBarFrame, navigationBarFrame, compassFrame; UINavigationBar *navigationBar = tester.viewController.navigationController.navigationBar; -- cgit v1.2.1