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

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

Issue 601083002: Allow WebRTC tests that watch for black frames to be off by one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | 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
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (pixels[i] != previousPixels[i]) { 180 if (pixels[i] != previousPixels[i]) {
181 return true; 181 return true;
182 } 182 }
183 } 183 }
184 return false; 184 return false;
185 } 185 }
186 186
187 function isVideoBlack(pixels) { 187 function isVideoBlack(pixels) {
188 for (var i = 0; i < pixels.length; i++) { 188 for (var i = 0; i < pixels.length; i++) {
189 // |pixels| is in RGBA. Ignore the alpha channel. 189 // |pixels| is in RGBA. Ignore the alpha channel.
190 if (pixels[i] != 0 && (i + 1) % 4 != 0) { 190 // We allow it to be off by 1, to account for rounding errors in YUV
191 // conversion.
192 if (pixels[i] != 0 && pixels[i] != 1 && (i + 1) % 4 != 0) {
191 return false; 193 return false;
192 } 194 }
193 } 195 }
194 return true; 196 return true;
195 } 197 }
196 198
197 // This function matches |left| and |right| and fails the test if the 199 // This function matches |left| and |right| and fails the test if the
198 // values don't match using normal javascript equality (i.e. the hard 200 // values don't match using normal javascript equality (i.e. the hard
199 // types of the operands aren't checked). 201 // types of the operands aren't checked).
200 function assertEquals(expected, actual) { 202 function assertEquals(expected, actual) {
201 if (actual != expected) { 203 if (actual != expected) {
202 failTest("expected '" + expected + "', got '" + actual + "'."); 204 failTest("expected '" + expected + "', got '" + actual + "'.");
203 } 205 }
204 } 206 }
205 207
206 function assertNotEquals(expected, actual) { 208 function assertNotEquals(expected, actual) {
207 if (actual === expected) { 209 if (actual === expected) {
208 failTest("expected '" + expected + "', got '" + actual + "'."); 210 failTest("expected '" + expected + "', got '" + actual + "'.");
209 } 211 }
210 } 212 }
211 213
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698