This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios] fixes #5129 added annotation property to MGLAnnotationView
Also added a test case for MGLAnnotationView
- Loading branch information
Showing
6 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |