OLD | NEW |
---|---|
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 Loading... | |
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 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.
| |
68 this.steps_ = this.steps_.map(function(f) { | |
69 return chrome.test.callbackPass(f.bind(this)); | |
70 }.bind(this)); | |
71 this.next(); | |
72 }; | |
73 | |
31 chrome.test.runTests([ | 74 chrome.test.runTests([ |
32 // Waits for the C++ code to send a string identifying a test, then runs that | 75 // Waits for the C++ code to send a string identifying a test, then runs that |
33 // test. | 76 // test. |
34 function testRunner() { | 77 function testRunner() { |
35 var command = chrome.extension.inIncognitoContext ? 'which test guest' : | 78 var command = chrome.extension.inIncognitoContext ? 'which test guest' : |
36 'which test non-guest'; | 79 'which test non-guest'; |
37 chrome.test.sendMessage(command, function(testCaseName) { | 80 chrome.test.sendMessage(command, function(testCaseName) { |
38 // Run one of the test cases defined in the testcase namespace, in | 81 // 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 | 82 // test_cases.js. The test case name is passed via StartTest call in |
40 // file_manager_browsertest.cc. | 83 // file_manager_browsertest.cc. |
41 if (testcase[testCaseName]) | 84 if (testcase[testCaseName]) |
42 testcase[testCaseName](); | 85 testcase[testCaseName](); |
43 else | 86 else |
44 chrome.test.fail('Bogus test name passed to testRunner()'); | 87 chrome.test.fail('Bogus test name passed to testRunner()'); |
45 }); | 88 }); |
46 } | 89 } |
47 ]); | 90 ]); |
OLD | NEW |