mirror of https://github.com/axmolengine/axmol.git
Merge pull request #13804 from ZhangMenghe/v3-UItestcase
[ci skip] UItestcase modification to be friendly
This commit is contained in:
commit
6b8d400517
|
@ -10,98 +10,67 @@ var UIVideoPlayerTest = UIMainLayer.extend({
|
||||||
window.video = video;
|
window.video = video;
|
||||||
this.addChild(video);
|
this.addChild(video);
|
||||||
|
|
||||||
video.setEventListener(ccui.VideoPlayer.EventType.PLAYING, function(sender){
|
var widgetSize = this._widget.getContentSize();
|
||||||
cc.log("VideoPlayer PLAYING");
|
var playState = this._topDisplayLabel;
|
||||||
});
|
playState.setString("Press buttons to start");
|
||||||
video.setEventListener(ccui.VideoPlayer.EventType.PAUSED, function(sender){
|
playState.y = widgetSize.height / 2.0 + playState.height * 1.5;
|
||||||
cc.log("VideoPlayer PAUSED");
|
this._bottomDisplayLabel.setString("");
|
||||||
});
|
|
||||||
video.setEventListener(ccui.VideoPlayer.EventType.STOPPED, function(sender){
|
|
||||||
cc.log("VideoPlayer STOPPED");
|
|
||||||
});
|
|
||||||
video.setEventListener(ccui.VideoPlayer.EventType.COMPLETED, function(sender){
|
|
||||||
cc.log("VideoPlayer COMPLETED");
|
|
||||||
});
|
|
||||||
|
|
||||||
var playState = new cc.LabelTTF("PLAY State", "Thonburi", 28);
|
|
||||||
playState.setPosition(400, 350);
|
|
||||||
this.addChild(playState);
|
|
||||||
|
|
||||||
ccui.VideoPlayer.EventType = {
|
|
||||||
PLAYING: "play",
|
|
||||||
PAUSED: "pause",
|
|
||||||
STOPPED: "stop",
|
|
||||||
COMPLETED: "complete"
|
|
||||||
};
|
|
||||||
var list = [
|
var list = [
|
||||||
{ name: "PLAYURL", func: function(){
|
{ name: "playURL", func: function(){
|
||||||
cc.log("play!");
|
playState.setString("Video from Web address");
|
||||||
playState.setString("play");
|
|
||||||
video.setURL("http://benchmark.cocos2d-x.org/cocosvideo.mp4");
|
video.setURL("http://benchmark.cocos2d-x.org/cocosvideo.mp4");
|
||||||
video.play();
|
video.play();
|
||||||
}},
|
}},
|
||||||
{ name: "PLAYLOCAL", func: function(){
|
{ name: "PlayLocal", func: function(){
|
||||||
cc.log("play!");
|
playState.setString("Video from Local resource");
|
||||||
playState.setString("play");
|
|
||||||
video.setURL("cocosvideo.mp4");
|
video.setURL("cocosvideo.mp4");
|
||||||
video.play();
|
video.play();
|
||||||
}},
|
}},
|
||||||
{ name: "STOP", func: function(){
|
{ name: "Pause", func: function(){
|
||||||
cc.log("stop!");
|
playState.setString("Pause playing");
|
||||||
playState.setString("stop");
|
|
||||||
video.stop();
|
|
||||||
}},
|
|
||||||
{ name: "PAUSE", func: function(){
|
|
||||||
cc.log("pause!");
|
|
||||||
playState.setString("pause");
|
|
||||||
video.pause();
|
video.pause();
|
||||||
}},
|
}},
|
||||||
{ name: "RESUME", func: function(){
|
{ name: "Resume", func: function(){
|
||||||
cc.log("resume!");
|
playState.setString("Resume");
|
||||||
playState.setString("resume");
|
|
||||||
video.resume();
|
video.resume();
|
||||||
}},
|
}},
|
||||||
{ name: "SEEKTO", func: function(){
|
{ name: "Stop", func: function(){
|
||||||
|
playState.setString("Stop playing");
|
||||||
|
video.stop();
|
||||||
|
}},
|
||||||
|
{ name: "SeekTo", func: function(){
|
||||||
var sec = ((Math.random() * 59) * 100 | 0) / 100;
|
var sec = ((Math.random() * 59) * 100 | 0) / 100;
|
||||||
cc.log("seekTo %f sec!", sec);
|
playState.setString("SeekTo %f sec", sec);
|
||||||
video.seekTo(sec);
|
video.seekTo(sec);
|
||||||
}},
|
}},
|
||||||
{ name: "ISPLAYING", func: function(){
|
|
||||||
cc.log("isPlaying!");
|
|
||||||
playState.setString("isPlaying");
|
|
||||||
cc.log(video.isPlaying());
|
|
||||||
}},
|
|
||||||
{ name: "Full Screen", func: function(){
|
{ name: "Full Screen", func: function(){
|
||||||
cc.log("setFullScreenEnabled!");
|
|
||||||
playState.setString("setFullScreenEnabled");
|
playState.setString("setFullScreenEnabled");
|
||||||
video.setFullScreenEnabled(true);
|
video.setFullScreenEnabled(true);
|
||||||
}},
|
}},
|
||||||
{ name: "Scale", func: function(){
|
{ name: "Scale", func: function(){
|
||||||
var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100;
|
var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100;
|
||||||
cc.log("setScale(%f)!", scale);
|
playState.setString( "setScale(%f)!" );
|
||||||
video.setScale(scale);
|
video.setScale(scale);
|
||||||
}},
|
}},
|
||||||
{ name: "AnchorPoint 0 / 1", func: function(){
|
{ name: "setAnchorPoint", func: function(){
|
||||||
var anp = video.getAnchorPoint();
|
var anpX = video.getAnchorPoint().x === 1 ? 0: video.getAnchorPoint().x+ 0.5;
|
||||||
if(anp.x === 1)
|
var anpY = video.getAnchorPoint().y === 1 ? 0: video.getAnchorPoint().y+ 0.5;
|
||||||
video.setAnchorPoint(0, 0);
|
video.setAnchorPoint(anpX, anpY);
|
||||||
else
|
|
||||||
video.setAnchorPoint(1, 1);
|
|
||||||
}},
|
|
||||||
{ name: "AnchorPoint 0.5", func: function(){
|
|
||||||
video.setAnchorPoint(0.5, 0.5);
|
|
||||||
}}
|
}}
|
||||||
];
|
];
|
||||||
|
|
||||||
var layer = this;
|
var layer = this;
|
||||||
list.forEach(function(item, i){
|
list.forEach(function(item, i){
|
||||||
var but = new ccui.Button();
|
var button = new ccui.Button();
|
||||||
but.setPosition( 140 + (i / 6 | 0) * 500, 300 - (i % 6) * 35);
|
i+1 !== list.length ? button.setScale(1.3) : button.setScale(1);
|
||||||
but.setTitleText(item.name);
|
button.setPosition( 140 + (i / 5 | 0) * 530, 320 - (i % 5) * 50);
|
||||||
but.setZoomScale(0.3);
|
button.setTitleText(item.name);
|
||||||
but.setPressedActionEnabled(true);
|
button.setTitleColor(cc.color.YELLOW);
|
||||||
but.addClickEventListener(item.func);
|
button.setZoomScale(0.3);
|
||||||
layer.addChild(but);
|
button.setPressedActionEnabled(true);
|
||||||
|
button.addClickEventListener(item.func);
|
||||||
|
layer.addChild(button);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,79 +37,69 @@ var UIWebViewTest = UIMainLayer.extend({
|
||||||
window.webView = webView;
|
window.webView = webView;
|
||||||
this.addChild(webView);
|
this.addChild(webView);
|
||||||
|
|
||||||
|
var widgetSize = this._widget.getContentSize();
|
||||||
webView.setEventListener(ccui.WebView.EventType.LOADED, function(sender, url){
|
var playState = this._topDisplayLabel;
|
||||||
cc.log("webview LOADED url:" + url);
|
playState.setString("Press buttons to start");
|
||||||
});
|
playState.y = widgetSize.height / 2.0 + playState.height * 1.5;
|
||||||
webView.setEventListener(ccui.WebView.EventType.LOADING, function(sender, url){
|
this._bottomDisplayLabel.setString("");
|
||||||
cc.log("webview LOADING url:" + url);
|
|
||||||
});
|
|
||||||
webView.setEventListener(ccui.WebView.EventType.ERROR, function(sender, url){
|
|
||||||
cc.log("webview ERROR url:" + url);
|
|
||||||
});
|
|
||||||
|
|
||||||
var list = [
|
var list = [
|
||||||
{ name: "loadURL", func: function(){
|
{ name: "loadURL", func: function(){
|
||||||
cc.log("loadURL!");
|
playState.setString("loadURL!");
|
||||||
webView.loadURL("src/GUITest/UIWebViewTest/webview2.html");
|
webView.loadURL("src/GUITest/UIWebViewTest/webview2.html");
|
||||||
}},
|
}},
|
||||||
{ name: "reload", func: function(){
|
{ name: "Reload", func: function(){
|
||||||
cc.log("reload!");
|
playState.setString("reload!");
|
||||||
webView.reload();
|
webView.reload();
|
||||||
}},
|
}},
|
||||||
{ name: "goBack", func: function(){
|
{ name: "goBack", func: function(){
|
||||||
if (webView.canGoBack())
|
if (webView.canGoBack())
|
||||||
{
|
{
|
||||||
cc.log("goBack!");
|
playState.setString("goBack!");
|
||||||
webView.goBack();
|
webView.goBack();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cc.log("can not goBack!");
|
playState.setString("can not goBack!");
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{ name: "goForward", func: function(){
|
{ name: "goForward", func: function(){
|
||||||
if (webView.canGoForward())
|
if (webView.canGoForward()) {
|
||||||
{
|
playState.setString("goForward!");
|
||||||
cc.log("goForward!");
|
|
||||||
webView.goForward();
|
webView.goForward();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
playState.setString("can not goForward!");
|
||||||
cc.log("can not goForward!");
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{ name: "evaluateJS", func: function(){
|
{ name: "EvaluateJS", func: function(){
|
||||||
cc.log("evaluateJS!");
|
playState.setString("evaluateJS!");
|
||||||
var code = "alert('evaluateJS!')";
|
var code = "alert('evaluateJS!')";
|
||||||
webView.evaluateJS(code);
|
webView.evaluateJS(code);
|
||||||
}},
|
}},
|
||||||
{ name: "Scale", func: function(){
|
{ name: "Scale", func: function(){
|
||||||
var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100;
|
var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100;
|
||||||
cc.log("setScale(%f)!", scale);
|
playState.setString("setScale(%f)!", scale);
|
||||||
webView.setScale(scale);
|
webView.setScale(scale);
|
||||||
}},
|
}},
|
||||||
{ name: "AnchorPoint 0 / 1", func: function(){
|
{ name: "setAnchorPoint", func: function(){
|
||||||
var anp = webView.getAnchorPoint();
|
var anpX = video.getAnchorPoint().x === 1 ? 0: video.getAnchorPoint().x+ 0.5;
|
||||||
if(anp.x === 1)
|
var anpY = video.getAnchorPoint().y === 1 ? 0: video.getAnchorPoint().y+ 0.5;
|
||||||
webView.setAnchorPoint(0, 0);
|
webView.setAnchorPoint(anpX, anpY);
|
||||||
else
|
|
||||||
webView.setAnchorPoint(1, 1);
|
|
||||||
}},
|
|
||||||
{ name: "AnchorPoint 0.5", func: function(){
|
|
||||||
webView.setAnchorPoint(0.5, 0.5);
|
|
||||||
}}
|
}}
|
||||||
];
|
];
|
||||||
|
|
||||||
var layer = this;
|
var layer = this;
|
||||||
list.forEach(function(item, i){
|
list.forEach(function(item, i){
|
||||||
var but = new ccui.Button();
|
var button = new ccui.Button();
|
||||||
but.setPosition( 140 + (i / 5 | 0) * 500, 300 - (i % 5) * 35);
|
i+1 !== list.length ? button.setScale(1.3) : button.setScale(1);
|
||||||
but.setTitleText(item.name);
|
button.setPosition( 140 + (i / 4 | 0) * 530, 320 - (i % 4) * 50);
|
||||||
but.setZoomScale(0.3);
|
button.setTitleText(item.name);
|
||||||
but.setPressedActionEnabled(true);
|
button.setTitleColor(cc.color.YELLOW);
|
||||||
but.addClickEventListener(item.func);
|
button.setZoomScale(0.3);
|
||||||
layer.addChild(but);
|
button.setPressedActionEnabled(true);
|
||||||
|
button.addClickEventListener(item.func);
|
||||||
|
layer.addChild(button);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue