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

Side by Side Diff: chrome/test/data/extensions/api_test/file_manager_browsertest/background.js

Issue 15809007: Clean up browser tests in Files.app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed further comments. Created 7 years, 6 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 | « no previous file | chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 /** 5 /**
6 * Extension ID of Files.app. 6 * Extension ID of Files.app.
7 * @type {string} 7 * @type {string}
8 * @const 8 * @const
9 */ 9 */
10 var FILE_MANAGER_EXTENSIONS_ID = 'hhaomjibdihmijegdhdafkllkbggdgoj'; 10 var FILE_MANAGER_EXTENSIONS_ID = 'hhaomjibdihmijegdhdafkllkbggdgoj';
(...skipping 10 matching lines...) Expand all
21 function callRemoteTestUtil(func, appId, args, callback) { 21 function callRemoteTestUtil(func, appId, args, callback) {
22 chrome.runtime.sendMessage( 22 chrome.runtime.sendMessage(
23 FILE_MANAGER_EXTENSIONS_ID, { 23 FILE_MANAGER_EXTENSIONS_ID, {
24 func: func, 24 func: func,
25 appId: appId, 25 appId: appId,
26 args: args 26 args: args
27 }, 27 },
28 callback); 28 callback);
29 } 29 }
30 30
31 /**
32 * Executes a sequence of test steps.
33 * @constructor
34 */
35 function StepsRunner() {
36 /**
37 * List of steps.
38 * @type {Array.function>}
39 * @private
40 */
41 this.steps_ = [];
42 }
43
44 /**
45 * Creates a StepsRunner instance and runs the passed steps.
46 */
47 StepsRunner.run = function(steps) {
48 var stepsRunner = new StepsRunner();
49 stepsRunner.run_(steps);
50 };
51
52 StepsRunner.prototype = {
53 /**
54 * @return {function} The next closure.
55 */
56 get next() {
57 return this.steps_.shift();
58 }
59 };
60
61 /**
62 * Runs a sequence of the added test steps.
63 * @type {Array.<function>} List of the sequential steps.
64 */
65 StepsRunner.prototype.run_ = function(steps) {
66 this.steps_ = steps.slice(0);
67
68 // An extra step which acts as an empty callback for optional asynchronous
69 // calls in the last provided step.
70 this.steps_.push(function() {});
71
72 this.steps_ = this.steps_.map(function(f) {
73 return chrome.test.callbackPass(f.bind(this));
74 }.bind(this));
75
76 this.next();
77 };
78
31 chrome.test.runTests([ 79 chrome.test.runTests([
32 // Waits for the C++ code to send a string identifying a test, then runs that 80 // Waits for the C++ code to send a string identifying a test, then runs that
33 // test. 81 // test.
34 function testRunner() { 82 function testRunner() {
35 var command = chrome.extension.inIncognitoContext ? 'which test guest' : 83 var command = chrome.extension.inIncognitoContext ? 'which test guest' :
36 'which test non-guest'; 84 'which test non-guest';
37 chrome.test.sendMessage(command, function(testCaseName) { 85 chrome.test.sendMessage(command, function(testCaseName) {
38 // Run one of the test cases defined in the testcase namespace, in 86 // Run one of the test cases defined in the testcase namespace, in
39 // test_cases.js. The test case name is passed via StartTest call in 87 // test_cases.js. The test case name is passed via StartTest call in
40 // file_manager_browsertest.cc. 88 // file_manager_browsertest.cc.
41 if (testcase[testCaseName]) 89 if (testcase[testCaseName])
42 testcase[testCaseName](); 90 testcase[testCaseName]();
43 else 91 else
44 chrome.test.fail('Bogus test name passed to testRunner()'); 92 chrome.test.fail('Bogus test name passed to testRunner()');
45 }); 93 });
46 } 94 }
47 ]); 95 ]);
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698