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 * Opens the main Files.app's window and waits until it is ready. | 6 * Opens the main Files.app's window and waits until it is ready. |
7 * | 7 * |
8 * @param {Object} appState App state. | 8 * @param {Object} appState App state. |
9 * @param {function(string)} callback Completion callback with the new window's | 9 * @param {function(string)} callback Completion callback with the new window's |
10 * App ID. | 10 * App ID. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 /** | 61 /** |
62 * Fakes pressing the down arrow until the given |filename| is selected. | 62 * Fakes pressing the down arrow until the given |filename| is selected. |
63 * | 63 * |
64 * @param {Window} contentWindow Window to be tested. | 64 * @param {Window} contentWindow Window to be tested. |
65 * @param {string} filename Name of the file to be selected. | 65 * @param {string} filename Name of the file to be selected. |
66 * @return {boolean} True if file got selected, false otherwise. | 66 * @return {boolean} True if file got selected, false otherwise. |
67 */ | 67 */ |
68 test.util.sync.selectFile = function(contentWindow, filename) { | 68 test.util.sync.selectFile = function(contentWindow, filename) { |
69 var rows = contentWindow.document.querySelectorAll('#detail-table li'); | 69 var rows = contentWindow.document.querySelectorAll('#detail-table li'); |
70 test.util.sync.fakeKeyDown( | 70 test.util.sync.fakeKeyDown( |
71 contentWindow, '#file-list', 'Home', false, false, false); | 71 contentWindow, '#file-list', 'Home', 'Home', false, false, false); |
72 for (var index = 0; index < rows.length; ++index) { | 72 for (var index = 0; index < rows.length; ++index) { |
73 var selection = test.util.sync.getSelectedFiles(contentWindow); | 73 var selection = test.util.sync.getSelectedFiles(contentWindow); |
74 if (selection.length === 1 && selection[0] === filename) | 74 if (selection.length === 1 && selection[0] === filename) |
75 return true; | 75 return true; |
76 test.util.sync.fakeKeyDown( | 76 test.util.sync.fakeKeyDown( |
77 contentWindow, '#file-list', 'Down', false, false, false); | 77 contentWindow, '#file-list', 'ArrowDown', 'Down', false, false, false); |
78 } | 78 } |
79 console.error('Failed to select file "' + filename + '"'); | 79 console.error('Failed to select file "' + filename + '"'); |
80 return false; | 80 return false; |
81 }; | 81 }; |
82 | 82 |
83 /** | 83 /** |
84 * Open the file by selectFile and fakeMouseDoubleClick. | 84 * Open the file by selectFile and fakeMouseDoubleClick. |
85 * | 85 * |
86 * @param {Window} contentWindow Window to be tested. | 86 * @param {Window} contentWindow Window to be tested. |
87 * @param {string} filename Name of the file to be opened. | 87 * @param {string} filename Name of the file to be opened. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 * @param {Window} contentWindow Window to be tested. | 180 * @param {Window} contentWindow Window to be tested. |
181 * @param {string} filename Name of the file to be copied. | 181 * @param {string} filename Name of the file to be copied. |
182 * @return {boolean} True if copying got simulated successfully. It does not | 182 * @return {boolean} True if copying got simulated successfully. It does not |
183 * say if the file got copied, or not. | 183 * say if the file got copied, or not. |
184 */ | 184 */ |
185 test.util.sync.copyFile = function(contentWindow, filename) { | 185 test.util.sync.copyFile = function(contentWindow, filename) { |
186 if (!test.util.sync.selectFile(contentWindow, filename)) | 186 if (!test.util.sync.selectFile(contentWindow, filename)) |
187 return false; | 187 return false; |
188 // Ctrl+C and Ctrl+V | 188 // Ctrl+C and Ctrl+V |
189 test.util.sync.fakeKeyDown( | 189 test.util.sync.fakeKeyDown( |
190 contentWindow, '#file-list', 'U+0043', true, false, false); | 190 contentWindow, '#file-list', 'w', 'U+0043', true, false, false); |
191 test.util.sync.fakeKeyDown( | 191 test.util.sync.fakeKeyDown( |
192 contentWindow, '#file-list', 'U+0056', true, false, false); | 192 contentWindow, '#file-list', 'v', 'U+0056', true, false, false); |
193 return true; | 193 return true; |
194 }; | 194 }; |
195 | 195 |
196 /** | 196 /** |
197 * Selects |filename| and fakes pressing the Delete key. | 197 * Selects |filename| and fakes pressing the Delete key. |
198 * | 198 * |
199 * @param {Window} contentWindow Window to be tested. | 199 * @param {Window} contentWindow Window to be tested. |
200 * @param {string} filename Name of the file to be deleted. | 200 * @param {string} filename Name of the file to be deleted. |
201 * @return {boolean} True if deleting got simulated successfully. It does not | 201 * @return {boolean} True if deleting got simulated successfully. It does not |
202 * say if the file got deleted, or not. | 202 * say if the file got deleted, or not. |
203 */ | 203 */ |
204 test.util.sync.deleteFile = function(contentWindow, filename) { | 204 test.util.sync.deleteFile = function(contentWindow, filename) { |
205 if (!test.util.sync.selectFile(contentWindow, filename)) | 205 if (!test.util.sync.selectFile(contentWindow, filename)) |
206 return false; | 206 return false; |
207 // Delete | 207 // Delete |
208 test.util.sync.fakeKeyDown( | 208 test.util.sync.fakeKeyDown( |
209 contentWindow, '#file-list', 'U+007F', false, false, false); | 209 contentWindow, '#file-list', 'Delete', 'U+007F', false, false, false); |
210 return true; | 210 return true; |
211 }; | 211 }; |
212 | 212 |
213 /** | 213 /** |
214 * Execute a command on the document in the specified window. | 214 * Execute a command on the document in the specified window. |
215 * | 215 * |
216 * @param {Window} contentWindow Window to be tested. | 216 * @param {Window} contentWindow Window to be tested. |
217 * @param {string} command Command name. | 217 * @param {string} command Command name. |
218 * @return {boolean} True if the command is executed successfully. | 218 * @return {boolean} True if the command is executed successfully. |
219 */ | 219 */ |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 * Obtains the preferences. | 352 * Obtains the preferences. |
353 * @param {function(Object)} callback Callback function with results returned by | 353 * @param {function(Object)} callback Callback function with results returned by |
354 * the script. | 354 * the script. |
355 */ | 355 */ |
356 test.util.async.getPreferences = function(callback) { | 356 test.util.async.getPreferences = function(callback) { |
357 chrome.fileManagerPrivate.getPreferences(callback); | 357 chrome.fileManagerPrivate.getPreferences(callback); |
358 }; | 358 }; |
359 | 359 |
360 // Register the test utils. | 360 // Register the test utils. |
361 test.util.registerRemoteTestUtils(); | 361 test.util.registerRemoteTestUtils(); |
OLD | NEW |