Browse Source

Added feedback from Code Review

Kevin Harwood 10 years ago
parent
commit
dd3a3872ef

+ 10 - 3
Tests/Tests/AFUIActivityIndicatorViewTests.m

@@ -42,7 +42,6 @@
 }
 
 - (void)tearDown {
-    // Put teardown code here. This method is called after the invocation of each test method in the class.
     [super tearDown];
     [self.sessionManager invalidateSessionCancelingTasks:YES];
     self.sessionManager = nil;
@@ -71,6 +70,9 @@
     NSURLSessionDataTask *task = [self.sessionManager
                                   dataTaskWithRequest:self.request
                                   completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+                                      //Without the dispatch after, this test would PASS errorenously because the test
+                                      //would finish before the notification was posted to all objects that were
+                                      //observing it.
                                       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                           [expectation fulfill];
                                       });
@@ -90,6 +92,9 @@
     NSURLSessionDataTask *task = [self.sessionManager
                                   dataTaskWithRequest:self.request
                                   completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+                                      //Without the dispatch after, this test would PASS errorenously because the test
+                                      //would finish before the notification was posted to all objects that were
+                                      //observing it.
                                       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                           [expectation fulfill];
                                       });
@@ -126,6 +131,9 @@
     AFHTTPRequestOperation *operation = [self.operationManager
                                          HTTPRequestOperationWithRequest:self.request
                                          success:^(AFHTTPRequestOperation *operation, id responseObject) {
+                                             //Without the dispatch after, this test would PASS errorenously because the test
+                                             //would finish before the notification was posted to all objects that were
+                                             //observing it.
                                              dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                                   [expectation fulfill];
                                              });
@@ -138,5 +146,4 @@
     [operation cancel];
 }
 
-
-@end
+@end

+ 9 - 2
Tests/Tests/AFUIRefreshControlTests.m

@@ -42,7 +42,6 @@
 }
 
 - (void)tearDown {
-    // Put teardown code here. This method is called after the invocation of each test method in the class.
     [super tearDown];
     [self.sessionManager invalidateSessionCancelingTasks:YES];
     self.sessionManager = nil;
@@ -71,6 +70,9 @@
     NSURLSessionDataTask *task = [self.sessionManager
                                   dataTaskWithRequest:self.request
                                   completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+                                      //Without the dispatch after, this test would PASS errorenously because the test
+                                      //would finish before the notification was posted to all objects that were
+                                      //observing it.
                                       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                           [expectation fulfill];
                                       });
@@ -90,6 +92,9 @@
     NSURLSessionDataTask *task = [self.sessionManager
                                   dataTaskWithRequest:self.request
                                   completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+                                      //Without the dispatch after, this test would PASS errorenously because the test
+                                      //would finish before the notification was posted to all objects that were
+                                      //observing it.
                                       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                           [expectation fulfill];
                                       });
@@ -126,6 +131,9 @@
     AFHTTPRequestOperation *operation = [self.operationManager
                                          HTTPRequestOperationWithRequest:self.request
                                          success:^(AFHTTPRequestOperation *operation, id responseObject) {
+                                             //Without the dispatch after, this test would PASS errorenously because the test
+                                             //would finish before the notification was posted to all objects that were
+                                             //observing it.
                                              dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                                  [expectation fulfill];
                                              });
@@ -138,5 +146,4 @@
     [operation cancel];
 }
 
-
 @end