diff options
Diffstat (limited to 'platform/darwin/test/MGLStyleTests.mm')
-rw-r--r-- | platform/darwin/test/MGLStyleTests.mm | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm index 8f610e338c..5ab17dd62e 100644 --- a/platform/darwin/test/MGLStyleTests.mm +++ b/platform/darwin/test/MGLStyleTests.mm @@ -359,20 +359,41 @@ } - (void)testAddingLayerOfTypeABeforeRemovingLayerOfTypeBWithSameIdentifier { - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source-identifier" shape:nil options:nil]; - [self.style addSource:source]; - // Add a fill layer - MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"some-identifier" source:source]; - [self.style addLayer:fillLayer]; + __weak MGLFillStyleLayer *weakFillLayer = nil; + __weak MGLLineStyleLayer *weakLineLayer = nil; - // Attempt to remove a line layer with the same identifier as the fill layer - MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:fillLayer.identifier source:source]; - [self.style removeLayer:lineLayer]; + @autoreleasepool { + + MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source-identifier" shape:nil options:nil]; + [self.style addSource:source]; + + // Add a fill layer + MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"some-identifier" source:source]; + weakFillLayer = fillLayer; + + [self.style addLayer:fillLayer]; - XCTAssertTrue([[self.style layerWithIdentifier:fillLayer.identifier] isMemberOfClass:[MGLFillStyleLayer class]]); + // Attempt to remove a line layer with the same identifier as the fill layer + MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:fillLayer.identifier source:source]; + weakLineLayer = lineLayer; + [self.style removeLayer:lineLayer]; + + // The above remove should fail, and the fill layer should still be there. + XCTAssertTrue([[self.style layerWithIdentifier:fillLayer.identifier] isMemberOfClass:[MGLFillStyleLayer class]]); + + // Finally remove the fill layer. + [self.style removeLayer:fillLayer]; + + fillLayer = nil; + lineLayer = nil; + } + + XCTAssertNil(weakFillLayer, @""); + XCTAssertNil(weakLineLayer, @""); } + - (NSString *)stringWithContentsOfStyleHeader { NSURL *styleHeaderURL = [[[NSBundle mgl_frameworkBundle].bundleURL URLByAppendingPathComponent:@"Headers" isDirectory:YES] |