diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ios/MapViewTests.m | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index 521549f5d2..9dd5821768 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -8,6 +8,7 @@ #import "LocationMocker/LocationMocker.h" #import <CoreLocation/CoreLocation.h> +#import <KIF/UIAutomationHelper.h> @interface MGLMapView (LocationManager) @@ -41,6 +42,15 @@ tester.mapView.delegate = self; } +- (void)approveLocationIfNeeded { + if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { + [UIAutomationHelper acknowledgeSystemAlert]; + [tester waitForTimeInterval:1]; + } + XCTAssertTrue([CLLocationManager locationServicesEnabled]); + XCTAssertEqual([CLLocationManager authorizationStatus], kCLAuthorizationStatusAuthorizedAlways); +} + - (void)testDirectionSet { tester.mapView.direction = 270; @@ -576,10 +586,9 @@ object:tester.mapView whileExecutingBlock:^{ tester.mapView.showsUserLocation = YES; + [self approveLocationIfNeeded]; }]; - [tester acknowledgeSystemAlert]; - XCTAssertEqualObjects(notification.name, @"mapViewWillStartLocatingUser", @"mapViewWillStartLocatingUser delegate should receive message"); @@ -613,7 +622,8 @@ - (void)testUserTrackingModeFollow { tester.mapView.userTrackingMode = MGLUserTrackingModeFollow; - [tester acknowledgeSystemAlert]; + [self approveLocationIfNeeded]; + [tester waitForAnimationsToFinish]; XCTAssertEqual(tester.mapView.userLocationVisible, YES, @@ -639,8 +649,9 @@ - (void)testUserTrackingModeFollowWithHeading { tester.mapView.userTrackingMode = MGLUserTrackingModeFollowWithHeading; - [tester acknowledgeSystemAlert]; - + [self approveLocationIfNeeded]; + [tester waitForAnimationsToFinish]; + XCTAssertEqual(tester.mapView.userLocationVisible, YES, @"user location should be visible"); |