diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-10-26 17:08:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-26 17:08:27 -0700 |
commit | 67ffc9685e573b10e4761b0bdb9962c79139f5da (patch) | |
tree | 89215ac8c3bc212ea3cf4e569d48d10e999590e2 /platform/ios/test | |
parent | 12093c10ad7557a92c8852bd6b61428990311dd4 (diff) | |
download | qtlocation-mapboxgl-67ffc9685e573b10e4761b0bdb9962c79139f5da.tar.gz |
[ios, macos] Make source ownership consistent and GeoJSON content properties writable
Use common initialization logic to create an unique pointer to an mbgl
source object, up front, when a MGL source is created. Keep a raw
pointer to the unique pointer that is pointed at the mbgl source
instance when a MGL source is created or when a MGL source is
obtained by identifier from MGLStyle. Once the transfer of ownership of the
mbgl source takes place, the unique ptr is null. The raw pointer can be used
internally for future work that involves mutating the source.
This also changes the URL, features, and geoJSONData content
properties for MGLGeoJSON source to be writable. If they are set with
valid data after a source has been added to the map then the map will
update to reflect the new data.
Diffstat (limited to 'platform/ios/test')
-rw-r--r-- | platform/ios/test/MGLGeoJSONSourceTests.mm | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/platform/ios/test/MGLGeoJSONSourceTests.mm b/platform/ios/test/MGLGeoJSONSourceTests.mm index c885873f77..96431ad018 100644 --- a/platform/ios/test/MGLGeoJSONSourceTests.mm +++ b/platform/ios/test/MGLGeoJSONSourceTests.mm @@ -32,8 +32,7 @@ XCTAssertEqual(mbglOptions.tolerance, 0.42); options = @{MGLGeoJSONClusterOption: @"number 1"}; - source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" URL:url options:options]; - XCTAssertThrows([source geoJSONOptions]); + XCTAssertThrows([[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" URL:url options:options]); } - (void)testMGLGeoJSONSourceWithData { @@ -43,8 +42,6 @@ NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding]; MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" geoJSONData:data options:nil]; - [source mbglSource]; - XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); XCTAssertTrue([source.features.firstObject isMemberOfClass:[MGLPolylineFeature class]]); @@ -56,8 +53,6 @@ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" features:@[polylineFeature] options:nil]; - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; - XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); XCTAssertTrue([source.features.firstObject isMemberOfClass:[MGLPolylineFeature class]]); @@ -95,8 +90,6 @@ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" features:@[polygonFeature] options:nil]; - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; - XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); MGLPolygonFeature *expectedPolygonFeature = (MGLPolygonFeature *)source.features.firstObject; @@ -131,8 +124,7 @@ MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5 interiorPolygons:@[polygon]]; MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" features:@[polygonFeature] options:nil]; - - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; + XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); @@ -148,8 +140,6 @@ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" features:@[multiPolylineFeature] options:nil]; - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; - XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); XCTAssertTrue([source.features.firstObject isMemberOfClass:[MGLMultiPolylineFeature class]]); @@ -179,8 +169,6 @@ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" features:@[multiPolygonFeature] options:nil]; - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; - XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); XCTAssertTrue([source.features.firstObject isMemberOfClass:[MGLMultiPolygonFeature class]]); @@ -193,8 +181,6 @@ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"souce-id" features:@[pointFeature] options:nil]; - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; - XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); XCTAssertTrue([source.features.firstObject isMemberOfClass:[MGLPointFeature class]]); @@ -208,11 +194,8 @@ CLLocationCoordinate2DMake(100.0, 1.0), CLLocationCoordinate2DMake(100.0, 0.0)}; MGLPointCollectionFeature *pointCollectionFeature = [MGLPointCollectionFeature pointCollectionWithCoordinates:coordinates count:5]; -; MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"souce-id" features:@[pointCollectionFeature] options:nil]; - - std::unique_ptr<mbgl::style::Source> mbglSource = [source mbglSource]; - + XCTAssertNotNil(source.features); XCTAssertEqual(source.features.count, 1); XCTAssertTrue([source.features.firstObject isMemberOfClass:[MGLPointCollectionFeature class]]); @@ -253,9 +236,7 @@ MGLShapeCollectionFeature *shapeCollectionFeature_1 = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[polygonFeature, polylineFeature, multiPolygonFeature, multiPolylineFeature, pointCollectionFeature, pointFeature, shapeCollectionFeature]]; - MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"" features:@[shapeCollectionFeature_1] options:nil]; - - XCTAssertThrowsSpecificNamed([source mbglSource], NSException, @"Method unavailable"); + XCTAssertThrowsSpecificNamed([[MGLGeoJSONSource alloc] initWithIdentifier:@"source-id" features:@[shapeCollectionFeature_1] options:nil], NSException, @"Method unavailable"); } @end |