Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| index bc60f6fb58f86668d2c4e8440117945320275a24..1c3d1a67a7641a825f013e8b1e5e1ec9a14ea975 100644 |
| --- a/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| +++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| @@ -28,6 +28,49 @@ function callRemoteTestUtil(func, appId, args, callback) { |
| callback); |
| } |
| +/** |
| + * Executes a sequence of test steps. |
| + * @constructor |
| + */ |
| +function StepsRunner() { |
| + /** |
| + * List of steps. |
| + * @type {Array.function>} |
| + * @private |
| + */ |
| + this.steps_ = []; |
| +} |
| + |
| +/** |
| + * Creates a StepsRunner instance and runs the passed steps. |
| + */ |
| +StepsRunner.run = function(steps) { |
| + var stepsRunner = new StepsRunner(); |
| + stepsRunner.run_(steps); |
| +}; |
| + |
| +StepsRunner.prototype = { |
| + /** |
| + * @return {function} The next closure. |
| + */ |
| + get next() { |
| + return this.steps_.shift(); |
| + } |
| +}; |
| + |
| +/** |
| + * Runs a sequence of the added test steps. |
| + * @type {Array.<function>} List of the sequential steps. |
| + */ |
| +StepsRunner.prototype.run_ = function(steps) { |
| + this.steps_ = steps.slice(0); |
| + this.steps_.push(function() {}); |
|
hashimoto
2013/05/30 08:21:45
nit: Please add a comment about the role of this e
mtomasz
2013/05/30 08:51:26
Done.
|
| + this.steps_ = this.steps_.map(function(f) { |
| + return chrome.test.callbackPass(f.bind(this)); |
| + }.bind(this)); |
| + this.next(); |
| +}; |
| + |
| chrome.test.runTests([ |
| // Waits for the C++ code to send a string identifying a test, then runs that |
| // test. |