Skip to content

Commit 229624f

Browse files
committed
CCPackageInstaller and tests cleansed of install data.
1 parent ed5b75b commit 229624f

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

UnitTests/CCPackageInstallerTests.m

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88

99
#import <XCTest/XCTest.h>
1010
#import "CCPackage.h"
11-
#import "CCPackageInstallData.h"
12-
#import "CCPackage+InstallData.h"
1311
#import "CCPackageInstaller.h"
14-
#import "CCDirector.h"
15-
#import "CCFileUtils.h"
1612
#import "CCPackageConstants.h"
13+
#import "CCPackage_private.h"
14+
1715

1816
@interface CCPackageInstallerTests : XCTestCase
1917

2018
@property (nonatomic, strong) CCPackage *package;
21-
@property (nonatomic, strong) CCPackageInstallData *installData;
2219
@property (nonatomic, copy) NSString *installPath;
2320
@property (nonatomic, strong) CCPackageInstaller *installer;
2421

@@ -36,9 +33,6 @@ - (void)setUp
3633
os:@"iOS"
3734
remoteURL:[NSURL URLWithString:@"http://test.foo"]];
3835

39-
self.installData = [[CCPackageInstallData alloc] initWithPackage:_package];
40-
[_package setInstallData:_installData];
41-
4236
NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
4337
self.installPath = [cachesPath stringByAppendingPathComponent:@"tests.Packages"];
4438

@@ -97,7 +91,7 @@ - (void)testInstallWithoutEnablingPackage
9791
- (void)testInstallFailingUnzippedPackageDoesNotExist
9892
{
9993
NSString *pathToPackage = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Resources-shared/Packages/DOES_NOT_EXIST"];
100-
_installData.unzipURL = [NSURL fileURLWithPath:pathToPackage];
94+
_package.unzipURL = [NSURL fileURLWithPath:pathToPackage];
10195

10296
NSError *error;
10397
BOOL success = [_installer installWithError:&error];
@@ -130,9 +124,9 @@ - (void)setupInstallablePackage
130124
{
131125
NSString *pathToPackage = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Resources-shared/Packages/testpackage-iOS-phonehd_unzipped"];
132126

133-
_installData.unzipURL = [NSURL fileURLWithPath:pathToPackage];
134-
_installData.folderName = @"testpackage-iOS-phonehd";
135-
_installData.enableOnDownload = NO;
127+
_package.unzipURL = [NSURL fileURLWithPath:pathToPackage];
128+
_package.folderName = @"testpackage-iOS-phonehd";
129+
_package.enableOnDownload = NO;
136130
}
137131

138132
@end

cocos2d/CCPackageInstaller.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#import "CCPackageInstaller.h"
22
#import "CCPackageConstants.h"
33
#import "CCPackage.h"
4-
#import "CCPackageInstallData.h"
5-
#import "CCPackage+InstallData.h"
6-
#import "CCPackageCocos2dEnabler.h"
74
#import "ccMacros.h"
85

96

@@ -34,10 +31,13 @@ - (instancetype)initWithPackage:(CCPackage *)package installPath:(NSString *)ins
3431

3532
- (BOOL)installWithError:(NSError **)error
3633
{
34+
35+
/* TODO
3736
CCPackageInstallData *installData = [_package installData];
3837
3938
NSAssert(installData != nil, @"installData must not be nil");
4039
NSAssert(installData.unzipURL != nil, @"installData.unzipURL must not be nil");
40+
*/
4141

4242
if (![self unzippedPackageFolderExists:error])
4343
{
@@ -58,16 +58,17 @@ - (BOOL)installWithError:(NSError **)error
5858

5959
- (BOOL)movePackageToInstallPathWithError:(NSError **)error
6060
{
61-
CCPackageInstallData *installData = [_package installData];
61+
// TODO
62+
// CCPackageInstallData *installData = [_package installData];
6263

63-
NSAssert(installData.unzipURL != nil, @"installData.unzipURL must not be nil.");
64-
NSAssert(installData.folderName != nil, @"installData.folderName must not be nil.");
64+
NSAssert(_package.unzipURL != nil, @"package.unzipURL must not be nil.");
65+
NSAssert(_package.folderName != nil, @"package.folderName must not be nil.");
6566

66-
[_package setValue:[NSURL fileURLWithPath:[_installPath stringByAppendingPathComponent:installData.folderName]] forKey:@"installURL"];
67+
[_package setValue:[NSURL fileURLWithPath:[_installPath stringByAppendingPathComponent:_package.folderName]] forKey:@"installURL"];
6768

6869
NSError *errorMove;
6970
NSFileManager *fileManager = [NSFileManager defaultManager];
70-
if (![fileManager moveItemAtPath:[installData.unzipURL.path stringByAppendingPathComponent:installData.folderName]
71+
if (![fileManager moveItemAtPath:[_package.unzipURL.path stringByAppendingPathComponent:_package.folderName]
7172
toPath:_package.installURL.path
7273
error:&errorMove])
7374
{
@@ -88,15 +89,18 @@ - (BOOL)movePackageToInstallPathWithError:(NSError **)error
8889

8990
- (BOOL)unzippedPackageFolderExists:(NSError **)error
9091
{
92+
/* TODO
9193
CCPackageInstallData *installData = [_package installData];
9294
NSAssert(installData.unzipURL, @"installData.unzipURL must not be nil");
95+
*/
96+
NSAssert(_package.unzipURL != nil, @"package.unzipURL must not be nil.");
9397

9498
NSFileManager *fileManager = [NSFileManager defaultManager];
95-
if (![fileManager fileExistsAtPath:installData.unzipURL.path])
99+
if (![fileManager fileExistsAtPath:_package.unzipURL.path])
96100
{
97101
[self setNewError:error
98102
code:PACKAGE_ERROR_INSTALL_UNZIPPED_PACKAGE_NOT_FOUND
99-
message:[NSString stringWithFormat:@"Package to install not found at path \"%@\"", installData.unzipURL]];
103+
message:[NSString stringWithFormat:@"Package to install not found at path \"%@\"", _package.unzipURL]];
100104

101105
CCLOG(@"[PACKAGE/INSTALL][ERROR] Moving unzipped package to installation folder, package already exists! %@", *error);
102106
return NO;

0 commit comments

Comments
 (0)