Skip to content

Commit ee00155

Browse files
committed
CCPackageUnzipper and tests cleansed of installData.
1 parent 159a3b0 commit ee00155

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

UnitTests/CCPackageUnzipperTests.m

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
#import <XCTest/XCTest.h>
1010
#import "CCPackageUnzipper.h"
1111
#import "CCPackage.h"
12-
#import "CCPackageInstallData.h"
13-
#import "CCPackage+InstallData.h"
1412
#import "CCPackageConstants.h"
1513
#import "CCPackageUnzipperDelegate.h"
1614
#import "CCUnitTestAssertions.h"
15+
#import "CCPackage_private.h"
1716

1817
@interface CCPackageUnzipperTests : XCTestCase <CCPackageUnzipperDelegate>
1918

2019
@property (nonatomic, strong) CCPackage *package;
21-
@property (nonatomic, strong) CCPackageInstallData *installData;
2220
@property (nonatomic, copy) NSString *unzipFolderPath;
2321
@property (nonatomic, strong) NSCondition *condition;
2422
@property (nonatomic) BOOL unzipperReturned;
@@ -38,7 +36,6 @@ - (void)setUp
3836
self.unzipperReturned = NO;
3937
self.unzippingError = nil;
4038
self.unzippingSuccessful = NO;
41-
4239
self.unzipFolderPath = [NSTemporaryDirectory() stringByAppendingPathComponent:PACKAGE_REL_UNZIP_FOLDER];
4340

4441
[self createUnzipFolder];
@@ -48,14 +45,9 @@ - (void)setUp
4845
os:@"iOS"
4946
remoteURL:[NSURL URLWithString:@"http://foo.fake/Foo-iOS-phonehd.zip"]];
5047

51-
self.installData = [[CCPackageInstallData alloc] initWithPackage:_package];
52-
[_package setInstallData:_installData];
53-
5448
NSString *pathToZip = [[NSBundle mainBundle] pathForResource:@"Resources-shared/Packages/testpackage-iOS-phonehd" ofType:@"zip"];
55-
_installData.localDownloadURL = [NSURL fileURLWithPath:pathToZip];
56-
_installData.unzipURL = [NSURL fileURLWithPath:[_unzipFolderPath stringByAppendingPathComponent:[_package standardIdentifier]]];
57-
58-
NSLog(@"%@", _installData.unzipURL.path);
49+
_package.localDownloadURL = [NSURL fileURLWithPath:pathToZip];
50+
_package.unzipURL = [NSURL fileURLWithPath:[_unzipFolderPath stringByAppendingPathComponent:[_package standardIdentifier]]];
5951
}
6052

6153
- (void)createUnzipFolder
@@ -92,7 +84,7 @@ - (void)testUnzipping
9284
[self unzipUntilDelegateMethodsReturn:nil];
9385

9486
NSFileManager *fileManager = [NSFileManager defaultManager];
95-
NSArray *contents = [fileManager contentsOfDirectoryAtURL:[_installData.unzipURL URLByAppendingPathComponent:@"testpackage-iOS-phonehd"]
87+
NSArray *contents = [fileManager contentsOfDirectoryAtURL:[_package.unzipURL URLByAppendingPathComponent:@"testpackage-iOS-phonehd"]
9688
includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey]
9789
options:NSDirectoryEnumerationSkipsSubdirectoryDescendants
9890
error:nil];
@@ -103,7 +95,7 @@ - (void)testUnzipping
10395

10496
- (void)testUnzippingOfNonExistingArchive
10597
{
106-
_installData.localDownloadURL = [NSURL fileURLWithPath:@"/foo.zip"];
98+
_package.localDownloadURL = [NSURL fileURLWithPath:@"/foo.zip"];
10799

108100
[self unzipUntilDelegateMethodsReturn:nil];
109101

@@ -126,11 +118,11 @@ - (void)testUnzippingOfInaccessibleUnzipFolder
126118
- (void)testUnzipOfPasswordProtectedPackage
127119
{
128120
NSString *pathToZip = [[NSBundle mainBundle] pathForResource:@"Resources-shared/Packages/password-iOS-phone" ofType:@"zip"];
129-
_installData.localDownloadURL = [NSURL fileURLWithPath:pathToZip];
121+
_package.localDownloadURL = [NSURL fileURLWithPath:pathToZip];
130122

131123
[self unzipUntilDelegateMethodsReturn:@"foobar"];
132124

133-
NSString *secretFilePath = [_installData.unzipURL.path stringByAppendingPathComponent:@"password-iOS-phone/secret.txt"];
125+
NSString *secretFilePath = [_package.unzipURL.path stringByAppendingPathComponent:@"password-iOS-phone/secret.txt"];
134126
NSError *error;
135127
NSString *contentsOfSecretFile = [NSString stringWithContentsOfFile:secretFilePath encoding:NSUTF8StringEncoding error:&error];
136128
XCTAssertNil(error);

cocos2d/CCPackageUnzipper.m

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#import "CCPackageUnzipperDelegate.h"
33
#import "CCPackage.h"
44
#import "SSZipArchive.h"
5-
#import "CCPackageInstallData.h"
6-
#import "CCPackage+InstallData.h"
75
#import "ccMacros.h"
86

97

@@ -43,12 +41,10 @@ - (void)unpackPackage;
4341

4442
- (void)unpackPackageOnQueue:(dispatch_queue_t)queue
4543
{
46-
CCPackageInstallData *installData = [_package installData];
47-
4844
NSAssert(queue != nil, @"queue must not be nil");
49-
NSAssert(installData != nil, @"installData must not be nil");
50-
NSAssert(installData.localDownloadURL != nil, @"package.localDownloadURL must not be nil");
51-
NSAssert(installData.unzipURL != nil, @"package.unzipURL must not be nil");
45+
NSAssert(_package != nil, @"package must not be nil");
46+
NSAssert(_package.localDownloadURL != nil, @"package.localDownloadURL must not be nil");
47+
NSAssert(_package.unzipURL != nil, @"package.unzipURL must not be nil");
5248

5349
self.queue = queue;
5450
[_package setValue:@(CCPackageStatusUnzipping) forKey:@"status"];
@@ -58,8 +54,8 @@ - (void)unpackPackageOnQueue:(dispatch_queue_t)queue
5854
CCLOGINFO(@"[PACKAGE/UNZIP][INFO]: Unzipping package... %@", _package);
5955

6056
NSError *error;
61-
BOOL success = [SSZipArchive unzipFileAtPath:installData.localDownloadURL.path
62-
toDestination:installData.unzipURL.path
57+
BOOL success = [SSZipArchive unzipFileAtPath:_package.localDownloadURL.path
58+
toDestination:_package.unzipURL.path
6359
overwrite:YES
6460
password:_password
6561
error:&error

0 commit comments

Comments
 (0)