incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdo...@apache.org
Subject spec commit: Adding Media class tests to autotest
Date Fri, 02 Mar 2012 21:23:25 GMT
Updated Branches:
  refs/heads/master ac46f7771 -> ad54f6a30


Adding Media class tests to autotest


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/ad54f6a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/ad54f6a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/ad54f6a3

Branch: refs/heads/master
Commit: ad54f6a30ff6299bcd96095193d46e4afdc87e4c
Parents: ac46f77
Author: macdonst <simon.macdonald@gmail.com>
Authored: Fri Mar 2 16:23:11 2012 -0500
Committer: macdonst <simon.macdonald@gmail.com>
Committed: Fri Mar 2 16:23:11 2012 -0500

----------------------------------------------------------------------
 autotest/index.html           |    1 +
 autotest/tests/media.tests.js |  142 ++++++++++++++++++++++++++++++-----
 2 files changed, 122 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/ad54f6a3/autotest/index.html
----------------------------------------------------------------------
diff --git a/autotest/index.html b/autotest/index.html
index 5349bda..5225946 100755
--- a/autotest/index.html
+++ b/autotest/index.html
@@ -26,6 +26,7 @@
     <script type="text/javascript" src="tests/device.tests.js"></script>
     <script type="text/javascript" src="tests/file.tests.js"></script>
     <script type="text/javascript" src="tests/geolocation.tests.js"></script>
+    <script type="text/javascript" src="tests/media.tests.js"></script>
     <script type="text/javascript" src="tests/network.tests.js"></script>
     <script type="text/javascript" src="tests/notification.tests.js"></script>
     <script type="text/javascript" src="tests/orientation.tests.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/ad54f6a3/autotest/tests/media.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/media.tests.js b/autotest/tests/media.tests.js
