Increase the VideoPlayer and webview tests

This commit is contained in:
VisualSJ 2015-05-15 15:31:03 +08:00
parent 1007c0bfdb
commit 01203a8b1b
6 changed files with 217 additions and 8 deletions

View File

@ -168,6 +168,8 @@
"src/GUITest/UITextFieldTest/UITextFieldTest.js",
"src/GUITest/UIRichTextTest/UIRichTextTest.js",
"src/GUITest/UITextTest/UITextTest.js",
"src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js",
"src/GUITest/UIWebViewTest/UIWebViewTest.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Acts.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Cons.js",

View File

@ -528,21 +528,40 @@
return new UIRichTextTest();
}
}
],
"UIVideoPlayer": [
{
title: "UIVideoPlayerTest",
func: function () {
return new UIVideoPlayerTest();
}
}
],
"UIWebViewTest": [
{
title: "UIWebViewTest",
func: function () {
return new UIWebViewTest();
}
}
]
};
var guiTestScene = null;
global.GUITestScene = cc.Class.extend({
runThisTest: function(){
cc.director.runScene(new listScene);
if(guiTestScene === null)
guiTestScene = new listScene;
cc.director.runScene(guiTestScene);
}
});
var listScene = TestScene.extend({
onEnter: function(){
TestScene.prototype.onEnter.call(this);
ctor: function(){
TestScene.prototype.ctor.call(this);
var menu = new cc.Menu();
menu.x = 0;
@ -567,6 +586,14 @@
this._menu = menu;
this.addChild(menu);
this._length = 0;
for(var p in testingItems){
this._length++;
}
},
onEnter: function(){
TestScene.prototype.onEnter.call(this);
if ('touches' in cc.sys.capabilities)
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
@ -591,11 +618,6 @@
}
}, this);
}
this._length = 0;
for(var p in testingItems){
this._length++;
}
},
moveMenu: function(delta){

View File

@ -0,0 +1,73 @@
var UIVideoPlayerTest = UIScene.extend({
onEnter: function(){
UIScene.prototype.onEnter.call(this);
var video = new ccui.VideoPlayer("res/cocosui/UITest/movie.mp4");
video.setContentSize(320, 240);
video.setPosition(800/2, 450/2);
video.setScale(0.5);
window.video = video;
this.addChild(video);
var list = [
{ name: "PLAY", func: function(){
cc.log("play!");
video.play();
}},
{ name: "STOP", func: function(){
cc.log("stop!");
video.stop();
}},
{ name: "PAUSE", func: function(){
cc.log("pause!");
video.pause();
}},
{ name: "RESUME", func: function(){
cc.log("resume!");
video.resume();
}},
{ name: "SEEKTO", func: function(){
var sec = ((Math.random() * 3) * 100 | 0) / 100;
cc.log("seekTo %f sec!", sec);
video.seekTo(sec);
}},
{ name: "ISPLAYING", func: function(){
cc.log("isPlaying!");
cc.log(video.isPlaying());
}},
{ name: "Full Screen", func: function(){
cc.log("setFullScreenEnabled!");
video.setFullScreenEnabled();
}},
{ name: "Scale", func: function(){
var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100;
cc.log("setScale(%f)!", scale);
video.setScale(scale);
}},
{ name: "AnchorPoint 0 / 1", func: function(){
var anp = video.getAnchorPoint();
if(anp.x === 1)
video.setAnchorPoint(0, 0);
else
video.setAnchorPoint(1, 1);
}},
{ name: "AnchorPoint 0.5", func: function(){
video.setAnchorPoint(0.5, 0.5);
}}
];
var layer = this;
list.forEach(function(item, i){
var but = new ccui.Button();
but.setPosition( 140 + (i / 5 | 0) * 500, 300 - (i % 5) * 35);
but.setTitleText(item.name);
but.setZoomScale(0.3);
but.setPressedActionEnabled(true);
but.addClickEventListener(item.func);
layer.addChild(but);
});
}
});

View File

@ -0,0 +1,70 @@
var UIWebViewTest = UIScene.extend({
onEnter: function(){
UIScene.prototype.onEnter.call(this);
var webView = new ccui.WebView("src/GUITest/UIWebViewTest/weview.html");
webView.setContentSize(320, 240);
webView.setPosition(800/2, 450/2);
webView.setScale(0.5);
window.webView = webView;
this.addChild(webView);
var cb = function(){
cc.log("loaded");
};
webView.addEventListener("load", cb);
var list = [
{ name: "loadURL", func: function(){
cc.log("loadURL!");
webView.loadURL("src/GUITest/UIWebViewTest/weview2.html");
}},
{ name: "reload", func: function(){
cc.log("reload!");
webView.reload();
}},
{ name: "goBack", func: function(){
cc.log("goBack!");
webView.goBack();
}},
{ name: "goForward", func: function(){
cc.log("goForward!");
webView.goForward();
}},
{ name: "evaluateJS", func: function(){
cc.log("evaluateJS!");
var code = "document.getElementById('test').innerHTML = 'evaluateJS!'";
webView.evaluateJS(code);
}},
{ name: "Scale", func: function(){
var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100;
cc.log("setScale(%f)!", scale);
webView.setScale(scale);
}},
{ name: "AnchorPoint 0 / 1", func: function(){
var anp = webView.getAnchorPoint();
if(anp.x === 1)
webView.setAnchorPoint(0, 0);
else
webView.setAnchorPoint(1, 1);
}},
{ name: "AnchorPoint 0.5", func: function(){
webView.setAnchorPoint(0.5, 0.5);
}}
];
var layer = this;
list.forEach(function(item, i){
var but = new ccui.Button();
but.setPosition( 140 + (i / 5 | 0) * 500, 300 - (i % 5) * 35);
but.setTitleText(item.name);
but.setZoomScale(0.3);
but.setPressedActionEnabled(true);
but.addClickEventListener(item.func);
layer.addChild(but);
});
}
});

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Test1</title>
</head>
<body>
<style>
body{ font-family: 微软雅黑; text-align: center; font-size: 26px; }
.title{ font-size: 40px; }
#test{ font-size: 30px;}
</style>
<div class="title">
Page 1
</div>
<div>
<a href="weview2.html">goto page2</a>
</div>
<div id="test"></div>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<style>
body{ font-family: 微软雅黑; text-align: center; font-size: 26px; }
.title{ font-size: 40px; }
#test{ font-size: 30px;}
</style>
<div class="title">
Page 2
</div>
<div>
<a href="weview.html">goto page1</a>
</div>
<div id="test"></div>
</body>
</html>