summaryrefslogtreecommitdiff
path: root/platform/darwin/test
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-02-20 16:39:23 -0800
committerJesse Bounds <jesse@rebounds.net>2017-02-23 15:07:43 -0800
commit59820fb63d9970c1e2cda9cf950b819b79b1e7f7 (patch)
tree4b8a17e6b22373c16195037a0ea70249e979088b /platform/darwin/test
parentde1913e2234179b4a569444dc4219381694f12fe (diff)
downloadqtlocation-mapboxgl-59820fb63d9970c1e2cda9cf950b819b79b1e7f7.tar.gz
[ios, macos] Simplify implementation of layer removal from map view
This reverts a previous change that recreated the pending and raw layer pointers if an identifier match caused a layer to be removed but the removed layer was of a different type than the layer triggering the removal This refactors the pointer replacement to use a simpler solution that returns early if the layer does not have a raw pointer loaded in the mbgl map instance.
Diffstat (limited to 'platform/darwin/test')
-rw-r--r--platform/darwin/test/MGLStyleTests.mm17
1 files changed, 16 insertions, 1 deletions
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm
index 86cf11d4aa..4f6f5f0dba 100644
--- a/platform/darwin/test/MGLStyleTests.mm
+++ b/platform/darwin/test/MGLStyleTests.mm
@@ -284,12 +284,27 @@
[self.style addLayer:circleLayer];
XCTAssertNotNil([self.style layerWithIdentifier:circleLayer.identifier]);
- MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"circle-layer"];
+ MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"background-layer"];
[self.style removeLayer:backgroundLayer];
[self.style addLayer:backgroundLayer];
XCTAssertNotNil([self.style layerWithIdentifier:backgroundLayer.identifier]);
}
+- (void)testAddingLayerOfTypeABeforeRemovingLayerOfTypeBWithSameIdentifier {
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source-removing-before-adding" shape:nil options:nil];
+ [self.style addSource:source];
+
+ // Add a fill layer with an identifer
+ MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"some-identifier" source:source];
+ [self.style addLayer:fillLayer];
+
+ // Remove a line layer (before adding it) with the same identifier as the fill layer previously added
+ MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:fillLayer.identifier source:source];
+ [self.style removeLayer:lineLayer];
+
+ XCTAssertTrue([[self.style layerWithIdentifier:fillLayer.identifier] isMemberOfClass:[MGLFillStyleLayer class]]);
+}
+
- (NSString *)stringWithContentsOfStyleHeader {
NSURL *styleHeaderURL = [[[NSBundle mgl_frameworkBundle].bundleURL
URLByAppendingPathComponent:@"Headers" isDirectory:YES]