index 43f9b1c..f1b03ab 100644
--- a/autotest/tests/media.tests.js
+++ b/autotest/tests/media.tests.js
@@ -1,31 +1,131 @@
-//
-// @TODO Update to Latest HTML5 Audio Element Spec
-// @see http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#audio
-//
 Tests.prototype.MediaTests = function() {	
-	module('Media (Audio)');
+	module('Media');
 	test("should exist", function() {
   		expect(1);
-		ok(typeof Audio === "function" || typeof Audio === "object", "'Audio' should be defined
as a function in global scope.");
+		ok(typeof Media === "function" || typeof Media === "object", "'Media' should be defined
as a function in global scope.");
 	});
+    test("should have the following properties", function() {
+        var media1 = new Media("dummy");
+        expect(4);
+        ok(typeof media1.id != 'undefined' && media1.id != null, "'Media' should
have an id property.");
+        ok(typeof media1.src != 'undefined', "'Media' should have an src property.");
+        ok(typeof media1._duration != 'undefined' && media1._duration != null, "'Media'
should have an _duration property.");
+        ok(typeof media1._position != 'undefined' && media1._position != null, "'Media'
should have an _position property.");
+        media1.release();
+    });
 	test("should define constants for Media errors", function() {
-		expect(5);
+		expect(6);
 		ok(MediaError != null && typeof MediaError != 'undefined', "MediaError object exists
in global scope.");
-		equals(MediaError.MEDIA_ERR_ABORTED, 1, "MediaError.MEDIA_ERR_ABORTED is equal to 1.");
+        equals(MediaError.MEDIA_ERR_NONE_ACTIVE, 0, "MediaError.MEDIA_ERR_NONE_ACTIVE is
equal to 0.");
+        equals(MediaError.MEDIA_ERR_ABORTED, 1, "MediaError.MEDIA_ERR_ABORTED is equal to
1.");
 		equals(MediaError.MEDIA_ERR_NETWORK, 2, "MediaError.MEDIA_ERR_NETWORK is equal to 2.");
 		equals(MediaError.MEDIA_ERR_DECODE, 3, "MediaError.MEDIA_ERR_DECODE is equal to 3.");
-		equals(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 4, "MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED
is equal to 4.");
-	});
-	test("should contain 'src', 'loop' and 'error' properties", function() {
-  		expect(7);
-		var audioSrc = '/test.mp3';
-		var audio = new Audio(audioSrc);
-  		ok(typeof audio == "object", "Instantiated 'Audio' object instance should be of type
'object.'");
-		ok(audio.src != null && typeof audio.src != 'undefined', "Instantiated 'Audio'
object's 'src' property should not be null or undefined.");
-		ok(audio.src.indexOf(audioSrc) >= 0, "Instantiated 'Audio' object's 'src' property should
match constructor parameter.");
-		ok(audio.loop != null && typeof audio.loop != 'undefined', "Instantiated 'Audio'
object's 'loop' property should not be null or undefined.");
-		ok(audio.loop == false, "Instantiated 'Audio' object's 'loop' property should initially
be false.");
-		ok(typeof audio.error != 'undefined', "Instantiated 'Audio' object's 'error' property should
not undefined.");
-		ok(audio.error == null, "Instantiated 'Audio' object's 'error' should initially be null.");
+		equals(MediaError.MEDIA_ERR_NONE_SUPPORTED, 4, "MediaError.MEDIA_ERR_NONE_SUPPORTED is
equal to 4.");
 	});
+    test("should contain a play function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.play != 'undefined' && media1.play != null, "Media.play
should not be null.");
+        ok(typeof media1.play == 'function', "Media.play should be a function.");
+        media1.release();
+    });
+    test("should contain a stop function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.stop != 'undefined' && media1.stop != null, "Media.stop
should not be null.");
+        ok(typeof media1.stop == 'function', "Media.stop should be a function.");
+        media1.release();
+    });
+    test("should contain a seekTo function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.seekTo != 'undefined' && media1.seekTo != null, "Media.seekTo
should not be null.");
+        ok(typeof media1.seekTo == 'function', "Media.seekTo should be a function.");
+        media1.release();
+    });
+    test("should contain a pause function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.pause != 'undefined' && media1.pause != null, "Media.pause
should not be null.");
+        ok(typeof media1.pause == 'function', "Media.pause should be a function.");
+        media1.release();
+    });
+    test("should contain a getDuration function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.getDuration != 'undefined' && media1.getDuration != null,
"Media.getDuration should not be null.");
+        ok(typeof media1.getDuration == 'function', "Media.getDuration should be a function.");
+        media1.release();
+    });
+    test("should contain a getCurrentPosition function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.getCurrentPosition != 'undefined' && media1.getCurrentPosition
!= null, "Media.getCurrentPosition should not be null.");
+        ok(typeof media1.getCurrentPosition == 'function', "Media.getCurrentPosition should
be a function.");
+        media1.release();
+    });
+    test("should contain a startRecord function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.startRecord != 'undefined' && media1.startRecord != null,
"Media.startRecord should not be null.");
+        ok(typeof media1.startRecord == 'function', "Media.startRecord should be a function.");
+        media1.release();
+    });
+    test("should contain a stopRecord function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.stopRecord != 'undefined' && media1.stopRecord != null,
"Media.stopRecord should not be null.");
+        ok(typeof media1.stopRecord == 'function', "Media.stopRecord should be a function.");
+        media1.release();
+    });
+    test("should contain a release function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.release != 'undefined' && media1.release != null, "Media.release
should not be null.");
+        ok(typeof media1.release == 'function', "Media.release should be a function.");
+        media1.release();
+    });
+    test("should contain a setVolume function", function() {
+        var media1 = new Media();
+        expect(2);
+        ok(typeof media1.setVolume != 'undefined' && media1.setVolume != null, "Media.setVolume
should not be null.");
+        ok(typeof media1.setVolume == 'function', "Media.setVolume should be a function.");
+        media1.release();
+    });
+    test("position should be set properly", function() {
+        var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
+        media1.play();
+        expect(1);
+        QUnit.stop(15000);
+        setTimeout(
+                function() {
+                    media1.getCurrentPosition(
+                        function(position) {
+                            console.log("position = " + position);
+                            ok(position >= 0.0, "position should not be -1");
+                            QUnit.start();
+                            media1.stop()
+                            media1.release();
+                        },
+                        function(e) {
+                            QUnit.start();
+                        }
+                    );
+                }
+           , 5000);
+    });
+    test("duration should be set properly", function() {
+        var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
+        media1.play();
+        expect(1);
+        QUnit.stop(15000);
+        setTimeout(
+                function() {
+                    ok(media1.getDuration() >= 0.0, "duration should not be -1");
+                    QUnit.start();
+                    media1.stop()
+                    media1.release();
+                }
+           , 5000);
+    });
 };
\ No newline at end of file


Mime
View raw message