diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index c053dca757a..a97f2d817bb 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -9,6 +9,9 @@ #import #import +const NSTimeInterval MGLAnimationDurationDefault = 0.3; +const NSTimeInterval MGLAnimationDurationOverDefault = MGLAnimationDurationDefault * 2; + @interface MapViewTests : KIFTestCase @end @@ -33,6 +36,8 @@ - (void)beforeEach { tester.viewController.navigationController.toolbarHidden = YES; tester.mapView.delegate = self; + + [tester waitForTimeInterval:0.5]; } - (void)approveLocationIfNeeded { @@ -46,12 +51,13 @@ - (void)approveLocationIfNeeded { - (void)testDirectionSet { [tester.mapView setDirection:270 animated:YES]; - [tester waitForAnimationsToFinish]; + [tester waitForTimeInterval:MGLAnimationDurationOverDefault]; XCTAssertEqual(tester.mapView.direction, 270, @"setting direction should take effect"); + [tester waitForAnimationsToFinish]; XCTAssertEqual(tester.compass.alpha, 1, @"compass should be visible when map is rotated"); @@ -63,19 +69,20 @@ - (void)testDirectionSet { - (void)testCompassTap { [tester.mapView setDirection:180 animated:YES]; - [tester waitForAnimationsToFinish]; + [tester waitForTimeInterval:MGLAnimationDurationOverDefault]; XCTAssertEqual(tester.mapView.direction, 180, @"setting direction should take effect"); [tester.compass tap]; - [tester waitForAnimationsToFinish]; + [tester waitForTimeInterval:MGLAnimationDurationOverDefault]; XCTAssertEqual(tester.mapView.direction, 0, @"tapping compass should reset map direction"); - + + [tester waitForAnimationsToFinish]; XCTAssertEqual(tester.compass.alpha, 0, @"compass should not be visible when map is unrotated"); @@ -86,19 +93,20 @@ - (void)testCompassTap { - (void)testDirectionReset { [tester.mapView setDirection:90 animated:YES]; - [tester waitForAnimationsToFinish]; + [tester waitForTimeInterval:MGLAnimationDurationOverDefault]; XCTAssertEqual(tester.mapView.direction, 90, @"setting direction should take effect"); [tester.mapView resetNorth]; - [tester waitForAnimationsToFinish]; + [tester waitForTimeInterval:MGLAnimationDurationOverDefault]; XCTAssertEqual(tester.mapView.direction, 0, @"resetting north should reset map direction"); + [tester waitForAnimationsToFinish]; XCTAssertEqual(tester.compass.alpha, 0, @"compass should not be visible when map is unrotated");