test for mediastreamtracklist behavior
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 31 May 2012 16:20:38 +0200
changeset 10 8eaa635ca62c
parent 9 87d86cd71219
child 11 377275c86294
test for mediastreamtracklist behavior
submitted/W3C/mediastreamtracklist.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/mediastreamtracklist.html	Thu May 31 16:20:38 2012 +0200
@@ -0,0 +1,52 @@
+<!doctype html>
+<html>
+<head>
+<title>Adding a track to a MediaStreamTrackList</title>
+<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
+<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia">
+<link rel='stylesheet' href='/resources/testharness.css' media='all'/>
+</head>
+<body>
+<p>When prompted, accept to share your audio stream.</p>
+<h1>Description</h1>
+<p>This test checks that adding a track to a MediaStreamTrackList works as expected.</p>
+
+<div id='log'></div>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=featuredetection.js></script>
+<script src=prefix.js></script>
+<script>
+var t = async_test("Tests that an addition to a MediaStreamTrackList works as expected");
+if (window.navigator.getUserMedia) { 
+  var audio, video;
+
+  navigator.getUserMedia({audio:true}, gotAudio);
+  function gotAudio(stream) {
+    audio = stream;
+    navigator.getUserMedia({video:true}, gotVideo);
+  }
+
+  function gotVideo(stream) {
+    video = stream;
+    t.step(function () {
+       assert_equals(video.audioTracks.length, 0, "video mediastream starts with no audio track");
+       video.audioTracks.add(audio.audioTracks[0]);
+       assert_equals(video.audioTracks.length, 1, "video mediastream has now one audio track");
+       video.audioTracks.add(audio.audioTracks[0]);
+       assert_equals(video.audioTracks.length, 1, "video mediastream still has one audio track");
+    });
+    audio.onaddtrack = function () {
+       assert_true(true, "onaddtrack is triggered on adding a track");
+       t.done();
+    };
+    t.step(function () {
+       assert_equals(audio.videoTracks.length, 0, "audio mediastream starts with no video track");
+       audio.videoTracks.add(video.videoTracks[1]);
+       assert_equals(audio.videoTracks.length, 1, "audio mediastream now has one video track");
+    });
+  }
+}
+</script>
+</body>
+</html>