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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/media/canvas_capture.html
diff --git a/content/test/data/media/canvas_capture.html b/content/test/data/media/canvas_capture.html
new file mode 100644
index 0000000000000000000000000000000000000000..15a904264cd67b56b580adbe8d4a03ca7311dda7
--- /dev/null
+++ b/content/test/data/media/canvas_capture.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Media Capture from DOM Elements (video/audio) Browser Test</title>
+</head>
+<body>
+ <div> Capture and playback from video/audio elements.</div>
+</body>
+<script type="text/javascript" src="webrtc_test_utilities.js"></script>
+<script>
+
+'use strict';
+
+const NUMBER_OF_EVENTS_TO_RECORD = 15;
+const ON_DATA_AVAILABLE_THRESHOLD = 10;
+
+function checkForRedraw(canvas, drawCounter, drawFunction) {
+ if (++drawCounter <= NUMBER_OF_EVENTS_TO_RECORD)
+ requestAnimationFrame(function(){drawFunction(canvas, drawCounter)})
+}
+
+function draw2d(canvas, drawCounter) {
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ checkForRedraw(canvas, drawCounter, draw2d);
+};
+
+function drawWebGL(canvas, drawCounter) {
+ var gl = canvas.getContext('webgl');
+ gl.clearColor(0, 1, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ checkForRedraw(canvas, drawCounter, drawWebGL);
+};
+
+function testCanvasCapture(drawFunction) {
+ var canvas = document.createElement('canvas');
+ document.body.appendChild(canvas);
+
+ var stream = canvas.captureStream();
+ assertTrue(stream, 'Error creating MediaStream');
+ assertEquals(1, stream.getVideoTracks().length);
+ assertEquals(0, stream.getAudioTracks().length);
+
+ var recorded_events = 0;
+ const recorder = new MediaRecorder(stream);
+ assertTrue(recorder, 'Error creating recorder out of the MediaStream');
+
+ recorder.ondataavailable = function(event) {
+ if (event.data.size > ON_DATA_AVAILABLE_THRESHOLD) {
+ if (++recorded_events == NUMBER_OF_EVENTS_TO_RECORD)
+ reportTestSuccess();
+ }
+ };
+
+ recorder.start(0);
+ drawFunction(canvas, 0);
+}
+
+</script>
+</body>
+</html>
« 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