summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-04-12 15:22:55 -0400
committerJesse Bounds <jesse@rebounds.net>2017-04-13 14:52:15 -0400
commit9340b4822a9d5f43952ba71ff16315d606de50bc (patch)
tree1984817588ebb6b5168d9a8484df86c49dc3fc48 /platform/darwin
parentcf8584538c8bf3c524a6dc54c07a301bf14523be (diff)
downloadqtlocation-mapboxgl-9340b4822a9d5f43952ba71ff16315d606de50bc.tar.gz
[ios, macos] Add Swift integration tests for map view delegate
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/test/MGLSDKTestHelpers.swift47
1 files changed, 47 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLSDKTestHelpers.swift b/platform/darwin/test/MGLSDKTestHelpers.swift
new file mode 100644
index 0000000000..82b5caa273
--- /dev/null
+++ b/platform/darwin/test/MGLSDKTestHelpers.swift
@@ -0,0 +1,47 @@
+import Foundation
+
+class MGLSDKTestHelpers {
+
+ class func checkTestsContainAllMethods(testClass: Swift.AnyClass, in p: Protocol) {
+ let testMethods = self.classMethodDescriptions(testClass)
+ let subjectMethods = self.protocolMethodDescriptions(p)
+
+ for method in subjectMethods {
+ if !testMethods.contains(method) {
+ XCTFail("\(String(describing: testClass)) does not contain \(method) from \(String(describing: p))")
+ }
+ }
+
+ XCTAssert(true)
+ }
+
+}
+
+extension MGLSDKTestHelpers {
+
+ class func protocolMethodDescriptions(_ p: Protocol) -> Set<String> {
+ var methods = Set<String>()
+ var methodCount = UInt32()
+ let methodDescriptionList: UnsafeMutablePointer<objc_method_description>! = protocol_copyMethodDescriptionList(p, false, true, &methodCount)
+ for i in 0..<Int(methodCount) {
+ let description: objc_method_description = methodDescriptionList[i]
+ methods.insert(description.name.description)
+ }
+ free(methodDescriptionList)
+ return methods
+ }
+
+ class func classMethodDescriptions(_ cls: Swift.AnyClass) -> Set<String> {
+ var methods = Set<String>()
+ var methodCount = UInt32()
+ let methodList: UnsafeMutablePointer<Method?>! = class_copyMethodList(cls, &methodCount)
+ for i in 0..<Int(methodCount) {
+ let method = methodList[i]
+ let selector : Selector = method_getName(method)
+ methods.insert(selector.description)
+ }
+ free(methodList)
+ return methods
+ }
+
+}