Skip to content

Commit 5b2dcd8

Browse files
author
Thayer J Andrews
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 0c24cba + 426e6a6 commit 5b2dcd8

21 files changed

+259
-240
lines changed

UnitTests/CCPackageCocos2dEnablerTests.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ - (void)testDisablePackage
6767
XCTAssertFalse([self isPackageInSearchPath]);
6868

6969
// Can't use [CCSprite spriteWithImageNamed:@"boredSmiley.png"], assertion exception is screwing up test result
70-
CGFloat *scale;
71-
NSString *path = [[CCFileUtils sharedFileUtils] fullPathForFilename:@"boredSmiley.png" contentScale:&scale];
70+
NSString *path = [[CCFileUtils sharedFileUtils] fullPathForFilename:@"boredSmiley.png" contentScale:NULL];
7271
XCTAssertNil(path);
7372
}
7473

UnitTests/CCPackageDownloadTests.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#import "CCDirector.h"
1515
#import "AppDelegate.h"
1616

17+
@interface CCPackageDownload()
18+
- (NSString *)createTempName;
19+
@end
20+
1721
static NSUInteger __fileDownloadSize = 0;
1822
static BOOL __support_range_request = YES;
1923

@@ -143,7 +147,7 @@ - (void)setUp
143147
self.downloadReturned = NO;
144148
self.downloadError = nil;
145149
self.downloadSuccessful = NO;
146-
self.shouldOverwriteDownloadedFile;
150+
[self shouldOverwriteDownloadedFile];
147151

148152
self.package = [[CCPackage alloc] initWithName:@"testpackage"
149153
resolution:@"phonehd"
@@ -307,7 +311,7 @@ - (void)testPauseDownload
307311

308312
XCTAssertEqual(_package.status, CCPackageStatusDownloadPaused);
309313
NSFileManager *fileManager = [NSFileManager defaultManager];
310-
NSString *tempName = [_download performSelector:@selector(createTempName)];
314+
NSString *tempName = [_download createTempName];
311315

312316
BOOL success = [fileManager fileExistsAtPath:[[_localURL.path stringByDeletingLastPathComponent] stringByAppendingPathComponent:tempName]]
313317
|| [fileManager fileExistsAtPath:_download.localURL.path];
@@ -341,7 +345,7 @@ - (void)setupPartialDownloadOnDisk
341345
NSString *fileName = [_package.remoteURL lastPathComponent];
342346
NSString *pathToPackage = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Resources-shared/Packages/%@", fileName] ofType:nil];
343347
NSData *data = [[NSData dataWithContentsOfFile:pathToPackage] subdataWithRange:NSMakeRange(0, 5000)];
344-
NSString *tempName = [_download performSelector:@selector(createTempName)];
348+
NSString *tempName = [_download createTempName];
345349
[data writeToFile:[[_localURL.path stringByDeletingLastPathComponent] stringByAppendingPathComponent:tempName] atomically:YES];
346350
}
347351

cocos2d-tests.xcodeproj/project.pbxproj

Lines changed: 25 additions & 100 deletions
Large diffs are not rendered by default.

cocos2d-ui-tests/tests/CCRendererTest.m

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ -(id)init
135135
// [self.contentNode addChild:sprite];
136136
//}
137137

138+
// Tests that vertex paging works so that render passes are not limited to 64k vertexes.
139+
// If vertex paging is broken, rendering will be broken in a very obvious (but undefined) way.
138140
-(void)setupVertexPagingTest
139141
{
140-
self.subTitle = @"Should draw a bird.";
142+
self.subTitle =
143+
@"Vertex paging test:\n"
144+
@"Should draw a bird.";
141145

142146
CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Sprites/bird.png"];
143147
sprite.position = ccp(50, 50);
@@ -165,9 +169,12 @@ -(void)setupVertexPagingTest
165169
}
166170

167171
#if !__CC_METAL_SUPPORTED_AND_ENABLED
172+
// Test CCClippingNode.
168173
-(void)setupClippingNodeTest
169174
{
170-
self.subTitle = @"ClippingNode test.";
175+
self.subTitle =
176+
@"ClippingNode test.\n"
177+
@"Should draw a gradient clipped by the shape of a human.";
171178

172179
CGSize size = [CCDirector sharedDirector].designSize;
173180

@@ -198,9 +205,12 @@ -(void)setupClippingNodeTest
198205
[clip addChild:grad];
199206
}
200207

208+
// Tests [CCRenderTexture newCGImage]
201209
-(void)setupInfiniteWindowTest
202210
{
203-
self.subTitle = @"Should draw an infinite window";
211+
self.subTitle =
212+
@"Should draw an infinite window\n"
213+
@"Let it run for 10 - 20 seconds to check for memory leaks.";
204214

205215
CCNode *contentNode = self.contentNode;
206216
CGSize size = [CCDirector sharedDirector].designSize;
@@ -234,6 +244,7 @@ -(void)setupInfiniteWindowTest
234244
}
235245
#endif
236246

247+
// Tests creating a shader using inline shader code and passing global/per-node uniforms.
237248
-(CCSprite *)simpleShaderTestHelper
238249
{
239250
CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Sprites/bird.png"];
@@ -283,7 +294,11 @@ void main(void){
283294
sprite2.position = ccp(0.3, 0.6);
284295
sprite2.shader = shader;
285296

286-
CCLabelTTF *label1 = [CCLabelTTF labelWithString:@"Using CCDirector.globalShaderUniforms" fontName:@"Helvetica" fontSize:10.0];
297+
NSString *label1Text =
298+
@"Using CCDirector.globalShaderUniforms:\n"
299+
@"Both nodes above should\n"
300+
@"cycle colors at the same speed.";
301+
CCLabelTTF *label1 = [CCLabelTTF labelWithString:label1Text fontName:@"Helvetica" fontSize:8.0];
287302
label1.positionType = CCPositionTypeNormalized;
288303
label1.position = ccp(0.3, 0.3);
289304
[self.contentNode addChild:label1];
@@ -292,7 +307,11 @@ void main(void){
292307
sprite3.position = ccp(0.7, 0.5);
293308
sprite3.shader = shader;
294309

295-
CCLabelTTF *label2 = [CCLabelTTF labelWithString:@"Using CCNode.shaderUniforms" fontName:@"Helvetica" fontSize:10.0];
310+
NSString *label2Text =
311+
@"Using CCNode.shaderUniforms:\n"
312+
@"The node above should\n"
313+
@"cycle colors twice as fast as the left nodes.";
314+
CCLabelTTF *label2 = [CCLabelTTF labelWithString:label2Text fontName:@"Helvetica" fontSize:8.0];
296315
label2.positionType = CCPositionTypeNormalized;
297316
label2.position = ccp(0.7, 0.3);
298317
[self.contentNode addChild:label2];
@@ -338,9 +357,12 @@ -(void)renderTextureHelper:(CCNode *)stage size:(CGSize)size
338357
[node addChild:sprite];
339358
}
340359

360+
// Tests that render textures work as expected. (flipping, blending, etc)
341361
-(void)setupRenderTextureTest
342362
{
343-
self.subTitle = @"Testing CCRenderTexture.";
363+
self.subTitle =
364+
@"Testing CCRenderTexture.\n"
365+
@"Right side should draw the same as the left, but clipped.";
344366

345367
CGSize size = CGSizeMake(128, 128);
346368

@@ -367,7 +389,8 @@ -(void)setupRenderTextureTest
367389
renderTexture.autoDraw = YES;
368390
}
369391

370-
-(void)setupShader1Test
392+
// TODO, this should really be turned into a unit test instead.
393+
-(void)setupShaderNamedTest_
371394
{
372395
self.subTitle = @"Useless fragment shader.";
373396

@@ -379,6 +402,8 @@ -(void)setupShader1Test
379402
[self.contentNode addChild:node];
380403
}
381404

405+
// Tests that CCMotionStreak works like it should.
406+
// CCMotionStreak assumes non-premultiplied textures so this test will look a little funny.
382407
- (void)setupMotionStreakNodeTest
383408
{
384409
self.subTitle = @"Testing CCMotionStreak";
@@ -393,7 +418,7 @@ - (void)setupMotionStreakNodeTest
393418

394419
// Maybe want to find a better texture than a random tile graphic?
395420
{
396-
CCMotionStreak *streak = [CCMotionStreak streakWithFade:15.0 minSeg:5 width:3 color:[CCColor whiteColor] textureFilename:@"Tiles/05.png"];
421+
CCMotionStreak *streak = [CCMotionStreak streakWithFade:15.0 minSeg:5 width:3 color:[CCColor whiteColor] textureFilename:@"Images/fire.png"];
397422
[stage addChild:streak];
398423

399424
[streak scheduleBlock:^(CCTimer *timer) {
@@ -405,7 +430,7 @@ - (void)setupMotionStreakNodeTest
405430
[timer repeatOnceWithInterval:0.01];
406431
} delay:0.0];
407432
}{
408-
CCMotionStreak *streak = [CCMotionStreak streakWithFade:0.5 minSeg:5 width:3 color:[CCColor redColor] textureFilename:@"Tiles/05.png"];
433+
CCMotionStreak *streak = [CCMotionStreak streakWithFade:0.5 minSeg:5 width:3 color:[CCColor redColor] textureFilename:@"Images/fire.png"];
409434
[stage addChild:streak];
410435

411436
[streak scheduleBlock:^(CCTimer *timer) {
@@ -668,14 +693,16 @@ - (void)setupProgressNodeTest
668693

669694
- (void)setupDrawNodeTest
670695
{
671-
self.subTitle = @"Testing CCDrawNode";
696+
self.subTitle =
697+
@"Testing CCDrawNode:\n"
698+
@"Should draw various shapes.";
672699

673700
CCDrawNode *draw = [CCDrawNode node];
674701

675702
[draw drawDot:ccp(100, 100) radius:50 color:[CCColor colorWithRed:0.5 green:0.0 blue:0.0 alpha:0.75]];
676703

677704
// This yellow dot should not be visible.
678-
[draw drawDot:ccp(150, 150) radius:50 color:[CCColor colorWithRed:0.5 green:0.5 blue:0.0 alpha:0.0]];
705+
[draw drawDot:ccp(150, 150) radius:50 color:[CCColor colorWithRed:0.5 green:0.5 blue:0.0 alpha:0.5]];
679706

680707
[draw drawSegmentFrom:ccp(100, 200) to:ccp(200, 200) radius:25 color:[CCColor colorWithRed:0.0 green:0.0 blue:0.5 alpha:0.75]];
681708

@@ -691,11 +718,12 @@ - (void)setupDrawNodeTest
691718

692719
CGPoint points2[] = {
693720
{325, 125},
694-
{375, 125},
695721
{350, 200},
722+
{375, 125},
696723
};
697724
[draw drawPolyWithVerts:points2 count:sizeof(points2)/sizeof(*points2) fillColor:[CCColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.75] borderWidth:0.0 borderColor:[CCColor whiteColor]];
698725

726+
[draw runAction:[CCActionFadeIn actionWithDuration:0.25]];
699727
[self.contentNode addChild:draw];
700728
}
701729

cocos2d.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@
441441
7A97912A19E646D8001FFC4D /* libObjectiveChipmunk-Android.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A40377B19E36EFF007B6E8F /* libObjectiveChipmunk-Android.a */; };
442442
7A97912B19E646F9001FFC4D /* libSSZipArchiveAndroid.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A40378319E36EFF007B6E8F /* libSSZipArchiveAndroid.a */; };
443443
83409E4919D5BADC004B7EB9 /* libSSZipArchive.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 83409E3619D5B791004B7EB9 /* libSSZipArchive.a */; };
444-
83B7DB7B19D32FD800B9A452 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 83E1A88D19C8C19D000A3BCA /* libz.dylib */; };
445444
83E1A86219C8ACA0000A3BCA /* CCPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E1A85A19C8ACA0000A3BCA /* CCPackage.h */; };
446445
83E1A86319C8ACA0000A3BCA /* CCPackage.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E1A85B19C8ACA0000A3BCA /* CCPackage.m */; };
447446
83E1A86419C8ACA0000A3BCA /* CCPackageConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E1A85C19C8ACA0000A3BCA /* CCPackageConstants.h */; };
@@ -1492,7 +1491,6 @@
14921491
buildActionMask = 2147483647;
14931492
files = (
14941493
83409E4919D5BADC004B7EB9 /* libSSZipArchive.a in Frameworks */,
1495-
83B7DB7B19D32FD800B9A452 /* libz.dylib in Frameworks */,
14961494
FC64014019C79716003E595A /* libObjectAL.a in Frameworks */,
14971495
D3903B1A19952ABD003AA81A /* Metal.framework in Frameworks */,
14981496
D24FAEEC198014B90043E27D /* GLKit.framework in Frameworks */,

0 commit comments

Comments
 (0)