Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: chrome/test/data/webui/async.js

Issue 7576024: Provide ability for WebUIBrowserTests to run asynchronous tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments, fixed chrome.send passthrough, fixed assertion tests to use runTestFunction. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/webui/assertions.js ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « chrome/test/data/webui/assertions.js ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698