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/30 21:26:39 UTC
[2/3] spec commit: CB 4878 - media tests should wait for file load
CB 4878 - media tests should wait for file load
(cherry picked from commit 4cba23f05443607e26cf82e7746f6fe55511e329)
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/00669d34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/00669d34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/00669d34
Branch: refs/heads/3.1.x
Commit: 00669d34d420a5dae3858190d3933ce2df9db340
Parents: 726758b
Author: David Kemp <dr...@chromium.org>
Authored: Fri Sep 20 08:17:31 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Sep 30 15:25:26 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/00669d34/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();
});
});
});