| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |