diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-09-27 21:02:28 -0700 |
---|---|---|
committer | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2017-10-03 13:28:22 +0200 |
commit | c07e779bac6865585bce90021120b7a050e93c70 (patch) | |
tree | 8504ef307e0414237534b6072909c756b21989ed /platform/darwin | |
parent | 1d714e1f35cd2c3b2d2acbb31164fb31110eb772 (diff) | |
download | qtlocation-mapboxgl-c07e779bac6865585bce90021120b7a050e93c70.tar.gz |
[ios] Work around Swift -> ObjC dictionary bridge issues
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/test/MGLNSStringAdditionsTests.m | 2 | ||||
-rw-r--r-- | 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<NSNumber>]] = [ - 0: [0: smallRadius], - 10: [200: smallRadius], - 20: [200: largeRadius] + 0: [0: MGLStyleValue<NSNumber>(rawValue: 5)], + 10: [200: MGLStyleValue<NSNumber>(rawValue: 5)], + 20: [200: MGLStyleValue<NSNumber>(rawValue: 20)] + ] + + let expectedStops = [ + 0: [0: MGLStyleValue<NSNumber>(rawValue: 5)], + 10: [200: MGLStyleValue<NSNumber>(rawValue: 5)], + 20: [200: MGLStyleValue<NSNumber>(rawValue: 20)] ] + circleStyleLayer.circleRadius = MGLStyleValue<NSNumber>( + interpolationMode: .exponential, + compositeStops: [ + 0: [0: MGLStyleValue<NSNumber>(rawValue: 5)], + 10: [200: MGLStyleValue<NSNumber>(rawValue: 5)], + 20: [200: MGLStyleValue<NSNumber>(rawValue: 20)] + ], + attributeName: "temp", + options: [.defaultValue: mediumRadius] + ) + let expectedCompositeExponentialValue = MGLStyleValue<NSNumber>( 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<NSNumber> { @@ -305,11 +333,30 @@ extension MGLStyleValueTests { // data-driven, composite function with inner interval color stop values nested in outer camera stops let expectedCompositeIntervalValue = MGLStyleValue<NSNumber>( interpolationMode: .interval, - compositeStops: radiusCompositeExponentialOrIntervalStops, + compositeStops: [ + + 10: [200: MGLStyleValue<NSNumber>(rawValue: 5)], + 20: [200: MGLStyleValue<NSNumber>(rawValue: 20)] + ], attributeName: "temp", options: nil ) - circleStyleLayer.circleRadius = expectedCompositeIntervalValue - XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeIntervalValue) + circleStyleLayer.circleRadius = MGLStyleValue<NSNumber>( + interpolationMode: .interval, + compositeStops: [ + 0: [0: MGLStyleValue<NSNumber>(rawValue: 5)], + 10: [200: MGLStyleValue<NSNumber>(rawValue: 5)], + 20: [200: MGLStyleValue<NSNumber>(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) } } |