OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Fails always. |
| 7 * @throw {Error} |
| 8 */ |
| 9 function testFailsAssert() { |
| 10 assertNotReached(); |
| 11 chrome.send('testContinues'); |
| 12 assertNotReached(); |
| 13 } |
| 14 |
| 15 /** |
| 16 * Records failure. |
| 17 */ |
| 18 function testFailsExpect() { |
| 19 expectNotReached(); |
| 20 chrome.send('testContinues'); |
| 21 expectNotReached(); |
| 22 } |
| 23 |
| 24 /** |
| 25 * Passes and sends testDone message for browser_test to call |
| 26 * testDone(). |
| 27 */ |
| 28 function testPasses() { |
| 29 expectTrue(true); |
| 30 chrome.send('testContinues'); |
| 31 assertFalse(false); |
| 32 } |
| 33 |
| 34 function testAsyncDoneFailFirstSyncPass() { |
| 35 expectNotReached(); |
| 36 chrome.send('testContinues'); |
| 37 } |
| 38 |
| 39 /** |
| 40 * Wraps the function represented by |name| similar to the way net_internals |
| 41 * tests are wrapped. |
| 42 * @param {string} name The name of the function to run. |
| 43 */ |
| 44 function runAsync(name) { |
| 45 // Strip |name| from arguments. |
| 46 var testArguments = Array.prototype.slice.call(arguments, 1); |
| 47 |
| 48 // call async function. |
| 49 var result = runTestFunction(name, this[name], testArguments); |
| 50 |
| 51 // Pass on success; bail on errors. |
| 52 if (result[0]) { |
| 53 chrome.send('testPasses'); |
| 54 } else { |
| 55 chrome.send('testFails'); |
| 56 testDone(result); |
| 57 } |
| 58 } |
| 59 |
| 60 /** |
| 61 * Sends a message to handler to start |testName| and returns. |
| 62 * @param {string} testName The name of the test to run. |
| 63 */ |
| 64 function startAsyncTest(testName) { |
| 65 chrome.send('startAsyncTest', [testName]); |
| 66 } |
OLD | NEW |