You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/09/20 15:48:26 UTC

[2/2] spec commit: CB 4878 - media tests should wait for file load

CB 4878 - media tests should wait for file load


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/4cba23f0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/4cba23f0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/4cba23f0

Branch: refs/heads/master
Commit: 4cba23f05443607e26cf82e7746f6fe55511e329
Parents: dc2f553
Author: David Kemp <dr...@chromium.org>
Authored: Fri Sep 20 08:17:31 2013 -0400
Committer: David Kemp <dr...@chromium.org>
Committed: Fri Sep 20 08:17:31 2013 -0400

----------------------------------------------------------------------
 autotest/tests/media.tests.js | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/4cba23f0/autotest/tests/media.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/media.tests.js b/autotest/tests/media.tests.js
index 6b23a47..87d860d 100644
--- a/autotest/tests/media.tests.js
+++ b/autotest/tests/media.tests.js
@@ -144,7 +144,13 @@ describe('Media', function () {
 	});
 
     it("media.spec.12 position should be set properly", function() {
-        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3"),
+        var win = jasmine.createSpy();
+        var fail = jasmine.createSpy();
+        var mediaState=Media.STOPPED;
+        var statuschange= function(statusCode){
+            mediaState=statusCode;
+        };
+        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",win,fail,statuschange),
             test = jasmine.createSpy().andCallFake(function(position) {
                     console.log("position = " + position);
                     expect(position).toBeGreaterThan(0.0);
@@ -154,9 +160,11 @@ describe('Media', function () {
 
         media1.play();
 
-        waits(5000);
+        waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
 
         runs(function () {
+            expect(fail).not.toHaveBeenCalled();
+            expect(win).not.toHaveBeenCalled();
             media1.getCurrentPosition(test, function () {});
         });
 
@@ -164,11 +172,18 @@ describe('Media', function () {
     });
 
     it("media.spec.13 duration should be set properly", function() {
-        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3");
+        var win = jasmine.createSpy();
+        var fail = jasmine.createSpy();
+        var mediaState=Media.STOPPED;
+        var statuschange= function(statusCode){
+            mediaState=statusCode;
+        };
+        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",win,fail,statuschange);
         media1.play();
-        waits(5000);
+        waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
         runs(function () {
             expect(media1.getDuration()).toBeGreaterThan(0.0);
+            expect(fail).not.toHaveBeenCalled();
         });
     });
 });