summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-10-25 23:23:11 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-10-26 15:16:15 -0700
commit12093c10ad7557a92c8852bd6b61428990311dd4 (patch)
tree6265047947e613e8b46bf1fff75fdb1fa08e24a8
parent62647a013ff398c28c8a2c2f37c2737006181302 (diff)
downloadqtlocation-mapboxgl-12093c10ad7557a92c8852bd6b61428990311dd4.tar.gz
[ios, macos] Added Swift MGLStyleValue tests
Added tests of MGLStyleValue written in Swift, along with bridging headers just in case they become needed in the future.
-rw-r--r--platform/darwin/test/MGLStyleValueTests.swift36
-rw-r--r--platform/darwin/test/test-Bridging-Header.h3
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj14
-rw-r--r--platform/ios/test/test-Bridging-Header.h3
-rw-r--r--platform/macos/macos.xcodeproj/project.pbxproj14
5 files changed, 70 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLStyleValueTests.swift b/platform/darwin/test/MGLStyleValueTests.swift
new file mode 100644
index 0000000000..f7bf343852
--- /dev/null
+++ b/platform/darwin/test/MGLStyleValueTests.swift
@@ -0,0 +1,36 @@
+import XCTest
+import Mapbox
+
+class MGLStyleValueTests: XCTestCase {
+ func testConstantValues() {
+ let geoJSONSource = MGLGeoJSONSource(identifier: "test", features: [], options: nil)
+ let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: geoJSONSource)
+
+ // Boolean
+ symbolStyleLayer.iconAllowOverlap = MGLStyleConstantValue(rawValue: true)
+ XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleConstantValue<NSNumber>).rawValue, true)
+
+ // Number
+ symbolStyleLayer.iconHaloWidth = MGLStyleConstantValue(rawValue: 3)
+ XCTAssertEqual((symbolStyleLayer.iconHaloWidth as! MGLStyleConstantValue<NSNumber>).rawValue, 3)
+
+ // String
+ symbolStyleLayer.textField = MGLStyleConstantValue(rawValue: "{name}")
+ XCTAssertEqual((symbolStyleLayer.textField as! MGLStyleConstantValue<NSString>).rawValue, "{name}")
+ }
+
+ func testFunctions() {
+ let geoJSONSource = MGLGeoJSONSource(identifier: "test", features: [], options: nil)
+ let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: geoJSONSource)
+
+ // Boolean
+ let stops: [NSNumber: MGLStyleValue<NSNumber>] = [
+ 1: MGLStyleValue(rawValue: true),
+ 2: MGLStyleValue(rawValue: false),
+ 3: MGLStyleValue(rawValue: true),
+ 4: MGLStyleValue(rawValue: false),
+ ]
+ symbolStyleLayer.iconAllowOverlap = MGLStyleFunction<NSNumber>(base: 1, stops: stops)
+ XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(base: 1, stops: stops))
+ }
+}
diff --git a/platform/darwin/test/test-Bridging-Header.h b/platform/darwin/test/test-Bridging-Header.h
new file mode 100644
index 0000000000..e11d920b12
--- /dev/null
+++ b/platform/darwin/test/test-Bridging-Header.h
@@ -0,0 +1,3 @@
+//
+// Use this file to import your target's public headers that you would like to expose to Swift.
+//
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 8253774766..48be68275b 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -174,6 +174,7 @@
DA1DC99B1CB6E064006E619F /* MBXViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1DC99A1CB6E064006E619F /* MBXViewController.m */; };
DA1DC99D1CB6E076006E619F /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DA1DC99C1CB6E076006E619F /* Default-568h@2x.png */; };
DA1DC99F1CB6E088006E619F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA1DC99E1CB6E088006E619F /* Assets.xcassets */; };
+ DA2207BF1DC0805F0002F84D /* MGLStyleValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2207BE1DC0805F0002F84D /* MGLStyleValueTests.swift */; };
DA25D5C01CCD9F8400607828 /* Root.plist in Resources */ = {isa = PBXBuildFile; fileRef = DA25D5BF1CCD9F8400607828 /* Root.plist */; };
DA25D5C61CCDA06800607828 /* Root.strings in Resources */ = {isa = PBXBuildFile; fileRef = DA25D5C41CCDA06800607828 /* Root.strings */; };
DA25D5CD1CCDA11500607828 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DA25D5B91CCD9EDE00607828 /* Settings.bundle */; };
@@ -601,6 +602,8 @@
DA1DC99A1CB6E064006E619F /* MBXViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXViewController.m; sourceTree = "<group>"; };
DA1DC99C1CB6E076006E619F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
DA1DC99E1CB6E088006E619F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
+ DA2207BD1DC0805F0002F84D /* test-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "test-Bridging-Header.h"; sourceTree = "<group>"; };
+ DA2207BE1DC0805F0002F84D /* MGLStyleValueTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MGLStyleValueTests.swift; path = ../../darwin/test/MGLStyleValueTests.swift; sourceTree = "<group>"; };
DA25D5B91CCD9EDE00607828 /* Settings.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Settings.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
DA25D5BF1CCD9F8400607828 /* Root.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Root.plist; sourceTree = "<group>"; };
DA25D5C51CCDA06800607828 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Root.strings; sourceTree = "<group>"; };
@@ -885,9 +888,11 @@
357579811D502AD4000B822E /* Styling */ = {
isa = PBXGroup;
children = (
+ DA2207BD1DC0805F0002F84D /* test-Bridging-Header.h */,
3575798F1D513EF1000B822E /* Layers */,
35B8E08B1D6C8B5100E768D2 /* MGLFilterTests.mm */,
40CFA64E1D78754A008103BD /* Sources */,
+ DA2207BE1DC0805F0002F84D /* MGLStyleValueTests.swift */,
);
name = Styling;
sourceTree = "<group>";
@@ -1713,6 +1718,7 @@
};
DA2E88501CC036F400F24E7B = {
CreatedOnToolsVersion = 7.3;
+ LastSwiftMigration = 0800;
};
DA8847D11CBAF91600AB86E3 = {
CreatedOnToolsVersion = 7.3;
@@ -1882,6 +1888,7 @@
357579851D502AF5000B822E /* MGLSymbolStyleLayerTests.m in Sources */,
357579871D502AFE000B822E /* MGLLineStyleLayerTests.m in Sources */,
357579891D502B06000B822E /* MGLCircleStyleLayerTests.m in Sources */,
+ DA2207BF1DC0805F0002F84D /* MGLStyleValueTests.swift in Sources */,
40CFA6511D7875BB008103BD /* MGLGeoJSONSourceTests.mm in Sources */,
DA35A2C51CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m in Sources */,
35B8E08C1D6C8B5100E768D2 /* MGLFilterTests.mm in Sources */,
@@ -2280,6 +2287,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 55D8C9941D0F133500F42F10 /* config.xcconfig */;
buildSettings = {
+ CLANG_ENABLE_MODULES = YES;
HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)";
INFOPLIST_FILE = test/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -2292,6 +2300,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "test/test-Bridging-Header.h";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -2299,6 +2310,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 55D8C9941D0F133500F42F10 /* config.xcconfig */;
buildSettings = {
+ CLANG_ENABLE_MODULES = YES;
HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)";
INFOPLIST_FILE = test/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -2311,6 +2323,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "test/test-Bridging-Header.h";
+ SWIFT_VERSION = 3.0;
};
name = Release;
};
diff --git a/platform/ios/test/test-Bridging-Header.h b/platform/ios/test/test-Bridging-Header.h
new file mode 100644
index 0000000000..e11d920b12
--- /dev/null
+++ b/platform/ios/test/test-Bridging-Header.h
@@ -0,0 +1,3 @@
+//
+// Use this file to import your target's public headers that you would like to expose to Swift.
+//
diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj
index 9c610a8202..0194a2e6c2 100644
--- a/platform/macos/macos.xcodeproj/project.pbxproj
+++ b/platform/macos/macos.xcodeproj/project.pbxproj
@@ -57,6 +57,7 @@
558F18221D0B13B100123F46 /* libmbgl-loop.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 558F18211D0B13B000123F46 /* libmbgl-loop.a */; };
55D9B4B11D005D3900C1CCE2 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D9B4B01D005D3900C1CCE2 /* libz.tbd */; };
DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */; };
+ DA2207BC1DC076940002F84D /* MGLStyleValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2207BB1DC076940002F84D /* MGLStyleValueTests.swift */; };
DA2DBBCB1D51E30A00D38FF9 /* MGLStyleLayerTests.xib in Resources */ = {isa = PBXBuildFile; fileRef = DA2DBBCA1D51E30A00D38FF9 /* MGLStyleLayerTests.xib */; };
DA35A2A41CC9EB1A00E826B2 /* MGLCoordinateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = DA35A2A31CC9EB1A00E826B2 /* MGLCoordinateFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA35A2A61CC9EB2700E826B2 /* MGLCoordinateFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = DA35A2A51CC9EB2700E826B2 /* MGLCoordinateFormatter.m */; };
@@ -271,6 +272,8 @@
55D9B4B01D005D3900C1CCE2 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
55FE0E8D1D100A0900FD240B /* config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = config.xcconfig; path = ../../build/macos/config.xcconfig; sourceTree = "<group>"; };
DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; };
+ DA2207BA1DC076930002F84D /* test-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "test-Bridging-Header.h"; sourceTree = "<group>"; };
+ DA2207BB1DC076940002F84D /* MGLStyleValueTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MGLStyleValueTests.swift; sourceTree = "<group>"; };
DA2DBBC71D51E26600D38FF9 /* MGLStyleLayerTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MGLStyleLayerTests.h; path = ../darwin/test/MGLStyleLayerTests.h; sourceTree = SOURCE_ROOT; };
DA2DBBC81D51E26600D38FF9 /* MGLStyleLayerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLStyleLayerTests.m; path = ../darwin/test/MGLStyleLayerTests.m; sourceTree = SOURCE_ROOT; };
DA2DBBCA1D51E30A00D38FF9 /* MGLStyleLayerTests.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MGLStyleLayerTests.xib; sourceTree = "<group>"; };
@@ -605,6 +608,7 @@
DA8F257C1D51C5F40010E6B5 /* Layers */ = {
isa = PBXGroup;
children = (
+ DA2207BA1DC076930002F84D /* test-Bridging-Header.h */,
DA2DBBC71D51E26600D38FF9 /* MGLStyleLayerTests.h */,
DA2DBBC81D51E26600D38FF9 /* MGLStyleLayerTests.m */,
DA8F25741D51C5F40010E6B5 /* MGLFillStyleLayerTests.m */,
@@ -616,6 +620,7 @@
DA8F257A1D51C5F40010E6B5 /* MGLRuntimeStylingHelper.h */,
DA8F257B1D51C5F40010E6B5 /* MGLRuntimeStylingHelper.m */,
DA2DBBCA1D51E30A00D38FF9 /* MGLStyleLayerTests.xib */,
+ DA2207BB1DC076940002F84D /* MGLStyleValueTests.swift */,
);
name = Layers;
sourceTree = "<group>";
@@ -1041,6 +1046,7 @@
};
DAE6C3301CC30DB200DB3429 = {
CreatedOnToolsVersion = 7.3;
+ LastSwiftMigration = 0800;
};
};
};
@@ -1197,6 +1203,7 @@
DAE6C3D31CC34C9900DB3429 /* MGLOfflinePackTests.m in Sources */,
DA35A2A81CC9F41600E826B2 /* MGLCoordinateFormatterTests.m in Sources */,
DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */,
+ DA2207BC1DC076940002F84D /* MGLStyleValueTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1465,6 +1472,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 55FE0E8D1D100A0900FD240B /* config.xcconfig */;
buildSettings = {
+ CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)";
INFOPLIST_FILE = test/Info.plist;
@@ -1477,6 +1485,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "../darwin/test/test-Bridging-Header.h";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -1484,6 +1495,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 55FE0E8D1D100A0900FD240B /* config.xcconfig */;
buildSettings = {
+ CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)";
INFOPLIST_FILE = test/Info.plist;
@@ -1496,6 +1508,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "../darwin/test/test-Bridging-Header.h";
+ SWIFT_VERSION = 3.0;
};
name = Release;
};