Skip to content

Commit 64fdf32

Browse files
Scheduler and Sys Tests can be automated
1 parent c8b192e commit 64fdf32

File tree

3 files changed

+42
-89
lines changed

3 files changed

+42
-89
lines changed

tests/RenderTextureTest/RenderTextureTest.js

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var RenderTextureBaseLayer = BaseTestLayer.extend({
6161
director.replaceScene(s);
6262
},
6363

64+
// automation
6465
numberOfPendingTests:function() {
6566
return ( (arrayOfRenderTextureTest.length-1) - sceneRenderTextureIdx );
6667
},

tests/SchedulerTest/SchedulerTest.js

+20-45
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,13 @@
2424
THE SOFTWARE.
2525
****************************************************************************/
2626
var TAG_ANIMATION_DANCE = 1;
27-
var MAX_TESTS = 8;
28-
var sceneIdx = -1;
27+
var schedulerTestSceneIdx = -1;
2928

3029
/*
3130
Base Layer
3231
*/
33-
var SchedulerTestLayer = cc.Layer.extend({
32+
var SchedulerTestLayer = BaseTestLayer.extend({
3433

35-
ctor:function() {
36-
cc.associateWithNative( this, cc.Layer );
37-
this.init();
38-
},
39-
40-
onEnter:function () {
41-
this._super();
42-
43-
var s = director.getWinSize();
44-
45-
var label = cc.LabelTTF.create(this.title(), "Arial", 30);
46-
this.addChild(label);
47-
label.setPosition(cc.p(s.width / 2, s.height - 50));
48-
49-
var subTitle = this.subtitle();
50-
if (subTitle != "") {
51-
var subLabel = cc.LabelTTF.create(subTitle, "Thonburi", 13);
52-
this.addChild(subLabel, 1);
53-
subLabel.setPosition(s.width / 2, s.height - 80);
54-
}
55-
56-
var item1 = cc.MenuItemImage.create("res/Images/b1.png", "res/Images/b2.png", this.onBackCallback, this);
57-
var item2 = cc.MenuItemImage.create("res/Images/r1.png", "res/Images/r2.png", this.onRestartCallback, this);
58-
var item3 = cc.MenuItemImage.create("res/Images/f1.png", "res/Images/f2.png", this.onNextCallback.bind(this) ); // another way to pass 'this'
59-
60-
var menu = cc.Menu.create(item1, item2, item3);
61-
menu.setPosition(0,0);
62-
item1.setPosition(s.width / 2 - 100, 30);
63-
item2.setPosition(s.width / 2, 30);
64-
item3.setPosition(s.width / 2 + 100, 30);
65-
66-
this.addChild(menu, 1);
67-
},
6834
title:function () {
6935
return "No title";
7036
},
@@ -92,7 +58,16 @@ var SchedulerTestLayer = cc.Layer.extend({
9258

9359
scene.addChild(layer);
9460
director.replaceScene(scene);
61+
},
62+
// automation
63+
numberOfPendingTests:function() {
64+
return ( (arrayOfSchedulerTest.length-1) - schedulerTestSceneIdx );
65+
},
66+
67+
getTestNumber:function() {
68+
return schedulerTestSceneIdx;
9569
}
70+
9671
});
9772

9873
/*
@@ -482,7 +457,7 @@ var ScheduleUsingSchedulerTest = SchedulerTestLayer.extend({
482457
*/
483458
var SchedulerTestScene = TestScene.extend({
484459
runThisTest:function () {
485-
sceneIdx = -1;
460+
schedulerTestSceneIdx = -1;
486461
var layer = nextSchedulerTest();
487462
this.addChild(layer);
488463

@@ -508,18 +483,18 @@ var arrayOfSchedulerTest = [
508483
];
509484

510485
var nextSchedulerTest = function () {
511-
sceneIdx++;
512-
sceneIdx = sceneIdx % arrayOfSchedulerTest.length;
486+
schedulerTestSceneIdx++;
487+
schedulerTestSceneIdx = schedulerTestSceneIdx % arrayOfSchedulerTest.length;
513488

514-
return new arrayOfSchedulerTest[sceneIdx]();
489+
return new arrayOfSchedulerTest[schedulerTestSceneIdx]();
515490
};
516491
var previousSchedulerTest = function () {
517-
sceneIdx--;
518-
if (sceneIdx < 0)
519-
sceneIdx += arrayOfSchedulerTest.length;
492+
schedulerTestSceneIdx--;
493+
if (schedulerTestSceneIdx < 0)
494+
schedulerTestSceneIdx += arrayOfSchedulerTest.length;
520495

521-
return new arrayOfSchedulerTest[sceneIdx]();
496+
return new arrayOfSchedulerTest[schedulerTestSceneIdx]();
522497
};
523498
var restartSchedulerTest = function () {
524-
return new arrayOfSchedulerTest[sceneIdx]();
499+
return new arrayOfSchedulerTest[schedulerTestSceneIdx]();
525500
};

tests/SysTest/SysTest.js

+21-44
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,18 @@
2424
THE SOFTWARE.
2525
****************************************************************************/
2626

27+
var sysTestSceneIdx = -1;
2728
//------------------------------------------------------------------
2829
//
2930
// SysTestBase
3031
//
3132
//------------------------------------------------------------------
32-
var SysTestBase = cc.LayerGradient.extend({
33+
var SysTestBase = BaseTestLayer.extend({
3334
_title:"",
3435
_subtitle:"",
3536

3637
ctor:function() {
37-
this._super();
38-
cc.associateWithNative( this, cc.LayerGradient );
39-
this.init( cc.c4b(0,0,0,255), cc.c4b(98,99,117,255));
40-
},
41-
onEnter:function () {
42-
this._super();
43-
44-
var label = cc.LabelTTF.create(this._title, "Arial", 28);
45-
this.addChild(label, 1);
46-
label.setPosition(cc.p(winSize.width / 2, winSize.height - 50));
47-
48-
if (this._subtitle !== "") {
49-
var l = cc.LabelTTF.create(this._subtitle, "Thonburi", 16);
50-
this.addChild(l, 1);
51-
l.setPosition(cc.p(winSize.width / 2, winSize.height - 80));
52-
}
53-
54-
var item1 = cc.MenuItemImage.create(s_pathB1, s_pathB2, this.onBackCallback, this);
55-
var item2 = cc.MenuItemImage.create(s_pathR1, s_pathR2, this.onRestartCallback, this);
56-
var item3 = cc.MenuItemImage.create(s_pathF1, s_pathF2, this.onNextCallback, this);
57-
58-
var menu = cc.Menu.create(item1, item2, item3);
59-
60-
menu.setPosition(cc.p(0,0));
61-
var cs = item2.getContentSize();
62-
item1.setPosition( cc.p(winSize.width/2 - cs.width*2, cs.height/2) );
63-
item2.setPosition( cc.p(winSize.width/2, cs.height/2) );
64-
item3.setPosition( cc.p(winSize.width/2 + cs.width*2, cs.height/2) );
65-
66-
this.addChild(menu, 1);
67-
},
68-
69-
onExit:function () {
70-
this._super();
38+
this._super(cc.c4b(0,0,0,255), cc.c4b(98,99,117,255));
7139
},
7240

7341
onRestartCallback:function (sender) {
@@ -84,7 +52,16 @@ var SysTestBase = cc.LayerGradient.extend({
8452
var s = new SysTestScene();
8553
s.addChild(previousSysTest());
8654
director.replaceScene(s);
55+
},
56+
// automation
57+
numberOfPendingTests:function() {
58+
return ( (arrayOfSysTest.length-1) - sysTestSceneIdx );
59+
},
60+
61+
getTestNumber:function() {
62+
return sysTestSceneIdx;
8763
}
64+
8865
});
8966

9067
//------------------------------------------------------------------
@@ -139,7 +116,7 @@ var CapabilitiesTest = SysTestBase.extend({
139116

140117
var SysTestScene = TestScene.extend({
141118
runThisTest:function () {
142-
sceneIdx = -1;
119+
sysTestSceneIdx = -1;
143120
var layer = nextSysTest();
144121
this.addChild(layer);
145122

@@ -158,19 +135,19 @@ var arrayOfSysTest = [
158135
];
159136

160137
var nextSysTest = function () {
161-
sceneIdx++;
162-
sceneIdx = sceneIdx % arrayOfSysTest.length;
138+
sysTestSceneIdx++;
139+
sysTestSceneIdx = sysTestSceneIdx % arrayOfSysTest.length;
163140

164-
return new arrayOfSysTest[sceneIdx]();
141+
return new arrayOfSysTest[sysTestSceneIdx]();
165142
};
166143
var previousSysTest = function () {
167-
sceneIdx--;
168-
if (sceneIdx < 0)
169-
sceneIdx += arrayOfSysTest.length;
144+
sysTestSceneIdx--;
145+
if (sysTestSceneIdx < 0)
146+
sysTestSceneIdx += arrayOfSysTest.length;
170147

171-
return new arrayOfSysTest[sceneIdx]();
148+
return new arrayOfSysTest[sysTestSceneIdx]();
172149
};
173150
var restartSysTest = function () {
174-
return new arrayOfSysTest[sceneIdx]();
151+
return new arrayOfSysTest[sysTestSceneIdx]();
175152
};
176153

0 commit comments

Comments
 (0)