mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Update reachability test
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
import CoreWLAN
|
||||||
@testable import OpenVPNAdapter
|
@testable import OpenVPNAdapter
|
||||||
|
|
||||||
class OpenVPNReachabilityTests: XCTestCase {
|
class OpenVPNReachabilityTests: XCTestCase {
|
||||||
@@ -22,16 +23,32 @@ class OpenVPNReachabilityTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testReachability() {
|
func testReachability() {
|
||||||
|
let wifiClient = CWWiFiClient.shared()
|
||||||
|
guard let interface = wifiClient.interface() else {
|
||||||
|
XCTFail()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let reachabilityExpectation = expectation(description: "me.ss-abramchuk.openvpn-adapter.reachability")
|
let reachabilityExpectation = expectation(description: "me.ss-abramchuk.openvpn-adapter.reachability")
|
||||||
|
|
||||||
let reachability = OpenVPNReachability()
|
let reachability = OpenVPNReachability()
|
||||||
reachability.reachabilityStatusChangedBlock = { status in
|
reachability.reachabilityStatusChangedBlock = { status in
|
||||||
print("Current Status: \(status.rawValue)")
|
if case OpenVPNReachabilityStatus.reachableViaWiFi = status {
|
||||||
|
reachabilityExpectation.fulfill()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reachability.startTracking()
|
reachability.startTracking()
|
||||||
|
|
||||||
waitForExpectations(timeout: 120.0, handler: nil)
|
DispatchQueue.main.asyncAfter(deadline: .now()) {
|
||||||
|
try? interface.setPower(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
|
||||||
|
try? interface.setPower(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForExpectations(timeout: 30.0, handler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user