Created
June 30, 2015 07:27
-
-
Save seivan/0becfffbb1d7665cebfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
+(BOOL)runLoopUntilTestPassesWithBlock:(__SHTestCaseInternalTestCaseConditional)theBlock withTimeOut:(NSTimeInterval)theTimeout; { | |
NSParameterAssert(theBlock); | |
NSParameterAssert(theTimeout >= 0); | |
NSDate * timeoutDate = [NSDate dateWithTimeIntervalSinceNow:theTimeout]; | |
NSTimeInterval timeoutTime = [timeoutDate timeIntervalSinceReferenceDate]; | |
NSTimeInterval currentTime = 0.0; | |
*/ | |
for (currentTime = [NSDate timeIntervalSinceReferenceDate]; | |
(theBlock() == NO && currentTime < timeoutTime); | |
currentTime = [NSDate timeIntervalSinceReferenceDate]) { | |
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; | |
} | |
/* return currentTime <= timeoutTime; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment