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

Side by Side Diff: content/test/data/media/webrtc_test_utilities.js

Issue 214663004: Add test for sending square resolution video on a PeerConnection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // These must match with how the video and canvas tags are declared in html. 5 // These must match with how the video and canvas tags are declared in html.
6 const VIDEO_TAG_WIDTH = 320; 6 const VIDEO_TAG_WIDTH = 320;
7 const VIDEO_TAG_HEIGHT = 240; 7 const VIDEO_TAG_HEIGHT = 240;
8 8
9 // Fake video capture background green is of value 135. 9 // Fake video capture background green is of value 135.
10 const COLOR_BACKGROUND_GREEN = 135; 10 const COLOR_BACKGROUND_GREEN = 135;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 var context = canvas.getContext('2d'); 65 var context = canvas.getContext('2d');
66 context.drawImage(videoElement, 0, 0, width, height); 66 context.drawImage(videoElement, 0, 0, width, height);
67 var pixels = context.getImageData(0, 0 , width, height / 3).data; 67 var pixels = context.getImageData(0, 0 , width, height / 3).data;
68 // Check that there is an old and a new picture with the same size to 68 // Check that there is an old and a new picture with the same size to
69 // compare and use the function |predicate| to detect the video state in 69 // compare and use the function |predicate| to detect the video state in
70 // that case. 70 // that case.
71 if (oldPixels.length == pixels.length && 71 if (oldPixels.length == pixels.length &&
72 predicate(pixels, oldPixels)) { 72 predicate(pixels, oldPixels)) {
73 console.log('Done looking at video in element ' + videoElementName); 73 console.log('Done looking at video in element ' + videoElementName);
74 clearInterval(waitVideo); 74 clearInterval(waitVideo);
75 callback(); 75 callback(videoElement.videoWidth, videoElement.videoHeight);
76 } 76 }
77 oldPixels = pixels; 77 oldPixels = pixels;
78 }, 200); 78 }, 200);
79 } 79 }
80 80
81 function waitForVideoAndExpectResolution(
82 videoElement,
phoglund_chromium 2014/03/28 08:33:30 Nit: indent 4 (or maybe if you can pull up the par
perkj_chrome 2014/03/28 09:14:23 Done.
83 expected_width,
84 expected_height) {
85 addExpectedEvent();
86 detectVideoPlaying(videoElement,
87 function (width, height) {
phoglund_chromium 2014/03/28 08:33:30 Nit: if you line break within the parameter list,
perkj_chrome 2014/03/28 09:14:23 Done.
88 assertEquals(expected_width, width);
89 assertEquals(expected_height, height);
90 eventOccured();
91 });
92 }
93
81 function waitForVideo(videoElement) { 94 function waitForVideo(videoElement) {
82 addExpectedEvent(); 95 addExpectedEvent();
83 detectVideoPlaying(videoElement, function () { eventOccured(); }); 96 detectVideoPlaying(videoElement, function () { eventOccured(); });
84 } 97 }
85 98
86 function waitForVideoToStop(videoElement) { 99 function waitForVideoToStop(videoElement) {
87 addExpectedEvent(); 100 addExpectedEvent();
88 detectVideoStopped(videoElement, function () { eventOccured(); }); 101 detectVideoStopped(videoElement, function () { eventOccured(); });
89 } 102 }
90 103
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 failTest("expected '" + expected + "', got '" + actual + "'."); 145 failTest("expected '" + expected + "', got '" + actual + "'.");
133 } 146 }
134 } 147 }
135 148
136 function assertNotEquals(expected, actual) { 149 function assertNotEquals(expected, actual) {
137 if (actual === expected) { 150 if (actual === expected) {
138 failTest("expected '" + expected + "', got '" + actual + "'."); 151 failTest("expected '" + expected + "', got '" + actual + "'.");
139 } 152 }
140 } 153 }
141 154
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698