|
@@ -64,17 +64,9 @@
|
|
handler:^BOOL(NSNotification *note) {
|
|
handler:^BOOL(NSNotification *note) {
|
|
AFNetworkReachabilityStatus status;
|
|
AFNetworkReachabilityStatus status;
|
|
status = [note.userInfo[AFNetworkingReachabilityNotificationStatusItem] integerValue];
|
|
status = [note.userInfo[AFNetworkingReachabilityNotificationStatusItem] integerValue];
|
|
- BOOL reachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
|
|
|
|
- || status == AFNetworkReachabilityStatusReachableViaWWAN);
|
|
|
|
-
|
|
|
|
- if (reachable) {
|
|
|
|
- XCTAssert(reachable,
|
|
|
|
- @"Expected network to be reachable but got '%@'",
|
|
|
|
- AFStringFromNetworkReachabilityStatus(status));
|
|
|
|
- XCTAssertEqual(reachable, manager.isReachable, @"Expected status to match 'isReachable'");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return reachable;
|
|
|
|
|
|
+ BOOL isReachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
|
|
|
|
+ || status == AFNetworkReachabilityStatusReachableViaWWAN);
|
|
|
|
+ return isReachable;
|
|
}];
|
|
}];
|
|
|
|
|
|
[manager startMonitoring];
|
|
[manager startMonitoring];
|
|
@@ -86,24 +78,21 @@
|
|
[self verifyReachabilityNotificationGetsPostedWithManager:self.addressReachability];
|
|
[self verifyReachabilityNotificationGetsPostedWithManager:self.addressReachability];
|
|
}
|
|
}
|
|
|
|
|
|
-//Commenting out for Travis Stability
|
|
|
|
-//- (void)testDomainReachabilityNotification {
|
|
|
|
-// [self verifyReachabilityNotificationGetsPostedWithManager:self.domainReachability];
|
|
|
|
-//}
|
|
|
|
|
|
+- (void)testDomainReachabilityNotification {
|
|
|
|
+ [self verifyReachabilityNotificationGetsPostedWithManager:self.domainReachability];
|
|
|
|
+}
|
|
|
|
|
|
- (void)verifyReachabilityStatusBlockGetsCalledWithManager:(AFNetworkReachabilityManager *)manager
|
|
- (void)verifyReachabilityStatusBlockGetsCalledWithManager:(AFNetworkReachabilityManager *)manager
|
|
{
|
|
{
|
|
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"reachability status change block gets called"];
|
|
|
|
|
|
+ __weak __block XCTestExpectation *expectation = [self expectationWithDescription:@"reachability status change block gets called"];
|
|
|
|
|
|
- typeof(manager) __weak weakManager = manager;
|
|
|
|
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
|
[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];
|
|
|
|
|
|
+ BOOL isReachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
|
|
|
|
+ || status == AFNetworkReachabilityStatusReachableViaWWAN);
|
|
|
|
+ if (isReachable) {
|
|
|
|
+ [expectation fulfill];
|
|
|
|
+ expectation = nil;
|
|
|
|
+ }
|
|
}];
|
|
}];
|
|
|
|
|
|
[manager startMonitoring];
|
|
[manager startMonitoring];
|
|
@@ -117,9 +106,8 @@
|
|
[self verifyReachabilityStatusBlockGetsCalledWithManager:self.addressReachability];
|
|
[self verifyReachabilityStatusBlockGetsCalledWithManager:self.addressReachability];
|
|
}
|
|
}
|
|
|
|
|
|
-//Commenting out for Travis Stability
|
|
|
|
-//- (void)testDomainReachabilityBlock {
|
|
|
|
-// [self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability];
|
|
|
|
-//}
|
|
|
|
|
|
+- (void)testDomainReachabilityBlock {
|
|
|
|
+ [self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability];
|
|
|
|
+}
|
|
|
|
|
|
@end
|
|
@end
|