diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-02-26 13:42:25 -0800 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-02-26 13:55:59 -0800 |
commit | 22a1da58765557fe37fb6461e64ec62443d9bda5 (patch) | |
tree | 3c3b7dde8af1f55987b2e87ecafdb9afe45123bf | |
parent | 47e6a031c9087b6d07a46ffbea0171fb24342ce1 (diff) | |
download | qtlocation-mapboxgl-upstream/custom-layer-style-changed-leak.tar.gz |
[ios] Adding a few more test cases. testOpenGLLayerDoesNotLeakWhenStyleChanged is failingupstream/custom-layer-style-changed-leak
-rw-r--r-- | platform/ios/Integration Tests/MBGLIntegrationTests.m | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/platform/ios/Integration Tests/MBGLIntegrationTests.m b/platform/ios/Integration Tests/MBGLIntegrationTests.m index 1008ef6c9f..cb3bdc3df6 100644 --- a/platform/ios/Integration Tests/MBGLIntegrationTests.m +++ b/platform/ios/Integration Tests/MBGLIntegrationTests.m @@ -88,6 +88,30 @@ 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; @@ -118,4 +142,73 @@ 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 |