Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: content/test/data/media/getusermedia_and_stop.html

Issue 13496009: Hookup the MediaStream glue for Adding and Removing tracks to an existing MediaStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments on content_browsertest Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/data/media/getusermedia_and_stop.html
diff --git a/content/test/data/media/getusermedia_and_stop.html b/content/test/data/media/getusermedia_and_stop.html
index f1c43bef012ea30a1bfd607e34e4b080ea8b2e17..2bb1262e22851e752705d46a8ece441e0b7c9b71 100644
--- a/content/test/data/media/getusermedia_and_stop.html
+++ b/content/test/data/media/getusermedia_and_stop.html
@@ -1,18 +1,72 @@
<html>
phoglund_chromium 2013/04/11 11:16:48 Rename this file to something like basic_getuserme
perkj_chrome 2013/04/11 11:50:48 Done.
<head>
+ <script type="text/javascript" src="webrtc_test_utilities.js"></script>
<script type="text/javascript">
+ $ = function(id) {
+ return document.getElementById(id);
+ };
+
+ var gLocalStream = null;
+
phoglund_chromium 2013/04/11 11:16:48 I'd prefer if this is done through some accessor.
perkj_chrome 2013/04/11 11:50:48 Done.
+ gAllEventsOccured = function() {
+ gLocalStream.stop();
+ document.title = 'OK';
+ }
+
+ // This test that a MediaStream can be created and a local preview
+ // rendered.
function getUserMedia(constraints) {
- navigator.webkitGetUserMedia(constraints, okCallback, failedCallback);
+ navigator.webkitGetUserMedia(constraints, displayAndWaitForVideo,
+ failedCallback);
}
-
+
+ // This test that a MediaStream can be cloned and that the clone can
+ // be rendered.
+ function getUserMediaAndClone() {
+ navigator.webkitGetUserMedia({video: true, audio: true},
+ createAndRenderClone, failedCallback);
+ }
+
function failedCallback(error) {
document.title = 'GetUserMedia call failed with code ' + error.code;
}
- function okCallback(stream) {
- stream.stop();
- document.title = 'OK';
+ function displayAndWaitForVideo(stream) {
+ gLocalStream = stream;
+ var localStreamUrl = webkitURL.createObjectURL(stream);
+ $('local-view').src = localStreamUrl;
+ waitForVideo('local-view');
+ }
+
+ function createAndRenderClone(stream) {
+ gLocalStream = stream;
+
+ var new_stream = new webkitMediaStream(stream.getAudioTracks());
+ expectEquals(new_stream.getAudioTracks().length, 1);
+ new_stream.addTrack(stream.getVideoTracks()[0]);
+ expectEquals(new_stream.getVideoTracks().length, 1);
+ new_stream.removeTrack(new_stream.getAudioTracks()[0]);
+ expectEquals(new_stream.getAudioTracks().length, 0);
+
+ var newStreamUrl = webkitURL.createObjectURL(new_stream);
+ $('local-view').src = newStreamUrl;
+ waitForVideo('local-view');
}
- </script>
+
+ </script>
</head>
+<body>
+ <table border="0">
+ <tr>
+ <td>Local Preview</td>
+ </tr>
+ <tr>
+ <td><video width="320" height="240" id="local-view"
+ autoplay="autoplay"></video></td>
+ <!-- Canvases are named after their corresponding video elements. -->
+ <td><canvas width="320" height="240" id="local-view-canvas"
+ style="display:none"></canvas></td>
+ </tr>
+ </table>
+</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698