mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-02-22 00:00:06 +08:00
55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
//
|
|
// OpenVPNReachabilityTests.swift
|
|
// OpenVPN Adapter
|
|
//
|
|
// Created by Sergey Abramchuk on 18.07.17.
|
|
//
|
|
//
|
|
|
|
import XCTest
|
|
import CoreWLAN
|
|
@testable import OpenVPNAdapter
|
|
|
|
class OpenVPNReachabilityTests: XCTestCase {
|
|
|
|
override func setUp() {
|
|
super.setUp()
|
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
}
|
|
|
|
override func tearDown() {
|
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
super.tearDown()
|
|
}
|
|
|
|
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
|
|
if case OpenVPNReachabilityStatus.reachableViaWiFi = status {
|
|
reachabilityExpectation.fulfill()
|
|
}
|
|
}
|
|
|
|
reachability.startTracking()
|
|
|
|
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)
|
|
}
|
|
|
|
}
|