diff --git a/test/qunit/assets/library/65/65535.json b/test/qunit/assets/library/65/65535.json new file mode 100644 index 0000000000..a4df3363c9 --- /dev/null +++ b/test/qunit/assets/library/65/65535.json @@ -0,0 +1,7 @@ +{ + "__type__": "TestDependency", + "name": "Prefab A", + "dependency": { + "__uuid__": "749417" + } +} \ No newline at end of file diff --git a/test/qunit/assets/library/74/749417.json b/test/qunit/assets/library/74/749417.json new file mode 100644 index 0000000000..b989312f4a --- /dev/null +++ b/test/qunit/assets/library/74/749417.json @@ -0,0 +1,7 @@ +{ + "__type__": "TestDependency", + "name": "Prefab B", + "dependency": { + "__uuid__": "65535" + } +} \ No newline at end of file diff --git a/test/qunit/unit-es5/_init.js b/test/qunit/unit-es5/_init.js index 4d4c092e3a..58dc51bf54 100644 --- a/test/qunit/unit-es5/_init.js +++ b/test/qunit/unit-es5/_init.js @@ -107,6 +107,17 @@ var TestScript = cc.Class({ } }); +var TestDependency = cc.Class({ + name: 'TestDependency', + extends: cc.Asset, + properties: { + dependency: { + default: '', + url: TestDependency, + } + } +}); + // mocks to test engine extends cc.engine = new (cc.Class({ diff --git a/test/qunit/unit-es5/test-asset-library.js b/test/qunit/unit-es5/test-asset-library.js index d398e2e127..8a93bbf072 100644 --- a/test/qunit/unit-es5/test-asset-library.js +++ b/test/qunit/unit-es5/test-asset-library.js @@ -5,6 +5,7 @@ var grossini_uuid = '748321'; var grossiniSprite_uuid = '1232218'; var selfReferenced_uuid = '123200'; + var circleReferenced_uuid = '65535'; largeModule('AssetLibrary', { setup: function () { @@ -81,4 +82,21 @@ }, 200); }); + asyncTest('load asset with circle referenced dependencies', function () { + AssetLibrary.loadAsset(circleReferenced_uuid, function (err, asset) { + if (err) { + ok(false, err.errorMessage); + return start(); + } + clearTimeout(timerId); + ok(asset.dependency, 'can load circle referenced asset'); + strictEqual(asset.dependency.dependency, asset, 'circle referenced asset should have dependency which equal to self'); + start(); + }); + var timerId = setTimeout(function () { + ok(false, 'time out!'); + start(); + }, 200); + }); + })();