diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-01-24 13:07:34 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-01-25 13:22:17 -0800 |
commit | 7684bc2125a020bf44e2a99cbd49f7b3618ba52e (patch) | |
tree | 86abf37d9139208fc078ea90c30162004fe4da81 /platform/darwin | |
parent | f5bcf186f63f0f10642dcee14a680667c36cbfdb (diff) | |
download | qtlocation-mapboxgl-7684bc2125a020bf44e2a99cbd49f7b3618ba52e.tar.gz |
[ios, macos] Testify MGLMapView gesture recognizer example
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/scripts/update-examples.js | 4 | ||||
-rw-r--r-- | platform/darwin/test/MGLDocumentationExampleTests.swift | 21 |
2 files changed, 23 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() {} } |