New ASDelegateProxy class to unify logic for Table & Collection forwarding. Fix dealloc-during-animation crash.

This commit is contained in:
Scott Goodson
2015-12-23 20:01:52 -08:00
parent 928c440b4c
commit ca57059322
14 changed files with 382 additions and 233 deletions

View File

@@ -11,45 +11,38 @@
#import <AsyncDisplayKit/ASBasicImageDownloader.h>
// Z in the name to delay running until after the test instance is operating normally.
@interface ASZBasicImageDownloaderTests : XCTestCase
@interface ASBasicImageDownloaderTests : XCTestCase
@end
@implementation ASZBasicImageDownloaderTests
@implementation ASBasicImageDownloaderTests
- (void)testAsynchronouslyDownloadTheSameURLTwice
{
ASBasicImageDownloader *downloader = [ASBasicImageDownloader sharedImageDownloader];
NSURL *URL = [NSURL URLWithString:@"http://wrongPath/wrongResource.png"];
dispatch_group_t group = dispatch_group_create();
__block BOOL firstDone = NO;
dispatch_group_enter(group);
[downloader downloadImageWithURL:URL
callbackQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
downloadProgressBlock:nil
completion:^(CGImageRef image, NSError *error) {
firstDone = YES;
dispatch_group_leave(group);
}];
__block BOOL secondDone = NO;
dispatch_group_enter(group);
[downloader downloadImageWithURL:URL
callbackQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
downloadProgressBlock:nil
completion:^(CGImageRef image, NSError *error) {
secondDone = YES;
dispatch_group_leave(group);
}];
XCTAssert(0 == dispatch_group_wait(group, dispatch_time(0, 10 * 1000000000)), @"URL loading takes too long");
XCTAssert(firstDone && secondDone, @"Not all handlers has been called");
sleep(3);
XCTAssert(firstDone && secondDone, @"Not all ASBasicImageDownloader completion handlers have been called after 3 seconds");
}
@end