OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * pyautoAPI object provides a set of functions used by PyAuto tests | 6 * pyautoAPI object provides a set of functions used by PyAuto tests |
7 * to drive the file manager. | 7 * to drive the file manager. |
8 * | 8 * |
9 * Refer to chrome/test/functional/chromeos_file_browser.py for examples | 9 * Refer to chrome/test/functional/chromeos_file_browser.py for examples |
10 * of how this API is used. | 10 * of how this API is used. |
| 11 * |
| 12 * TODO(olege): Fix style warnings. |
11 */ | 13 */ |
12 var pyautoAPI = { | 14 var pyautoAPI = { |
13 /** | 15 /** |
14 * Add the item with given name to the current selection. | 16 * Add the item with given name to the current selection. |
15 * | 17 * |
16 * @param {string} name Name of the item to add to selection | 18 * @param {string} name Name of the item to add to selection |
17 * @return {boolean} Whether item exists. | 19 * @return {boolean} Whether item exists. |
18 */ | 20 */ |
19 addItemToSelection: function(name) { | 21 addItemToSelection: function(name) { |
20 var entryExists = false; | 22 var entryExists = false; |
21 var dm = fileManager.directoryModel_.fileList; | 23 var dm = fileManager.directoryModel_.getFileList(); |
22 for (var i = 0; i < dm.length; i++) { | 24 for (var i = 0; i < dm.length; i++) { |
23 if (dm.item(i).name == name) { | 25 if (dm.item(i).name == name) { |
24 fileManager.currentList_.selectionModel.setIndexSelected(i, true); | 26 fileManager.currentList_.selectionModel.setIndexSelected(i, true); |
25 fileManager.currentList_.scrollIndexIntoView(i); | 27 fileManager.currentList_.scrollIndexIntoView(i); |
26 fileManager.focusCurrentList_(); | 28 fileManager.focusCurrentList_(); |
27 entryExists = true; | 29 entryExists = true; |
28 break; | 30 break; |
29 } | 31 } |
30 } | 32 } |
31 this.sendValue_(entryExists); | 33 this.sendValue_(entryExists); |
32 }, | 34 }, |
33 | 35 |
34 /** | 36 /** |
35 * List all items in the current directory. | 37 * List all items in the current directory. |
36 * We assume names do not contain '|' charecter. | 38 * We assume names do not contain '|' charecter. |
37 * | 39 * |
38 * @return {object} A a list of item names. | 40 * @return {object} A a list of item names. |
39 */ | 41 */ |
40 listDirectory: function() { | 42 listDirectory: function() { |
41 var list = []; | 43 var list = []; |
42 var dm = fileManager.directoryModel_.fileList; | 44 var dm = fileManager.directoryModel_.getFileList(); |
43 for (var i = 0; i < dm.length; i++) { | 45 for (var i = 0; i < dm.length; i++) { |
44 list.push(dm.item(i).name); | 46 list.push(dm.item(i).name); |
45 } | 47 } |
46 this.sendJSONValue_(list); | 48 this.sendJSONValue_(list); |
47 }, | 49 }, |
48 | 50 |
49 /** | 51 /** |
50 * Save the item using the given name. | 52 * Save the item using the given name. |
51 * | 53 * |
52 * @param {string} name Name given to item to be saved. | 54 * @param {string} name Name given to item to be saved. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 window.domAutomationController.send(JSON.stringify(value)); | 223 window.domAutomationController.send(JSON.stringify(value)); |
222 }, | 224 }, |
223 | 225 |
224 /** | 226 /** |
225 * Callback function signalling completion of operation. | 227 * Callback function signalling completion of operation. |
226 */ | 228 */ |
227 sendDone_: function() { | 229 sendDone_: function() { |
228 window.domAutomationController.send('done'); | 230 window.domAutomationController.send('done'); |
229 } | 231 } |
230 }; | 232 }; |
OLD | NEW |