Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added queue pausing for unit test

  • Loading branch information...
commit 124159304725ed372a1dda364fc69d2f2e309d84 1 parent b6656d4
@Cocoanetics authored
View
4 Core/Source/DTZipArchive/DTZipArchiveGZip.m
@@ -21,6 +21,8 @@ - (NSString *)_inflatedFileName;
@property (assign, getter = isCancelling) BOOL cancelling;
@property (assign, getter = isUncompressing) BOOL uncompressing;
+@property (readonly, nonatomic) dispatch_queue_t uncompressingQueue;
+
@end
@implementation DTZipArchiveGZip
@@ -298,7 +300,7 @@ - (BOOL)_uncompressZipArchiveNode:(DTZipArchiveNode *)node targetPath:(NSString
z_stream strm;
strm.next_in = (Bytef *)[_data bytes];
- strm.avail_in = [_data length];
+ strm.avail_in = (uInt)[_data length];
strm.total_out = 0;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
View
15 Test/Source/DTZipArchiveTest.m
@@ -11,6 +11,13 @@
#import "DTZipArchiveGZip.h"
#import "DTZipArchiveNode.h"
+
+@interface DTZipArchivePKZip (private)
+
+@property (readonly, nonatomic) dispatch_queue_t uncompressingQueue;
+
+@end
+
@implementation DTZipArchiveTest
- (void)tearDown
@@ -591,15 +598,21 @@ - (void)testCancelUncompressingGZip
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
NSString *sampleZipPath = [testBundle pathForResource:@"gzip_sample.txt" ofType:@"gz"];
- DTZipArchive *zipArchive = [DTZipArchive archiveAtPath:sampleZipPath];
+ DTZipArchivePKZip *zipArchive = (DTZipArchivePKZip *)[DTZipArchive archiveAtPath:sampleZipPath];
+
+ // suspend the queue to let us set the cancel
+ dispatch_suspend(zipArchive.uncompressingQueue);
[zipArchive uncompressToPath:[testBundle bundlePath] completion:^(NSError *error) {
STFail(@"Should not complete uncompressing after cancel was called");
}];
+ // resume
[zipArchive cancelAllUncompressing];
+ dispatch_resume(zipArchive.uncompressingQueue);
+
[NSThread sleepForTimeInterval:0.2];
}
Please sign in to comment.
Something went wrong with that request. Please try again.