Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Adding a few more test cases. testOpenGLLayerDoesNotLeakWhenSty…
Browse files Browse the repository at this point in the history
…leChanged is failing
  • Loading branch information
Asheem Mamoowala authored and akitchen committed Feb 27, 2018
1 parent 47e6a03 commit fafedb6
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions platform/ios/Integration Tests/MBGLIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ - (void)testAddingRemovingOpenGLLayer {
addRemoveGLLayer();
}

- (void)testAddingRemovingOpenGLLayerWithoutRendering {
XCTAssertNotNil(self.style);

void(^addRemoveGLLayer)(void) = ^{
MGLOpenGLStyleLayer *layer = nil;
__weak id weakLayer = nil;

@autoreleasepool {

layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"];
[self.style insertLayer:layer atIndex:0];
weakLayer = layer;
layer = nil;
[self.style removeLayer:weakLayer];
}

XCTAssertNil(weakLayer);
};

addRemoveGLLayer();
addRemoveGLLayer();
addRemoveGLLayer();
}

- (void)testReusingOpenGLLayer {
NSTimeInterval waitInterval = 0.02;

Expand Down Expand Up @@ -118,4 +142,73 @@ - (void)testOpenGLLayerDoesNotLeakWhenCreatedAndDestroyedWithoutAddingToStyle {
XCTAssertNil(weakLayer);
}

- (void)testOpenGLLayerDoesNotLeakWhenRemovedFromStyle {
NSTimeInterval waitInterval = 0.02;

MGLOpenGLStyleLayer *layer;
__weak id weakLayer;
@autoreleasepool {
layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"];
weakLayer = layer;
[self.style insertLayer:layer atIndex:0];
layer = nil;

[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];

[self.style removeLayer:[self.style layerWithIdentifier:@"gl-layer"]];
[self.mapView setNeedsDisplay];

[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];
}
XCTAssertNil(weakLayer);
}

- (void)testOpenGLLayerDoesNotLeakWhenStyleChanged {
NSTimeInterval waitInterval = 0.02;
__weak id weakLayer;

@autoreleasepool {
MGLOpenGLStyleLayer *layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"];
weakLayer = layer;
[self.style insertLayer:layer atIndex:0];
layer = nil;

[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];

NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
_styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
[self.mapView setStyleURL:styleURL];

[self waitForExpectationsWithTimeout:1 handler:nil];
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];
}
XCTAssertNil(weakLayer);
}

- (void)testReusingOpenGLLayerIdentifier {
NSTimeInterval waitInterval = 0.02;
MGLOpenGLStyleLayer *layer1, *layer2;
@autoreleasepool {
layer1 = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"];
[self.style insertLayer:layer1 atIndex:0];

[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];

[self.style removeLayer:layer1];

layer2 = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"];
[self.style insertLayer:layer2 atIndex:0];

[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];

[self.style removeLayer:layer2];

[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]];
}
XCTAssertNotNil(layer1);
XCTAssertNotNil(layer2);
XCTAssertNil([layer1 style]);
XCTAssertNil([layer2 style]);
}

@end

0 comments on commit fafedb6

Please sign in to comment.