summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-24 13:07:34 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-01-25 13:22:17 -0800
commit7684bc2125a020bf44e2a99cbd49f7b3618ba52e (patch)
tree86abf37d9139208fc078ea90c30162004fe4da81
parentf5bcf186f63f0f10642dcee14a680667c36cbfdb (diff)
downloadqtlocation-mapboxgl-7684bc2125a020bf44e2a99cbd49f7b3618ba52e.tar.gz
[ios, macos] Testify MGLMapView gesture recognizer example
-rw-r--r--platform/darwin/scripts/update-examples.js4
-rw-r--r--platform/darwin/test/MGLDocumentationExampleTests.swift21
-rw-r--r--platform/ios/src/MGLMapView.h1
3 files changed, 24 insertions, 2 deletions
diff --git a/platform/darwin/scripts/update-examples.js b/platform/darwin/scripts/update-examples.js
index 6291326068..e6b747a460 100644
--- a/platform/darwin/scripts/update-examples.js
+++ b/platform/darwin/scripts/update-examples.js
@@ -108,10 +108,10 @@ function completeExamples(os) {
}
// Resolve conditional compilation blocks.
- example = example.replace(/^(\s*)#if\s+os\((iOS|macOS)\)\n([^]*?)(?:^\1#else\n([^]*?))?^\1#endif\n/gm,
+ example = example.replace(/^(\s*)#if\s+os\((iOS|macOS)\)\n([^]*?)(?:^\1#else\n([^]*?))?^\1#endif\b\n?/gm,
function (m, indentation, ifOs, ifCase, elseCase) {
return (os === ifOs ? ifCase : elseCase).replace(new RegExp('^ ', 'gm'), '');
- });
+ }).replace(/\n$/, '');
// Insert the test method contents into the documentation comment just
// above the substructure.
diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift
index d796b4e708..9336db7e49 100644
--- a/platform/darwin/test/MGLDocumentationExampleTests.swift
+++ b/platform/darwin/test/MGLDocumentationExampleTests.swift
@@ -217,4 +217,25 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "contour"))
}
+
+ func testMGLMapView() {
+ //#-example-code
+ #if os(macOS)
+ class MapClickGestureRecognizer: NSClickGestureRecognizer {
+ override func shouldRequireFailure(of otherGestureRecognizer: NSGestureRecognizer) -> Bool {
+ return otherGestureRecognizer is NSClickGestureRecognizer
+ }
+ }
+ #else
+ let mapTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(myCustomFunction))
+ for recognizer in mapView.gestureRecognizers! where recognizer is UITapGestureRecognizer {
+ mapTapGestureRecognizer.require(toFail: recognizer)
+ }
+ mapView.addGestureRecognizer(mapTapGestureRecognizer)
+ #endif
+ //#-end-example-code
+ }
+
+ // For testMGLMapView().
+ func myCustomFunction() {}
}
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 0d65ea2fb1..1f2031e055 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -84,6 +84,7 @@ typedef NS_ENUM(NSUInteger, MGLAnnotationVerticalAlignment) {
for recognizer in mapView.gestureRecognizers! where recognizer is UITapGestureRecognizer {
mapTapGestureRecognizer.require(toFail: recognizer)
}
+ mapView.addGestureRecognizer(mapTapGestureRecognizer)
```
@note You are responsible for getting permission to use the map data and for