mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-05-05 05:40:15 +08:00
New ASDelegateProxy class to unify logic for Table & Collection forwarding. Fix dealloc-during-animation crash.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user