Skip to content

Commit

Permalink
Test for notification publishing the metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Caelin Jackson-King committed Jun 28, 2018
1 parent fba4f36 commit aed00d3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Tests/Tests/AFURLSessionManagerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ - (void)testDownloadTaskDoesReportProgress {
[self waitForExpectationsWithCommonTimeout];
}

- (void)testSessionTaskDoesReportMetrics {
[self expectationForNotification:AFNetworkingTaskDidCompleteNotification object:nil handler:^BOOL(NSNotification * _Nonnull notification) {
#if AF_CAN_USE_AT_AVAILABLE
if (@available(iOS 10, macOS 10.12, watchOS 3, tvOS 10, *)) {
return [notification userInfo][AFNetworkingTaskDidCompleteSessionTaskMetrics] != nil;
}
#endif
return YES;
}];
NSURLSessionTask *task = [self.localManager downloadTaskWithRequest:[self bigImageURLRequest]
progress:nil
destination:nil
completionHandler:nil];
[task resume];
[self waitForExpectationsWithCommonTimeout];
}

// iOS 7 has a bug that may return nil for a session. To simulate that, nil out the
// session and it will return nil itself.
- (void)testFileUploadTaskReturnsNilWithBug {
Expand Down

0 comments on commit aed00d3

Please sign in to comment.