From c07e779bac6865585bce90021120b7a050e93c70 Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Wed, 27 Sep 2017 21:02:28 -0700 Subject: [ios] Work around Swift -> ObjC dictionary bridge issues --- platform/darwin/test/MGLNSStringAdditionsTests.m | 2 +- platform/darwin/test/MGLStyleValueTests.swift | 65 ++++++++++++++++++++---- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/platform/darwin/test/MGLNSStringAdditionsTests.m b/platform/darwin/test/MGLNSStringAdditionsTests.m index f07f2c1423..03503b7f8a 100644 --- a/platform/darwin/test/MGLNSStringAdditionsTests.m +++ b/platform/darwin/test/MGLNSStringAdditionsTests.m @@ -19,7 +19,7 @@ XCTAssertEqualObjects([@"Improve the map" mgl_titleCasedStringWithLocale:locale], @"Improve the Map"); XCTAssertEqualObjects([@"Improve The Map" mgl_titleCasedStringWithLocale:locale], @"Improve The Map"); - + XCTAssertEqualObjects([@"Improve a map" mgl_titleCasedStringWithLocale:locale], @"Improve a Map"); XCTAssertEqualObjects([@"Improve A Map" mgl_titleCasedStringWithLocale:locale], @"Improve A Map"); diff --git a/platform/darwin/test/MGLStyleValueTests.swift b/platform/darwin/test/MGLStyleValueTests.swift index 05e0dc8953..c559037588 100644 --- a/platform/darwin/test/MGLStyleValueTests.swift +++ b/platform/darwin/test/MGLStyleValueTests.swift @@ -267,22 +267,50 @@ extension MGLStyleValueTests { options: [.defaultValue: defaultRadius] ) circleStyleLayer.circleRadius = expectedCompositeCategoricalValue - XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeCategoricalValue) + + var compositeValue = circleStyleLayer.circleRadius as! MGLCompositeStyleFunction + var expectedCompositeValue = expectedCompositeCategoricalValue as! MGLCompositeStyleFunction + XCTAssertEqual(compositeValue.attributeName, expectedCompositeValue.attributeName) + XCTAssertEqual(compositeValue.stops as NSDictionary, radiusCompositeCategoricalStops as NSDictionary) + XCTAssertEqual(compositeValue.interpolationMode, expectedCompositeValue.interpolationMode) + XCTAssertEqual(compositeValue.defaultValue, expectedCompositeValue.defaultValue) // data-driven, composite function with inner exponential color stop values nested in outer camera stops let radiusCompositeExponentialOrIntervalStops: [Float: [Float: MGLStyleValue]] = [ - 0: [0: smallRadius], - 10: [200: smallRadius], - 20: [200: largeRadius] + 0: [0: MGLStyleValue(rawValue: 5)], + 10: [200: MGLStyleValue(rawValue: 5)], + 20: [200: MGLStyleValue(rawValue: 20)] + ] + + let expectedStops = [ + 0: [0: MGLStyleValue(rawValue: 5)], + 10: [200: MGLStyleValue(rawValue: 5)], + 20: [200: MGLStyleValue(rawValue: 20)] ] + circleStyleLayer.circleRadius = MGLStyleValue( + interpolationMode: .exponential, + compositeStops: [ + 0: [0: MGLStyleValue(rawValue: 5)], + 10: [200: MGLStyleValue(rawValue: 5)], + 20: [200: MGLStyleValue(rawValue: 20)] + ], + attributeName: "temp", + options: [.defaultValue: mediumRadius] + ) + let expectedCompositeExponentialValue = MGLStyleValue( interpolationMode: .exponential, compositeStops: radiusCompositeExponentialOrIntervalStops, attributeName: "temp", options: [.defaultValue: mediumRadius] ) - circleStyleLayer.circleRadius = expectedCompositeExponentialValue - XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeExponentialValue) + + compositeValue = circleStyleLayer.circleRadius as! MGLCompositeStyleFunction + expectedCompositeValue = expectedCompositeExponentialValue as! MGLCompositeStyleFunction + XCTAssertEqual(compositeValue.attributeName, expectedCompositeValue.attributeName) + XCTAssertEqual(compositeValue.stops as NSDictionary, expectedStops as NSDictionary) + XCTAssertEqual(compositeValue.interpolationMode, expectedCompositeValue.interpolationMode) + XCTAssertEqual(compositeValue.defaultValue, expectedCompositeValue.defaultValue) // get a value back if let returnedCircleRadius = circleStyleLayer.circleRadius as? MGLCompositeStyleFunction { @@ -305,11 +333,30 @@ extension MGLStyleValueTests { // data-driven, composite function with inner interval color stop values nested in outer camera stops let expectedCompositeIntervalValue = MGLStyleValue( interpolationMode: .interval, - compositeStops: radiusCompositeExponentialOrIntervalStops, + compositeStops: [ + + 10: [200: MGLStyleValue(rawValue: 5)], + 20: [200: MGLStyleValue(rawValue: 20)] + ], attributeName: "temp", options: nil ) - circleStyleLayer.circleRadius = expectedCompositeIntervalValue - XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeIntervalValue) + circleStyleLayer.circleRadius = MGLStyleValue( + interpolationMode: .interval, + compositeStops: [ + 0: [0: MGLStyleValue(rawValue: 5)], + 10: [200: MGLStyleValue(rawValue: 5)], + 20: [200: MGLStyleValue(rawValue: 20)] + ], + attributeName: "temp", + options: nil + ) + + compositeValue = circleStyleLayer.circleRadius as! MGLCompositeStyleFunction + expectedCompositeValue = expectedCompositeIntervalValue as! MGLCompositeStyleFunction + XCTAssertEqual(compositeValue.attributeName, expectedCompositeValue.attributeName) + XCTAssertEqual(compositeValue.stops as NSDictionary, expectedStops as NSDictionary) + XCTAssertEqual(compositeValue.interpolationMode, expectedCompositeValue.interpolationMode) + XCTAssertEqual(compositeValue.defaultValue, expectedCompositeValue.defaultValue) } } -- cgit v1.2.1