You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2012/03/27 23:31:05 UTC

[2/2] spec commit: Update auto media tests to try and play invalid file

Update auto media tests to try and play invalid file

This will test that an appropriate error object and code is returned


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

Branch: refs/heads/master
Commit: 1d43c998df62997fe5d4805ee8c98e4c6a2b3b14
Parents: c838e04
Author: Becky Gibson <be...@apache.org>
Authored: Wed Mar 21 19:52:53 2012 -0400
Committer: Becky Gibson <be...@apache.org>
Committed: Wed Mar 21 19:52:53 2012 -0400

----------------------------------------------------------------------
 autotest/tests/media.tests.js |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/1d43c998/autotest/tests/media.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/media.tests.js b/autotest/tests/media.tests.js
index f1b03ab..cf6ded4 100644
--- a/autotest/tests/media.tests.js
+++ b/autotest/tests/media.tests.js
@@ -92,6 +92,27 @@ Tests.prototype.MediaTests = function() {
         ok(typeof media1.setVolume == 'function', "Media.setVolume should be a function.");
         media1.release();
     });
+	test("should return MediaError for bad filename", function() {
+		expect(2);
+		QUnit.stop(10000);
+		var badMedia = null;
+		var releaseMedia = function() {
+			badMedia.release();
+		};
+		var win = function() {
+			ok(0, "should NOT succeed with bad media file name");
+			releaseMedia();
+			QUnit.start();
+		};
+		var fail = function(result){
+			ok(typeof result == 'object', "Object returned in media.play failure callback is of type 'object' (actually MediaError).");
+			ok(result.code == MediaError.MEDIA_ERR_ABORTED, "Object returned in media.find failure callback has a code property which equal to MediaError.MEDIA_ERR_ABORTED");
+			releaseMedia();
+			QUnit.start(); 
+		};
+		badMedia = new Media("invalid.file.name", win,fail);
+		badMedia.play();
+	});
     test("position should be set properly", function() {
         var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
         media1.play();