summaryrefslogtreecommitdiff
path: root/platform/darwin/test
diff options
context:
space:
mode:
authorRoman Blum <rmnblm@gmail.com>2016-12-06 02:16:13 +0100
committerMinh Nguyễn <mxn@1ec5.org>2016-12-05 17:16:13 -0800
commit1045934d5e62eaf85bc280ce2d75e7558f5a5104 (patch)
treecf299675768bb6ba1996d3a312823b60737bc109 /platform/darwin/test
parent5579e67804369777819babba5cf6e25eb91ee77e (diff)
downloadqtlocation-mapboxgl-1045934d5e62eaf85bc280ce2d75e7558f5a5104.tar.gz
[core, ios, macos] Add image accessor to MGLStyle (#7096)
* [core] Add interface to get image from sprite atlas * [tests] Add tests for Map::getImage * [ios, macos] WIP: get MGLImage for name from style * [ios, macos] Fixed -imageForName: Convert from sprite images to platform images using the existing encodePNG() function, which is also used for printing. Allow -imageForName: to return nil without an assertion failure. Added a basic test.
Diffstat (limited to 'platform/darwin/test')
-rw-r--r--platform/darwin/test/MGLStyleTests.mm24
-rw-r--r--platform/darwin/test/Media.xcassets/Contents.json6
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json26
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.pngbin0 -> 407 bytes
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.pngbin0 -> 680 bytes
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.pngbin0 -> 903 bytes
6 files changed, 56 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm
index 4c0c163b38..8f0d2502fb 100644
--- a/platform/darwin/test/MGLStyleTests.mm
+++ b/platform/darwin/test/MGLStyleTests.mm
@@ -17,6 +17,11 @@
#import <mbgl/util/default_styles.hpp>
#import <XCTest/XCTest.h>
+#if TARGET_OS_IPHONE
+ #import <UIKit/UIKit.h>
+#else
+ #import <Cocoa/Cocoa.h>
+#endif
#import <objc/runtime.h>
@interface MGLStyleTests : XCTestCase
@@ -175,4 +180,23 @@
return styleHeader;
}
+- (void)testImages {
+ NSString *imageName = @"TrackingLocationMask";
+#if TARGET_OS_IPHONE
+ MGLImage *image = [MGLImage imageNamed:imageName
+ inBundle:[NSBundle bundleForClass:[self class]]
+ compatibleWithTraitCollection:nil];
+#else
+ MGLImage *image = [[NSBundle bundleForClass:[self class]] imageForResource:imageName];
+#endif
+ XCTAssertNotNil(image);
+
+ [self.mapView.style setImage:image forName:imageName];
+ MGLImage *styleImage = [self.mapView.style imageForName:imageName];
+
+ XCTAssertNotNil(styleImage);
+ XCTAssertEqual(image.size.width, styleImage.size.width);
+ XCTAssertEqual(image.size.height, styleImage.size.height);
+}
+
@end
diff --git a/platform/darwin/test/Media.xcassets/Contents.json b/platform/darwin/test/Media.xcassets/Contents.json
new file mode 100644
index 0000000000..da4a164c91
--- /dev/null
+++ b/platform/darwin/test/Media.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json
new file mode 100644
index 0000000000..08cd551fc7
--- /dev/null
+++ b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "TrackingLocationMask.png",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "filename" : "TrackingLocationMask@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "filename" : "TrackingLocationMask@3x.png",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template"
+ }
+} \ No newline at end of file
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.png b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.png
new file mode 100644
index 0000000000..bb7348c482
--- /dev/null
+++ b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.png
Binary files differ
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.png b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.png
new file mode 100644
index 0000000000..35c5a293ec
--- /dev/null
+++ b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.png
Binary files differ
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.png b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.png
new file mode 100644
index 0000000000..af523975a5
--- /dev/null
+++ b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.png
Binary files differ