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 // If a test is reported to succeed and later a crash occurs |
phoglund_chromium
2015/04/10 09:47:58
Well, it's not "in the scope of the timer", it's r
perkj_chrome
2015/04/10 09:57:29
Done.
| |
30 // after the reporting JavaScript has completed, the test will pass. | |
31 // By completing the test in the scope of a timer, the reporting | |
32 // JavaScript will finish and if that leads to a crash, it happens | |
33 // before the test is reported to pass. | |
34 setTimeout(function () { | |
35 window.domAutomationController.send('OK'); | |
36 }, 0); | |
30 } | 37 } |
31 | 38 |
32 // Returns a custom return value to the test. | 39 // Returns a custom return value to the test. |
33 function sendValueToTest(value) { | 40 function sendValueToTest(value) { |
34 window.domAutomationController.send(value); | 41 window.domAutomationController.send(value); |
35 } | 42 } |
36 | 43 |
37 // Immediately fails the test on the C++ side. | 44 // Immediately fails the test on the C++ side. |
38 function failTest(reason) { | 45 function failTest(reason) { |
39 var error = new Error(reason); | 46 var error = new Error(reason); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 devices.forEach(function(device) { | 228 devices.forEach(function(device) { |
222 if (device.kind == 'video') | 229 if (device.kind == 'video') |
223 hasVideoInputDevice = true; | 230 hasVideoInputDevice = true; |
224 }); | 231 }); |
225 | 232 |
226 if (hasVideoInputDevice) | 233 if (hasVideoInputDevice) |
227 sendValueToTest('has-video-input-device'); | 234 sendValueToTest('has-video-input-device'); |
228 else | 235 else |
229 sendValueToTest('no-video-input-devices'); | 236 sendValueToTest('no-video-input-devices'); |
230 }); | 237 }); |
231 } | 238 } |
OLD | NEW |