summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLStyleLayerTests.m
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-12 16:48:17 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-01-13 10:26:43 -0800
commit4d5036616f85ff87ffe9042739872b1a080015b2 (patch)
tree586bc460e60c638c7ab83c074ba15a473e18a889 /platform/darwin/test/MGLStyleLayerTests.m
parent85fc75db8ddb5e045d5612fb38925535a8bb1804 (diff)
downloadqtlocation-mapboxgl-4d5036616f85ff87ffe9042739872b1a080015b2.tar.gz
[ios, macos] Rewrote style layer tests
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.
Diffstat (limited to 'platform/darwin/test/MGLStyleLayerTests.m')
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.m69
1 files changed, 43 insertions, 26 deletions
diff --git a/platform/darwin/test/MGLStyleLayerTests.m b/platform/darwin/test/MGLStyleLayerTests.m
index 0bf5072391..1dba9f4305 100644
--- a/platform/darwin/test/MGLStyleLayerTests.m
+++ b/platform/darwin/test/MGLStyleLayerTests.m
@@ -4,37 +4,32 @@
#define TEST_STRICT_NAMING_CONVENTIONS 0
-@implementation MGLStyleLayerTests {
- XCTestExpectation *_styleLoadingExpectation;
-}
+@implementation MGLStyleLayerTests
@dynamic layerType;
-- (void)setUp {
- [super setUp];
- [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
- NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
- self.mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 256, 256) styleURL:styleURL];
- self.mapView.delegate = self;
- if (!self.mapView.style) {
- _styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
- [self waitForExpectationsWithTimeout:1 handler:nil];
- }
-}
-
-- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
- XCTAssertNotNil(mapView.style);
- XCTAssertEqual(mapView.style, style);
- XCTAssertNil(style.name);
+- (void)testProperties {
+ MGLPointFeature *feature = [[MGLPointFeature alloc] init];
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- [_styleLoadingExpectation fulfill];
-}
-
-- (void)tearDown {
- _styleLoadingExpectation = nil;
- _mapView = nil;
+ MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
+
+ XCTAssertEqualObjects(layer.identifier, @"layerID");
+ XCTAssertEqualObjects(layer.sourceIdentifier, source.identifier);
+
+ XCTAssertTrue(layer.visible);
+ layer.visible = NO;
+ XCTAssertFalse(layer.visible);
+ layer.visible = YES;
+ XCTAssertTrue(layer.visible);
+
+ XCTAssertEqual(layer.minimumZoomLevel, -INFINITY);
+ layer.minimumZoomLevel = 22;
+ XCTAssertEqual(layer.minimumZoomLevel, 22);
- [super tearDown];
+ XCTAssertEqual(layer.maximumZoomLevel, INFINITY);
+ layer.maximumZoomLevel = 0;
+ XCTAssertEqual(layer.maximumZoomLevel, 0);
}
- (void)testPropertyName:(NSString *)name isBoolean:(BOOL)isBoolean {
@@ -99,3 +94,25 @@
}
@end
+
+@implementation NSValue (MGLStyleLayerTestAdditions)
+
++ (instancetype)valueWithMGLVector:(CGVector)vector {
+#if TARGET_OS_IPHONE
+ return [self valueWithCGVector:vector];
+#else
+ return [self value:&vector withObjCType:@encode(CGVector)];
+#endif
+}
+
+- (CGVector)MGLVectorValue {
+#if TARGET_OS_IPHONE
+ return self.CGVectorValue;
+#else
+ CGVector vector;
+ [self getValue:&vector];
+ return vector;
+#endif
+}
+
+@end