From 19b42a34aed215d09b32b270e427ea02cf6f25a8 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 22 Apr 2017 16:01:24 +0800 Subject: [PATCH 1/2] Fix audio not supported in test environment --- test/qunit/unit-es5/test-loader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/qunit/unit-es5/test-loader.js b/test/qunit/unit-es5/test-loader.js index c09dea24ca..5e03f0bff3 100644 --- a/test/qunit/unit-es5/test-loader.js +++ b/test/qunit/unit-es5/test-loader.js @@ -127,7 +127,9 @@ asyncTest('Load with dependencies', function () { ok(items.isCompleted(), 'be able to load all resources'); depsProgression.expect(depsCount, 'should call progress callback for all ' + depsCount + ' dependencies'); progressCallback.expect(total, 'should call ' + total + ' times progress callback for ' + total + ' resources'); - strictEqual(loader.getResCount(), total, 'getResCount should return correct count of loaded resources'); + var count = loader.getResCount(); + // Test environment doesn't load audio + ok(count === total-1 || count === total, 'getResCount should return correct count of loaded resources'); loader.releaseAll(); start(); From 3a7c704da15bc81b9fe4c04adb2383f6cb5e71fc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 23 Apr 2017 22:19:40 +0800 Subject: [PATCH 2/2] Use isPhantomJS to detect test environment --- test/qunit/unit-es5/test-loader.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/qunit/unit-es5/test-loader.js b/test/qunit/unit-es5/test-loader.js index 5e03f0bff3..4436e71fc8 100644 --- a/test/qunit/unit-es5/test-loader.js +++ b/test/qunit/unit-es5/test-loader.js @@ -82,7 +82,6 @@ asyncTest('Load with dependencies', function () { }); var json1 = { - id: assetDir + '/library/65/6545543', url: assetDir + '/library/65/6545543', type: 'deps' }; @@ -98,7 +97,7 @@ asyncTest('Load with dependencies', function () { var depsProgression = new Callback().enable(); var progressCallback = new Callback(function (completedCount, totalCount, item) { - if (item.id === json1.id) { + if (item.id === json1.url) { var dep = loader.getRes(dep1); ok(dep instanceof cc.Texture2D, 'should correctly load dependent image1'); dep = loader.getRes(dep2); @@ -128,8 +127,13 @@ asyncTest('Load with dependencies', function () { depsProgression.expect(depsCount, 'should call progress callback for all ' + depsCount + ' dependencies'); progressCallback.expect(total, 'should call ' + total + ' times progress callback for ' + total + ' resources'); var count = loader.getResCount(); - // Test environment doesn't load audio - ok(count === total-1 || count === total, 'getResCount should return correct count of loaded resources'); + if (isPhantomJS) { + // Test environment doesn't load audio + strictEqual(count, total-1, 'getResCount should return correct count of loaded resources'); + } + else { + strictEqual(count, total, 'getResCount should return correct count of loaded resources'); + } loader.releaseAll(); start();