Tweak tests to ensure old waitUntilAllOperationsAreFinished behaviour works again
Showing
4 changed files
with
7 additions
and
19 deletions
@@ -10,8 +10,6 @@ | @@ -10,8 +10,6 @@ | ||
10 | // Portions are based on the ImageClient example from Apple: | 10 | // Portions are based on the ImageClient example from Apple: |
11 | // See: http://developer.apple.com/samplecode/ImageClient/listing37.html | 11 | // See: http://developer.apple.com/samplecode/ImageClient/listing37.html |
12 | 12 | ||
13 | -#import <Cocoa/Cocoa.h> | ||
14 | - | ||
15 | @interface ASIHTTPRequest : NSOperation { | 13 | @interface ASIHTTPRequest : NSOperation { |
16 | 14 | ||
17 | //The url for this operation, should include GET params in the query string where appropriate | 15 | //The url for this operation, should include GET params in the query string where appropriate |
@@ -629,7 +629,7 @@ static NSRecursiveLock *progressLock; | @@ -629,7 +629,7 @@ static NSRecursiveLock *progressLock; | ||
629 | - (void)requestFinished | 629 | - (void)requestFinished |
630 | { | 630 | { |
631 | if (didFinishSelector && ![self isCancelled] && [delegate respondsToSelector:didFinishSelector]) { | 631 | if (didFinishSelector && ![self isCancelled] && [delegate respondsToSelector:didFinishSelector]) { |
632 | - [delegate performSelectorOnMainThread:didFinishSelector withObject:self waitUntilDone:YES]; | 632 | + [delegate performSelectorOnMainThread:didFinishSelector withObject:self waitUntilDone:[NSThread isMainThread]]; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
@@ -648,7 +648,7 @@ static NSRecursiveLock *progressLock; | @@ -648,7 +648,7 @@ static NSRecursiveLock *progressLock; | ||
648 | NSLog(problem); | 648 | NSLog(problem); |
649 | 649 | ||
650 | if (didFailSelector && ![self isCancelled] && [delegate respondsToSelector:didFailSelector]) { | 650 | if (didFailSelector && ![self isCancelled] && [delegate respondsToSelector:didFailSelector]) { |
651 | - [delegate performSelectorOnMainThread:didFailSelector withObject:self waitUntilDone:YES]; | 651 | + [delegate performSelectorOnMainThread:didFailSelector withObject:self waitUntilDone:[NSThread isMainThread]]; |
652 | } | 652 | } |
653 | } | 653 | } |
654 | } | 654 | } |
@@ -823,7 +823,7 @@ static NSRecursiveLock *progressLock; | @@ -823,7 +823,7 @@ static NSRecursiveLock *progressLock; | ||
823 | ignoreError = YES; | 823 | ignoreError = YES; |
824 | [self setLastActivityTime:nil]; | 824 | [self setLastActivityTime:nil]; |
825 | if ([delegate respondsToSelector:@selector(authorizationNeededForRequest:)]) { | 825 | if ([delegate respondsToSelector:@selector(authorizationNeededForRequest:)]) { |
826 | - [delegate performSelectorOnMainThread:@selector(authorizationNeededForRequest:) withObject:self waitUntilDone:YES]; | 826 | + [delegate performSelectorOnMainThread:@selector(authorizationNeededForRequest:) withObject:self waitUntilDone:[NSThread isMainThread]]; |
827 | [authenticationLock lockWhenCondition:2]; | 827 | [authenticationLock lockWhenCondition:2]; |
828 | [authenticationLock unlock]; | 828 | [authenticationLock unlock]; |
829 | 829 | ||
@@ -865,7 +865,7 @@ static NSRecursiveLock *progressLock; | @@ -865,7 +865,7 @@ static NSRecursiveLock *progressLock; | ||
865 | // We've got no credentials, let's ask the delegate to sort this out | 865 | // We've got no credentials, let's ask the delegate to sort this out |
866 | ignoreError = YES; | 866 | ignoreError = YES; |
867 | if ([delegate respondsToSelector:@selector(authorizationNeededForRequest:)]) { | 867 | if ([delegate respondsToSelector:@selector(authorizationNeededForRequest:)]) { |
868 | - [delegate performSelectorOnMainThread:@selector(authorizationNeededForRequest:) withObject:self waitUntilDone:YES]; | 868 | + [delegate performSelectorOnMainThread:@selector(authorizationNeededForRequest:) withObject:self waitUntilDone:[NSThread isMainThread]]; |
869 | [authenticationLock lockWhenCondition:2]; | 869 | [authenticationLock lockWhenCondition:2]; |
870 | [authenticationLock unlock]; | 870 | [authenticationLock unlock]; |
871 | [self attemptToApplyCredentialsAndResume]; | 871 | [self attemptToApplyCredentialsAndResume]; |
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | // Copyright 2008 All-Seeing Interactive. All rights reserved. | 6 | // Copyright 2008 All-Seeing Interactive. All rights reserved. |
7 | // | 7 | // |
8 | 8 | ||
9 | -#import <Cocoa/Cocoa.h> | ||
10 | 9 | ||
11 | @interface ASINetworkQueue : NSOperationQueue { | 10 | @interface ASINetworkQueue : NSOperationQueue { |
12 | 11 |
@@ -66,10 +66,7 @@ | @@ -66,10 +66,7 @@ | ||
66 | 66 | ||
67 | [networkQueue go]; | 67 | [networkQueue go]; |
68 | 68 | ||
69 | - endDate = [NSDate distantFuture]; | 69 | + [networkQueue waitUntilAllOperationsAreFinished]; |
70 | - while (!complete) { | ||
71 | - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate]; | ||
72 | - } | ||
73 | 70 | ||
74 | success = (progress == 1.0); | 71 | success = (progress == 1.0); |
75 | STAssertTrue(success,@"Failed to increment progress properly"); | 72 | STAssertTrue(success,@"Failed to increment progress properly"); |
@@ -121,10 +118,7 @@ | @@ -121,10 +118,7 @@ | ||
121 | 118 | ||
122 | [networkQueue go]; | 119 | [networkQueue go]; |
123 | 120 | ||
124 | - NSDate* endDate = [NSDate distantFuture]; | 121 | + [networkQueue waitUntilAllOperationsAreFinished]; |
125 | - while (!complete) { | ||
126 | - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate]; | ||
127 | - } | ||
128 | 122 | ||
129 | 123 | ||
130 | BOOL success; | 124 | BOOL success; |
@@ -190,10 +184,7 @@ | @@ -190,10 +184,7 @@ | ||
190 | 184 | ||
191 | [networkQueue go]; | 185 | [networkQueue go]; |
192 | 186 | ||
193 | - NSDate* endDate = [NSDate distantFuture]; | 187 | + [networkQueue waitUntilAllOperationsAreFinished]; |
194 | - while (!complete) { | ||
195 | - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate]; | ||
196 | - } | ||
197 | 188 | ||
198 | 189 | ||
199 | [requestThatShouldFail release]; | 190 | [requestThatShouldFail release]; |
-
Please register or login to post a comment