Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Device specific tests for Multiple Views/Activities #176

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/LabelTest/LabelTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1738,11 +1738,15 @@ var arrayOfLabelTest = [
LabelTTFA8Test,
LabelTTFFontInitTest,
LabelTTFAlignment,
LabelTTFStrokeShadowTest,

LabelsEmpty
];

if( sys.platform != "browser"){
//Not implement in HTML5
arrayOfLabelTest.push(LabelTTFStrokeShadowTest);
}

var nextLabelTest = function () {
labelTestIdx++;
labelTestIdx = labelTestIdx % arrayOfLabelTest.length;
Expand Down
138 changes: 138 additions & 0 deletions tests/MultiViewTest/MultiViewTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/****************************************************************************

http://www.cocos2d-html5.org
http://www.cocos2d-iphone.org
http://www.cocos2d-x.org


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

var multiViewTestSceneIdx = -1;
//------------------------------------------------------------------
//
// MultiViewTestBase
//
//------------------------------------------------------------------
var MultiViewTestBase = BaseTestLayer.extend({
_title:"",
_subtitle:"",

ctor:function() {
this._super(cc.c4b(0,0,0,255), cc.c4b(98,99,117,255));
},

onRestartCallback:function (sender) {
var s = new MultiViewTestScene();
s.addChild(restartMultiViewTest());
director.replaceScene(s);
},
onNextCallback:function (sender) {
var s = new MultiViewTestScene();
s.addChild(nextMultiViewTest());
director.replaceScene(s);
},
onBackCallback:function (sender) {
var s = new MultiViewTestScene();
s.addChild(previousMultiViewTest());
director.replaceScene(s);
},
// automation
numberOfPendingTests:function() {
return ( (arrayOfMultiViewTest.length-1) - multiViewTestSceneIdx );
},

getTestNumber:function() {
return multiViewTestSceneIdx;
}

});


//------------------------------------------------------------------
//
// CapabilitiesTest
//
//------------------------------------------------------------------
var KillAndSwitchTest = MultiViewTestBase.extend({
_title:"Stability test: Kill and Switch Activity/View",
_subtitle:"Coming back into cocos2d-x should start a new instance of TestJavascript",

handleCloseActivity: function() {
cc.switchAndKillActivity();
},

ctor:function () {
this._super();

var clickButton = cc.MenuItemFont.create("Click here to kill this cocos2d-x Activity and switch to new one", this.handleCloseActivity, this);
var menu = cc.Menu.create(clickButton);
menu.alignItemsVertically();
this.addChild(menu);
}
});


var MultiViewTestScene = TestScene.extend({
runThisTest:function () {
multiViewTestSceneIdx = -1;
var layer = nextMultiViewTest();
this.addChild(layer);

director.replaceScene(this);
}
});

//
// Flow control
//

var arrayOfMultiViewTest = [
];

var arrayOfIOSSpeceficTests = [
];

var arrayOfAndroidSpeceficTests = [
KillAndSwitchTest
];

if(sys.os == "android") {
arrayOfMultiViewTest = arrayOfMultiViewTest.concat(arrayOfAndroidSpeceficTests);
} else if(sys.os == "ios") {
arrayOfMultiViewTest.concat(arrayOfIOSSpeceficTests);
}

var nextMultiViewTest = function () {
multiViewTestSceneIdx++;
multiViewTestSceneIdx = multiViewTestSceneIdx % arrayOfMultiViewTest.length;

return new arrayOfMultiViewTest[multiViewTestSceneIdx]();
};
var previousMultiViewTest = function () {
multiViewTestSceneIdx--;
if (multiViewTestSceneIdx < 0)
multiViewTestSceneIdx += arrayOfMultiViewTest.length;

return new arrayOfMultiViewTest[multiViewTestSceneIdx]();
};
var restartMultiViewTest = function () {
return new arrayOfMultiViewTest[multiViewTestSceneIdx]();
};

4 changes: 2 additions & 2 deletions tests/tests-boot-jsb.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var tests_files = [

// base class
'BaseTestLayer/BaseTestLayer.js',

'ActionManagerTest/ActionManagerTest.js',
'ActionsTest/ActionsTest.js',
'ChipmunkTest/ChipmunkTest.js',
Expand Down Expand Up @@ -55,7 +54,8 @@ var tests_files = [
'TileMapTest/TileMapTest.js',
'TransitionsTest/TransitionsTest.js',
'UnitTest/UnitTest.js',
'SysTest/SysTest.js'
'SysTest/SysTest.js',
'MultiViewTest/MultiViewTest.js'
];

for (var i = 0; i < tests_files.length; i++) {
Expand Down
22 changes: 18 additions & 4 deletions tests/tests-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ var testNames = [
},
{
title:"ClippingNode Test",
platforms: PLATFORM_JSB_AND_WEBGL,
platforms: PLATFORM_HTML5_WEBGL,
testScene:function () {
return new ClippingNodeTestScene();
}
Expand Down Expand Up @@ -285,7 +285,7 @@ var testNames = [
{
title:"Extensions Test",
resource:g_extensions,
platforms: PLATFORM_HTML5,
platforms: PLATFORM_ALL,
testScene:function () {
return new ExtensionsTestScene();
}
Expand Down Expand Up @@ -366,9 +366,9 @@ var testNames = [
return new NodeTestScene();
}
},
//"MotionStreakTest",
{
title:"OpenGL Test",
resource:g_opengl_resources,
platforms: PLATFORM_JSB_AND_WEBGL,
testScene:function () {
return new OpenGLTestScene();
Expand All @@ -393,7 +393,6 @@ var testNames = [
{
title:"Performance Test",
platforms: PLATFORM_ALL,
resource:g_performace,
testScene:function () {
return new PerformanceTestScene();
}
Expand Down Expand Up @@ -514,6 +513,21 @@ var testNames = [
//"ZwoptexTest",
];

var androidTestNames = [
{
title:"MultiView Tests",
platforms: PLATFORM_ALL,
testScene:function () {
return new MultiViewTestScene();
}
}
]

if(sys.os == "android") {
testNames = testNames.concat(androidTestNames);
}


var s_rcVisible = cc.rect(0, 0, 0, 0);
var s_ptCenter = cc.p(0, 0);
var s_ptTop = cc.p(0, 0);
Expand Down