Merge pull request #12139 from jianglong0156/webviewandvideo

webview and videoplayer test case bug fix
This commit is contained in:
pandamicro 2015-06-03 10:10:08 +08:00
commit 413b22d9f9
4 changed files with 121 additions and 103 deletions

View File

@ -136,15 +136,22 @@ ccui.RichElementCustomNode.prototype._ctor = function(tag, color, opacity, custo
customNode !== undefined && this.init(tag, color, opacity, customNode);
};
ccui.WebView.prototype._ctor = function(url){
this.init();
url !== undefined && this.loadURL(url);
};
if (ccui.WebView)
{
ccui.WebView.prototype._ctor = function(url){
this.init();
url !== undefined && this.loadURL(url);
};
}
if (ccui.VideoPlayer)
{
ccui.VideoPlayer.prototype._ctor = function(url){
this.init();
url !== undefined && this.setURL(url);
};
}
ccui.VideoPlayer.prototype._ctor = function(url){
this.init();
url !== undefined && this.setURL(url);
};
cc.Scale9Sprite.prototype._ctor = function(file, rect, capInsets){
rect = rect || cc.rect(0, 0, 0, 0);

View File

@ -373,100 +373,106 @@ ccui.Scale9Sprite.prototype.updateWithBatchNode = function (batchNode, originalR
this.updateWithSprite(sprite, originalRect, rotated, cc.p(0, 0), cc.size(originalRect.width, originalRect.height), capInsets);
};
/**
* The WebView support list of events
* @type {{LOADING: string, LOADED: string, ERROR: string}}
*/
ccui.WebView.EventType = {
LOADING: "loading",
LOADED: "load",
ERROR: "error",
JS_EVALUATED: "js"
};
ccui.WebView.prototype._loadURL = ccui.WebView.prototype.loadURL;
ccui.WebView.prototype.loadURL = function (url) {
if (url.indexOf("http://") >= 0)
{
this._loadURL(url);
}
else
{
this.loadFile(url);
}
};
if (ccui.WebView)
{
/**
* The WebView support list of events
* @type {{LOADING: string, LOADED: string, ERROR: string}}
*/
ccui.WebView.EventType = {
LOADING: "loading",
LOADED: "load",
ERROR: "error",
JS_EVALUATED: "js"
};
ccui.WebView.prototype.setEventListener = function(event, callback){
switch(event)
{
case ccui.WebView.EventType.LOADING:
this.setOnShouldStartLoading(callback);
break;
case ccui.WebView.EventType.LOADED:
this.setOnDidFinishLoading(callback);
break;
case ccui.WebView.EventType.ERROR:
this.setOnDidFailLoading(callback);
break;
case ccui.WebView.EventType.JS_EVALUATED:
//this.setOnJSCallback(callback);
cc.log("unsupport web event:" + event);
break;
default:
cc.log("unsupport web event:" + event);
break;
}
};
ccui.WebView.prototype._loadURL = ccui.WebView.prototype.loadURL;
ccui.WebView.prototype.loadURL = function (url) {
if (url.indexOf("http://") >= 0)
{
this._loadURL(url);
}
else
{
this.loadFile(url);
}
};
/**
* The VideoPlayer support list of events
* @type {{PLAYING: string, PAUSED: string, STOPPED: string, COMPLETED: string}}
*/
ccui.VideoPlayer.EventType = {
PLAYING: "play",
PAUSED: "pause",
STOPPED: "stop",
COMPLETED: "complete"
};
ccui.WebView.prototype.setEventListener = function(event, callback){
switch(event)
{
case ccui.WebView.EventType.LOADING:
this.setOnShouldStartLoading(callback);
break;
case ccui.WebView.EventType.LOADED:
this.setOnDidFinishLoading(callback);
break;
case ccui.WebView.EventType.ERROR:
this.setOnDidFailLoading(callback);
break;
case ccui.WebView.EventType.JS_EVALUATED:
//this.setOnJSCallback(callback);
cc.log("unsupport web event:" + event);
break;
default:
cc.log("unsupport web event:" + event);
break;
}
};
}
if (ccui.VideoPlayer)
{
/**
* The VideoPlayer support list of events
* @type {{PLAYING: string, PAUSED: string, STOPPED: string, COMPLETED: string}}
*/
ccui.VideoPlayer.EventType = {
PLAYING: "play",
PAUSED: "pause",
STOPPED: "stop",
COMPLETED: "complete"
};
ccui.VideoPlayer.prototype._setURL = ccui.VideoPlayer.prototype.setURL;
ccui.VideoPlayer.prototype.setURL = function (url) {
if (url.indexOf("http://") >= 0)
{
this._setURL(url);
}
else
{
this.setFileName(url);
}
};
ccui.VideoPlayer.prototype._setURL = ccui.VideoPlayer.prototype.setURL;
ccui.VideoPlayer.prototype.setURL = function (url) {
if (url.indexOf("http://") >= 0)
{
this._setURL(url);
}
else
{
this.setFileName(url);
}
};
ccui.VideoPlayer.prototype.setEventListener = function(event, callback){
if (!this.videoPlayerCallback)
{
this.videoPlayerCallback = function(sender, eventType){
cc.log("videoEventCallback eventType:" + eventType);
switch (eventType) {
case 0:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING](sender);
break;
case 1:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED](sender);
break;
case 2:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED](sender);
break;
case 3:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED](sender);
break;
default:
break;
}
};
this.addEventListener(this.videoPlayerCallback);
}
this["VideoPlayer_"+event] = callback;
};
ccui.VideoPlayer.prototype.setEventListener = function(event, callback){
if (!this.videoPlayerCallback)
{
this.videoPlayerCallback = function(sender, eventType){
cc.log("videoEventCallback eventType:" + eventType);
switch (eventType) {
case 0:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING](sender);
break;
case 1:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED](sender);
break;
case 2:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED](sender);
break;
case 3:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED](sender);
break;
default:
break;
}
};
this.addEventListener(this.videoPlayerCallback);
}
this["VideoPlayer_"+event] = callback;
};
}
/*
* UIWidget temporary solution to addChild
* addNode and addChild function should be merged in ccui.Widget

View File

@ -528,24 +528,29 @@
return new UIRichTextTest();
}
}
],
"UIVideoPlayer": [
]
};
if (cc.sys.os == cc.sys.OS_ANDROID || cc.sys.os == cc.sys.OS_IOS || !cc.sys.isNative)
{
testingItems["UIVideoPlayer"] = [
{
title: "UIVideoPlayerTest",
func: function () {
return new UIVideoPlayerTest();
}
}
],
"UIWebViewTest": [
];
testingItems["UIWebViewTest"] = [
{
title: "UIWebViewTest",
func: function () {
return new UIWebViewTest();
}
}
]
};
];
}
var guiTestScene = null;
global.GUITestScene = cc.Class.extend({