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); customNode !== undefined && this.init(tag, color, opacity, customNode);
}; };
ccui.WebView.prototype._ctor = function(url){ if (ccui.WebView)
this.init(); {
url !== undefined && this.loadURL(url); 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){ cc.Scale9Sprite.prototype._ctor = function(file, rect, capInsets){
rect = rect || cc.rect(0, 0, 0, 0); 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); 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; if (ccui.WebView)
ccui.WebView.prototype.loadURL = function (url) { {
if (url.indexOf("http://") >= 0) /**
{ * The WebView support list of events
this._loadURL(url); * @type {{LOADING: string, LOADED: string, ERROR: string}}
} */
else ccui.WebView.EventType = {
{ LOADING: "loading",
this.loadFile(url); LOADED: "load",
} ERROR: "error",
}; JS_EVALUATED: "js"
};
ccui.WebView.prototype.setEventListener = function(event, callback){ ccui.WebView.prototype._loadURL = ccui.WebView.prototype.loadURL;
switch(event) ccui.WebView.prototype.loadURL = function (url) {
{ if (url.indexOf("http://") >= 0)
case ccui.WebView.EventType.LOADING: {
this.setOnShouldStartLoading(callback); this._loadURL(url);
break; }
case ccui.WebView.EventType.LOADED: else
this.setOnDidFinishLoading(callback); {
break; this.loadFile(url);
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.setEventListener = function(event, callback){
* The VideoPlayer support list of events switch(event)
* @type {{PLAYING: string, PAUSED: string, STOPPED: string, COMPLETED: string}} {
*/ case ccui.WebView.EventType.LOADING:
ccui.VideoPlayer.EventType = { this.setOnShouldStartLoading(callback);
PLAYING: "play", break;
PAUSED: "pause", case ccui.WebView.EventType.LOADED:
STOPPED: "stop", this.setOnDidFinishLoading(callback);
COMPLETED: "complete" 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 = ccui.VideoPlayer.prototype.setURL;
ccui.VideoPlayer.prototype.setURL = function (url) { ccui.VideoPlayer.prototype.setURL = function (url) {
if (url.indexOf("http://") >= 0) if (url.indexOf("http://") >= 0)
{ {
this._setURL(url); this._setURL(url);
} }
else else
{ {
this.setFileName(url); this.setFileName(url);
} }
}; };
ccui.VideoPlayer.prototype.setEventListener = function(event, callback){ ccui.VideoPlayer.prototype.setEventListener = function(event, callback){
if (!this.videoPlayerCallback) if (!this.videoPlayerCallback)
{ {
this.videoPlayerCallback = function(sender, eventType){ this.videoPlayerCallback = function(sender, eventType){
cc.log("videoEventCallback eventType:" + eventType); cc.log("videoEventCallback eventType:" + eventType);
switch (eventType) { switch (eventType) {
case 0: case 0:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING](sender); this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PLAYING](sender);
break; break;
case 1: case 1:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED](sender); this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.PAUSED](sender);
break; break;
case 2: case 2:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED](sender); this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.STOPPED](sender);
break; break;
case 3: case 3:
this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED](sender); this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED] && this["VideoPlayer_"+ccui.VideoPlayer.EventType.COMPLETED](sender);
break; break;
default: default:
break; break;
} }
}; };
this.addEventListener(this.videoPlayerCallback); this.addEventListener(this.videoPlayerCallback);
} }
this["VideoPlayer_"+event] = callback; this["VideoPlayer_"+event] = callback;
}; };
}
/* /*
* UIWidget temporary solution to addChild * UIWidget temporary solution to addChild
* addNode and addChild function should be merged in ccui.Widget * addNode and addChild function should be merged in ccui.Widget

View File

@ -528,24 +528,29 @@
return new UIRichTextTest(); 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", title: "UIVideoPlayerTest",
func: function () { func: function () {
return new UIVideoPlayerTest(); return new UIVideoPlayerTest();
} }
} }
], ];
"UIWebViewTest": [
testingItems["UIWebViewTest"] = [
{ {
title: "UIWebViewTest", title: "UIWebViewTest",
func: function () { func: function () {
return new UIWebViewTest(); return new UIWebViewTest();
} }
} }
] ];
}; }
var guiTestScene = null; var guiTestScene = null;
global.GUITestScene = cc.Class.extend({ global.GUITestScene = cc.Class.extend({