mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
remove deprecated files
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
var NodeWrapper = require('./node');
|
||||
|
||||
var DrawNodeWrapper = cc.Class({
|
||||
name: 'cc.DrawNodeWrapper',
|
||||
extends: NodeWrapper,
|
||||
|
||||
createNode: function(node){
|
||||
node = node || new cc.DrawNode();
|
||||
|
||||
NodeWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
cc.DrawNodeWrapper = module.exports = DrawNodeWrapper;
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
var LayerWrapper = require('./layer');
|
||||
|
||||
var LayerColorWrapper = cc.Class({
|
||||
name: 'cc.LayerColorWrapper',
|
||||
extends: LayerWrapper,
|
||||
|
||||
createNode: function (node) {
|
||||
node = node || new cc.LayerColor();
|
||||
|
||||
LayerWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
cc.LayerColorWrapper = module.exports = LayerColorWrapper;
|
||||
@@ -1,44 +0,0 @@
|
||||
|
||||
var NodeWrapper = require('./node');
|
||||
|
||||
var LayerWrapper = cc.Class({
|
||||
name: 'cc.LayerWrapper',
|
||||
extends: NodeWrapper,
|
||||
|
||||
properties: {
|
||||
bake: {
|
||||
default: false,
|
||||
|
||||
notify: function (value) {
|
||||
if (!this.targetN) return;
|
||||
|
||||
if (typeof value === 'boolean') {
|
||||
if (value) {
|
||||
this.targetN.bake();
|
||||
}
|
||||
else {
|
||||
this.targetN.unbake();
|
||||
}
|
||||
}
|
||||
else {
|
||||
cc.errorID(7301);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
createNode: function (node) {
|
||||
node = node || new cc.Layer();
|
||||
node.setAnchorPoint(0, 0);
|
||||
|
||||
if (this.bake) {
|
||||
node.bake();
|
||||
}
|
||||
|
||||
NodeWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
cc.LayerWrapper = module.exports = LayerWrapper;
|
||||
@@ -1,55 +0,0 @@
|
||||
|
||||
var NodeWrapper = require('./node');
|
||||
|
||||
var SpriteBatchNodeWrapper = cc.Class({
|
||||
name: 'cc.SpriteBatchNodeWrapper',
|
||||
extends: NodeWrapper,
|
||||
|
||||
properties: {
|
||||
|
||||
texture_: {
|
||||
get: function () {
|
||||
var tex = this.targetN.texture;
|
||||
return (tex && tex.url) || '';
|
||||
},
|
||||
set: function (value) {
|
||||
this.targetN.initWithFile(value);
|
||||
},
|
||||
url: cc.Texture2D
|
||||
},
|
||||
|
||||
texture: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
visible: false
|
||||
},
|
||||
|
||||
_textureObject: {
|
||||
default: null
|
||||
},
|
||||
},
|
||||
|
||||
onBeforeSerialize: function () {
|
||||
NodeWrapper.prototype.onBeforeSerialize.call(this);
|
||||
|
||||
this.texture = this.texture_;
|
||||
this._textureObject = this.targetN.texture;
|
||||
},
|
||||
|
||||
createNode: function (node) {
|
||||
node = node || new cc.SpriteBatchNode(new cc.Texture2D());
|
||||
|
||||
NodeWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
if (this.texture) {
|
||||
node.texture = cc.textureCache.addImage(this.texture);
|
||||
}
|
||||
else if (this._textureObject) {
|
||||
node.texture = this._textureObject;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
cc.SpriteBatchNodeWrapper = module.exports = SpriteBatchNodeWrapper;
|
||||
@@ -1,140 +0,0 @@
|
||||
|
||||
var WidgetWrapper = require('./widget');
|
||||
|
||||
var CheckBoxWrapper = cc.Class({
|
||||
name: 'cc.CheckBoxWrapper',
|
||||
extends: WidgetWrapper,
|
||||
|
||||
properties: {
|
||||
bg_: {
|
||||
get: function () {
|
||||
return this.bg;
|
||||
},
|
||||
set: function ( value ) {
|
||||
this.bg = value;
|
||||
this.targetN.loadTextureBackGround( value );
|
||||
},
|
||||
url: cc.Texture2D,
|
||||
displayName: 'Bg'
|
||||
},
|
||||
|
||||
bgPressed_: {
|
||||
get: function () {
|
||||
return this.bgPressed;
|
||||
},
|
||||
set: function ( value ) {
|
||||
this.bgPressed = value;
|
||||
this.targetN.loadTextureBackGroundSelected( value );
|
||||
},
|
||||
url: cc.Texture2D,
|
||||
displayName: 'Bg Pressed'
|
||||
},
|
||||
|
||||
bgDisabled_: {
|
||||
get: function () {
|
||||
return this.bgDisabled;
|
||||
},
|
||||
set: function ( value ) {
|
||||
this.bgDisabled = value;
|
||||
this.targetN.loadTextureBackGroundDisabled( value );
|
||||
},
|
||||
url: cc.Texture2D,
|
||||
displayName: 'Bg Disabled'
|
||||
},
|
||||
|
||||
fg_: {
|
||||
get: function () {
|
||||
return this.fg;
|
||||
},
|
||||
set: function ( value ) {
|
||||
this.fg = value;
|
||||
this.targetN.loadTextureFrontCross( value );
|
||||
},
|
||||
url: cc.Texture2D,
|
||||
displayName: 'Fg'
|
||||
},
|
||||
|
||||
fgDisabled_: {
|
||||
get: function () {
|
||||
return this.fgDisabled;
|
||||
},
|
||||
set: function ( value ) {
|
||||
this.fgDisabled = value;
|
||||
this.targetN.loadTextureFrontCrossDisabled( value );
|
||||
},
|
||||
url: cc.Texture2D,
|
||||
displayName: 'Fg Disabled'
|
||||
},
|
||||
|
||||
selected: {
|
||||
get: function () {
|
||||
return this.targetN.selected;
|
||||
},
|
||||
set: function (value) {
|
||||
if (typeof value === 'boolean') {
|
||||
this.targetN.selected = value;
|
||||
}
|
||||
else {
|
||||
cc.errorID(7300);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bg: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
visible: false
|
||||
},
|
||||
|
||||
bgPressed: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
visible: false
|
||||
},
|
||||
|
||||
bgDisabled: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
visible: false
|
||||
},
|
||||
|
||||
fg: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
visible: false
|
||||
},
|
||||
|
||||
fgDisabled: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
visible: false
|
||||
},
|
||||
|
||||
_selected: {
|
||||
default: null
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
onBeforeSerialize: function () {
|
||||
WidgetWrapper.prototype.onBeforeSerialize.call(this);
|
||||
|
||||
this._selected = this.selected;
|
||||
},
|
||||
|
||||
createNode: function (node) {
|
||||
|
||||
node = node || new ccui.CheckBox();
|
||||
node.loadTextures(this.bg, this.bgPressed, this.fg, this.bgDisabled, this.fgDisabled);
|
||||
|
||||
if (this._selected !== null) {
|
||||
node.selected = this._selected;
|
||||
}
|
||||
|
||||
WidgetWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
cc.CheckBoxWrapper = module.exports = CheckBoxWrapper;
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
var ScrollViewWrapper = require('./scroll-view');
|
||||
|
||||
var ListViewWrapper = cc.Class({
|
||||
name: 'cc.ListViewWrapper',
|
||||
extends: ScrollViewWrapper,
|
||||
|
||||
createNode: function (node) {
|
||||
node = node || new ccui.ListView();
|
||||
|
||||
ScrollViewWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
cc.ListViewWrapper = module.exports = ListViewWrapper;
|
||||
@@ -1,79 +0,0 @@
|
||||
|
||||
var WidgetWrapper = require('./widget');
|
||||
|
||||
var TextAtlasWrapper = cc.Class({
|
||||
name: 'cc.TextAtlasWrapper',
|
||||
extends: WidgetWrapper,
|
||||
|
||||
properties: {
|
||||
text: {
|
||||
get: function () {
|
||||
return this.targetN.string;
|
||||
},
|
||||
set: function (value) {
|
||||
if (typeof value === 'string') {
|
||||
this.targetN.string = value;
|
||||
}
|
||||
else {
|
||||
cc.errorID(1703);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
texture: {
|
||||
default: '',
|
||||
url: cc.Texture2D,
|
||||
|
||||
notify: function () {
|
||||
this.updateProperties();
|
||||
}
|
||||
},
|
||||
|
||||
itemWidth: {
|
||||
default: 0,
|
||||
notify: function () {
|
||||
this.updateProperties();
|
||||
}
|
||||
},
|
||||
|
||||
itemHeight: {
|
||||
default: 0,
|
||||
notify: function () {
|
||||
this.updateProperties();
|
||||
}
|
||||
},
|
||||
|
||||
startCharMap: {
|
||||
default: '0',
|
||||
notify: function () {
|
||||
this.updateProperties();
|
||||
}
|
||||
},
|
||||
|
||||
_text: {
|
||||
default: 'Label'
|
||||
},
|
||||
},
|
||||
|
||||
updateProperties: function () {
|
||||
if (!this.targetN) return;
|
||||
this.targetN.setProperty(this.text, this.texture, this.itemWidth, this.itemHeight, this.startCharMap);
|
||||
},
|
||||
|
||||
onBeforeSerialize: function () {
|
||||
WidgetWrapper.prototype.onBeforeSerialize.call(this);
|
||||
|
||||
this._text = this.text;
|
||||
},
|
||||
|
||||
createNode: function (node) {
|
||||
node = node || new ccui.TextAtlas();
|
||||
node.setProperty(this._text, this.texture, this.itemWidth, this.itemHeight, this.startCharMap);
|
||||
|
||||
WidgetWrapper.prototype.createNode.call(this, node);
|
||||
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
cc.TextAtlasWrapper = module.exports = TextAtlasWrapper;
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
setFontToNode: function(fontAsset, node) {
|
||||
if (fontAsset) {
|
||||
var config = {type:'font', name: fontAsset.fontFamily, url:fontAsset.url, srcs:[fontAsset.url]};
|
||||
cc.loader.load(config, function (err, result) {
|
||||
if (err) throw err;
|
||||
|
||||
node.fontName = config.name;
|
||||
});
|
||||
}
|
||||
else {
|
||||
node.fontName = 'Arial';
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
var _assetUrls = [
|
||||
{ uuid: "", url: getAssetsPath('12/123456/1.jpg') },
|
||||
{ uuid: "", url: getAssetsPath('91/91048d06-d998-4499-94c3-a5e0eccd40cf/1.fnt') }
|
||||
];
|
||||
|
||||
describe( 'test asset', function () {
|
||||
|
||||
it( 'cc.Texture2D.createNodeByInfo', function (done) {
|
||||
|
||||
cc.Texture2D.createNodeByInfo(_assetUrls[0].url, function (err, node) {
|
||||
if (err) throw err;
|
||||
|
||||
assert( node );
|
||||
assert( node.texture );
|
||||
expect( node.texture.url ).equal( _assetUrls[0].url );
|
||||
expect( node instanceof _ccsg.Sprite );
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it( 'cc.BitmapFont.createNodeByInfo', function (done) {
|
||||
cc.BitmapFont.createNodeByInfo(_assetUrls[1].url, function (err, node) {
|
||||
if (err) throw err;
|
||||
|
||||
expect( node._fntFile ).equal( _assetUrls[1].url );
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,120 +0,0 @@
|
||||
|
||||
var _text = 'test bitmap-font';
|
||||
|
||||
describe( 'test BitmapFont wrapper', function () {
|
||||
var node,
|
||||
wrapper,
|
||||
url = window.getAssetsPath('bitmap-font.fnt');
|
||||
|
||||
beforeEach(function () {
|
||||
node = new cc.LabelBMFont();
|
||||
wrapper = cc.getWrapper(node);
|
||||
});
|
||||
|
||||
it( 'BitmapFont wrapper exists', function () {
|
||||
assert( node );
|
||||
assert( wrapper );
|
||||
|
||||
expect( wrapper.align ).equal( cc.TextAlignment.LEFT );
|
||||
expect( wrapper.anchor ).equal( cc._TextAnchor.MiddleCenter );
|
||||
});
|
||||
|
||||
it( 'anchor', function () {
|
||||
wrapper.anchor = cc._TextAnchor.TopRight;
|
||||
|
||||
var anchorPoint = node.getAnchorPoint();
|
||||
|
||||
expect( anchorPoint.x ).equal( 1 );
|
||||
expect( anchorPoint.y ).equal( 1 );
|
||||
expect( wrapper.anchor ).equal( cc._TextAnchor.TopRight );
|
||||
|
||||
wrapper.anchor = cc._TextAnchor.BottomLeft;
|
||||
|
||||
anchorPoint = node.getAnchorPoint();
|
||||
|
||||
expect( anchorPoint.x ).equal( 0 );
|
||||
expect( anchorPoint.y ).equal( 0 );
|
||||
expect( wrapper.anchor ).equal( cc._TextAnchor.BottomLeft );
|
||||
|
||||
wrapper.anchor = cc._TextAnchor.MiddleCenter;
|
||||
|
||||
anchorPoint = node.getAnchorPoint();
|
||||
|
||||
expect( anchorPoint.x ).equal( 0.5 );
|
||||
expect( anchorPoint.y ).equal( 0.5 );
|
||||
expect( wrapper.anchor ).equal( cc._TextAnchor.MiddleCenter );
|
||||
});
|
||||
|
||||
it( 'align', function () {
|
||||
wrapper.align = cc.TextAlignment.LEFT;
|
||||
|
||||
expect( wrapper.align ).equal( cc.TextAlignment.LEFT );
|
||||
expect( node._alignment ).equal( cc.TextAlignment.LEFT );
|
||||
});
|
||||
|
||||
it( 'text', function () {
|
||||
wrapper.text = 'tttt';
|
||||
|
||||
expect( wrapper.text ).equal( 'tttt' );
|
||||
expect( node.string ).equal( 'tttt' );
|
||||
});
|
||||
|
||||
it( 'change font', function () {
|
||||
|
||||
wrapper.bitmapFont = url;
|
||||
|
||||
expect( wrapper.bitmapFont ).equal( url );
|
||||
expect( node._fntFile ).equal( url );
|
||||
});
|
||||
|
||||
it( 'simple serialize', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._text ).equal( '' );
|
||||
expect( wrapper._anchor ).equal( cc._TextAnchor.MiddleCenter );
|
||||
expect( wrapper._align ).equal( cc.TextAlignment.LEFT );
|
||||
expect( wrapper._bitmapFont ).equal( '' );
|
||||
});
|
||||
|
||||
it( 'serialize with property', function () {
|
||||
|
||||
wrapper.text = _text;
|
||||
wrapper.anchor = cc._TextAnchor.BottomRight;
|
||||
wrapper.align = cc.TextAlignment.RIGHT;
|
||||
wrapper.bitmapFont = url;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._text ).equal( _text );
|
||||
expect( wrapper._anchor ).equal( cc._TextAnchor.BottomRight );
|
||||
expect( wrapper._align ).equal( cc.TextAlignment.RIGHT );
|
||||
expect( wrapper.bitmapFont ).equal( url );
|
||||
});
|
||||
|
||||
it( 'simple createNode', function() {
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof cc.LabelBMFont );
|
||||
expect( node._fntFile ).equal( '' );
|
||||
expect( node.string ).equal( '' );
|
||||
expect( node.textAlign ).equal( cc.TextAlignment.LEFT );
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function () {
|
||||
wrapper.text = _text;
|
||||
wrapper.anchor = cc._TextAnchor.BottomRight;
|
||||
wrapper.align = cc.TextAlignment.RIGHT;
|
||||
wrapper.bitmapFont = url;
|
||||
wrapper._bitmapFontToLoad = url;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof cc.LabelBMFont );
|
||||
expect( node._fntFile ).equal( url );
|
||||
expect( node.string ).equal( _text );
|
||||
expect( node.textAlign ).equal( cc.TextAlignment.RIGHT );
|
||||
});
|
||||
});
|
||||
@@ -1,103 +0,0 @@
|
||||
|
||||
describe( 'test button wrapper', function () {
|
||||
var Async = require('async');
|
||||
|
||||
var node,
|
||||
wrapper,
|
||||
asset,
|
||||
uuid = '223459',
|
||||
url = window.getAssetsPath('button.png');
|
||||
|
||||
before( function (done) {
|
||||
cc.AssetLibrary.loadAsset(uuid, function (err, a) {
|
||||
if (err) throw err;
|
||||
|
||||
asset = a;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
node = new ccui.Button();
|
||||
wrapper = cc.getWrapper(node);
|
||||
});
|
||||
|
||||
it( 'normalTexture', function () {
|
||||
wrapper._normalTexture = url;
|
||||
|
||||
expect( wrapper._normalTexture ).equal( url );
|
||||
});
|
||||
|
||||
it( 'pressedTexture', function () {
|
||||
wrapper._pressedTexture = url;
|
||||
|
||||
expect( wrapper._pressedTexture ).equal( url );
|
||||
});
|
||||
|
||||
it( 'disabledTexture', function () {
|
||||
wrapper._disabledTexture = url;
|
||||
|
||||
expect( wrapper._disabledTexture ).equal( url );
|
||||
});
|
||||
|
||||
it( 'simple serialize', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._normalTexture ).equal( '' );
|
||||
expect( wrapper._pressedTexture ).equal( '' );
|
||||
expect( wrapper._disabledTexture ).equal( '' );
|
||||
|
||||
expect( wrapper._text ).equal( '' );
|
||||
expect( wrapper._fontSize ).equal( 16 );
|
||||
expect( wrapper._font ).equal( null );
|
||||
expect( wrapper._fontFamily ).equal( 'Arial' );
|
||||
});
|
||||
|
||||
it( 'serialize with property', function () {
|
||||
wrapper._normalTexture = url;
|
||||
wrapper._pressedTexture = url;
|
||||
wrapper._disabledTexture = url;
|
||||
|
||||
wrapper.text = 'Text';
|
||||
wrapper.fontSize = 30;
|
||||
wrapper._font = asset;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._normalTexture ).equal( url );
|
||||
expect( wrapper._pressedTexture ).equal( url );
|
||||
expect( wrapper._disabledTexture ).equal( url );
|
||||
|
||||
expect( wrapper._text ).equal( 'Text' );
|
||||
expect( wrapper._fontSize ).equal( 30 );
|
||||
expect( wrapper._font._uuid ).equal( uuid );
|
||||
});
|
||||
|
||||
it( 'simple createNode', function () {
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof ccui.Button );
|
||||
expect( node.titleText ).equal( 'Button' );
|
||||
expect( node.titleFontName ).equal('Arial');
|
||||
expect( node.titleFontSize ).equal(16);
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function () {
|
||||
|
||||
wrapper.text = 'Text';
|
||||
wrapper.fontSize = 30;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
wrapper._normalTexture = url;
|
||||
wrapper._pressedTexture = url;
|
||||
wrapper._disabledTexture = url;
|
||||
wrapper._font = asset;
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof ccui.Button );
|
||||
expect( node.titleText ).equal( 'Text' );
|
||||
expect( node.titleFontSize ).equal(30);
|
||||
});
|
||||
});
|
||||
@@ -1,104 +0,0 @@
|
||||
describe( 'test engine', function () {
|
||||
|
||||
it( 'pause when init runtime', function () {
|
||||
expect(cc.game.isPaused()).to.be.true;
|
||||
});
|
||||
|
||||
it( 'pause runtime', function () {
|
||||
cc.game.pause();
|
||||
|
||||
expect( cc.game.isPaused() ).to.be.true;
|
||||
});
|
||||
|
||||
it( 'resume runtime', function() {
|
||||
cc.game.resume();
|
||||
|
||||
expect( cc.game.isPaused() ).to.be.false;
|
||||
});
|
||||
|
||||
it( 'getRunningScene', function () {
|
||||
assert( cc.director.getRunningScene() );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe( 'cc.engine.getIntersectionList', function () {
|
||||
var scene;
|
||||
var nodes;
|
||||
var wrappers;
|
||||
|
||||
var oldScene;
|
||||
|
||||
before(function () {
|
||||
oldScene = cc.director.getRunningScene();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
cc.director.runScene(oldScene);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
scene = new _ccsg.Scene();
|
||||
cc.director.runScene(scene);
|
||||
|
||||
nodes = [];
|
||||
wrappers = [];
|
||||
|
||||
for(var i = 0; i<2; i++) {
|
||||
var node = new _ccsg.Node();
|
||||
var wrapper = cc.getWrapper(node);
|
||||
node.setAnchorPoint(0.5, 0.5);
|
||||
|
||||
scene.addChild(node);
|
||||
wrapper.size = new cc.Vec2(100, 100);
|
||||
|
||||
nodes.push(node);
|
||||
wrappers.push(wrapper);
|
||||
}
|
||||
|
||||
wrappers[0].position = new cc.Vec2(100, 100);
|
||||
wrappers[1].position = new cc.Vec2(200, 200);
|
||||
});
|
||||
|
||||
|
||||
it( 'should get an empty array if not intersects any node', function () {
|
||||
var rect = new cc.Rect(0,0, 49,49);
|
||||
var list = cc.engine.getIntersectionList(rect);
|
||||
|
||||
expect( list.length ).to.equal( 0 );
|
||||
});
|
||||
|
||||
it( 'should get an array with a node if intersects a node', function () {
|
||||
var rect = new cc.Rect(0,0, 50,50);
|
||||
var list = cc.engine.getIntersectionList(rect);
|
||||
|
||||
expect( list.length ).to.equal( 1 );
|
||||
});
|
||||
|
||||
it( 'should not get the node if the node rotate and not intersects it', function () {
|
||||
wrappers[0].rotation = 45;
|
||||
|
||||
var rect = new cc.Rect(0,0, 64,64);
|
||||
var list = cc.engine.getIntersectionList(rect);
|
||||
|
||||
expect( list.length ).to.equal( 0 );
|
||||
});
|
||||
|
||||
it( 'should get the node if the node rotate and intersects it', function () {
|
||||
wrappers[0].rotation = 45;
|
||||
|
||||
var rect = new cc.Rect(0,0, 65,65);
|
||||
var list = cc.engine.getIntersectionList(rect);
|
||||
|
||||
expect( list.length ).to.equal( 1 );
|
||||
});
|
||||
|
||||
it( 'should get an array with two nodes if intersects two nodes', function () {
|
||||
|
||||
var rect = new cc.Rect(0,0, 200,200);
|
||||
var list = cc.engine.getIntersectionList(rect);
|
||||
|
||||
expect( list.length ).to.equal( 2 );
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,73 +0,0 @@
|
||||
var Path = require('path');
|
||||
|
||||
// util methods
|
||||
window.getAssetsPath = function () {
|
||||
[].splice.call(arguments, 0, 0, __dirname, 'fixtures/assets');
|
||||
|
||||
return Path.resolve( Path.join.apply(Path, arguments) );
|
||||
};
|
||||
|
||||
|
||||
|
||||
Editor.isRuntime = true;
|
||||
|
||||
// canvas assets
|
||||
var Meta = Editor.require('app://asset-db/lib/meta');
|
||||
Editor.metas = {
|
||||
asset: Meta.AssetMeta,
|
||||
folder: Meta.FolderMeta
|
||||
};
|
||||
Editor.assets = {};
|
||||
Editor.inspectors = {};
|
||||
|
||||
// cocos
|
||||
Editor.require('unpack://engine');
|
||||
|
||||
// init asset library
|
||||
cc.AssetLibrary.init({
|
||||
libraryPath: Path.resolve(Path.join(__dirname, 'fixtures/library'))
|
||||
});
|
||||
|
||||
describe('test wrappers', function () {
|
||||
// test wrappers
|
||||
var pageTests = [
|
||||
'engine',
|
||||
'scene',
|
||||
'node',
|
||||
'sprite',
|
||||
'bitmap-font',
|
||||
'button',
|
||||
'particle',
|
||||
'label-ttf',
|
||||
'scale9-sprite',
|
||||
"asset"
|
||||
];
|
||||
|
||||
var option = {
|
||||
width: 400,
|
||||
height: 400,
|
||||
id: 'gameCanvas'
|
||||
};
|
||||
|
||||
it('init runtime', function(done) {
|
||||
cc.game.run(option, function () {
|
||||
cc.view.resizeWithBrowserSize(true);
|
||||
|
||||
var scene = new _ccsg.Scene();
|
||||
|
||||
// scene anchor point need be 0,0
|
||||
scene.setAnchorPoint(0.0, 0.0);
|
||||
|
||||
cc.view.setFrameSize(width, height);
|
||||
|
||||
cc.director.runScene(scene);
|
||||
cc.game.pause();
|
||||
|
||||
pageTests.forEach( function (test) {
|
||||
require( Path.join(__dirname, 'page', test + '.js' ) );
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,93 +0,0 @@
|
||||
|
||||
describe( 'cc.LabelTTFWrapper', function () {
|
||||
var Async = require('async');
|
||||
|
||||
var node,
|
||||
wrapper,
|
||||
asset,
|
||||
uuid = '223459';
|
||||
|
||||
before( function (done) {
|
||||
cc.AssetLibrary.loadAsset(uuid, function (err, a) {
|
||||
if (err) throw err;
|
||||
|
||||
asset = a;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
node = new cc.LabelTTF();
|
||||
wrapper = cc.getWrapper(node);
|
||||
});
|
||||
|
||||
|
||||
it( 'simple serialize should success', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._fontSize ).equal( 16 );
|
||||
expect( wrapper.font ).equal( null );
|
||||
expect( wrapper._fontFamily ).equal( 'Arial' );
|
||||
expect( wrapper._text ).equal( '' );
|
||||
expect( wrapper._align ).equal( cc.TextAlignment.LEFT );
|
||||
expect( wrapper._verticalAlign ).equal( cc.VerticalTextAlignment.TOP );
|
||||
expect( wrapper._boundingBox ).deep.equal( [0,0] );
|
||||
expect( wrapper._lineHeight ).equal( 18 );
|
||||
|
||||
});
|
||||
|
||||
it( 'serialize with property should success', function () {
|
||||
|
||||
wrapper.text = 'Text';
|
||||
wrapper.fontSize = 30;
|
||||
wrapper.font = asset;
|
||||
wrapper.align = cc.TextAlignment.CENTER;
|
||||
wrapper.verticalAlign = cc.TextAlignment.CENTER;
|
||||
wrapper.lineHeight = 100;
|
||||
wrapper.boundingBox = new cc.Vec2(100, 100);
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._text ).equal( 'Text' );
|
||||
expect( wrapper._fontSize ).equal( 30 );
|
||||
expect( wrapper.font._uuid ).equal( uuid );
|
||||
expect( wrapper._fontFamily ).equal( 'Abberancy' );
|
||||
expect( wrapper._align ).equal( cc.TextAlignment.CENTER );
|
||||
expect( wrapper._verticalAlign ).equal( cc.TextAlignment.CENTER );
|
||||
expect( wrapper._lineHeight ).equal( 100 );
|
||||
expect( wrapper._boundingBox ).deep.equal( [100,100] );
|
||||
});
|
||||
|
||||
it( 'simple createNode should success', function () {
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof cc.LabelTTF );
|
||||
expect( node.string ).equal( 'Label' );
|
||||
expect( node.fontName ).equal('Arial');
|
||||
expect( node.fontSize ).equal(16);
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function () {
|
||||
|
||||
wrapper.text = 'Text';
|
||||
wrapper.fontSize = 30;
|
||||
wrapper.font = asset;
|
||||
wrapper.align = cc.TextAlignment.CENTER;
|
||||
wrapper.verticalAlign = cc.TextAlignment.CENTER;
|
||||
wrapper.lineHeight = 100;
|
||||
wrapper.boundingBox = new cc.Vec2(100, 100);
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof cc.LabelTTF );
|
||||
expect( node.string ).equal( 'Text' );
|
||||
expect( node.fontName ).equal('Abberancy');
|
||||
expect( node.fontSize ).equal(30);
|
||||
expect( node.textAlign ).equal( cc.TextAlignment.CENTER );
|
||||
expect( node.verticalAlign ).equal( cc.TextAlignment.CENTER );
|
||||
expect( node.getLineHeight() ).equal( 100 );
|
||||
expect( node.boundingWidth ).equal(100);
|
||||
expect( node.boundingHeight ).equal(100);
|
||||
});
|
||||
});
|
||||
@@ -1,322 +0,0 @@
|
||||
|
||||
describe( 'test node wrapper', function () {
|
||||
|
||||
var scene,
|
||||
node,
|
||||
wrapper;
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
node = new _ccsg.Node();
|
||||
wrapper = cc.getWrapper(node);
|
||||
|
||||
scene = cc.director.getRunningScene();
|
||||
|
||||
wrapper.position = new cc.Vec2(0, 0);
|
||||
wrapper.rotation = 0;
|
||||
wrapper.scale = new cc.Vec2(1, 1);
|
||||
wrapper.size = new cc.Vec2(0, 0);
|
||||
});
|
||||
|
||||
it ( 'node wrapper exists', function () {
|
||||
assert( node );
|
||||
assert( wrapper );
|
||||
});
|
||||
|
||||
it ( 'name', function () {
|
||||
wrapper.name = "node";
|
||||
|
||||
expect( wrapper.name ).to.equal( 'node' );
|
||||
});
|
||||
|
||||
it( 'parentN', function () {
|
||||
|
||||
wrapper.parentN = scene;
|
||||
|
||||
expect( wrapper.parentN ).to.equal( scene );
|
||||
});
|
||||
|
||||
it( 'set parentN to null', function () {
|
||||
wrapper.parentN = null;
|
||||
|
||||
expect( wrapper.parentN ).to.equal( null );
|
||||
});
|
||||
|
||||
it( 'childrenN', function () {
|
||||
var child = new _ccsg.Node();
|
||||
var childWrapper = cc.getWrapper(child);
|
||||
|
||||
childWrapper.parentN = node;
|
||||
|
||||
expect( childWrapper.parentN ).to.equal( node );
|
||||
assert( wrapper.childrenN );
|
||||
expect( wrapper.childrenN.length ).to.equal( 1 );
|
||||
});
|
||||
|
||||
it( 'position', function () {
|
||||
wrapper.position = new cc.Vec2(100, 200);
|
||||
|
||||
assert( wrapper.position instanceof cc.Vec2);
|
||||
expect( wrapper.position.x ).equal( 100 );
|
||||
expect( wrapper.position.y ).equal( 200 );
|
||||
});
|
||||
|
||||
it( 'world position', function () {
|
||||
|
||||
wrapper.parentN = scene;
|
||||
scene.setPosition(100, 300);
|
||||
|
||||
wrapper.worldPosition = new cc.Vec2(100, 200);
|
||||
|
||||
assert( wrapper.worldPosition instanceof cc.Vec2);
|
||||
|
||||
expect( wrapper.worldPosition.x ).equal( 100 );
|
||||
expect( wrapper.worldPosition.y ).equal( 200 );
|
||||
|
||||
expect( wrapper.position.x ).equal( 0 );
|
||||
expect( wrapper.position.y ).equal( -100 );
|
||||
|
||||
scene.setPosition(0, 0);
|
||||
});
|
||||
|
||||
it( 'rotation', function () {
|
||||
wrapper.rotation = 90;
|
||||
|
||||
expect( wrapper.rotation ).to.be.a('number');
|
||||
expect( wrapper.rotation ).equal( 90 );
|
||||
});
|
||||
|
||||
it( 'world rotation', function () {
|
||||
|
||||
wrapper.parentN = scene;
|
||||
|
||||
scene.rotation = 45;
|
||||
wrapper.worldRotation = 90;
|
||||
|
||||
expect( wrapper.worldRotation ).to.be.a('number');
|
||||
|
||||
expect( wrapper.rotation ).equal( 45 );
|
||||
expect( wrapper.worldRotation ).equal( 90 );
|
||||
|
||||
scene.rotation = 0;
|
||||
});
|
||||
|
||||
it( 'scale', function () {
|
||||
wrapper.scale = new cc.Vec2( 1.5, 2);
|
||||
|
||||
assert( wrapper.scale instanceof cc.Vec2 );
|
||||
expect( wrapper.scale.x ).equal( 1.5 );
|
||||
expect( wrapper.scale.y ).equal( 2 );
|
||||
});
|
||||
|
||||
it( 'world scale', function () {
|
||||
|
||||
wrapper.parentN = scene;
|
||||
|
||||
scene.scale = 2;
|
||||
wrapper.scale = new cc.Vec2(0.5, 2);
|
||||
|
||||
expect( wrapper.worldScale.x ).equal( 1 );
|
||||
expect( wrapper.worldScale.y ).equal( 4 );
|
||||
|
||||
scene.scale = 1;
|
||||
});
|
||||
|
||||
|
||||
it( 'color', function () {
|
||||
|
||||
wrapper.color = new cc.Color(1.0, 0.5, 0.9, 0.3);
|
||||
|
||||
assert( wrapper.color instanceof cc.Color );
|
||||
|
||||
// When convert cc.Color to cc.Color, it will cut off the decimals.
|
||||
// So the test will fail.
|
||||
|
||||
// expect( wrapper.color.r ).equal( 1.0 );
|
||||
// expect( wrapper.color.g ).equal( 0.5 );
|
||||
// expect( wrapper.color.b ).equal( 0.9 );
|
||||
// expect( wrapper.color.a ).equal( 0.3 );
|
||||
});
|
||||
|
||||
it( 'size', function () {
|
||||
wrapper.size = new cc.Vec2( 400, 200 );
|
||||
|
||||
assert( wrapper.size instanceof cc.Vec2 );
|
||||
expect( wrapper.size.x ).equal( 400 );
|
||||
expect( wrapper.size.y ).equal( 200 );
|
||||
});
|
||||
|
||||
it( 'anchorPoint', function () {
|
||||
wrapper.anchorPoint = new cc.Vec2( 0, 1);
|
||||
|
||||
assert( wrapper.anchorPoint instanceof cc.Vec2 );
|
||||
expect( wrapper.anchorPoint.x ).equal( 0 );
|
||||
expect( wrapper.anchorPoint.y ).equal( 1 );
|
||||
});
|
||||
|
||||
it( 'getWorldOrientedBounds', function () {
|
||||
wrapper.position = new cc.Vec2(100, 100);
|
||||
wrapper.rotation = 0;
|
||||
wrapper.size = new cc.Vec2(400, 400);
|
||||
|
||||
var bounds = wrapper.getWorldOrientedBounds();
|
||||
|
||||
expect( bounds[0].x ).equal( 100 );
|
||||
expect( bounds[0].y ).equal( 500 );
|
||||
expect( bounds[1].x ).equal( 100 );
|
||||
expect( bounds[1].y ).equal( 100 );
|
||||
expect( bounds[2].x ).equal( 500 );
|
||||
expect( bounds[2].y ).equal( 100 );
|
||||
expect( bounds[3].x ).equal( 500 );
|
||||
expect( bounds[3].y ).equal( 500 );
|
||||
});
|
||||
|
||||
it( 'getWorldBounds', function () {
|
||||
wrapper.position = new cc.Vec2(100, 100);
|
||||
wrapper.size = new cc.Vec2(400, 400);
|
||||
|
||||
var rect = wrapper.getWorldBounds();
|
||||
|
||||
expect( rect.x ).equal( 100 );
|
||||
expect( rect.y ).equal( 100 );
|
||||
expect( rect.width ).equal( 400 );
|
||||
expect( rect.height ).equal( 400 );
|
||||
});
|
||||
|
||||
it( 'simple serialize', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [0, 0] );
|
||||
expect( wrapper._scale ).to.deep.equal( [1, 1] );
|
||||
expect( wrapper._size ).to.deep.equal( [0, 0] );
|
||||
expect( wrapper._color ).to.deep.equal( [1, 1, 1, 1] );
|
||||
expect( wrapper._rotation ).equal( 0 );
|
||||
});
|
||||
|
||||
it( 'serialize with property', function () {
|
||||
|
||||
wrapper.position = new cc.Vec2(11, 22);
|
||||
wrapper.scale = new cc.Vec2(2, 3);
|
||||
wrapper.color = new cc.Color(1.0, 0.5, 0.9, 0.3);
|
||||
wrapper.rotation = 11;
|
||||
wrapper.anchorPoint = new cc.Vec2(1, 0);
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [11, 22] );
|
||||
expect( wrapper._scale ).to.deep.equal( [2, 3] );
|
||||
expect( wrapper._size ).to.deep.equal( [0, 0] );
|
||||
expect( wrapper._color ).to.deep.equal( [1, 0.4980392156862745, 0.8980392156862745, 0.2980392156862745] );
|
||||
expect( wrapper._rotation ).equal( 11 );
|
||||
expect( wrapper._anchorPoint ).to.deep.equal( [1, 0] );
|
||||
});
|
||||
|
||||
it( 'simple createNode', function () {
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node.rotation ).equal( 0 );
|
||||
expect( node.x ).equal( 0 );
|
||||
expect( node.y ).equal( 0 );
|
||||
expect( node.scaleX ).equal( 1 );
|
||||
expect( node.scaleY ).equal( 1 );
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function () {
|
||||
wrapper.position = new cc.Vec2(11, 22);
|
||||
wrapper.scale = new cc.Vec2(2, 3);
|
||||
wrapper.rotation = 31;
|
||||
wrapper.anchorPoint = new cc.Vec2(1, 0);
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node.rotation ).equal( 31 );
|
||||
expect( node.x ).equal( 11 );
|
||||
expect( node.y ).equal( 22 );
|
||||
expect( node.scaleX ).equal( 2 );
|
||||
expect( node.scaleY ).equal( 3 );
|
||||
expect( node.anchorX ).equal( 1 );
|
||||
expect( node.anchorY ).equal( 0 );
|
||||
});
|
||||
|
||||
describe( 'NodeWrapper.transformPointToWorld', function() {
|
||||
it( 'should transform point from local to world space', function () {
|
||||
wrapper.worldPosition = new cc.Vec2(300, 300);
|
||||
|
||||
var point = wrapper.transformPointToWorld(new cc.Vec2(0, 0));
|
||||
|
||||
expect( point.x ).equal( 300 );
|
||||
expect( point.y ).equal( 300 );
|
||||
});
|
||||
});
|
||||
|
||||
describe( 'NodeWrapper.transformPointToLocal ', function () {
|
||||
|
||||
it( 'should transform point from local to world space', function () {
|
||||
wrapper.worldPosition = new cc.Vec2(300, 300);
|
||||
|
||||
var point = wrapper.transformPointToLocal(new cc.Vec2(300, 400));
|
||||
|
||||
expect( point.x ).equal( 0 );
|
||||
expect( point.y ).equal( 100 );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe( 'NodeWrapper siblingIndex', function () {
|
||||
var nodes;
|
||||
var scene;
|
||||
|
||||
beforeEach(function () {
|
||||
scene = new _ccsg.Scene();
|
||||
nodes = [];
|
||||
|
||||
for(var i=0; i<5; i++) {
|
||||
var node = new _ccsg.Node();
|
||||
nodes.push(node);
|
||||
scene.addChild(node);
|
||||
}
|
||||
});
|
||||
|
||||
it( 'should be last if set siblingIndex to -1', function () {
|
||||
var wrapper = cc.getWrapper(nodes[0]);
|
||||
|
||||
wrapper.setSiblingIndex(-1);
|
||||
|
||||
expect( wrapper.getSiblingIndex() ).equal( nodes.length-1 );
|
||||
});
|
||||
|
||||
it( 'should be 3 if 1st node\'s set siblingIndex to 3', function () {
|
||||
var wrapper = cc.getWrapper(nodes[0]);
|
||||
|
||||
wrapper.setSiblingIndex(3);
|
||||
|
||||
expect( wrapper.getSiblingIndex() ).equal( 3 );
|
||||
});
|
||||
|
||||
it( 'should be 3 if set 2nd node\'s siblingIndex to 3', function () {
|
||||
var wrapper = cc.getWrapper(nodes[2]);
|
||||
|
||||
wrapper.setSiblingIndex(3);
|
||||
|
||||
expect( wrapper.getSiblingIndex() ).equal( 3 );
|
||||
});
|
||||
|
||||
it( 'should be 0 if set 3rd node\'s siblingIndex to 0', function () {
|
||||
var wrapper = cc.getWrapper(nodes[3]);
|
||||
|
||||
wrapper.setSiblingIndex(0);
|
||||
|
||||
expect( wrapper.getSiblingIndex() ).equal( 0 );
|
||||
});
|
||||
|
||||
it( 'should be 2 if set 3rd node\'s siblingIndex to 2', function () {
|
||||
var wrapper = cc.getWrapper(nodes[3]);
|
||||
|
||||
wrapper.setSiblingIndex(2);
|
||||
|
||||
expect( wrapper.getSiblingIndex() ).equal( 2 );
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
describe( 'test Particle wrapper', function () {
|
||||
var Async = require('async');
|
||||
|
||||
var node,
|
||||
wrapper,
|
||||
particleUrl = window.getAssetsPath('particle.plist'),
|
||||
textureUrl = window.getAssetsPath('sprite.jpg');
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
node = new _ccsg.ParticleSystem();
|
||||
wrapper = cc.getWrapper(node);
|
||||
});
|
||||
|
||||
function setShareProperties () {
|
||||
wrapper.maxParticles = 20;
|
||||
wrapper.duration = 30;
|
||||
wrapper.emissionRate = 40;
|
||||
wrapper.life = 50;
|
||||
wrapper.lifeVariance = 60;
|
||||
wrapper.startColor = new cc.Color(1, 0, 1, 1);
|
||||
wrapper.startColorVariance = new cc.Color(1, 0, 1, 1);
|
||||
wrapper.endColor = new cc.Color(1, 0, 1, 1);
|
||||
wrapper.endColorVariance = new cc.Color(1, 0, 1, 1);
|
||||
wrapper.angle = 110;
|
||||
wrapper.angleVariance = 120;
|
||||
wrapper.startSize = 130;
|
||||
wrapper.startSizeVariance = 140;
|
||||
wrapper.endSize = 150;
|
||||
wrapper.endSizeVariance = 160;
|
||||
wrapper.startSpin = 170;
|
||||
wrapper.startSpinVariance = 180;
|
||||
wrapper.endSpin = 190;
|
||||
wrapper.endSpinVariance = 200;
|
||||
wrapper.sourcePosition = new cc.Vec2(100, 100);
|
||||
wrapper.sourcePositionVariance = new cc.Vec2(100, 100);
|
||||
wrapper.positionType = _ccsg.ParticleSystem.Type.FREE;
|
||||
}
|
||||
|
||||
function setGravityModeProperties () {
|
||||
wrapper.emitterMode = _ccsg.ParticleSystem.Mode.GRAVITY;
|
||||
wrapper.gravity = new cc.Vec2(100, 100);
|
||||
wrapper.speed = 1;
|
||||
wrapper.speedVariance = 2;
|
||||
wrapper.tangentialAccel = 3;
|
||||
wrapper.tangentialAccelVariance = 4;
|
||||
wrapper.radialAccel = 5;
|
||||
wrapper.radialAccelVariance = 6;
|
||||
wrapper.rotationIsDir = 7;
|
||||
}
|
||||
|
||||
function setRadiusProperties () {
|
||||
wrapper.emitterMode = _ccsg.ParticleSystem.Mode.RADIUS;
|
||||
wrapper.startRadius = 8;
|
||||
wrapper.startRadiusVariance = 9;
|
||||
wrapper.endRadius = 10;
|
||||
wrapper.endRadiusVariance = 11;
|
||||
wrapper.rotatePerSecond = 12;
|
||||
wrapper.rotatePerSecondVariance = 13;
|
||||
}
|
||||
|
||||
|
||||
it( 'Particle wrapper should exists', function () {
|
||||
assert( node );
|
||||
assert( wrapper);
|
||||
});
|
||||
|
||||
it( 'particle file', function () {
|
||||
wrapper.file = particleUrl;
|
||||
|
||||
expect( wrapper.file ).equal( particleUrl );
|
||||
});
|
||||
|
||||
it( 'particle texture', function () {
|
||||
wrapper.texture = textureUrl;
|
||||
|
||||
expect( wrapper.texture ).equal( textureUrl );
|
||||
});
|
||||
|
||||
describe( 'serialize', function () {
|
||||
|
||||
it( 'should success if no properties be set', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._file ).equal( '' );
|
||||
});
|
||||
|
||||
it( 'should success if properties be set', function () {
|
||||
|
||||
wrapper.file = particleUrl;
|
||||
setShareProperties();
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._file ).equal( particleUrl );
|
||||
});
|
||||
|
||||
it( 'should not serialize custom properties if custom is false', function () {
|
||||
wrapper.custom = false;
|
||||
|
||||
setShareProperties();
|
||||
setGravityModeProperties();
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._serializeObject ).to.equal( null );
|
||||
});
|
||||
|
||||
it( 'should also keep .plist file if custom is true', function () {
|
||||
wrapper.file = particleUrl;
|
||||
wrapper.custom = true;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._file ).to.equal( particleUrl );
|
||||
});
|
||||
|
||||
|
||||
it( 'should not serialize radius mode properties if emitterMode is gravity mode', function () {
|
||||
|
||||
wrapper.custom = true;
|
||||
wrapper.file = particleUrl;
|
||||
|
||||
setShareProperties();
|
||||
setGravityModeProperties();
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._serializeObject ).to.deep.equal( {
|
||||
maxParticles: 20,
|
||||
duration: 30,
|
||||
emissionRate: 40,
|
||||
life: 50,
|
||||
lifeVariance: 60,
|
||||
startColor: [ 1, 0, 1, 1 ],
|
||||
startColorVariance: [ 1, 0, 1, 1 ],
|
||||
endColor: [ 1, 0, 1, 1 ],
|
||||
endColorVariance: [ 1, 0, 1, 1 ],
|
||||
angle: 110,
|
||||
angleVariance: 120,
|
||||
startSize: 130,
|
||||
startSizeVariance: 140,
|
||||
endSize: 150,
|
||||
endSizeVariance: 160,
|
||||
startSpin: 170,
|
||||
startSpinVariance: 180,
|
||||
endSpin: 190,
|
||||
endSpinVariance: 200,
|
||||
sourcePosition: [ 100, 100 ],
|
||||
sourcePositionVariance: [ 100, 100 ],
|
||||
positionType: 0,
|
||||
emitterMode: 0,
|
||||
gravity: [ 100, 100 ],
|
||||
speed: 1,
|
||||
speedVariance: 2,
|
||||
tangentialAccel: 3,
|
||||
tangentialAccelVariance: 4,
|
||||
radialAccel: 5,
|
||||
radialAccelVariance: 6,
|
||||
rotationIsDir: 7
|
||||
});
|
||||
});
|
||||
|
||||
it( 'should not serialize gravity mode properties if emitterMode is radius mode', function () {
|
||||
|
||||
wrapper.custom = true;
|
||||
wrapper.file = particleUrl;
|
||||
|
||||
setShareProperties();
|
||||
setRadiusProperties();
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._serializeObject ).to.deep.equal( {
|
||||
maxParticles: 20,
|
||||
duration: 30,
|
||||
emissionRate: 40,
|
||||
life: 50,
|
||||
lifeVariance: 60,
|
||||
startColor: [ 1, 0, 1, 1 ],
|
||||
startColorVariance: [ 1, 0, 1, 1 ],
|
||||
endColor: [ 1, 0, 1, 1 ],
|
||||
endColorVariance: [ 1, 0, 1, 1 ],
|
||||
angle: 110,
|
||||
angleVariance: 120,
|
||||
startSize: 130,
|
||||
startSizeVariance: 140,
|
||||
endSize: 150,
|
||||
endSizeVariance: 160,
|
||||
startSpin: 170,
|
||||
startSpinVariance: 180,
|
||||
endSpin: 190,
|
||||
endSpinVariance: 200,
|
||||
sourcePosition: [ 100, 100 ],
|
||||
sourcePositionVariance: [ 100, 100 ],
|
||||
positionType: 0,
|
||||
emitterMode: 1,
|
||||
startRadius: 8,
|
||||
startRadiusVariance: 9,
|
||||
endRadius: 10,
|
||||
endRadiusVariance: 11,
|
||||
rotatePerSecond: 12,
|
||||
rotatePerSecondVariance: 13
|
||||
});
|
||||
});
|
||||
|
||||
it( 'should serialize texture if custom is true and texture be set', function () {
|
||||
wrapper.custom = true;
|
||||
wrapper.texture = textureUrl;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._texture ).equal( textureUrl );
|
||||
});
|
||||
});
|
||||
|
||||
describe( 'createNode', function () {
|
||||
|
||||
it( 'should success if only call createNode', function() {
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node._plistFile ).equal( '' );
|
||||
});
|
||||
|
||||
it( 'should not set file to node but need keep file', function () {
|
||||
wrapper.file = wrapper._fileToLoad = particleUrl;
|
||||
wrapper.custom = true;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node._plistFile ).equal( particleUrl );
|
||||
});
|
||||
|
||||
it( 'should only deserialize gravity and share properties if emitterMode is gravity mode', function () {
|
||||
wrapper.custom = true;
|
||||
|
||||
setShareProperties();
|
||||
setGravityModeProperties();
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
wrapper._file = particleUrl;
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node.totalParticles ).equal( 20 );
|
||||
expect( node.gravity ).to.deep.equal( cc.p(100, 100) );
|
||||
|
||||
expect( node.startRadius ).equal( 0 );
|
||||
expect( node.startRadiusVar ).equal( 0 );
|
||||
});
|
||||
|
||||
|
||||
it( 'should only deserialize radius and share properties if emitterMode is radius mode', function () {
|
||||
wrapper.custom = true;
|
||||
|
||||
setShareProperties();
|
||||
setRadiusProperties();
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
wrapper._file = particleUrl;
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node.totalParticles ).equal( 20 );
|
||||
|
||||
expect( node.gravity ).to.deep.equal( cc.p(0, 0) );
|
||||
|
||||
expect( node.startRadius ).equal( 8 );
|
||||
expect( node.startRadiusVar ).equal( 9 );
|
||||
});
|
||||
|
||||
it( 'should deserialize texture if custom is true and texture be setted', function () {
|
||||
wrapper.texture = wrapper._texToLoad = textureUrl;
|
||||
wrapper.custom = true;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
expect( node._texture.url ).equal( textureUrl );
|
||||
});
|
||||
})
|
||||
|
||||
});
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
describe( 'cc.Scale9SpriteWrapper', function () {
|
||||
var sprite,
|
||||
wrapper,
|
||||
url = window.getAssetsPath('sprite.jpg');
|
||||
|
||||
beforeEach(function () {
|
||||
sprite = new ccui.ImageView();
|
||||
wrapper = cc.getWrapper(sprite);
|
||||
});
|
||||
|
||||
it( 'should exists', function () {
|
||||
assert( sprite );
|
||||
assert( wrapper );
|
||||
});
|
||||
|
||||
it( 'texture', function () {
|
||||
|
||||
wrapper.texture_ = url;
|
||||
expect( wrapper.texture_ ).equal( url );
|
||||
|
||||
assert( sprite._imageRenderer.texture );
|
||||
expect( sprite._imageRenderer.texture.url ).equal( url );
|
||||
});
|
||||
|
||||
|
||||
it( 'simple serialize', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper.texture ).equal( '' );
|
||||
});
|
||||
|
||||
it( 'serialize with property', function () {
|
||||
|
||||
wrapper.texture_ = url;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper.texture ).to.equal( url );
|
||||
});
|
||||
|
||||
it( 'simple createNode', function () {
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof ccui.ImageView );
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function() {
|
||||
|
||||
wrapper.texture_ = url;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof ccui.ImageView );
|
||||
|
||||
assert( node._imageRenderer.texture );
|
||||
expect( node._imageRenderer.texture.url ).equal( url );
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,128 +0,0 @@
|
||||
describe( 'test scene wrapper', function () {
|
||||
var scene,
|
||||
wrapper;
|
||||
|
||||
var assets = [
|
||||
{ url: 'sprite.jpg' },
|
||||
{ url: 'bitmap-font.png' },
|
||||
{ url: 'bitmap-font.fnt' }
|
||||
];
|
||||
|
||||
beforeEach(function () {
|
||||
scene = new _ccsg.Scene();
|
||||
wrapper = cc.getWrapper(scene);
|
||||
});
|
||||
|
||||
it( 'scene wrapper exists', function () {
|
||||
var wrapperType = cc.getWrapperType(scene);
|
||||
|
||||
assert( scene );
|
||||
assert( wrapper );
|
||||
assert( wrapperType );
|
||||
});
|
||||
|
||||
it( 'childrenN', function () {
|
||||
assert( wrapper.childrenN );
|
||||
|
||||
var node = new _ccsg.Node();
|
||||
var node2 = new _ccsg.Node();
|
||||
|
||||
scene.addChild(node);
|
||||
scene.addChild(node2);
|
||||
|
||||
expect( wrapper.childrenN.length ).equal( 2 );
|
||||
});
|
||||
|
||||
it( 'position', function () {
|
||||
wrapper.position = new cc.Vec2( 100, 200);
|
||||
|
||||
expect( wrapper.position.x ).equal( 100 );
|
||||
expect( wrapper.position.y ).equal( 200 );
|
||||
});
|
||||
|
||||
it( 'scale', function() {
|
||||
wrapper.scale = new cc.Vec2( 2, 3);
|
||||
|
||||
expect( wrapper.scale.x ).equal( 2 );
|
||||
expect( wrapper.scale.y ).equal( 3 );
|
||||
});
|
||||
|
||||
it( 'world transform', function () {
|
||||
wrapper.worldPosition = new cc.Vec2( 100, 200);
|
||||
wrapper.worldScale = new cc.Vec2( 1, 2);
|
||||
wrapper.worldRotation = 30;
|
||||
|
||||
expect( wrapper.worldPosition.x ).equal( 100 );
|
||||
expect( wrapper.worldPosition.y ).equal( 200 );
|
||||
expect( wrapper.worldScale.x ).equal( 1 );
|
||||
expect( wrapper.worldScale.y ).equal( 2 );
|
||||
expect( wrapper.worldRotation ).equal( 30 );
|
||||
});
|
||||
|
||||
it( 'preloadAssets', function ( done ) {
|
||||
|
||||
assets = assets.map( function (asset) {
|
||||
return {url: window.getAssetsPath(asset.url)};
|
||||
});
|
||||
|
||||
wrapper.preloadAssets( assets, [], done);
|
||||
});
|
||||
|
||||
it( 'preloadAssets when cc.director paused', function ( done ) {
|
||||
|
||||
cc.director.pause();
|
||||
|
||||
assets = assets.map( function (asset) {
|
||||
return {url: window.getAssetsPath(asset.url)};
|
||||
});
|
||||
|
||||
wrapper.preloadAssets( assets, [], function () {
|
||||
cc.director.resume();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it( 'simple serialize', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [0, 0] );
|
||||
expect( wrapper._scale ).to.deep.equal( [1, 1] );
|
||||
});
|
||||
|
||||
it( 'serialize with property', function () {
|
||||
|
||||
wrapper.position = new cc.Vec2(11, 22);
|
||||
wrapper.scale = new cc.Vec2(2, 3);
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [11, 22] );
|
||||
expect( wrapper._scale ).to.deep.equal( [2, 3] );
|
||||
});
|
||||
|
||||
it( 'createNode', function () {
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof _ccsg.Scene );
|
||||
|
||||
expect( node.x ).equal( 0 );
|
||||
expect( node.y ).equal( 0 );
|
||||
expect( node.scaleX ).equal( 1 );
|
||||
expect( node.scaleY ).equal( 1 );
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function () {
|
||||
wrapper.position = new cc.Vec2(11, 22);
|
||||
wrapper.scale = new cc.Vec2(2, 3);
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof _ccsg.Scene );
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [11, 22] );
|
||||
expect( wrapper._scale ).to.deep.equal( [2, 3] );
|
||||
});
|
||||
});
|
||||
@@ -1,98 +0,0 @@
|
||||
|
||||
describe( 'test sprite wrapper', function () {
|
||||
var sprite,
|
||||
wrapper,
|
||||
url = window.getAssetsPath('sprite.jpg');
|
||||
|
||||
beforeEach(function () {
|
||||
sprite = new _ccsg.Sprite();
|
||||
wrapper = cc.getWrapper(sprite);
|
||||
});
|
||||
|
||||
it( 'sprite wrapper exists', function () {
|
||||
assert( sprite );
|
||||
assert( wrapper );
|
||||
});
|
||||
|
||||
it( 'texture', function () {
|
||||
|
||||
wrapper.texture = url;
|
||||
expect( wrapper.texture ).equal( url );
|
||||
|
||||
assert( sprite.texture );
|
||||
expect( sprite.texture.url ).equal( url );
|
||||
});
|
||||
|
||||
it( 'set texture to null', function () {
|
||||
|
||||
wrapper.texture = null;
|
||||
|
||||
assert( wrapper.texture === '');
|
||||
assert( sprite.texture === null);
|
||||
});
|
||||
|
||||
it( 'simple serialize', function () {
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [0, 0] );
|
||||
expect( wrapper._scale ).to.deep.equal( [1, 1] );
|
||||
expect( wrapper._size ).to.deep.equal( [0, 0] );
|
||||
expect( wrapper._color ).to.deep.equal( [1, 1, 1, 1] );
|
||||
expect( wrapper._rotation ).equal( 0 );
|
||||
expect( wrapper.texture ).equal( '' );
|
||||
});
|
||||
|
||||
it( 'serialize with property', function () {
|
||||
|
||||
wrapper.texture = url;
|
||||
|
||||
wrapper.position = new cc.Vec2(100, 100);
|
||||
wrapper.rotation = 78;
|
||||
wrapper.scale = new cc.Vec2(3, 1);
|
||||
wrapper.color = new cc.Color(0.3, 0.2, 0.9, 1);
|
||||
|
||||
wrapper.name = 'sprite';
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
expect( wrapper._position ).to.deep.equal( [100, 100] );
|
||||
expect( wrapper._scale ).to.deep.equal( [3, 1] );
|
||||
expect( wrapper._size ).to.deep.equal( [256, 67] );
|
||||
expect( wrapper._color ).to.deep.equal( [0.2980392156862745, 0.2, 0.8980392156862745, 1] );
|
||||
expect( wrapper._rotation ).equal( 78 );
|
||||
expect( wrapper._name ).equal( 'sprite' );
|
||||
|
||||
});
|
||||
|
||||
it( 'simple createNode', function () {
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof _ccsg.Sprite );
|
||||
|
||||
expect( node.texture ).equal( null );
|
||||
|
||||
expect( node.rotation ).equal( 0 );
|
||||
expect( node.x ).equal( 0 );
|
||||
expect( node.y ).equal( 0 );
|
||||
expect( node.scaleX ).equal( 1 );
|
||||
expect( node.scaleY ).equal( 1 );
|
||||
});
|
||||
|
||||
it( 'createNode with onBeforeSerialize called', function() {
|
||||
|
||||
wrapper.position = new cc.Vec2(11, 22);
|
||||
|
||||
wrapper.texture = wrapper._texToLoad = url;
|
||||
|
||||
wrapper.onBeforeSerialize();
|
||||
|
||||
var node = wrapper.createNode();
|
||||
|
||||
assert( node instanceof _ccsg.Sprite );
|
||||
expect( node.x ).equal( 11 );
|
||||
expect( node.y ).equal( 22 );
|
||||
|
||||
assert( node.texture );
|
||||
expect( node.texture.url ).equal( url );
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user