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 a test case, but this can be overridden. |
phoglund_chromium
2013/09/09 07:56:34
by an automated test case, such as a browser test
kjellander_chromium
2013/09/09 08:11:53
Done.
| |
18 * @private | 18 * @private |
19 */ | 19 */ |
20 var gReturnCallback = sendToPyAuto; | 20 var gReturnCallback = sendToTest; |
21 | 21 |
22 /** | 22 /** |
23 * The callback to send debug messages to. By default we assume console.log. | 23 * The callback to send debug messages to. By default we assume console.log. |
24 * @private | 24 * @private |
25 */ | 25 */ |
26 var gDebugCallback = consoleLog_; | 26 var gDebugCallback = consoleLog_; |
27 | 27 |
28 /** | 28 /** |
29 * Returns the list of errors and clears the list. | 29 * Returns the list of errors and clears the list. |
30 * | 30 * |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 /** | 79 /** |
80 * Sends a value back to the test. | 80 * Sends a value back to the test. |
81 * | 81 * |
82 * @param {string} message The message to return. | 82 * @param {string} message The message to return. |
83 */ | 83 */ |
84 function returnToTest(message) { | 84 function returnToTest(message) { |
85 gReturnCallback(message); | 85 gReturnCallback(message); |
86 } | 86 } |
87 | 87 |
88 /** | 88 /** |
89 * Sends a message to the PyAuto test case. Requires that this javascript was | 89 * 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 | 90 * loaded by the test. This will make the test proceed if it is blocked in a |
91 * ExecuteJavascript call. | 91 * ExecuteJavascript call. |
92 * | 92 * |
93 * @param {string} message The message to send. | 93 * @param {string} message The message to send. |
94 */ | 94 */ |
95 function sendToPyAuto(message) { | 95 function sendToTest(message) { |
96 debug('Returning ' + message + ' to PyAuto.'); | 96 debug('Returning ' + message + ' to test.'); |
97 window.domAutomationController.send(message); | 97 window.domAutomationController.send(message); |
98 } | 98 } |
99 | 99 |
100 /** | 100 /** |
101 * Adds a test failure without affecting the control flow. If the test is | 101 * 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 | 102 * 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 | 103 * message. Otherwise, the error is saved and it is up to the test to check it |
104 * with getAnyTestFailures. | 104 * with getAnyTestFailures. |
105 * | 105 * |
106 * @param {string} reason The reason why the test failed. | 106 * @param {string} reason The reason why the test failed. |
(...skipping 15 matching lines...) Expand all Loading... | |
122 function failTest(reason) { | 122 function failTest(reason) { |
123 addTestFailure(reason); | 123 addTestFailure(reason); |
124 return new Error(reason); | 124 return new Error(reason); |
125 } | 125 } |
126 | 126 |
127 /** @private */ | 127 /** @private */ |
128 function consoleLog_(message) { | 128 function consoleLog_(message) { |
129 // It is not legal to treat console.log as a first-class object, so wrap it. | 129 // It is not legal to treat console.log as a first-class object, so wrap it. |
130 console.log(message); | 130 console.log(message); |
131 } | 131 } |
OLD | NEW |