cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject cordova-plugin-media git commit: CB-8428 Fix multiple `done()` calls in media plugin test on devices where audio is not configured
Date Thu, 05 Feb 2015 15:38:21 GMT
Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master bae9b8cf4 -> fb45b2a01


CB-8428 Fix multiple `done()` calls in media plugin test on devices where audio is not configured

github close #44


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/fb45b2a0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/fb45b2a0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/fb45b2a0

Branch: refs/heads/master
Commit: fb45b2a01bedee3eb0262e722d330258c70b9a1b
Parents: bae9b8c
Author: Nikhil Khandelwal <nikhilkh@microsoft.com>
Authored: Wed Feb 4 01:03:56 2015 -0800
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Thu Feb 5 18:38:19 2015 +0300

----------------------------------------------------------------------
 tests/tests.js | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/fb45b2a0/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 4424b39..ea8826d 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -24,6 +24,7 @@ exports.defineAutoTests = function () {
         var info = typeof msg == 'undefined' ? 'Unexpected error callback' : msg;
         expect(true).toFailWithMessage(info + '\n' + JSON.stringify(error));
         done();
+        this.done = true;
     };
 
     var succeed = function (done, msg) {
@@ -179,6 +180,7 @@ exports.defineAutoTests = function () {
         });
 
         it("media.spec.16 position should be set properly", function (done) {
+            var self = this;
             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
             mediaState = Media.MEDIA_STOPPED,
             successCallback,
@@ -194,16 +196,19 @@ exports.defineAutoTests = function () {
                             expect(position).toBeGreaterThan(0.0);
                             media1.stop();
                             media1.release();
-                            done();
-                        }, failed.bind(null, done, 'media1.getCurrentPosition - Error getting
media current position'));
+                            if (!self.done) {
+                                done();
+                            }
+                        }, failed.bind(self, done, 'media1.getCurrentPosition - Error getting
media current position'));
                     }, 1000);
                 }
             },
-            media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1
= new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
+            media1 = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1
= new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
             media1.play();
         });
 
         it("media.spec.17 duration should be set properly", function (done) {
+            var self = this;
             if (cordova.platformId === 'blackberry10') {
                 expect(true).toFailWithMessage('Platform does not supported this feature');
                 done();
@@ -222,11 +227,13 @@ exports.defineAutoTests = function () {
                         expect(media1.getDuration()).toBeGreaterThan(0.0);
                         media1.stop();
                         media1.release();
-                        done();
+                        if (!self.done) {
+                            done();
+                        }
                     }, 1000);
                 }
             },
-            media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1
= new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
+            media1 = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1
= new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
             media1.play();
         });
     });
@@ -572,9 +579,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         table.setAttribute("id", tableId);
         return table;
     }
-    
+
 //Audio && Record Elements
-    var elementsResultsAudio= 
+    var elementsResultsAudio=
     [{
             id : "statusTag",
             content : "Status:",
@@ -719,7 +726,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
             }
         }
     ];
-    
+
     //Title audio results
     var div = document.createElement('h2');
     div.appendChild(document.createTextNode('Audio'));
@@ -727,7 +734,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     contentEl.appendChild(div);
     //Generate and add results table
     contentEl.appendChild(generateTable('info', 3, 3, elementsResultsAudio));
-    
+
     //Title audio actions
     div = document.createElement('h2');
     div.appendChild(document.createTextNode('Actions'));
@@ -794,7 +801,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     div.setAttribute("style", "background:#B0C4DE;border:1px solid #FFA07A;margin:15px 6px
0px;min-width:295px;max-width:97%;padding:4px 0px 2px 10px;min-height:160px;max-height:200px;overflow:auto");
     div.appendChild(list);
     contentEl.appendChild(div);
-    
+
     //Title Record Audio
     div = document.createElement('h2');
     div.appendChild(document.createTextNode('Record Audio'));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message