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