OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Waits until a dialog with an OK button is shown and accepts it. | 8 * Waits until a dialog with an OK button is shown and accepts it. |
9 * | 9 * |
10 * @param {string} windowId Target window ID. | 10 * @param {string} windowId Target window ID. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 * @param {string} windowId ID of the window. | 206 * @param {string} windowId ID of the window. |
207 * @param {string} oldName Old name of a file. | 207 * @param {string} oldName Old name of a file. |
208 * @param {string} newName New name of a file. | 208 * @param {string} newName New name of a file. |
209 * @return {Promise} Promise to be fulfilled on success. | 209 * @return {Promise} Promise to be fulfilled on success. |
210 */ | 210 */ |
211 function renameFile(windowId, oldName, newName) { | 211 function renameFile(windowId, oldName, newName) { |
212 return remoteCall.callRemoteTestUtil('selectFile', windowId, [oldName]). | 212 return remoteCall.callRemoteTestUtil('selectFile', windowId, [oldName]). |
213 then(function() { | 213 then(function() { |
214 // Push Ctrl+Enter. | 214 // Push Ctrl+Enter. |
215 return remoteCall.fakeKeyDown( | 215 return remoteCall.fakeKeyDown( |
216 windowId, '#detail-table', 'Enter', true, false, false); | 216 windowId, '#detail-table', 'Enter', 'Enter', true, false, false); |
217 }).then(function() { | 217 }).then(function() { |
218 // Wait for rename text field. | 218 // Wait for rename text field. |
219 return remoteCall.waitForElement(windowId, 'input.rename'); | 219 return remoteCall.waitForElement(windowId, 'input.rename'); |
220 }).then(function() { | 220 }).then(function() { |
221 // Type new file name. | 221 // Type new file name. |
222 return remoteCall.callRemoteTestUtil( | 222 return remoteCall.callRemoteTestUtil( |
223 'inputText', windowId, ['input.rename', newName]); | 223 'inputText', windowId, ['input.rename', newName]); |
224 }).then(function() { | 224 }).then(function() { |
225 // Push Enter. | 225 // Push Enter. |
226 return remoteCall.fakeKeyDown( | 226 return remoteCall.fakeKeyDown( |
227 windowId, 'input.rename', 'Enter', false, false, false); | 227 windowId, 'input.rename', 'Enter', 'Enter', false, false, false); |
228 }); | 228 }); |
229 } | 229 } |
230 | 230 |
231 /** | 231 /** |
232 * Test for renaming a new directory. | 232 * Test for renaming a new directory. |
233 * @param {string} path Initial path. | 233 * @param {string} path Initial path. |
234 * @param {Array<TestEntryInfo>} initialEntrySet Initial set of entries. | 234 * @param {Array<TestEntryInfo>} initialEntrySet Initial set of entries. |
235 * @param {string} pathInBreadcrumb Initial path which is shown in breadcrumb. | 235 * @param {string} pathInBreadcrumb Initial path which is shown in breadcrumb. |
236 * @return {Promise} Promise to be fulfilled on success. | 236 * @return {Promise} Promise to be fulfilled on success. |
237 */ | 237 */ |
238 function testRenameNewDirectory(path, initialEntrySet, pathInBreadcrumb) { | 238 function testRenameNewDirectory(path, initialEntrySet, pathInBreadcrumb) { |
239 var expectedRows = TestEntryInfo.getExpectedRows(initialEntrySet); | 239 var expectedRows = TestEntryInfo.getExpectedRows(initialEntrySet); |
240 | 240 |
241 return new Promise(function(resolve) { | 241 return new Promise(function(resolve) { |
242 setupAndWaitUntilReady(null, path, resolve); | 242 setupAndWaitUntilReady(null, path, resolve); |
243 }).then(function(results) { | 243 }).then(function(results) { |
244 var windowId = results.windowId; | 244 var windowId = results.windowId; |
245 return remoteCall.waitForFiles(windowId, expectedRows).then(function() { | 245 return remoteCall.waitForFiles(windowId, expectedRows).then(function() { |
246 return remoteCall.fakeKeyDown( | 246 return remoteCall.fakeKeyDown( |
247 windowId, '#list-container', 'U+0045', true, false, false); | 247 windowId, '#list-container', 'e', 'U+0045', true, false, false); |
248 }).then(function() { | 248 }).then(function() { |
249 // Wait for rename text field. | 249 // Wait for rename text field. |
250 return remoteCall.waitForElement(windowId, 'input.rename'); | 250 return remoteCall.waitForElement(windowId, 'input.rename'); |
251 }).then(function() { | 251 }).then(function() { |
252 // Type new file name. | 252 // Type new file name. |
253 return remoteCall.callRemoteTestUtil( | 253 return remoteCall.callRemoteTestUtil( |
254 'inputText', windowId, ['input.rename', 'foo']); | 254 'inputText', windowId, ['input.rename', 'foo']); |
255 }).then(function() { | 255 }).then(function() { |
256 // Press Enter. | 256 // Press Enter. |
257 return remoteCall.fakeKeyDown( | 257 return remoteCall.fakeKeyDown( |
258 windowId, 'input.rename', 'Enter', false, false, false); | 258 windowId, 'input.rename', 'Enter', 'Enter', false, false, false); |
259 }).then(function() { | 259 }).then(function() { |
260 // Press Enter again to try to get into the new directory. | 260 // Press Enter again to try to get into the new directory. |
261 return remoteCall.fakeKeyDown( | 261 return remoteCall.fakeKeyDown( |
262 windowId, '#list-container', 'Enter', false, false, false); | 262 windowId, '#list-container', 'Enter', 'Enter', false, false, false); |
263 }).then(function() { | 263 }).then(function() { |
264 // Confirm that it doesn't move the directory since it's in renaming | 264 // Confirm that it doesn't move the directory since it's in renaming |
265 // process. | 265 // process. |
266 return remoteCall.waitUntilCurrentDirectoryIsChanged(windowId, | 266 return remoteCall.waitUntilCurrentDirectoryIsChanged(windowId, |
267 pathInBreadcrumb); | 267 pathInBreadcrumb); |
268 }).then(function() { | 268 }).then(function() { |
269 // Wait until rename is completed. | 269 // Wait until rename is completed. |
270 return remoteCall.waitForElementLost(windowId, 'li[renaming]'); | 270 return remoteCall.waitForElementLost(windowId, 'li[renaming]'); |
271 }).then(function() { | 271 }).then(function() { |
272 // Press Enter again. | 272 // Press Enter again. |
273 return remoteCall.fakeKeyDown(windowId, '#list-container', 'Enter', | 273 return remoteCall.fakeKeyDown(windowId, '#list-container', 'Enter', |
274 false, false, false); | 274 'Enter', false, false, false); |
275 }).then(function() { | 275 }).then(function() { |
276 // Confirm that it moves to renamed directory. | 276 // Confirm that it moves to renamed directory. |
277 return remoteCall.waitUntilCurrentDirectoryIsChanged(windowId, | 277 return remoteCall.waitUntilCurrentDirectoryIsChanged(windowId, |
278 pathInBreadcrumb + '/foo'); | 278 pathInBreadcrumb + '/foo'); |
279 }); | 279 }); |
280 }); | 280 }); |
281 } | 281 } |
282 | 282 |
283 /** | 283 /** |
284 * Test for renaming a file. | 284 * Test for renaming a file. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 testcase.renameNewDirectoryDownloads = function() { | 357 testcase.renameNewDirectoryDownloads = function() { |
358 testPromise(testRenameNewDirectory(RootPath.DOWNLOADS, | 358 testPromise(testRenameNewDirectory(RootPath.DOWNLOADS, |
359 BASIC_LOCAL_ENTRY_SET, '/Downloads')); | 359 BASIC_LOCAL_ENTRY_SET, '/Downloads')); |
360 }; | 360 }; |
361 | 361 |
362 testcase.renameNewDirectoryDrive = function() { | 362 testcase.renameNewDirectoryDrive = function() { |
363 testPromise(testRenameNewDirectory(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET, | 363 testPromise(testRenameNewDirectory(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET, |
364 '/My Drive')); | 364 '/My Drive')); |
365 }; | 365 }; |
OLD | NEW |