From 4d5036616f85ff87ffe9042739872b1a080015b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 12 Jan 2017 16:48:17 -0800 Subject: [ios, macos] Rewrote style layer tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced the style layer integration tests with unit tests. Test conversion of style values to property values and vice versa, not just round-tripping. Test the initial state and null-resetting of each null-resettable property. Test NSValue additions for style attribute enumerations. Test properties common to all style layer classes. Test MGLStyle’s source and layer collections. Eviscerated implementations of unavailable style layer properties corresponding to style specification properties that were renamed. Implemented corresponding getters to prevent ivars from being autosynthesized for these unavailable properties. Added a missing bridging header to the iOS test project. --- platform/darwin/test/MGLStyleTests.mm | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'platform/darwin/test/MGLStyleTests.mm') diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm index 82de27973b..176217619d 100644 --- a/platform/darwin/test/MGLStyleTests.mm +++ b/platform/darwin/test/MGLStyleTests.mm @@ -39,7 +39,6 @@ - (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style { XCTAssertNotNil(mapView.style); XCTAssertEqual(mapView.style, style); - XCTAssertNil(style.name); [_styleLoadingExpectation fulfill]; } @@ -135,6 +134,24 @@ }]; } +- (void)testName { + XCTAssertNil(self.style.name); +} + +- (void)testSources { + NSSet *initialSources = self.style.sources; + if ([initialSources.anyObject.identifier isEqualToString:@"com.mapbox.annotations"]) { + XCTAssertEqual(self.style.sources.count, 1); + } else { + XCTAssertEqual(self.style.sources.count, 0); + } + MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil]; + [self.style addSource:shapeSource]; + XCTAssertEqual(self.style.sources.count, initialSources.count + 1); + [self.style removeSource:shapeSource]; + XCTAssertEqual(self.style.sources.count, initialSources.count); +} + - (void)testAddingSourcesTwice { MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil]; [self.style addSource:shapeSource]; @@ -157,6 +174,22 @@ XCTAssertThrowsSpecificNamed([self.style addSource: source2], NSException, @"MGLRedundantSourceIdentifierException"); } +- (void)testLayers { + NSArray *initialLayers = self.style.layers; + if ([initialLayers.firstObject.identifier isEqualToString:@"com.mapbox.annotations.points"]) { + XCTAssertEqual(self.style.layers.count, 1); + } else { + XCTAssertEqual(self.style.layers.count, 0); + } + MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil]; + [self.style addSource:shapeSource]; + MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fillLayer" source:shapeSource]; + [self.style addLayer:fillLayer]; + XCTAssertEqual(self.style.layers.count, initialLayers.count + 1); + [self.style removeLayer:fillLayer]; + XCTAssertEqual(self.style.layers.count, initialLayers.count); +} + - (void)testAddingLayersTwice { MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil]; @@ -212,6 +245,10 @@ return styleHeader; } +- (void)testClasses { + XCTAssertEqual(self.style.styleClasses.count, 0); +} + - (void)testImages { NSString *imageName = @"TrackingLocationMask"; #if TARGET_OS_IPHONE -- cgit v1.2.1