summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLDocumentationExampleTests.swift
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-01-04 12:55:19 -0600
committerFabian Guerra <fabian.guerra@mapbox.com>2018-01-04 12:55:19 -0600
commit187b6dc31cf281b5157de1acd92f3e8ef9d0acf9 (patch)
tree1d9eaac5d1e8393d8fd665aa678581a6086a9eb6 /platform/darwin/test/MGLDocumentationExampleTests.swift
parentc62b0af24fc76b4bb2eb34100611dd3ee9ee5536 (diff)
parent760ef23ac3faf4437cadb52983383c9501336964 (diff)
downloadqtlocation-mapboxgl-187b6dc31cf281b5157de1acd92f3e8ef9d0acf9.tar.gz
Merge branch 'release-agua' into masterupstream/fabian-merge-release-agua
# Conflicts: # circle.yml # cmake/core-files.cmake # platform/android/CHANGELOG.md # platform/android/MapboxGLAndroidSDK/build.gradle # platform/android/MapboxGLAndroidSDK/gradle.properties # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java # platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml # platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java # platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/LocalGlyphActivity.java # platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java # platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_local_glyph.xml # platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml # platform/darwin/src/MGLMapSnapshotter.mm # platform/darwin/src/MGLRendererConfiguration.h # platform/ios/CHANGELOG.md # platform/ios/DEVELOPING.md # platform/ios/INSTALL.md # platform/ios/README.md # platform/ios/resources/bg.lproj/Localizable.strings # platform/ios/resources/es.lproj/Localizable.strings # platform/ios/resources/vi.lproj/Localizable.strings # platform/ios/src/MGLMapView.mm # platform/macos/macos.xcodeproj/project.pbxproj # src/mbgl/text/glyph_manager.cpp
Diffstat (limited to 'platform/darwin/test/MGLDocumentationExampleTests.swift')
-rw-r--r--platform/darwin/test/MGLDocumentationExampleTests.swift35
1 files changed, 29 insertions, 6 deletions
diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift
index 8762af9ba4..668e5f57f8 100644
--- a/platform/darwin/test/MGLDocumentationExampleTests.swift
+++ b/platform/darwin/test/MGLDocumentationExampleTests.swift
@@ -27,11 +27,11 @@ import Mapbox
class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
var mapView: MGLMapView!
var styleLoadingExpectation: XCTestExpectation!
+ static let styleURL = Bundle(for: MGLDocumentationExampleTests.self).url(forResource: "one-liner", withExtension: "json")!
override func setUp() {
super.setUp()
- let styleURL = Bundle(for: MGLDocumentationExampleTests.self).url(forResource: "one-liner", withExtension: "json")
- mapView = MGLMapView(frame: CGRect(x: 0, y: 0, width: 256, height: 256), styleURL: styleURL)
+ mapView = MGLMapView(frame: CGRect(x: 0, y: 0, width: 256, height: 256), styleURL: MGLDocumentationExampleTests.styleURL)
mapView.delegate = self
styleLoadingExpectation = expectation(description: "Map view should finish loading style")
waitForExpectations(timeout: 1, handler: nil)
@@ -279,6 +279,27 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
}
func testMGLMapSnapshotter() {
+ let expectation = self.expectation(description: "MGLMapSnapshotter should produce a snapshot")
+ #if os(macOS)
+ var image: NSImage? {
+ didSet {
+ expectation.fulfill()
+ }
+ }
+ #else
+ var image: UIImage? {
+ didSet {
+ expectation.fulfill()
+ }
+ }
+ #endif
+
+ class MGLStyle {
+ static func satelliteStreetsStyleURL() -> URL {
+ return MGLDocumentationExampleTests.styleURL
+ }
+ }
+
//#-example-code
let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), fromDistance: 100, pitch: 20, heading: 0)
@@ -287,13 +308,15 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
let snapshotter = MGLMapSnapshotter(options: options)
snapshotter.start { (snapshot, error) in
- if error != nil {
- // error handler
- } else {
- // image handler
+ if let error = error {
+ fatalError(error.localizedDescription)
}
+
+ image = snapshot?.image
}
//#-end-example-code
+
+ wait(for: [expectation], timeout: 1)
}
// For testMGLMapView().