CB-4969 : media.spec.12 fails with 0 position
(cherry picked from commit 9fbd54d9dc4afb99a7dc802cfaf6e91fc0f40c42)
diff --git a/autotest/tests/media.tests.js b/autotest/tests/media.tests.js
index 87d860d..19883ba 100644
--- a/autotest/tests/media.tests.js
+++ b/autotest/tests/media.tests.js
@@ -144,13 +144,13 @@
});
it("media.spec.12 position should be set properly", function() {
- var win = jasmine.createSpy();
+ var playcomplete = jasmine.createSpy();
var fail = jasmine.createSpy();
- var mediaState=Media.STOPPED;
+ var mediaState=Media.MEDIA_STOPPED;
var statuschange= function(statusCode){
mediaState=statusCode;
};
- var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",win,fail,statuschange),
+ var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",playcomplete,fail,statuschange),
test = jasmine.createSpy().andCallFake(function(position) {
console.log("position = " + position);
expect(position).toBeGreaterThan(0.0);
@@ -159,22 +159,24 @@
});
media1.play();
-
waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
-
+ // make sure we are at least one second into the file
+ waits(1000);
runs(function () {
expect(fail).not.toHaveBeenCalled();
- expect(win).not.toHaveBeenCalled();
+ // note that the file is about 60 seconds long and we kill the play almost immediately
+ // as a result, the playcomplete should not happen
+ expect(playcomplete).not.toHaveBeenCalled();
media1.getCurrentPosition(test, function () {});
});
- waitsFor(function () { return test.wasCalled; }, Tests.TEST_TIMEOUT);
+ waitsFor(function () { return test.wasCalled || fail.wasCalled; }, Tests.TEST_TIMEOUT);
});
it("media.spec.13 duration should be set properly", function() {
var win = jasmine.createSpy();
var fail = jasmine.createSpy();
- var mediaState=Media.STOPPED;
+ var mediaState=Media.MEDIA_STOPPED;
var statuschange= function(statusCode){
mediaState=statusCode;
};