diff --git a/CCDebugger.js b/CCDebugger.js index 6e70bc6c9c..333c712baf 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -267,7 +267,7 @@ cc._LogInfos = { } }; -if (CC_EDITOR || CC_TEST) { +if (CC_DEV) { cc._LogInfos.Editor = { Class: { callSuperCtor: "cc.Class will automatically call super constructor of %s, you should not call it manually." diff --git a/cocos2d/animation/animation-animator.js b/cocos2d/animation/animation-animator.js index 9fdecf0ea9..949bef9044 100644 --- a/cocos2d/animation/animation-animator.js +++ b/cocos2d/animation/animation-animator.js @@ -68,7 +68,7 @@ p.setStateTime = function (state, time) { } } -if (CC_EDITOR || CC_TEST) { +if (CC_DEV) { p.reloadClip = function (state) { initClipData(this.target, state); }; diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 7eff54e223..b3c8eb382b 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -286,7 +286,7 @@ var Node = cc.Class({ var parent = this._parent; var destroyByParent = parent && (parent._objFlags & Destroying); if ( !destroyByParent ) { - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { this._registerIfAttached(false); } } @@ -568,7 +568,7 @@ var Node = cc.Class({ // INTERNAL - _registerIfAttached: (CC_EDITOR || CC_TEST) && function (register) { + _registerIfAttached: CC_DEV && function (register) { if (register) { cc.engine.attachedObjsForEditor[this.uuid] = this; cc.engine.emit('node-attach-to-scene', {target: this}); @@ -630,7 +630,7 @@ var Node = cc.Class({ if (activeInHierarchyBefore !== shouldActiveNow) { this._onActivatedInHierarchy(shouldActiveNow); } - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { var scene = cc.director.getScene(); var inCurrentSceneBefore = oldParent && oldParent.isChildOf(scene); var inCurrentSceneNow = this._parent && this._parent.isChildOf(scene); diff --git a/cocos2d/core/CCScene.js b/cocos2d/core/CCScene.js index 66c951d44f..73e68ffaaf 100644 --- a/cocos2d/core/CCScene.js +++ b/cocos2d/core/CCScene.js @@ -81,7 +81,7 @@ cc.Scene = cc.Class({ _activate: function () { var i, child, children = this._children, len = children.length; - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { // register all nodes to editor for (i = 0; i < len; ++i) { child = children[i]; diff --git a/cocos2d/core/assets/CCPrefab.js b/cocos2d/core/assets/CCPrefab.js index 80af448f20..a2ed15b3bf 100644 --- a/cocos2d/core/assets/CCPrefab.js +++ b/cocos2d/core/assets/CCPrefab.js @@ -32,7 +32,7 @@ var Prefab = cc.Class({ // instantiate var node = cc.instantiate(this.data); - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { Editor.PrefabUtils.onPrefabInstantiated(this, node); } diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index b45fefe518..f68d6c1e0a 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -150,8 +150,8 @@ var _callLateUpdate = CC_EDITOR ? function (event) { // Yes, the id might have a conflict problem once every 365 days // if the game runs at 60 FPS and each frame 4760273 counts of new HashObject's id are requested. var CompId = 0; -var IdPrefix = (CC_EDITOR || CC_TEST) && ('Comp' + Editor.NonUuidMark); -var getNewId = (CC_EDITOR || CC_TEST) && function () { +var IdPrefix = CC_DEV && ('Comp' + Editor.NonUuidMark); +var getNewId = CC_DEV && function () { return IdPrefix + (++CompId); }; @@ -169,7 +169,7 @@ var Component = cc.Class({ name: 'cc.Component', extends: cc.Object, - ctor: (CC_EDITOR || CC_TEST) && function () { + ctor: CC_DEV && function () { if (CC_EDITOR) { Editor._AssetsWatcher.initComponent(this); } @@ -209,7 +209,7 @@ var Component = cc.Class({ if (id) { return id; } - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { id = this._id = getNewId(); cc.engine.attachedObjsForEditor[id] = this; return id; @@ -555,7 +555,7 @@ var Component = cc.Class({ // do remove component this.node._removeComponent(this); - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { delete cc.engine.attachedObjsForEditor[this._id]; } } diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 090f37dedc..7f037bfaa0 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -183,7 +183,7 @@ var _metaClass = { if ( !forceSerializable ) { Attr.attr(this, name, Attr.NonSerialized); } - if (forceSerializable || (CC_EDITOR || CC_TEST)) { + if (forceSerializable || CC_DEV) { // 不论是否 hide in inspector 都要添加到 props,否则 asset watcher 不能正常工作 _appendProp(this, name/*, true*/); } @@ -201,7 +201,7 @@ var _metaClass = { }); } - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { Attr.attr(this, name, {hasGetter: true}); // 方便 editor 做判断 } return this; @@ -216,7 +216,7 @@ var _metaClass = { } } - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { Object.defineProperty(this.prototype, name, { //set: function setter_editorWrapper (value) { // if (this._observing) { @@ -457,7 +457,7 @@ function _checkCtor (ctor) { } function normalizeClassName (className) { - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { var DefaultName = 'CCClass'; if (className) { className = className.replace(/\./g, '_'); @@ -535,7 +535,7 @@ function _createCtor (ctor, baseClass, mixins, className, options) { // create class constructor var body; - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { body = '(function ' + normalizeClassName(className) + '(){\n'; } else { @@ -772,7 +772,7 @@ function FireClass (options) { if (typeof func === 'function' || func === null) { cls.prototype[funcName] = func; } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { var correct = TYPO_TO_CORRECT[funcName]; if (correct) { cc.warn('Unknown parameter of %s.%s, maybe you want is "%s".', name, funcName, correct); @@ -872,7 +872,7 @@ function parseAttributes (attrs, className, propName) { }); break; case 'Object': - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { cc.error('Please define "type" parameter of %s.%s as the actual constructor.', className, propName); } break; @@ -891,7 +891,7 @@ function parseAttributes (attrs, className, propName) { enumList: Enum.getList(type) }); } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error('Please define "type" parameter of %s.%s as the constructor of %s.', className, propName, type); } } @@ -899,7 +899,7 @@ function parseAttributes (attrs, className, propName) { result.push(Attr.ObjectType(type)); //result.push( { expectedTypeOf: 'object' } ); } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error('Unknown "type" parameter of %s.%s:%s', className, propName, type); } } @@ -920,7 +920,7 @@ function parseAttributes (attrs, className, propName) { result.push(typeof attrCreater === 'function' ? attrCreater(val) : attrCreater); } } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error('The %s of %s.%s must be type %s', attrName, className, propName, expectType); } } @@ -928,7 +928,7 @@ function parseAttributes (attrs, className, propName) { parseSimpleAttr('rawType', 'string', Attr.RawType); parseSimpleAttr('editorOnly', 'boolean', Attr.EditorOnly); - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { parseSimpleAttr('displayName', 'string'); parseSimpleAttr('multiline', 'boolean', {multiline: true}); parseSimpleAttr('readonly', 'boolean', {readonly: true}); @@ -942,7 +942,7 @@ function parseAttributes (attrs, className, propName) { result.push(Attr.NonSerialized); } - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { var visible = attrs.visible; if (typeof visible !== 'undefined') { if (!attrs.visible) { @@ -967,11 +967,11 @@ function parseAttributes (attrs, className, propName) { if (range.length >= 2) { result.push(Attr.Range(range[0], range[1])); } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error('The length of range array must be 2'); } } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error(ERR_Type, '"range"', className + '.' + propName, 'array'); } } @@ -985,20 +985,20 @@ function parseAttributes (attrs, className, propName) { if (typeof def === 'boolean') { result.push(Attr.Nullable(boolPropName, def)); } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error(ERR_Type, '"default"', 'nullable object', 'boolean'); } } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error(ERR_Type, '"propName"', 'nullable object', 'string'); } } - else if (CC_EDITOR || CC_TEST) { + else if (CC_DEV) { cc.error(ERR_Type, '"nullable"', className + '.' + propName, 'object'); } } - if (CC_EDITOR || CC_TEST) { + if (CC_DEV) { var watch = attrs.watch; if (watch) { if (typeof watch === 'object') { diff --git a/cocos2d/core/platform/CCObject.js b/cocos2d/core/platform/CCObject.js index 5db585c69b..922136c59b 100644 --- a/cocos2d/core/platform/CCObject.js +++ b/cocos2d/core/platform/CCObject.js @@ -232,7 +232,7 @@ prototype.destroy = function () { return true; }; -if (CC_EDITOR || CC_TEST) { +if (CC_DEV) { /** * In fact, Object's "destroy" will not trigger the destruct operation in Firebal Editor. * The destruct operation will be executed by Undo system later. @@ -347,7 +347,7 @@ cc.isValid = function (value) { } }; -if (CC_EDITOR || CC_TEST) { +if (CC_DEV) { Object.defineProperty(CCObject, '_willDestroy', { value: function (obj) { return !(obj._objFlags & Destroyed) && (obj._objFlags & ToDestroy) > 0; diff --git a/cocos2d/core/platform/deserialize.js b/cocos2d/core/platform/deserialize.js index 3cb82b666a..64dc720337 100644 --- a/cocos2d/core/platform/deserialize.js +++ b/cocos2d/core/platform/deserialize.js @@ -27,7 +27,7 @@ var JS = require('./js'); var CCObject = require('./CCObject'); -var EDITOR = CC_EDITOR || CC_TEST; +var EDITOR = CC_DEV; var ENABLE_TARGET = EDITOR; // HELPERS diff --git a/cocos2d/core/platform/js.js b/cocos2d/core/platform/js.js index 3ae9b3308e..1bb5289d85 100644 --- a/cocos2d/core/platform/js.js +++ b/cocos2d/core/platform/js.js @@ -260,7 +260,7 @@ function getTempCID () { } js._isTempClassId = function (id) { - return (CC_EDITOR || CC_TEST) && (typeof id !== 'string' || id.startsWith(TCID_PREFIX)); + return CC_DEV && (typeof id !== 'string' || id.startsWith(TCID_PREFIX)); }; // id 注册 diff --git a/test/qunit/unit/test-spriteRenderer.js b/test/qunit/unit/test-spriteRenderer.js index 5611dee542..d5c6108ba1 100644 --- a/test/qunit/unit/test-spriteRenderer.js +++ b/test/qunit/unit/test-spriteRenderer.js @@ -1,6 +1,6 @@ largeModule('Sprite'); -asyncTest('basic test', function () { +test('basic test', function () { var url = assetDir + '/button.png'; var node = new cc.Node(); @@ -15,13 +15,6 @@ asyncTest('basic test', function () { var texture = cc.textureCache.addImage(url); newSprite.setTexture(texture); render.spriteFrame = newSprite; - if (!texture.isLoaded()) { - render.spriteFrame.once('load', function () { - strictEqual(render._sgNode._resourceData._texture.url, url, 'texture set success'); - start(); - }); - } - else { - strictEqual(render._sgNode._resourceData._texture.url, url, 'texture set success'); - } + + ok(true); });