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 StepsRunner.prototype = { | |
45 /** | |
46 * @return {function} The next closure. | |
47 */ | |
48 get next() { | |
49 return this.steps_.shift(); | |
50 } | |
51 }; | |
52 | |
53 /** | |
54 * Runs a sequence of the added test steps. | |
55 * @type {Array.<function>} List of the sequential steps. | |
56 */ | |
57 StepsRunner.prototype.run = function(steps) { | |
58 this.steps_ = steps.slice(0); | |
59 this.steps_.push(function() {}); | |
hirono
2013/05/30 04:46:10
How about putting 'checkIfNoErrorsOccured' here?
mtomasz
2013/05/30 06:40:53
I was thinking about, however I thought that putti
hirono
2013/05/30 07:08:59
I'm not sure, but StepsRunner already have the rol
mtomasz
2013/05/30 07:30:11
Hm, callbackPass is just a utility to make tests w
hashimoto
2013/05/30 08:21:45
I feel neutral about this point.
Making StepsRunne
mtomasz
2013/05/30 08:51:26
That's a good idea. I will write a utility which a
| |
60 this.steps_ = this.steps_.map(function(f) { | |
61 return chrome.test.callbackPass(f); | |
62 }); | |
63 this.next(); | |
64 }; | |
65 | |
31 chrome.test.runTests([ | 66 chrome.test.runTests([ |
32 // Waits for the C++ code to send a string identifying a test, then runs that | 67 // Waits for the C++ code to send a string identifying a test, then runs that |
33 // test. | 68 // test. |
34 function testRunner() { | 69 function testRunner() { |
35 var command = chrome.extension.inIncognitoContext ? 'which test guest' : | 70 var command = chrome.extension.inIncognitoContext ? 'which test guest' : |
36 'which test non-guest'; | 71 'which test non-guest'; |
37 chrome.test.sendMessage(command, function(testCaseName) { | 72 chrome.test.sendMessage(command, function(testCaseName) { |
38 // Run one of the test cases defined in the testcase namespace, in | 73 // 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 | 74 // test_cases.js. The test case name is passed via StartTest call in |
40 // file_manager_browsertest.cc. | 75 // file_manager_browsertest.cc. |
41 if (testcase[testCaseName]) | 76 if (testcase[testCaseName]) |
42 testcase[testCaseName](); | 77 testcase[testCaseName](); |
43 else | 78 else |
44 chrome.test.fail('Bogus test name passed to testRunner()'); | 79 chrome.test.fail('Bogus test name passed to testRunner()'); |
45 }); | 80 }); |
46 } | 81 } |
47 ]); | 82 ]); |
OLD | NEW |