|
@@ -1,6 +1,5 @@
|
|
|
// AFNetworkReachabilityManagerTests.h
|
|
|
-//
|
|
|
-// Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com)
|
|
|
+// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
@@ -34,10 +33,10 @@
|
|
|
|
|
|
- (void)setUp {
|
|
|
[super setUp];
|
|
|
-
|
|
|
+
|
|
|
//both of these manager objects should always be reachable when the tests are run
|
|
|
self.domainReachability = [AFNetworkReachabilityManager managerForDomain:@"localhost"];
|
|
|
-
|
|
|
+
|
|
|
//don't use the shared manager because it retains state between tests
|
|
|
//but recreate it each time in the same way that the shared manager is created
|
|
|
struct sockaddr_in address;
|
|
@@ -51,7 +50,7 @@
|
|
|
{
|
|
|
[self.addressReachability stopMonitoring];
|
|
|
[self.domainReachability stopMonitoring];
|
|
|
-
|
|
|
+
|
|
|
[super tearDown];
|
|
|
}
|
|
|
|
|
@@ -74,17 +73,17 @@
|
|
|
status = [note.userInfo[AFNetworkingReachabilityNotificationStatusItem] integerValue];
|
|
|
BOOL reachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
|
|
|
|| status == AFNetworkReachabilityStatusReachableViaWWAN);
|
|
|
-
|
|
|
+
|
|
|
XCTAssert(reachable,
|
|
|
@"Expected network to be reachable but got '%@'",
|
|
|
AFStringFromNetworkReachabilityStatus(status));
|
|
|
XCTAssertEqual(reachable, manager.isReachable, @"Expected status to match 'isReachable'");
|
|
|
-
|
|
|
+
|
|
|
return YES;
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
[manager startMonitoring];
|
|
|
-
|
|
|
+
|
|
|
[self waitForExpectationsWithTimeout:5 handler:nil];
|
|
|
}
|
|
|
|
|
@@ -99,20 +98,20 @@
|
|
|
- (void)verifyReachabilityStatusBlockGetsCalledWithManager:(AFNetworkReachabilityManager *)manager
|
|
|
{
|
|
|
XCTestExpectation *expectation = [self expectationWithDescription:@"reachability status change block gets called"];
|
|
|
-
|
|
|
+
|
|
|
typeof(manager) __weak weakManager = manager;
|
|
|
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
|
|
BOOL reachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
|
|
|
|| status == AFNetworkReachabilityStatusReachableViaWWAN);
|
|
|
-
|
|
|
+
|
|
|
XCTAssert(reachable, @"Expected network to be reachable but got '%@'", AFStringFromNetworkReachabilityStatus(status));
|
|
|
XCTAssertEqual(reachable, weakManager.isReachable, @"Expected status to match 'isReachable'");
|
|
|
-
|
|
|
+
|
|
|
[expectation fulfill];
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
[manager startMonitoring];
|
|
|
-
|
|
|
+
|
|
|
[self waitForExpectationsWithTimeout:5 handler:^(NSError *error) {
|
|
|
[manager setReachabilityStatusChangeBlock:nil];
|
|
|
}];
|