[macos] Run style layer tests headlessly (#7684)

* [macos] Run style layer tests headlessly

* [ios, macos] How about a manual expectation?
This commit is contained in:
Minh Nguyễn
2017-01-11 15:30:55 -08:00
committed by GitHub
parent 71a5453690
commit 57644b2804

View File

@@ -4,7 +4,9 @@
#define TEST_STRICT_NAMING_CONVENTIONS 0
@implementation MGLStyleLayerTests
@implementation MGLStyleLayerTests {
XCTestExpectation *_styleLoadingExpectation;
}
@dynamic layerType;
@@ -20,21 +22,24 @@
_mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 256, 256) styleURL:styleURL];
[vc.view addSubview:_mapView];
#else
NSWindowController *windowController = [[NSWindowController alloc] initWithWindowNibName:@"MGLStyleLayerTests" owner:self];
NSView *contentView = windowController.window.contentView;
_mapView = [[MGLMapView alloc] initWithFrame:contentView.bounds styleURL:styleURL];
[contentView addSubview:_mapView];
[windowController showWindow:nil];
_mapView = [[MGLMapView alloc] initWithFrame:NSMakeRect(0, 0, 256, 256) styleURL:styleURL];
#endif
_mapView.delegate = self;
XCTAssertNil(_mapView.style);
[self keyValueObservingExpectationForObject:self.mapView keyPath:@"style" handler:^BOOL(MGLMapView * _Nonnull observedMapView, NSDictionary * _Nonnull change) {
return observedMapView.style != nil;
}];
_styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
[self waitForExpectationsWithTimeout:1 handler:nil];
}
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
XCTAssertNotNil(mapView.style);
XCTAssertEqual(mapView.style, style);
XCTAssertNil(style.name);
[_styleLoadingExpectation fulfill];
}
- (void)tearDown {
_styleLoadingExpectation = nil;
_mapView = nil;
[super tearDown];