diff options
Diffstat (limited to 'platform/darwin/test')
-rw-r--r-- | platform/darwin/test/MGLBackgroundStyleLayerTests.m | 9 | ||||
-rw-r--r-- | platform/darwin/test/MGLCircleStyleLayerTests.m | 25 | ||||
-rw-r--r-- | platform/darwin/test/MGLFeatureTests.mm | 165 | ||||
-rw-r--r-- | platform/darwin/test/MGLFillStyleLayerTests.m | 16 | ||||
-rw-r--r-- | platform/darwin/test/MGLFilterTests.mm | 16 | ||||
-rw-r--r-- | platform/darwin/test/MGLLineStyleLayerTests.m | 34 | ||||
-rw-r--r-- | platform/darwin/test/MGLRasterStyleLayerTests.m | 7 | ||||
-rw-r--r-- | platform/darwin/test/MGLRuntimeStylingHelper.h | 38 | ||||
-rw-r--r-- | platform/darwin/test/MGLRuntimeStylingHelper.m | 120 | ||||
-rw-r--r-- | platform/darwin/test/MGLSymbolStyleLayerTests.m | 97 |
10 files changed, 337 insertions, 190 deletions
diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.m b/platform/darwin/test/MGLBackgroundStyleLayerTests.m index f4fdae61a4..2681b773ae 100644 --- a/platform/darwin/test/MGLBackgroundStyleLayerTests.m +++ b/platform/darwin/test/MGLBackgroundStyleLayerTests.m @@ -9,18 +9,15 @@ @implementation MGLBackgroundLayerTests - (void)testBackgroundLayer { - NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; - NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url]; -MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithLayerIdentifier:@"layerID" source:source]; - [self.mapView.style addSource:source]; + MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"layerID"]; [self.mapView.style addLayer:layer]; layer.backgroundColor = [MGLRuntimeStylingHelper testColor]; layer.backgroundPattern = [MGLRuntimeStylingHelper testString]; layer.backgroundOpacity = [MGLRuntimeStylingHelper testNumber]; - MGLBackgroundStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"]; + MGLBackgroundStyleLayer *gLayer = (MGLBackgroundStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGLBackgroundStyleLayer class]]); XCTAssertEqualObjects(gLayer.backgroundColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.backgroundPattern, [MGLRuntimeStylingHelper testString]); XCTAssertEqualObjects(gLayer.backgroundOpacity, [MGLRuntimeStylingHelper testNumber]); diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.m b/platform/darwin/test/MGLCircleStyleLayerTests.m index 0e70c3f836..54ba8be6c1 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.m +++ b/platform/darwin/test/MGLCircleStyleLayerTests.m @@ -11,9 +11,9 @@ - (void)testCircleLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url]; -MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithLayerIdentifier:@"layerID" source:source]; + MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; [self.mapView.style addSource:source]; + MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; layer.circleRadius = [MGLRuntimeStylingHelper testNumber]; @@ -21,33 +21,36 @@ MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithLayerIdentifie layer.circleBlur = [MGLRuntimeStylingHelper testNumber]; layer.circleOpacity = [MGLRuntimeStylingHelper testNumber]; layer.circleTranslate = [MGLRuntimeStylingHelper testOffset]; - layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)]; - layer.circlePitchScale = [MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)]; + layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]; + layer.circlePitchScale = [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]; - MGLCircleStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"]; + MGLCircleStyleLayer *gLayer = (MGLCircleStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGLCircleStyleLayer class]]); XCTAssertEqualObjects(gLayer.circleRadius, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.circleColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.circleBlur, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.circleOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.circleTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)]], @"%@ is not equal to %@", gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)]); - XCTAssert([(NSValue *)gLayer.circlePitchScale isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)]], @"%@ is not equal to %@", gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)]); + XCTAssert([gLayer.circleTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); + XCTAssert([gLayer.circlePitchScale isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]); layer.circleRadius = [MGLRuntimeStylingHelper testNumberFunction]; layer.circleColor = [MGLRuntimeStylingHelper testColorFunction]; layer.circleBlur = [MGLRuntimeStylingHelper testNumberFunction]; layer.circleOpacity = [MGLRuntimeStylingHelper testNumberFunction]; layer.circleTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; - layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)]; - layer.circlePitchScale = [MGLRuntimeStylingHelper testEnumFunction:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)]; + layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]; + layer.circlePitchScale = [MGLRuntimeStylingHelper testEnumFunction:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]; XCTAssertEqualObjects(gLayer.circleRadius, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.circleColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.circleBlur, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.circleOpacity, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffsetFunction]); - XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)]); - XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)]); + XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); + XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnumFunction:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]); } @end diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 1b1722f172..18c3fd16c2 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -158,4 +158,169 @@ XCTAssertEqual(string, shape.attributes[@"string"]); } +- (void)testPointFeatureGeoJSONDictionary { + MGLPointFeature<MGLFeaturePrivate> *pointFeature = (MGLPointFeature<MGLFeaturePrivate> *)[[MGLPointFeature alloc] init]; + CLLocationCoordinate2D coordinate = { 10, 10 }; + pointFeature.coordinate = coordinate; + + // A GeoJSON feature + // when there are no identifier or properties + NSDictionary *geoJSONFeature = [pointFeature geoJSONDictionary]; + + // it has the correct type + XCTAssertEqualObjects(geoJSONFeature[@"type"], @"Feature"); + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"Point", + @"coordinates": @[@(coordinate.longitude), @(coordinate.latitude)]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); + // it has no "id" key (or value) + XCTAssertNil(geoJSONFeature[@"id"]); + // it has a null representation of the properties object + XCTAssertEqualObjects(geoJSONFeature[@"properties"], [NSNull null]); + + // when there is a string identifier + pointFeature.identifier = @"string-id"; + + // it has the identifier in the result + geoJSONFeature = [pointFeature geoJSONDictionary]; + XCTAssertEqualObjects(geoJSONFeature[@"id"], pointFeature.identifier); + + // when there are properties + pointFeature.attributes = @{@"name": @"name-value"}; + + // it has the properties value in the result + geoJSONFeature = [pointFeature geoJSONDictionary]; + XCTAssertEqualObjects(geoJSONFeature[@"properties"], pointFeature.attributes); +} + +- (void)testPolylineFeatureGeoJSONDictionary { + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coords[] = { coord1, coord2 }; + MGLPolylineFeature *polyLineFeature = [MGLPolylineFeature polylineWithCoordinates:coords count:2]; + + // A GeoJSON feature + NSDictionary *geoJSONFeature = [polyLineFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"LineString", + @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)]]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); +} + +- (void)testPolygonFeatureGeoJSONDictionary { + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coord3 = { 0, 0 }; + CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 }; + MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coords count:3]; + + // A GeoJSON feature + NSDictionary *geoJSONFeature = [polygonFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"Polygon", + @"coordinates": @[@[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]]]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); +} + +- (void)testMultiPointFeatureGeoJSONDictionary { + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coord3 = { 0, 0 }; + CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 }; + MGLMultiPointFeature *multiPointFeature = [MGLMultiPointFeature multiPointWithCoordinates:coords count:3]; + + // A GeoJSON feature + NSDictionary *geoJSONFeature = [multiPointFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"MultiPoint", + @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); +} + +- (void)testMultiPolylineFeatureGeoJSONDictionary { + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coord3 = { 0, 0 }; + CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 }; + + MGLPolyline *polyLine1 = [MGLPolyline polylineWithCoordinates:coords count:3]; + MGLPolyline *polyLine2 = [MGLPolyline polylineWithCoordinates:coords count:3]; + + MGLMultiPolylineFeature *multiPolylineFeature = [MGLMultiPolylineFeature multiPolylineWithPolylines:@[polyLine1, polyLine2]]; + + // A GeoJSON feature + NSDictionary *geoJSONFeature = [multiPolylineFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"MultiLineString", + @"coordinates": @[@[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]], + @[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]]]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); +} + +- (void)testMultiPolygonFeatureGeoJSONDictionary { + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coord3 = { 0, 0 }; + CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 }; + + MGLPolygon *polygon1 = [MGLPolygon polygonWithCoordinates:coords count:3]; + MGLPolygon *polygon2 = [MGLPolygon polygonWithCoordinates:coords count:3]; + + MGLMultiPolygonFeature *multiPolylineFeature = [MGLMultiPolygonFeature multiPolygonWithPolygons:@[polygon1, polygon2]]; + + // A GeoJSON feature + NSDictionary *geoJSONFeature = [multiPolylineFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"MultiPolygon", + @"coordinates": @[ + @[@[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]]], + @[@[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]]]]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); +} + +- (void)testShapeCollectionFeatureGeoJSONDictionary { + MGLPointAnnotation *pointFeature = [[MGLPointAnnotation alloc] init]; + CLLocationCoordinate2D pointCoordinate = { 10, 10 }; + pointFeature.coordinate = pointCoordinate; + + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coords[] = { coord1, coord2 }; + MGLPolyline *polyline = [MGLPolyline polylineWithCoordinates:coords count:2]; + + MGLShapeCollectionFeature *shapeCollectionFeature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[pointFeature, + polyline]]; + // A GeoJSON feature + NSDictionary *geoJSONFeature = [shapeCollectionFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"GeometryCollection", + @"geometries": @[ + @{@"type": @"Point", + @"coordinates": @[@(pointCoordinate.longitude), @(pointCoordinate.latitude)]}, + @{@"type": @"LineString", + @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)]]} + ]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); +} + @end diff --git a/platform/darwin/test/MGLFillStyleLayerTests.m b/platform/darwin/test/MGLFillStyleLayerTests.m index 7994d76517..7b31207902 100644 --- a/platform/darwin/test/MGLFillStyleLayerTests.m +++ b/platform/darwin/test/MGLFillStyleLayerTests.m @@ -11,9 +11,9 @@ - (void)testFillLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url]; -MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithLayerIdentifier:@"layerID" source:source]; + MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; [self.mapView.style addSource:source]; + MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; layer.fillAntialias = [MGLRuntimeStylingHelper testBool]; @@ -21,16 +21,18 @@ MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithLayerIdentifier:@" layer.fillColor = [MGLRuntimeStylingHelper testColor]; layer.fillOutlineColor = [MGLRuntimeStylingHelper testColor]; layer.fillTranslate = [MGLRuntimeStylingHelper testOffset]; - layer.fillTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)]; + layer.fillTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]; layer.fillPattern = [MGLRuntimeStylingHelper testString]; - MGLFillStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"]; + MGLFillStyleLayer *gLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGLFillStyleLayer class]]); XCTAssertEqualObjects(gLayer.fillAntialias, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.fillOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.fillColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.fillOutlineColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.fillTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.fillTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)]], @"%@ is not equal to %@", gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)]); + XCTAssert([gLayer.fillTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]); XCTAssertEqualObjects(gLayer.fillPattern, [MGLRuntimeStylingHelper testString]); layer.fillAntialias = [MGLRuntimeStylingHelper testBoolFunction]; @@ -38,7 +40,7 @@ MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithLayerIdentifier:@" layer.fillColor = [MGLRuntimeStylingHelper testColorFunction]; layer.fillOutlineColor = [MGLRuntimeStylingHelper testColorFunction]; layer.fillTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; - layer.fillTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)]; + layer.fillTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]; layer.fillPattern = [MGLRuntimeStylingHelper testStringFunction]; XCTAssertEqualObjects(gLayer.fillAntialias, [MGLRuntimeStylingHelper testBoolFunction]); @@ -46,7 +48,7 @@ MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithLayerIdentifier:@" XCTAssertEqualObjects(gLayer.fillColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.fillOutlineColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.fillTranslate, [MGLRuntimeStylingHelper testOffsetFunction]); - XCTAssertEqualObjects(gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)]); + XCTAssertEqualObjects(gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]); XCTAssertEqualObjects(gLayer.fillPattern, [MGLRuntimeStylingHelper testStringFunction]); } diff --git a/platform/darwin/test/MGLFilterTests.mm b/platform/darwin/test/MGLFilterTests.mm index 6fbe5f0157..2bb188575b 100644 --- a/platform/darwin/test/MGLFilterTests.mm +++ b/platform/darwin/test/MGLFilterTests.mm @@ -18,9 +18,9 @@ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; NSData *geoJSONData = [NSData dataWithContentsOfURL:url]; - source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"test-source" geoJSONData:geoJSONData]; + source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"test-source" geoJSONData:geoJSONData options:nil]; [self.mapView.style addSource:source]; - layer = [[MGLLineStyleLayer alloc] initWithLayerIdentifier:@"test-layer" source:source]; + layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"test-layer" source:source]; } - (void)tearDown @@ -74,18 +74,6 @@ [self.mapView.style addLayer:layer]; } -- (void)testContainsPredicate -{ - // core does not have a "contains" filter but we can achieve the equivalent by creating an `mbgl::style::InFilter` - // and searching the value for the key - NSPredicate *expectedPredicate = [NSPredicate predicateWithFormat:@"park IN %@", @[@"park", @"neighbourhood"]]; - NSPredicate *containsPredicate = [NSPredicate predicateWithFormat:@"%@ CONTAINS %@", @[@"park", @"neighbourhood"], @"park"]; - - layer.predicate = containsPredicate; - XCTAssertEqualObjects(layer.predicate, expectedPredicate); - [self.mapView.style addLayer:layer]; -} - - (void)testBetweenPredicate { // core does not have a "between" filter but we can achieve the equivalent by creating a set of greater than or equal / less than or equal diff --git a/platform/darwin/test/MGLLineStyleLayerTests.m b/platform/darwin/test/MGLLineStyleLayerTests.m index ff607f2e2b..801bc12ff8 100644 --- a/platform/darwin/test/MGLLineStyleLayerTests.m +++ b/platform/darwin/test/MGLLineStyleLayerTests.m @@ -11,19 +11,19 @@ - (void)testLineLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url]; -MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithLayerIdentifier:@"layerID" source:source]; + MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; [self.mapView.style addSource:source]; + MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; - layer.lineCap = [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)]; - layer.lineJoin = [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)]; + layer.lineCap = [MGLRuntimeStylingHelper testEnum:MGLLineCapSquare type:@encode(MGLLineCap)]; + layer.lineJoin = [MGLRuntimeStylingHelper testEnum:MGLLineJoinMiter type:@encode(MGLLineJoin)]; layer.lineMiterLimit = [MGLRuntimeStylingHelper testNumber]; layer.lineRoundLimit = [MGLRuntimeStylingHelper testNumber]; layer.lineOpacity = [MGLRuntimeStylingHelper testNumber]; layer.lineColor = [MGLRuntimeStylingHelper testColor]; layer.lineTranslate = [MGLRuntimeStylingHelper testOffset]; - layer.lineTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)]; + layer.lineTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]; layer.lineWidth = [MGLRuntimeStylingHelper testNumber]; layer.lineGapWidth = [MGLRuntimeStylingHelper testNumber]; layer.lineOffset = [MGLRuntimeStylingHelper testNumber]; @@ -31,15 +31,19 @@ MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithLayerIdentifier:@" layer.lineDasharray = [MGLRuntimeStylingHelper testDashArray]; layer.linePattern = [MGLRuntimeStylingHelper testString]; - MGLLineStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"]; - XCTAssert([(NSValue *)gLayer.lineCap isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)]], @"%@ is not equal to %@", gLayer.lineCap, [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)]); - XCTAssert([(NSValue *)gLayer.lineJoin isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)]], @"%@ is not equal to %@", gLayer.lineJoin, [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)]); + MGLLineStyleLayer *gLayer = (MGLLineStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGLLineStyleLayer class]]); + XCTAssert([gLayer.lineCap isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.lineCap, [MGLRuntimeStylingHelper testEnum:MGLLineCapSquare type:@encode(MGLLineCap)]); + XCTAssert([gLayer.lineJoin isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.lineJoin, [MGLRuntimeStylingHelper testEnum:MGLLineJoinMiter type:@encode(MGLLineJoin)]); XCTAssertEqualObjects(gLayer.lineMiterLimit, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineRoundLimit, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.lineTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.lineTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)]], @"%@ is not equal to %@", gLayer.lineTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)]); + XCTAssert([gLayer.lineTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.lineTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]); XCTAssertEqualObjects(gLayer.lineWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineGapWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineOffset, [MGLRuntimeStylingHelper testNumber]); @@ -47,14 +51,14 @@ MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithLayerIdentifier:@" XCTAssertEqualObjects(gLayer.lineDasharray, [MGLRuntimeStylingHelper testDashArray]); XCTAssertEqualObjects(gLayer.linePattern, [MGLRuntimeStylingHelper testString]); - layer.lineCap = [MGLRuntimeStylingHelper testEnumFunction:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)]; - layer.lineJoin = [MGLRuntimeStylingHelper testEnumFunction:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)]; + layer.lineCap = [MGLRuntimeStylingHelper testEnumFunction:MGLLineCapSquare type:@encode(MGLLineCap)]; + layer.lineJoin = [MGLRuntimeStylingHelper testEnumFunction:MGLLineJoinMiter type:@encode(MGLLineJoin)]; layer.lineMiterLimit = [MGLRuntimeStylingHelper testNumberFunction]; layer.lineRoundLimit = [MGLRuntimeStylingHelper testNumberFunction]; layer.lineOpacity = [MGLRuntimeStylingHelper testNumberFunction]; layer.lineColor = [MGLRuntimeStylingHelper testColorFunction]; layer.lineTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; - layer.lineTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)]; + layer.lineTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]; layer.lineWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.lineGapWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.lineOffset = [MGLRuntimeStylingHelper testNumberFunction]; @@ -62,14 +66,14 @@ MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithLayerIdentifier:@" layer.lineDasharray = [MGLRuntimeStylingHelper testDashArrayFunction]; layer.linePattern = [MGLRuntimeStylingHelper testStringFunction]; - XCTAssertEqualObjects(gLayer.lineCap, [MGLRuntimeStylingHelper testEnumFunction:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)]); - XCTAssertEqualObjects(gLayer.lineJoin, [MGLRuntimeStylingHelper testEnumFunction:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)]); + XCTAssertEqualObjects(gLayer.lineCap, [MGLRuntimeStylingHelper testEnumFunction:MGLLineCapSquare type:@encode(MGLLineCap)]); + XCTAssertEqualObjects(gLayer.lineJoin, [MGLRuntimeStylingHelper testEnumFunction:MGLLineJoinMiter type:@encode(MGLLineJoin)]); XCTAssertEqualObjects(gLayer.lineMiterLimit, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.lineRoundLimit, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.lineOpacity, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.lineColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.lineTranslate, [MGLRuntimeStylingHelper testOffsetFunction]); - XCTAssertEqualObjects(gLayer.lineTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)]); + XCTAssertEqualObjects(gLayer.lineTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]); XCTAssertEqualObjects(gLayer.lineWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.lineGapWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.lineOffset, [MGLRuntimeStylingHelper testNumberFunction]); diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.m b/platform/darwin/test/MGLRasterStyleLayerTests.m index 7158c9aef2..f68f6d3283 100644 --- a/platform/darwin/test/MGLRasterStyleLayerTests.m +++ b/platform/darwin/test/MGLRasterStyleLayerTests.m @@ -11,9 +11,9 @@ - (void)testRasterLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url]; -MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithLayerIdentifier:@"layerID" source:source]; + MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; [self.mapView.style addSource:source]; + MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; layer.rasterOpacity = [MGLRuntimeStylingHelper testNumber]; @@ -24,7 +24,8 @@ MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithLayerIdentifie layer.rasterContrast = [MGLRuntimeStylingHelper testNumber]; layer.rasterFadeDuration = [MGLRuntimeStylingHelper testNumber]; - MGLRasterStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"]; + MGLRasterStyleLayer *gLayer = (MGLRasterStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGLRasterStyleLayer class]]); XCTAssertEqualObjects(gLayer.rasterOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.rasterHueRotate, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.rasterBrightnessMin, [MGLRuntimeStylingHelper testNumber]); diff --git a/platform/darwin/test/MGLRuntimeStylingHelper.h b/platform/darwin/test/MGLRuntimeStylingHelper.h index 6626d13901..8857dba9c5 100644 --- a/platform/darwin/test/MGLRuntimeStylingHelper.h +++ b/platform/darwin/test/MGLRuntimeStylingHelper.h @@ -1,35 +1,35 @@ #import <Foundation/Foundation.h> #import "MGLTypes.h" -#import "MGLStyleAttributeFunction.h" +#import "MGLStyleValue.h" @interface MGLRuntimeStylingHelper : NSObject -+ (NSArray *)testPadding; -+ (MGLStyleAttributeFunction *)testPaddingFunction; ++ (MGLStyleConstantValue<NSValue *> *)testPadding; ++ (MGLStyleFunction<NSValue *> *)testPaddingFunction; -+ (NSArray *)testOffset; -+ (MGLStyleAttributeFunction *)testOffsetFunction; ++ (MGLStyleConstantValue<NSValue *> *)testOffset; ++ (MGLStyleFunction<NSValue *> *)testOffsetFunction; -+ (NSArray *)testFont; -+ (MGLStyleAttributeFunction *)testFontFunction; ++ (MGLStyleConstantValue<NSArray<NSString *> *> *)testFont; ++ (MGLStyleFunction<NSArray<NSString *> *> *)testFontFunction; -+ (NSArray *)testDashArray; -+ (MGLStyleAttributeFunction *)testDashArrayFunction; ++ (MGLStyleConstantValue<NSArray<NSNumber *> *> *)testDashArray; ++ (MGLStyleFunction<NSArray<NSNumber *> *> *)testDashArrayFunction; -+ (NSNumber *)testNumber; -+ (MGLStyleAttributeFunction *)testNumberFunction; ++ (MGLStyleConstantValue<NSNumber *> *)testNumber; ++ (MGLStyleFunction<NSNumber *> *)testNumberFunction; -+ (NSNumber *)testBool; -+ (MGLStyleAttributeFunction *)testBoolFunction; ++ (MGLStyleConstantValue<NSNumber *> *)testBool; ++ (MGLStyleFunction<NSNumber *> *)testBoolFunction; -+ (NSString *)testString; -+ (MGLStyleAttributeFunction *)testStringFunction; ++ (MGLStyleConstantValue<NSString *> *)testString; ++ (MGLStyleFunction<NSString *> *)testStringFunction; -+ (MGLColor *)testColor; -+ (MGLStyleAttributeFunction *)testColorFunction; ++ (MGLStyleConstantValue<MGLColor *> *)testColor; ++ (MGLStyleFunction<MGLColor *> *)testColorFunction; -+ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type; -+ (MGLStyleAttributeFunction *)testEnumFunction:(NSUInteger)value type:(const char *)type; ++ (MGLStyleConstantValue<NSValue *> *)testEnum:(NSUInteger)value type:(const char *)type; ++ (MGLStyleFunction<NSValue *> *)testEnumFunction:(NSUInteger)value type:(const char *)type; @end diff --git a/platform/darwin/test/MGLRuntimeStylingHelper.m b/platform/darwin/test/MGLRuntimeStylingHelper.m index 29e80086ec..955c664f2c 100644 --- a/platform/darwin/test/MGLRuntimeStylingHelper.m +++ b/platform/darwin/test/MGLRuntimeStylingHelper.m @@ -10,7 +10,7 @@ @implementation MGLRuntimeStylingHelper -+ (NSValue *)testPadding ++ (MGLStyleConstantValue<NSValue *> *)testPadding { MGLEdgeInsets insets = { .top = 1, @@ -18,129 +18,105 @@ .bottom = 1, .right = 1, }; - return [NSValue value:&insets withObjCType:@encode(MGLEdgeInsets)]; + return [MGLStyleConstantValue<NSValue *> valueWithRawValue:[NSValue value:&insets withObjCType:@encode(MGLEdgeInsets)]]; } -+ (MGLStyleAttributeFunction *)testPaddingFunction ++ (MGLStyleFunction<NSValue *> *)testPaddingFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testPadding, - }; - return function; + return [MGLStyleFunction<NSValue *> functionWithStops:@{@(18): self.testPadding}]; } -+ (NSValue *)testOffset ++ (MGLStyleConstantValue<NSValue *> *)testOffset { CGVector vector = CGVectorMake(1, 1); - return [NSValue value:&vector withObjCType:@encode(CGVector)]; + return [MGLStyleConstantValue<NSValue *> valueWithRawValue:[NSValue value:&vector withObjCType:@encode(CGVector)]]; } -+ (MGLStyleAttributeFunction *)testOffsetFunction ++ (MGLStyleFunction<NSValue *> *)testOffsetFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testOffset, - }; - return function; + return [MGLStyleFunction<NSValue *> valueWithStops:@{ @(18): self.testOffset }]; } -+ (NSArray *)testFont ++ (MGLStyleConstantValue<NSArray<NSString *> *> *)testFont { - return @[@"Open Sans Regular", @"Arial Unicode MS Regular"]; + return [MGLStyleConstantValue<NSArray<NSString *> *> valueWithRawValue:@[@"Open Sans Regular", @"Arial Unicode MS Regular"]]; } -+ (MGLStyleAttributeFunction *)testFontFunction ++ (MGLStyleFunction<NSArray<NSString *> *> *)testFontFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testFont, - }; - return function; + return [MGLStyleFunction<NSArray<NSString *> *> valueWithStops:@{ @18: self.testFont }]; } -+ (NSArray *)testDashArray ++ (MGLStyleConstantValue<NSArray<NSNumber *> *> *)testDashArray { - return @[@1, @2]; + return [MGLStyleConstantValue<NSArray<NSNumber *> *> valueWithRawValue:@[@1, @2]]; } -+ (MGLStyleAttributeFunction *)testDashArrayFunction ++ (MGLStyleFunction<NSArray<NSNumber *> *> *)testDashArrayFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testDashArray, - }; - return function; + return [MGLStyleFunction<NSArray<NSNumber *> *> valueWithStops:@{ + @18: self.testDashArray, + }]; } -+ (NSNumber *)testNumber ++ (MGLStyleConstantValue<NSNumber *> *)testNumber { - return @1; + return [MGLStyleConstantValue<NSNumber *> valueWithRawValue:@1]; } -+ (MGLStyleAttributeFunction *)testNumberFunction ++ (MGLStyleFunction<NSNumber *> *)testNumberFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testNumber, - }; - return function; + return [MGLStyleFunction<NSNumber *> valueWithStops:@{ + @18: self.testNumber, + }]; } -+ (NSNumber *)testBool ++ (MGLStyleConstantValue<NSNumber *> *)testBool { - return @YES; + return [MGLStyleConstantValue<NSNumber *> valueWithRawValue:@YES]; } -+ (MGLStyleAttributeFunction *)testBoolFunction ++ (MGLStyleFunction<NSNumber *> *)testBoolFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testBool, - }; - return function; + return [MGLStyleFunction<NSNumber *> valueWithStops:@{ + @18: self.testBool, + }]; } -+ (NSString *)testString ++ (MGLStyleConstantValue<NSString *> *)testString { - return @"test"; + return [MGLStyleConstantValue<NSString *> valueWithRawValue:@"test"]; } -+ (MGLStyleAttributeFunction *)testStringFunction ++ (MGLStyleFunction<NSString *> *)testStringFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testString, - }; - return function; + return [MGLStyleFunction<NSString *> valueWithStops:@{ + @18: self.testString, + }]; } -+ (MGLColor *)testColor ++ (MGLStyleConstantValue<MGLColor *> *)testColor { - return [MGLColor redColor]; + return [MGLStyleConstantValue<MGLColor *> valueWithRawValue:[MGLColor redColor]]; } -+ (MGLStyleAttributeFunction *)testColorFunction ++ (MGLStyleFunction<MGLColor *> *)testColorFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testColor, - }; - return function; + return [MGLStyleFunction<MGLColor *> valueWithStops:@{ + @18: self.testColor, + }]; } -+ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type ++ (MGLStyleConstantValue<NSValue *> *)testEnum:(NSUInteger)value type:(const char *)type { - return [NSValue value:&value withObjCType:type]; + return [MGLStyleConstantValue<NSValue *> valueWithRawValue:[NSValue value:&value withObjCType:type]]; } -+ (MGLStyleAttributeFunction *)testEnumFunction:(NSUInteger)value type:(const char *)type ++ (MGLStyleFunction<NSValue *> *)testEnumFunction:(NSUInteger)value type:(const char *)type { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): [self testEnum:value type:type], - }; - return function; + return [MGLStyleFunction<NSValue *> valueWithStops:@{ + @18: [self testEnum:value type:type], + }]; } @end diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.m b/platform/darwin/test/MGLSymbolStyleLayerTests.m index 096a49b571..f60ae7c2a8 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.m +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.m @@ -11,41 +11,41 @@ - (void)testSymbolLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url]; -MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifier:@"layerID" source:source]; + MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; [self.mapView.style addSource:source]; + MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; - layer.symbolPlacement = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)]; + layer.symbolPlacement = [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]; layer.symbolSpacing = [MGLRuntimeStylingHelper testNumber]; layer.symbolAvoidEdges = [MGLRuntimeStylingHelper testBool]; layer.iconAllowOverlap = [MGLRuntimeStylingHelper testBool]; layer.iconIgnorePlacement = [MGLRuntimeStylingHelper testBool]; layer.iconOptional = [MGLRuntimeStylingHelper testBool]; - layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]; + layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]; layer.iconSize = [MGLRuntimeStylingHelper testNumber]; - layer.iconTextFit = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitBoth type:@encode(MGLSymbolStyleLayerIconTextFit)]; + layer.iconTextFit = [MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]; layer.iconTextFitPadding = [MGLRuntimeStylingHelper testPadding]; layer.iconImage = [MGLRuntimeStylingHelper testString]; layer.iconRotate = [MGLRuntimeStylingHelper testNumber]; layer.iconPadding = [MGLRuntimeStylingHelper testNumber]; layer.iconKeepUpright = [MGLRuntimeStylingHelper testBool]; layer.iconOffset = [MGLRuntimeStylingHelper testOffset]; - layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]; - layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]; + layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]; + layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]; layer.textField = [MGLRuntimeStylingHelper testString]; layer.textFont = [MGLRuntimeStylingHelper testFont]; layer.textSize = [MGLRuntimeStylingHelper testNumber]; layer.textMaxWidth = [MGLRuntimeStylingHelper testNumber]; layer.textLineHeight = [MGLRuntimeStylingHelper testNumber]; layer.textLetterSpacing = [MGLRuntimeStylingHelper testNumber]; - layer.textJustify = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)]; - layer.textAnchor = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)]; + layer.textJustify = [MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]; + layer.textAnchor = [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]; layer.textMaxAngle = [MGLRuntimeStylingHelper testNumber]; layer.textRotate = [MGLRuntimeStylingHelper testNumber]; layer.textPadding = [MGLRuntimeStylingHelper testNumber]; layer.textKeepUpright = [MGLRuntimeStylingHelper testBool]; - layer.textTransform = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)]; + layer.textTransform = [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]; layer.textOffset = [MGLRuntimeStylingHelper testOffset]; layer.textAllowOverlap = [MGLRuntimeStylingHelper testBool]; layer.textIgnorePlacement = [MGLRuntimeStylingHelper testBool]; @@ -56,46 +56,55 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie layer.iconHaloWidth = [MGLRuntimeStylingHelper testNumber]; layer.iconHaloBlur = [MGLRuntimeStylingHelper testNumber]; layer.iconTranslate = [MGLRuntimeStylingHelper testOffset]; - layer.iconTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)]; + layer.iconTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]; layer.textOpacity = [MGLRuntimeStylingHelper testNumber]; layer.textColor = [MGLRuntimeStylingHelper testColor]; layer.textHaloColor = [MGLRuntimeStylingHelper testColor]; layer.textHaloWidth = [MGLRuntimeStylingHelper testNumber]; layer.textHaloBlur = [MGLRuntimeStylingHelper testNumber]; layer.textTranslate = [MGLRuntimeStylingHelper testOffset]; - layer.textTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)]; + layer.textTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]; - MGLSymbolStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"]; - XCTAssert([(NSValue *)gLayer.symbolPlacement isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)]], @"%@ is not equal to %@", gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)]); + MGLSymbolStyleLayer *gLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGLSymbolStyleLayer class]]); + XCTAssert([gLayer.symbolPlacement isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]); XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.symbolAvoidEdges, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBool]); - XCTAssert([(NSValue *)gLayer.iconRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]], @"%@ is not equal to %@", gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]); + XCTAssert([gLayer.iconRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]); XCTAssertEqualObjects(gLayer.iconSize, [MGLRuntimeStylingHelper testNumber]); - XCTAssert([(NSValue *)gLayer.iconTextFit isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitBoth type:@encode(MGLSymbolStyleLayerIconTextFit)]], @"%@ is not equal to %@", gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitBoth type:@encode(MGLSymbolStyleLayerIconTextFit)]); + XCTAssert([gLayer.iconTextFit isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]); XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPadding]); XCTAssertEqualObjects(gLayer.iconImage, [MGLRuntimeStylingHelper testString]); XCTAssertEqualObjects(gLayer.iconRotate, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.textPitchAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]], @"%@ is not equal to %@", gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]); - XCTAssert([(NSValue *)gLayer.textRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]], @"%@ is not equal to %@", gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]); + XCTAssert([gLayer.textPitchAlignment isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]); + XCTAssert([gLayer.textRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]); XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testString]); XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFont]); XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textMaxWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textLineHeight, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textLetterSpacing, [MGLRuntimeStylingHelper testNumber]); - XCTAssert([(NSValue *)gLayer.textJustify isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)]], @"%@ is not equal to %@", gLayer.textJustify, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)]); - XCTAssert([(NSValue *)gLayer.textAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)]], @"%@ is not equal to %@", gLayer.textAnchor, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)]); + XCTAssert([gLayer.textJustify isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textJustify, [MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]); + XCTAssert([gLayer.textAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]); XCTAssertEqualObjects(gLayer.textMaxAngle, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textRotate, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textPadding, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textKeepUpright, [MGLRuntimeStylingHelper testBool]); - XCTAssert([(NSValue *)gLayer.textTransform isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)]], @"%@ is not equal to %@", gLayer.textTransform, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)]); + XCTAssert([gLayer.textTransform isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]); XCTAssertEqualObjects(gLayer.textOffset, [MGLRuntimeStylingHelper testOffset]); XCTAssertEqualObjects(gLayer.textAllowOverlap, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.textIgnorePlacement, [MGLRuntimeStylingHelper testBool]); @@ -106,45 +115,47 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie XCTAssertEqualObjects(gLayer.iconHaloWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconHaloBlur, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.iconTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)]], @"%@ is not equal to %@", gLayer.iconTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)]); + XCTAssert([gLayer.iconTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.iconTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]); XCTAssertEqualObjects(gLayer.textOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.textHaloColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.textHaloWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textHaloBlur, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.textTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)]], @"%@ is not equal to %@", gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)]); + XCTAssert([gLayer.textTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]); - layer.symbolPlacement = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)]; + layer.symbolPlacement = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]; layer.symbolSpacing = [MGLRuntimeStylingHelper testNumberFunction]; layer.symbolAvoidEdges = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconAllowOverlap = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconIgnorePlacement = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconOptional = [MGLRuntimeStylingHelper testBoolFunction]; - layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]; + layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]; layer.iconSize = [MGLRuntimeStylingHelper testNumberFunction]; - layer.iconTextFit = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconTextFitBoth type:@encode(MGLSymbolStyleLayerIconTextFit)]; + layer.iconTextFit = [MGLRuntimeStylingHelper testEnumFunction:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]; layer.iconTextFitPadding = [MGLRuntimeStylingHelper testPaddingFunction]; layer.iconImage = [MGLRuntimeStylingHelper testStringFunction]; layer.iconRotate = [MGLRuntimeStylingHelper testNumberFunction]; layer.iconPadding = [MGLRuntimeStylingHelper testNumberFunction]; layer.iconKeepUpright = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconOffset = [MGLRuntimeStylingHelper testOffsetFunction]; - layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]; - layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]; + layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]; + layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]; layer.textField = [MGLRuntimeStylingHelper testStringFunction]; layer.textFont = [MGLRuntimeStylingHelper testFontFunction]; layer.textSize = [MGLRuntimeStylingHelper testNumberFunction]; layer.textMaxWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.textLineHeight = [MGLRuntimeStylingHelper testNumberFunction]; layer.textLetterSpacing = [MGLRuntimeStylingHelper testNumberFunction]; - layer.textJustify = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)]; - layer.textAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)]; + layer.textJustify = [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustifyRight type:@encode(MGLTextJustify)]; + layer.textAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]; layer.textMaxAngle = [MGLRuntimeStylingHelper testNumberFunction]; layer.textRotate = [MGLRuntimeStylingHelper testNumberFunction]; layer.textPadding = [MGLRuntimeStylingHelper testNumberFunction]; layer.textKeepUpright = [MGLRuntimeStylingHelper testBoolFunction]; - layer.textTransform = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)]; + layer.textTransform = [MGLRuntimeStylingHelper testEnumFunction:MGLTextTransformLowercase type:@encode(MGLTextTransform)]; layer.textOffset = [MGLRuntimeStylingHelper testOffsetFunction]; layer.textAllowOverlap = [MGLRuntimeStylingHelper testBoolFunction]; layer.textIgnorePlacement = [MGLRuntimeStylingHelper testBoolFunction]; @@ -155,45 +166,45 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie layer.iconHaloWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.iconHaloBlur = [MGLRuntimeStylingHelper testNumberFunction]; layer.iconTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; - layer.iconTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)]; + layer.iconTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]; layer.textOpacity = [MGLRuntimeStylingHelper testNumberFunction]; layer.textColor = [MGLRuntimeStylingHelper testColorFunction]; layer.textHaloColor = [MGLRuntimeStylingHelper testColorFunction]; layer.textHaloWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.textHaloBlur = [MGLRuntimeStylingHelper testNumberFunction]; layer.textTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; - layer.textTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)]; + layer.textTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]; - XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)]); + XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]); XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.symbolAvoidEdges, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBoolFunction]); - XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]); + XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]); XCTAssertEqualObjects(gLayer.iconSize, [MGLRuntimeStylingHelper testNumberFunction]); - XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconTextFitBoth type:@encode(MGLSymbolStyleLayerIconTextFit)]); + XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnumFunction:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]); XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPaddingFunction]); XCTAssertEqualObjects(gLayer.iconImage, [MGLRuntimeStylingHelper testStringFunction]); XCTAssertEqualObjects(gLayer.iconRotate, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffsetFunction]); - XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]); - XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]); + XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]); + XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]); XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testStringFunction]); XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFontFunction]); XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textMaxWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textLineHeight, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textLetterSpacing, [MGLRuntimeStylingHelper testNumberFunction]); - XCTAssertEqualObjects(gLayer.textJustify, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)]); - XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)]); + XCTAssertEqualObjects(gLayer.textJustify, [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustifyRight type:@encode(MGLTextJustify)]); + XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]); XCTAssertEqualObjects(gLayer.textMaxAngle, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textRotate, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textPadding, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textKeepUpright, [MGLRuntimeStylingHelper testBoolFunction]); - XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)]); + XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnumFunction:MGLTextTransformLowercase type:@encode(MGLTextTransform)]); XCTAssertEqualObjects(gLayer.textOffset, [MGLRuntimeStylingHelper testOffsetFunction]); XCTAssertEqualObjects(gLayer.textAllowOverlap, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.textIgnorePlacement, [MGLRuntimeStylingHelper testBoolFunction]); @@ -204,14 +215,14 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie XCTAssertEqualObjects(gLayer.iconHaloWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.iconHaloBlur, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.iconTranslate, [MGLRuntimeStylingHelper testOffsetFunction]); - XCTAssertEqualObjects(gLayer.iconTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)]); + XCTAssertEqualObjects(gLayer.iconTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]); XCTAssertEqualObjects(gLayer.textOpacity, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.textHaloColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.textHaloWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textHaloBlur, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textTranslate, [MGLRuntimeStylingHelper testOffsetFunction]); - XCTAssertEqualObjects(gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)]); + XCTAssertEqualObjects(gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]); } @end |