OLD | NEW |
1 /** | 1 /** |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /** | 7 /** |
8 * This list keeps track of failures in the test. This is necessary to keep | 8 * This list keeps track of failures in the test. This is necessary to keep |
9 * track of failures that happen outside of PyAuto test calls and need to be | 9 * track of failures that happen outside of test calls and need to be reported |
10 * reported asynchronously. | 10 * asynchronously. |
11 * @private | 11 * @private |
12 */ | 12 */ |
13 var gFailures = []; | 13 var gFailures = []; |
14 | 14 |
15 /** | 15 /** |
16 * The callback to send test messages to. By default we will assume that we | 16 * The callback to send test messages to. By default we will assume that we |
17 * are being run by a PyAuto test case, but this can be overridden. | 17 * are being run by an automated test case such as a browser test, but this can |
| 18 * be overridden. |
18 * @private | 19 * @private |
19 */ | 20 */ |
20 var gReturnCallback = sendToPyAuto; | 21 var gReturnCallback = sendToTest; |
21 | 22 |
22 /** | 23 /** |
23 * The callback to send debug messages to. By default we assume console.log. | 24 * The callback to send debug messages to. By default we assume console.log. |
24 * @private | 25 * @private |
25 */ | 26 */ |
26 var gDebugCallback = consoleLog_; | 27 var gDebugCallback = consoleLog_; |
27 | 28 |
28 /** | 29 /** |
29 * Returns the list of errors and clears the list. | 30 * Returns the list of errors and clears the list. |
30 * | 31 * |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 /** | 80 /** |
80 * Sends a value back to the test. | 81 * Sends a value back to the test. |
81 * | 82 * |
82 * @param {string} message The message to return. | 83 * @param {string} message The message to return. |
83 */ | 84 */ |
84 function returnToTest(message) { | 85 function returnToTest(message) { |
85 gReturnCallback(message); | 86 gReturnCallback(message); |
86 } | 87 } |
87 | 88 |
88 /** | 89 /** |
89 * Sends a message to the PyAuto test case. Requires that this javascript was | 90 * Sends a message to the test case. Requires that this javascript was |
90 * loaded by PyAuto. This will make the test proceed if it is blocked in a | 91 * loaded by the test. This will make the test proceed if it is blocked in a |
91 * ExecuteJavascript call. | 92 * ExecuteJavascript call. |
92 * | 93 * |
93 * @param {string} message The message to send. | 94 * @param {string} message The message to send. |
94 */ | 95 */ |
95 function sendToPyAuto(message) { | 96 function sendToTest(message) { |
96 debug('Returning ' + message + ' to PyAuto.'); | 97 debug('Returning ' + message + ' to test.'); |
97 window.domAutomationController.send(message); | 98 window.domAutomationController.send(message); |
98 } | 99 } |
99 | 100 |
100 /** | 101 /** |
101 * Adds a test failure without affecting the control flow. If the test is | 102 * Adds a test failure without affecting the control flow. If the test is |
102 * blocked, this function will immediately break that call with an error | 103 * blocked, this function will immediately break that call with an error |
103 * message. Otherwise, the error is saved and it is up to the test to check it | 104 * message. Otherwise, the error is saved and it is up to the test to check it |
104 * with getAnyTestFailures. | 105 * with getAnyTestFailures. |
105 * | 106 * |
106 * @param {string} reason The reason why the test failed. | 107 * @param {string} reason The reason why the test failed. |
(...skipping 15 matching lines...) Expand all Loading... |
122 function failTest(reason) { | 123 function failTest(reason) { |
123 addTestFailure(reason); | 124 addTestFailure(reason); |
124 return new Error(reason); | 125 return new Error(reason); |
125 } | 126 } |
126 | 127 |
127 /** @private */ | 128 /** @private */ |
128 function consoleLog_(message) { | 129 function consoleLog_(message) { |
129 // It is not legal to treat console.log as a first-class object, so wrap it. | 130 // It is not legal to treat console.log as a first-class object, so wrap it. |
130 console.log(message); | 131 console.log(message); |
131 } | 132 } |
OLD | NEW |