diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2015-10-13 17:53:13 -0700 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-10-15 11:33:58 -0700 |
commit | 6e1b1836f472dee2a57cf11766eb1a04a11ad40a (patch) | |
tree | 33057639d638c179960cc4b4e32e5e106facb819 /test/ios/MapViewTests.m | |
parent | 074d61a55e32e83173ec12b2eb34b78ddaaf0ef1 (diff) | |
download | qtlocation-mapboxgl-6e1b1836f472dee2a57cf11766eb1a04a11ad40a.tar.gz |
fixes #2611: iOS test app long press drops debug marker
Diffstat (limited to 'test/ios/MapViewTests.m')
-rw-r--r-- | test/ios/MapViewTests.m | 40 |
1 files changed, 40 insertions, 0 deletions
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<MGLAnnotation>)annotation { + return YES; +} + - (void)testTopLayoutGuide { CGRect statusBarFrame, navigationBarFrame, compassFrame; UINavigationBar *navigationBar = tester.viewController.navigationController.navigationBar; |