summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2019-07-19 16:54:48 -0700
committerJason Wray <jason@mapbox.com>2019-07-19 16:54:48 -0700
commitc5a2bd9219fa43e74046627732c54509a9264d02 (patch)
tree842a86217b6cf270c101a12a82640748a77bb874
parent2c24d34e821c6d03f3c7f3913238d4705a762049 (diff)
downloadqtlocation-mapboxgl-upstream/friedbunny-adds-compass-tap-test.tar.gz
-rw-r--r--platform/ios/test/MGLMapViewCompassViewTests.mm12
1 files changed, 11 insertions, 1 deletions
diff --git a/platform/ios/test/MGLMapViewCompassViewTests.mm b/platform/ios/test/MGLMapViewCompassViewTests.mm
index 4e00d69a67..e38ba95efe 100644
--- a/platform/ios/test/MGLMapViewCompassViewTests.mm
+++ b/platform/ios/test/MGLMapViewCompassViewTests.mm
@@ -11,8 +11,9 @@
- (void)handleTapGesture:(__unused UITapGestureRecognizer *)sender;
@end
-@interface MGLCompassButtonTests : XCTestCase
+@interface MGLCompassButtonTests : XCTestCase <MGLMapViewDelegate>
@property (nonatomic) MGLMapView *mapView;
+@property (nonatomic) XCTestExpectation *regionDidChangeExpectation;
@end
@implementation MGLCompassButtonTests
@@ -23,11 +24,13 @@
[MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
self.mapView = [[MGLMapView alloc] initWithFrame:UIScreen.mainScreen.bounds styleURL:styleURL];
+ self.mapView.delegate = self;
}
- (void)tearDown {
self.mapView = nil;
[MGLAccountManager setAccessToken:nil];
+ self.regionDidChangeExpectation = nil;
[super tearDown];
}
@@ -88,7 +91,10 @@
XCTAssertEqualWithAccuracy(self.mapView.direction, 45, 0.001);
XCTAssertEqual(self.mapView.compassView.alpha, 1, @"Compass should continue to be visible when direction changes.");
+ // Resetting to north happens with animation, so wait for it to finish.
+ self.regionDidChangeExpectation = [[XCTestExpectation alloc] initWithDescription:@"region-did-change"];
[self.mapView.compassView handleTapGesture:nil];
+ [self waitForExpectations:@[self.regionDidChangeExpectation] timeout:5.0];
XCTAssertEqual(self.mapView.direction, 0, @"Tapping the compass should reset direction to north.");
}
@@ -109,4 +115,8 @@
return MGLDegreesFromRadians(angle);
}
+- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
+ [self.regionDidChangeExpectation fulfill];
+}
+
@end