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

Side by Side Diff: content/test/data/media/canvas_capture.html

Issue 2658973002: Add content_browsertest for checking canvas capture frame rate (Closed)
Patch Set: add content browsertest Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « content/browser/webrtc/webrtc_capture_from_element_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Media Capture from DOM Elements (video/audio) Browser Test</title>
5 </head>
6 <body>
7 <div> Capture and playback from video/audio elements.</div>
8 </body>
9 <script type="text/javascript" src="webrtc_test_utilities.js"></script>
10 <script>
11
12 'use strict';
13
14 const NUMBER_OF_EVENTS_TO_RECORD = 15;
15 const ON_DATA_AVAILABLE_THRESHOLD = 10;
16
17 function checkForRedraw(canvas, drawCounter, drawFunction) {
18 if (++drawCounter <= NUMBER_OF_EVENTS_TO_RECORD)
19 requestAnimationFrame(function(){drawFunction(canvas, drawCounter)})
20 }
21
22 function draw2d(canvas, drawCounter) {
23 var ctx = canvas.getContext('2d');
24 ctx.fillStyle = 'green';
25 ctx.fillRect(0, 0, canvas.width, canvas.height);
26 checkForRedraw(canvas, drawCounter, draw2d);
27 };
28
29 function drawWebGL(canvas, drawCounter) {
30 var gl = canvas.getContext('webgl');
31 gl.clearColor(0, 1, 0, 1);
32 gl.clear(gl.COLOR_BUFFER_BIT);
33 checkForRedraw(canvas, drawCounter, drawWebGL);
34 };
35
36 function testCanvasCapture(drawFunction) {
37 var canvas = document.createElement('canvas');
38 document.body.appendChild(canvas);
39
40 var stream = canvas.captureStream();
41 assertTrue(stream, 'Error creating MediaStream');
42 assertEquals(1, stream.getVideoTracks().length);
43 assertEquals(0, stream.getAudioTracks().length);
44
45 var recorded_events = 0;
46 const recorder = new MediaRecorder(stream);
47 assertTrue(recorder, 'Error creating recorder out of the MediaStream');
48
49 recorder.ondataavailable = function(event) {
50 if (event.data.size > ON_DATA_AVAILABLE_THRESHOLD) {
51 if (++recorded_events == NUMBER_OF_EVENTS_TO_RECORD)
52 reportTestSuccess();
53 }
54 };
55
56 recorder.start(0);
57 drawFunction(canvas, 0);
58 }
59
60 </script>
61 </body>
62 </html>
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_capture_from_element_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698