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

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

Issue 68263016: Add simple test for VideoTrack.stop(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the video detector to work with fake devices. Created 7 years, 1 month 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.html
diff --git a/content/test/data/media/getusermedia.html b/content/test/data/media/getusermedia.html
index 14ce8d5755df0ef0e87e984232cbd8ece99066bc..80f57883ded5b52b13a43eb15637dda8abedfa92 100644
--- a/content/test/data/media/getusermedia.html
+++ b/content/test/data/media/getusermedia.html
@@ -5,19 +5,19 @@
$ = function(id) {
return document.getElementById(id);
};
-
+
var gLocalStream = null;
-
+
setAllEventsOccuredHandler(function() {
gLocalStream.stop();
- document.title = 'OK';
+ document.title = 'OK';
});
-
- // This test that a MediaStream can be created and a local preview
+
+ // This test that a MediaStream can be created and a local preview
// rendered.
function getUserMedia(constraints) {
- navigator.webkitGetUserMedia(constraints, displayAndWaitForVideo,
- failedCallback);
+ navigator.webkitGetUserMedia(constraints,
+ displayAndWaitForVideoToStartAndStop, failedCallback);
}
function getUserMediaWithAnalysis(constraints) {
@@ -25,22 +25,23 @@
constraints, displayAndWaitForAndAnalyzeVideo, failedCallback);
}
- // This test that a MediaStream can be cloned and that the clone can
+ // 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 displayAndWaitForVideo(stream) {
+ function displayAndWaitForVideoToStartAndStop(stream) {
gLocalStream = stream;
var localStreamUrl = webkitURL.createObjectURL(stream);
$('local-view').src = localStreamUrl;
- waitForVideo('local-view');
+ document.title = 'Waiting for video...';
+ detectVideoIn('local-view', stopVideoTrack);
phoglund_chromium 2013/11/14 09:01:18 This doesn't read very intuitively since IMO it lo
perkj_chrome 2013/11/14 13:29:07 Done.
}
function displayAndWaitForAndAnalyzeVideo(stream) {
@@ -53,7 +54,7 @@
function createAndRenderClone(stream) {
gLocalStream = stream;
// TODO(perkj): --use-fake-device-for-media-stream do not currently
- // work with audio devices and not all bots has a microphone.
+ // work with audio devices and not all bots has a microphone.
new_stream = new webkitMediaStream();
new_stream.addTrack(stream.getVideoTracks()[0]);
expectEquals(new_stream.getVideoTracks().length, 1);
@@ -63,12 +64,17 @@
new_stream.removeTrack(new_stream.getAudioTracks()[0]);
expectEquals(new_stream.getAudioTracks().length, 0);
}
-
+
var newStreamUrl = webkitURL.createObjectURL(new_stream);
- $('local-view').src = newStreamUrl;
+ $('local-view').src = newStreamUrl;
waitForVideo('local-view');
}
+ function stopVideoTrack() {
+ waitForVideoToStop('local-view');
phoglund_chromium 2013/11/14 09:01:18 You should be able to swap this statement and the
perkj_chrome 2013/11/14 13:29:07 Done.
+ gLocalStream.getVideoTracks()[0].stop();
+ }
+
function analyzeVideo() {
document.title = 'Waiting for video...';
addExpectedEvent();
@@ -78,7 +84,7 @@
});
}
- </script>
+ </script>
</head>
<body>
<table border="0">
@@ -87,7 +93,7 @@
</tr>
<tr>
<td><video width="320" height="240" id="local-view"
- autoplay="autoplay"></video></td>
+ 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>
« no previous file with comments | « no previous file | content/test/data/media/webrtc_test_utilities.js » ('j') | content/test/data/media/webrtc_test_utilities.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698