Skip to content

Commit

Permalink
[iOS] Wait for style loading, then rotation, then compass fading
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Nov 4, 2015
1 parent 8ba2e90 commit 1eb4bbb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/ios/MapViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#import <CoreLocation/CoreLocation.h>
#import <KIF/UIAutomationHelper.h>

const NSTimeInterval MGLAnimationDurationDefault = 0.3;
const NSTimeInterval MGLAnimationDurationOverDefault = MGLAnimationDurationDefault * 2;

@interface MapViewTests : KIFTestCase <MGLMapViewDelegate>

@end
Expand All @@ -33,6 +36,8 @@ - (void)beforeEach {
tester.viewController.navigationController.toolbarHidden = YES;

tester.mapView.delegate = self;

[tester waitForTimeInterval:0.5];
}

- (void)approveLocationIfNeeded {
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 1eb4bbb

Please sign in to comment.