diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-06-27 13:54:58 -0700 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2016-06-27 14:15:10 -0700 |
commit | 1fa1819de1ffadc74c07972b7195cfdaea663507 (patch) | |
tree | c29cbec1e727a245629cfeb85233ad9c79c6c2fb /platform/ios/test/MGLAnnotationViewTests.m | |
parent | 8956179ce06bca099fca765ce6172980dfe7a998 (diff) | |
parent | 2d9ffcbadbfa0d6f2ecf16e0a33457a17017f583 (diff) | |
download | qtlocation-mapboxgl-1fa1819de1ffadc74c07972b7195cfdaea663507.tar.gz |
[ios] Merge branch 'release-ios-v3.3.0'
This merges v3.3.0 at beta 2 stage. Conflicts related to the os x ->
macOS rename were corrected manually.
Diffstat (limited to 'platform/ios/test/MGLAnnotationViewTests.m')
-rw-r--r-- | platform/ios/test/MGLAnnotationViewTests.m | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/platform/ios/test/MGLAnnotationViewTests.m b/platform/ios/test/MGLAnnotationViewTests.m new file mode 100644 index 0000000000..541c43b5a1 --- /dev/null +++ b/platform/ios/test/MGLAnnotationViewTests.m @@ -0,0 +1,62 @@ +#import <Mapbox/Mapbox.h> +#import <XCTest/XCTest.h> + +static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReuseIdentifer"; + +@interface MGLTestAnnotation : NSObject <MGLAnnotation> +@property (nonatomic, assign) CLLocationCoordinate2D coordinate; +@end + +@implementation MGLTestAnnotation +@end + +@interface MGLAnnotationViewTests : XCTestCase <MGLMapViewDelegate> +@property (nonatomic) XCTestExpectation *expectation; +@property (nonatomic) MGLMapView *mapView; +@property (nonatomic, weak) MGLAnnotationView *annotationView; +@end + +@implementation MGLAnnotationViewTests + +- (void)setUp +{ + [super setUp]; + _mapView = [[MGLMapView alloc] initWithFrame:CGRectZero]; + _mapView.delegate = self; +} + +- (void)testAnnotationView +{ + _expectation = [self expectationWithDescription:@"annotation property"]; + + MGLTestAnnotation *annotation = [[MGLTestAnnotation alloc] init]; + [_mapView addAnnotation:annotation]; + + [self waitForExpectationsWithTimeout:1 handler:nil]; + + XCTAssert(_mapView.annotations.count == 1, @"number of annotations should be 1"); + XCTAssertNotNil(_annotationView.annotation, @"annotation property should not be nil"); + + [_mapView removeAnnotation:_annotationView.annotation]; + + XCTAssert(_mapView.annotations.count == 0, @"number of annotations should be 0"); + XCTAssertNil(_annotationView.annotation, @"annotation property should be nil"); +} + +- (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation +{ + MGLAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:MGLTestAnnotationReuseIdentifer]; + + if (!annotationView) + { + annotationView = [[MGLAnnotationView alloc] initWithReuseIdentifier:MGLTestAnnotationReuseIdentifer]; + } + + _annotationView = annotationView; + + [_expectation fulfill]; + + return annotationView; +} + +@end |