summaryrefslogtreecommitdiff
path: root/platform/ios/test
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-09-01 13:26:09 -0700
committerJesse Bounds <jesse@rebounds.net>2016-09-02 14:48:37 -0700
commit08f55af91491033c3da2b5a3de1e7bcb900b8964 (patch)
treee60d7a48e3440736054afe01b6a429dba8241bff /platform/ios/test
parentad095e458db7eee4085ec8be2528cdfa257371fd (diff)
downloadqtlocation-mapboxgl-08f55af91491033c3da2b5a3de1e7bcb900b8964.tar.gz
[ios, macos] Use NSDictionary for geojson source options.
This removes a previous implementation of geojson options that used a new type to transfer the data around. Added in its place is an options API that takes an NSDictionary that works similarly to NSAttributedString and many other Cocoa APIs that take options. The options parser now expects the developer to send values of the type noted in the documentation and it simply converts the NSNumber to the correct type (integer, double, or bool) for mbgl. However, an exception is raised if the value is not an NSNumber.
Diffstat (limited to 'platform/ios/test')
-rw-r--r--platform/ios/test/MGLGeoJSONSourceTests.mm39
1 files changed, 39 insertions, 0 deletions
diff --git a/platform/ios/test/MGLGeoJSONSourceTests.mm b/platform/ios/test/MGLGeoJSONSourceTests.mm
new file mode 100644
index 0000000000..76353dc76b
--- /dev/null
+++ b/platform/ios/test/MGLGeoJSONSourceTests.mm
@@ -0,0 +1,39 @@
+#import <XCTest/XCTest.h>
+
+#import <Mapbox/Mapbox.h>
+#import "MGLGeoJSONSource_Private.h"
+
+#include <mbgl/style/sources/geojson_source.hpp>
+
+@interface MGLGeoJSONSourceTests : XCTestCase
+
+@end
+
+@implementation MGLGeoJSONSourceTests
+
+- (void)testMGLGeoJSONSourceWithOptions {
+ NSURL *url = [NSURL URLWithString:@"http://www.mapbox.com/source"];
+
+ NSDictionary *options = @{MGLGeoJSONClusterOption: @(YES),
+ MGLGeoJSONClusterRadiusOption: @42,
+ MGLGeoJSONClusterMaximumZoomLevelOption: @98,
+ MGLGeoJSONMaximumZoomLevelOption: @99,
+ MGLGeoJSONBufferOption: @1976,
+ MGLGeoJSONToleranceOption: @0.42};
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"source-id" URL:url options:options];
+
+ auto mbglOptions = [source geoJSONOptions];
+ XCTAssertTrue(mbglOptions.cluster);
+ XCTAssertEqual(mbglOptions.clusterRadius, 42);
+ XCTAssertEqual(mbglOptions.clusterMaxZoom, 98);
+ XCTAssertEqual(mbglOptions.maxzoom, 99);
+ XCTAssertEqual(mbglOptions.buffer, 1976);
+ XCTAssertEqual(mbglOptions.tolerance, 0.42);
+
+ // when the supplied option cluster value is not of the correct type
+ options = @{MGLGeoJSONClusterOption: @"number 1"};
+ source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"source-id" URL:url options:options];
+ XCTAssertThrows([source geoJSONOptions]);
+}
+
+@end