From e6c387f8fd9ef6d96ad96fbf752449a10cb73ab4 Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Mon, 15 Feb 2021 21:20:22 +0000 Subject: [PATCH] Fixup to perform a full load --- Tests/base/NSURLHandle/test00.m | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Tests/base/NSURLHandle/test00.m b/Tests/base/NSURLHandle/test00.m index dafb864b8..adedd2613 100644 --- a/Tests/base/NSURLHandle/test00.m +++ b/Tests/base/NSURLHandle/test00.m @@ -67,7 +67,7 @@ resourceDataDidBecomeAvailable: (NSData *)newBytes { [_receivedData release]; } - _receivedData = newBytes; + _receivedData = [newBytes retain]; } - (void) URLHandle: (NSURLHandle *)sender @@ -108,7 +108,7 @@ resourceDidFailLoadingWithReason: (NSString *)reason [handle beginLoadInBackground]; [handle cancelLoadInBackground]; PASS([self status] == URLHandleClientDidCancelLoading, - "URLHandleResourceDidCancelLoading called"); + "URLHandleClientDidCancelLoading called"); [handle release]; handle = [[cls alloc] initWithURL: url cached: NO]; @@ -118,16 +118,22 @@ resourceDidFailLoadingWithReason: (NSString *)reason */ [handle writeProperty: @"POST" forKey: GSHTTPPropertyMethodKey]; [handle writeData: [@"Hello" dataUsingEncoding: NSASCIIStringEncoding]]; - + [handle setReturnAll: YES]; [handle loadInBackground]; PASS([self status] == URLHandleClientDidBeginLoading, - "URLHandleResourceDidBeginLoading called"); + "URLHandleClientDidBeginLoading called"); - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode - beforeDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; - PASS([self status] == URLHandleClientDidBeginLoading, - "URLHandleResourceDidFinishLoading called"); + NSDate *limit = [NSDate dateWithTimeIntervalSinceNow: 5.0]; + while ([limit timeIntervalSinceNow] > 0.0 + && [self status] != URLHandleClientDidFinishLoading) + { + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode + beforeDate: limit]; + } + PASS([self status] == URLHandleClientDidFinishLoading, + "URLHandleClientDidFinishLoading called"); + NSLog(@"Data %@", [handle availableResourceData]); [handle release]; return 0; }