aboutsummaryrefslogtreecommitdiffstats
path: root/platform/ios/Integration Tests/MGLStyleLoadingIntegrationTests.m
blob: 38f3e51340b829d30753d7e047656f11a2bab399 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#import "MGLMapViewIntegrationTest.h"

@interface MGLStyleLoadingIntegrationTests : MGLMapViewIntegrationTest
@property (nonatomic) XCTestExpectation *styleLoadingExpectation;
@end

@implementation MGLStyleLoadingIntegrationTests

- (void)setUp {
    [super setUp];
    if (!self.mapView.style) {
        [self waitForMapViewToFinishLoadingStyleWithTimeout:10];
    }
}

- (void)tearDown {
    self.styleLoadingExpectation = nil;
}

- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
    XCTAssertNotNil(mapView.style);
    XCTAssertEqual(mapView.style, style);
    
    [self.styleLoadingExpectation fulfill];
}

- (void)waitForMapViewToFinishLoadingStyleWithTimeout:(NSTimeInterval)timeout {
    XCTAssertNil(self.styleLoadingExpectation);
    self.styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
    [self waitForExpectations:@[self.styleLoadingExpectation] timeout:timeout];
}

- (MGLStyle *)style {
    return self.mapView.style;
}
@end