Skip to content

Commit ed4d792

Browse files
committed
Merge branch 'develop' of github.com:cocos2d/cocos2d-swift into CCDirector/MergeSchedulerAndActionManager
Conflicts: cocos2d-tests.xcodeproj/project.pbxproj cocos2d.xcodeproj/project.pbxproj
2 parents 924bedc + 00e1a3f commit ed4d792

29 files changed

+2209
-102
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ url=https://github.com/slembcke/Chipmunk2D.git
88
[submodule "external/SSZipArchive"]
99
path = external/SSZipArchive
1010
url = https://github.com/spritebuilder/ssziparchive.git
11+
[submodule "external/OCMock"]
12+
path = external/OCMock
13+
url = https://github.com/erikdoe/ocmock.git

UnitTests/CCFileUtilTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#import <XCTest/XCTest.h>
99
#import "cocos2d.h"
10-
#import "CCUnitTestAssertions.h"
10+
#import "CCUnitTestHelperMacros.h"
1111

1212

1313
#import "CCFile_Private.h"
@@ -178,8 +178,8 @@ - (void)testLoadFileNameLookupsInAllSearchPaths
178178

179179
[[CCFileUtils sharedFileUtils] loadFileNameLookupsInAllSearchPathsWithName:@"fileLookup.plist"];
180180
NSDictionary *filenameLookup = [CCFileUtils sharedFileUtils].filenameLookup;
181-
CCAssertEqualStrings(filenameLookup[@"baa.psd"], @"baa.png");
182-
CCAssertEqualStrings(filenameLookup[@"foo.wav"], @"foo.mp4");
181+
XCTAssertEqualObjects(filenameLookup[@"baa.psd"], @"baa.png");
182+
XCTAssertEqualObjects(filenameLookup[@"foo.wav"], @"foo.mp4");
183183
}
184184

185185
-(void)testCCFileUtilsSearchModeSuffix

UnitTests/CCFileUtilsDatabaseTests.m

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//
2+
// CCFileUtilsDatabaseTests.m
3+
// cocos2d-tests
4+
//
5+
// Created by Nicky Weber on 13.01.15.
6+
// Copyright (c) 2015 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "CCFileUtilsDatabase.h"
11+
#import "FileSystemTestCase.h"
12+
#import "CCUnitTestHelperMacros.h"
13+
#import "CCFileMetaData.h"
14+
15+
@interface CCFileUtilsDatabaseTests : FileSystemTestCase
16+
17+
@property (nonatomic, strong) CCFileUtilsDatabase *fileUtilsDB;
18+
@property (nonatomic, copy) NSString *searchPath;
19+
@property (nonatomic, copy) NSString *dbPath;
20+
21+
@end
22+
23+
@implementation CCFileUtilsDatabaseTests
24+
25+
- (void)setUp
26+
{
27+
[super setUp];
28+
29+
NSString *json = MULTILINESTRING(
30+
{
31+
"version" : 1,
32+
"data" : {
33+
"images/foo.png" : {
34+
"UIScale" : true,
35+
"filename" : "images/foo.jpg",
36+
"localizations" : {
37+
"en" : "images/foo-en.jpg"
38+
}
39+
}
40+
}
41+
}
42+
);
43+
44+
self.searchPath = [self fullPathForFile:@"Resources"];
45+
self.dbPath = @"config/filedb.json";
46+
47+
[self createFilesWithContents:@{@"Resources/config/filedb.json" : [json dataUsingEncoding:NSUTF8StringEncoding]}];
48+
49+
self.fileUtilsDB = [[CCFileUtilsDatabase alloc] init];
50+
}
51+
52+
- (void)testAddDatabaseWithFilePathInSearchPath
53+
{
54+
NSError *error;
55+
XCTAssertTrue([_fileUtilsDB addJSONWithFilePath:_dbPath forSearchPath:_searchPath error:&error]);
56+
57+
CCFileMetaData *metaData = [_fileUtilsDB metaDataForFileNamed:@"images/foo.png" inSearchPath:_searchPath];
58+
59+
XCTAssertNotNil(metaData);
60+
XCTAssertNil(error);
61+
XCTAssertEqualObjects(metaData.filename, @"images/foo.jpg");
62+
XCTAssertEqualObjects(metaData.localizations, @{@"en" : @"images/foo-en.jpg"});
63+
};
64+
65+
- (void)testRemoveDatabaseWithFilePathInSearchPath
66+
{
67+
XCTAssertTrue([_fileUtilsDB addJSONWithFilePath:_dbPath forSearchPath:_searchPath error:NULL]);
68+
69+
[_fileUtilsDB removeEntriesForSearchPath:[self fullPathForFile:@"Resources"]];
70+
71+
CCFileMetaData *metaData = [_fileUtilsDB metaDataForFileNamed:@"images/foo.png" inSearchPath:[self fullPathForFile:@"Resources"]];
72+
73+
XCTAssertNil(metaData);
74+
}
75+
76+
- (void)testAddDataBaseWithCorruptJSON
77+
{
78+
NSString *json = MULTILINESTRING(
79+
{
80+
[] asdasdasd {}
81+
};
82+
);
83+
84+
[self createFilesWithContents:@{@"Resources/config/filedb.json" : [json dataUsingEncoding:NSUTF8StringEncoding]}];
85+
86+
NSError *error;
87+
XCTAssertFalse([_fileUtilsDB addJSONWithFilePath:_dbPath forSearchPath:_searchPath error:&error]);
88+
XCTAssertNotNil(error);
89+
}
90+
91+
- (void)testAddDataBaseWithNonExistingDatabaseFile
92+
{
93+
NSError *error;
94+
XCTAssertFalse([_fileUtilsDB addJSONWithFilePath:@"/adasdasd/ddddd.json" forSearchPath:_searchPath error:&error]);
95+
XCTAssertNotNil(error);
96+
}
97+
98+
@end

0 commit comments

Comments
 (0)