Chromium Code Reviews| 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; |
| 11 | 11 |
| 12 // Number of test events to occur before the test pass. When the test pass, | 12 // Number of test events to occur before the test pass. When the test pass, |
| 13 // the function gAllEventsOccured is called. | 13 // the function gAllEventsOccured is called. |
| 14 var gNumberOfExpectedEvents = 0; | 14 var gNumberOfExpectedEvents = 0; |
| 15 | 15 |
| 16 // Number of events that currently have occurred. | 16 // Number of events that currently have occurred. |
| 17 var gNumberOfEvents = 0; | 17 var gNumberOfEvents = 0; |
| 18 | 18 |
| 19 var gAllEventsOccured = function () {}; | 19 var gAllEventsOccured = function () {}; |
| 20 | 20 |
| 21 // Use this function to set a function that will be called once all expected | 21 // Use this function to set a function that will be called once all expected |
| 22 // events has occurred. | 22 // events has occurred. |
| 23 function setAllEventsOccuredHandler(handler) { | 23 function setAllEventsOccuredHandler(handler) { |
| 24 gAllEventsOccured = handler; | 24 gAllEventsOccured = handler; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Tells the C++ code we succeeded, which will generally exit the test. | 27 // Tells the C++ code we succeeded, which will generally exit the test. |
| 28 function reportTestSuccess() { | 28 function reportTestSuccess() { |
| 29 window.domAutomationController.send('OK'); | 29 // This function enqueues sending an OK back to the test, rather than doing |
|
phoglund_chromium
2015/04/10 09:58:40
Nit: indent comments 2 steps.
| |
| 30 // it directly. We do this so we catch crashes that occur in the current | |
| 31 // execution context, but after reportTestSuccess is invoked. | |
| 32 setTimeout(function () { | |
| 33 window.domAutomationController.send('OK'); | |
| 34 }, 0); | |
| 30 } | 35 } |
| 31 | 36 |
| 32 // Returns a custom return value to the test. | 37 // Returns a custom return value to the test. |
| 33 function sendValueToTest(value) { | 38 function sendValueToTest(value) { |
| 34 window.domAutomationController.send(value); | 39 window.domAutomationController.send(value); |
| 35 } | 40 } |
| 36 | 41 |
| 37 // Immediately fails the test on the C++ side. | 42 // Immediately fails the test on the C++ side. |
| 38 function failTest(reason) { | 43 function failTest(reason) { |
| 39 var error = new Error(reason); | 44 var error = new Error(reason); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 devices.forEach(function(device) { | 226 devices.forEach(function(device) { |
| 222 if (device.kind == 'video') | 227 if (device.kind == 'video') |
| 223 hasVideoInputDevice = true; | 228 hasVideoInputDevice = true; |
| 224 }); | 229 }); |
| 225 | 230 |
| 226 if (hasVideoInputDevice) | 231 if (hasVideoInputDevice) |
| 227 sendValueToTest('has-video-input-device'); | 232 sendValueToTest('has-video-input-device'); |
| 228 else | 233 else |
| 229 sendValueToTest('no-video-input-devices'); | 234 sendValueToTest('no-video-input-devices'); |
| 230 }); | 235 }); |
| 231 } | 236 } |
| OLD | NEW |