Skip to content

Commit 49586f9

Browse files
committed
Testing cleanup from Monday(?).
1 parent 040e8b7 commit 49586f9

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

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/CCNoARC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ -(CCRenderBuffer)enqueueLines:(NSUInteger)lineCount andVertexes:(NSUInteger)vert
181181
NSUInteger firstVertex = _buffers->_vertexBuffer->_count;
182182
NSUInteger firstIndex = _buffers->_indexBuffer->_count;
183183

184-
// Value is 0 unless there a page boundary overlap would occur.
184+
// Value is 0 unless a page boundary overlap would occur.
185185
NSUInteger vertexPageOffset = PageOffset(firstVertex, vertexCount);
186186

187187
// Split vertexes into pages of 2^16 vertexes since GLES2 requires indexing with shorts.

0 commit comments

Comments
 (0)