From 93bef62d7f09d5f1fabe5e7fa961955ca1f563bc Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Tue, 18 Jul 2017 21:19:31 +0300 Subject: [PATCH] Update reachability test --- .../OpenVPNReachabilityTests.swift | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/OpenVPN Adapter Tests/OpenVPNReachabilityTests.swift b/OpenVPN Adapter Tests/OpenVPNReachabilityTests.swift index 7e93e65..85db5d1 100644 --- a/OpenVPN Adapter Tests/OpenVPNReachabilityTests.swift +++ b/OpenVPN Adapter Tests/OpenVPNReachabilityTests.swift @@ -7,6 +7,7 @@ // import XCTest +import CoreWLAN @testable import OpenVPNAdapter class OpenVPNReachabilityTests: XCTestCase { @@ -22,16 +23,32 @@ class OpenVPNReachabilityTests: XCTestCase { } 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 reachability = OpenVPNReachability() reachability.reachabilityStatusChangedBlock = { status in - print("Current Status: \(status.rawValue)") + if case OpenVPNReachabilityStatus.reachableViaWiFi = status { + reachabilityExpectation.fulfill() + } } 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) } }