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

Unified Diff: third_party/WebKit/LayoutTests/media/video-capture-preview.html

Issue 2112003002: Convert video-canvas* and video-capture* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use timeupdate event Created 4 years, 6 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: third_party/WebKit/LayoutTests/media/video-capture-preview.html
diff --git a/third_party/WebKit/LayoutTests/media/video-capture-preview.html b/third_party/WebKit/LayoutTests/media/video-capture-preview.html
index c1ce6ff92b64fe65d47b6a3f575189337c248bae..be5d798c8a6b063c6d370508eab85bec214205d0 100644
--- a/third_party/WebKit/LayoutTests/media/video-capture-preview.html
+++ b/third_party/WebKit/LayoutTests/media/video-capture-preview.html
@@ -1,70 +1,33 @@
-<!DOCTYPE HTML">
-<html>
-<head>
-<script src=media-file.js></script>
-<!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
-<script src=video-test.js></script>
-<script src=video-played.js></script>
-
-<script type="text/javascript">
-
-var previewURL = "";
-var localStream = null;
-
-if (window.internals)
- window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
-
-function startPreview()
-{
- video.src = previewURL;
-}
-
-function gotStream(stream)
-{
- consoleWrite("got a stream");
- previewURL = URL.createObjectURL(stream);
- startPreview();
- consoleWrite("start preview");
- localStream = stream;
- var playTimeInMillisecond = 2500;
- var replayIfTimeIsReached = function ()
- {
- startPreview();
- consoleWrite("restart preview");
- setTimeout(endTest, playTimeInMillisecond);
+<!DOCTYPE html>
+<title>Verify video play using media stream as video src.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<video autoplay></video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ navigator.webkitGetUserMedia({video:true}, function(stream) {
+ var previewURL = URL.createObjectURL(stream);
+
+ video.ontimeupdate = t.step_func(function() {
+ // restart preview.
+ video.src = previewURL;
+ video.ontimeupdate = t.step_func_done();
+ });
+
+ //start preview.
+ video.src = previewURL;
+ }, getStreamFailed);
+
+ function getStreamFailed(error) {
+ t.unreached_func();
}
- setTimeout(replayIfTimeIsReached, playTimeInMillisecond);
-}
-
-function gotStreamFailed(error)
-{
- consoleWrite("Failed to get access to local media. Error code was " + error.code);
-}
-
-function playPreview()
-{
- findMediaElement();
- try {
- consoleWrite("request access to local media");
- navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed);
- } catch (e) {
- consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")");
- }
-
- waitForEvent("error");
- waitForEvent("loadstart");
- waitForEvent("loadeddata");
- waitForEvent("canplay");
- waitForEvent("play");
- waitForEvent("canplaythrough");
-}
-
-</script>
-</head>
-
-<body onload="playPreview()">
-<video width="320" height="240" autoplay="autoplay"></video>
-</body>
-</html>
+ video.onerror = t.unreached_func();
+ video.onloadstart = t.step_func(function() {});
+ video.onloadeddata = t.step_func(function() {});
+ video.oncanplay = t.step_func(function() {});
+ video.onplay = t.step_func(function() {});
+ video.oncanplaythrough = t.step_func(function() {});
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698