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 * Namespace for test related things. | 6 * Namespace for test related things. |
7 */ | 7 */ |
8 var test = test || {}; | 8 var test = test || {}; |
9 | 9 |
10 /** | 10 /** |
11 * Namespace for test utility functions. | 11 * Namespace for test utility functions. |
12 */ | 12 */ |
13 test.util = {}; | 13 test.util = {}; |
14 | 14 |
15 /** | 15 /** |
16 * Extension ID of the testing extension. | 16 * Extension ID of the testing extension. |
17 * @type {string} | 17 * @type {string} |
18 * @const | 18 * @const |
19 */ | 19 */ |
20 test.util.TESTING_EXTENSION_ID = 'oobinhbdbiehknkpbpejbbpdbkdjmoco'; | 20 test.util.TESTING_EXTENSION_ID = 'oobinhbdbiehknkpbpejbbpdbkdjmoco'; |
21 | 21 |
22 /** | 22 /** |
23 * Opens the main Files.app's window and waits until it is ready. | 23 * Opens the main Files.app's window and waits until it is ready. |
24 * | 24 * |
25 * @param {string} path Path of the directory to be opened. | 25 * @param {string} path Path of the directory to be opened. |
26 * @param {function(string)} callback Completion callback with the new window's | 26 * @param {function(string)} callback Completion callback with the new window's |
27 * App ID. | 27 * App ID. |
28 */ | 28 */ |
29 test.util.openMainWindow = function(path, callback) { | 29 test.util.openMainWindow = function(path, callback) { |
30 var appId = launchFileManager({defaultPath: path}); | 30 var appId; |
31 function helper() { | 31 function helper() { |
32 if (appWindows[appId]) { | 32 if (appWindows[appId]) { |
33 var contentWindow = appWindows[appId].contentWindow; | 33 var contentWindow = appWindows[appId].contentWindow; |
34 var table = contentWindow.document.querySelector('#detail-table'); | 34 var table = contentWindow.document.querySelector('#detail-table'); |
35 if (table) { | 35 if (table) { |
36 callback(appId); | 36 callback(appId); |
37 return; | 37 return; |
38 } | 38 } |
39 } | 39 } |
40 window.setTimeout(helper, 50); | 40 window.setTimeout(helper, 50); |
41 } | 41 } |
42 helper(); | 42 launchFileManager({defaultPath: path}, |
| 43 undefined, // opt_type |
| 44 undefined, // opt_id |
| 45 function(id) { |
| 46 appId = id; |
| 47 helper(); |
| 48 }); |
43 }; | 49 }; |
44 | 50 |
45 /** | 51 /** |
46 * Gets total Javascript error count from each app window. | 52 * Gets total Javascript error count from each app window. |
47 * @return {number} Error count. | 53 * @return {number} Error count. |
48 */ | 54 */ |
49 test.util.getErrorCount = function() { | 55 test.util.getErrorCount = function() { |
50 var totalCount = 0; | 56 var totalCount = 0; |
51 for (var appId in appWindows) { | 57 for (var appId in appWindows) { |
52 var contentWindow = appWindows[appId].contentWindow; | 58 var contentWindow = appWindows[appId].contentWindow; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 default: | 473 default: |
468 console.error('Window function ' + request.func + ' not found.'); | 474 console.error('Window function ' + request.func + ' not found.'); |
469 } | 475 } |
470 } | 476 } |
471 return false; | 477 return false; |
472 }); | 478 }); |
473 }; | 479 }; |
474 | 480 |
475 // Register the test utils. | 481 // Register the test utils. |
476 test.util.registerRemoteTestUtils(); | 482 test.util.registerRemoteTestUtils(); |
OLD | NEW |