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

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

Issue 15682007: Files.app: Removed a side effect of StepsRunner.next. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a JsDoc. 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 | no next file » | 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 17 matching lines...) Expand all
28 callback); 28 callback);
29 } 29 }
30 30
31 /** 31 /**
32 * Executes a sequence of test steps. 32 * Executes a sequence of test steps.
33 * @constructor 33 * @constructor
34 */ 34 */
35 function StepsRunner() { 35 function StepsRunner() {
36 /** 36 /**
37 * List of steps. 37 * List of steps.
38 * @type {Array.function>} 38 * @type {Array.<function>}
mtomasz 2013/06/04 03:41:59 Oops! Thanks!
39 * @private 39 * @private
40 */ 40 */
41 this.steps_ = []; 41 this.steps_ = [];
42 } 42 }
43 43
44 /** 44 /**
45 * Creates a StepsRunner instance and runs the passed steps. 45 * Creates a StepsRunner instance and runs the passed steps.
46 */ 46 */
47 StepsRunner.run = function(steps) { 47 StepsRunner.run = function(steps) {
48 var stepsRunner = new StepsRunner(); 48 var stepsRunner = new StepsRunner();
49 stepsRunner.run_(steps); 49 stepsRunner.run_(steps);
50 }; 50 };
51 51
52 StepsRunner.prototype = { 52 StepsRunner.prototype = {
53 /** 53 /**
54 * @return {function} The next closure. 54 * @return {function} The next closure.
55 */ 55 */
56 get next() { 56 get next() {
57 return this.steps_.shift(); 57 return this.steps_[0];
58 } 58 }
59 }; 59 };
60 60
61 /** 61 /**
62 * Runs a sequence of the added test steps. 62 * Runs a sequence of the added test steps.
63 * @type {Array.<function>} List of the sequential steps. 63 * @type {Array.<function>} List of the sequential steps.
64 */ 64 */
65 StepsRunner.prototype.run_ = function(steps) { 65 StepsRunner.prototype.run_ = function(steps) {
66 this.steps_ = steps.slice(0); 66 this.steps_ = steps.slice(0);
67 67
68 // An extra step which acts as an empty callback for optional asynchronous 68 // An extra step which acts as an empty callback for optional asynchronous
69 // calls in the last provided step. 69 // calls in the last provided step.
70 this.steps_.push(function() {}); 70 this.steps_.push(function() {});
71 71
72 this.steps_ = this.steps_.map(function(f) { 72 this.steps_ = this.steps_.map(function(f) {
73 return chrome.test.callbackPass(f.bind(this)); 73 return chrome.test.callbackPass(function() {
74 this.steps_.shift();
75 f.apply(this, arguments);
76 }.bind(this));
74 }.bind(this)); 77 }.bind(this));
75 78
76 this.next(); 79 this.next();
77 }; 80 };
78 81
79 chrome.test.runTests([ 82 chrome.test.runTests([
80 // Waits for the C++ code to send a string identifying a test, then runs that 83 // Waits for the C++ code to send a string identifying a test, then runs that
81 // test. 84 // test.
82 function testRunner() { 85 function testRunner() {
83 var command = chrome.extension.inIncognitoContext ? 'which test guest' : 86 var command = chrome.extension.inIncognitoContext ? 'which test guest' :
84 'which test non-guest'; 87 'which test non-guest';
85 chrome.test.sendMessage(command, function(testCaseName) { 88 chrome.test.sendMessage(command, function(testCaseName) {
86 // Run one of the test cases defined in the testcase namespace, in 89 // Run one of the test cases defined in the testcase namespace, in
87 // test_cases.js. The test case name is passed via StartTest call in 90 // test_cases.js. The test case name is passed via StartTest call in
88 // file_manager_browsertest.cc. 91 // file_manager_browsertest.cc.
89 if (testcase[testCaseName]) 92 if (testcase[testCaseName])
90 testcase[testCaseName](); 93 testcase[testCaseName]();
91 else 94 else
92 chrome.test.fail('Bogus test name passed to testRunner()'); 95 chrome.test.fail('Bogus test name passed to testRunner()');
93 }); 96 });
94 } 97 }
95 ]); 98 ]);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698