| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Sets up for directory tree context menu test. In addition to normal setup, we | 6 * Sets up for directory tree context menu test. In addition to normal setup, we |
| 7 * add destination directory. | 7 * add destination directory. |
| 8 */ | 8 */ |
| 9 function setupForDirectoryTreeContextMenuTest() { | 9 function setupForDirectoryTreeContextMenuTest() { |
| 10 var windowId; | 10 var windowId; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 */ | 138 */ |
| 139 function navigateToDestinationDirectoryAndTestPaste(windowId) { | 139 function navigateToDestinationDirectoryAndTestPaste(windowId) { |
| 140 // Navigates to destination directory. | 140 // Navigates to destination directory. |
| 141 return navigateWithDirectoryTree(windowId, '/destination').then(function() { | 141 return navigateWithDirectoryTree(windowId, '/destination').then(function() { |
| 142 // Confirm files before paste. | 142 // Confirm files before paste. |
| 143 return remoteCall.waitForFiles(windowId, ITEMS_IN_DEST_DIR_BEFORE_PASTE, | 143 return remoteCall.waitForFiles(windowId, ITEMS_IN_DEST_DIR_BEFORE_PASTE, |
| 144 {ignoreLastModifiedTime: true}); | 144 {ignoreLastModifiedTime: true}); |
| 145 }).then(function() { | 145 }).then(function() { |
| 146 // Paste | 146 // Paste |
| 147 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, | 147 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, |
| 148 ['body', 'U+0056' /* v */, true /* ctrl */, false, false]); | 148 ['body', 'v', 'U+0056' /* v */, true /* ctrl */, false, false]); |
| 149 }).then(function() { | 149 }).then(function() { |
| 150 // Confirm the photos directory is pasted correctly. | 150 // Confirm the photos directory is pasted correctly. |
| 151 return remoteCall.waitForFiles(windowId, ITEMS_IN_DEST_DIR_AFTER_PASTE, | 151 return remoteCall.waitForFiles(windowId, ITEMS_IN_DEST_DIR_AFTER_PASTE, |
| 152 {ignoreLastModifiedTime: true}); | 152 {ignoreLastModifiedTime: true}); |
| 153 }); | 153 }); |
| 154 } | 154 } |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * Rename photos directory to specified name by using directory tree. | 157 * Rename photos directory to specified name by using directory tree. |
| 158 */ | 158 */ |
| 159 function renamePhotosDirectoryTo(windowId, newName, useKeyboardShortcut) { | 159 function renamePhotosDirectoryTo(windowId, newName, useKeyboardShortcut) { |
| 160 return (useKeyboardShortcut ? | 160 return (useKeyboardShortcut ? |
| 161 remoteCall.callRemoteTestUtil( | 161 remoteCall.callRemoteTestUtil( |
| 162 'fakeKeyDown', windowId, | 162 'fakeKeyDown', windowId, |
| 163 ['body', 'Enter', true /* ctrl */, false, false]) : | 163 ['body', 'Enter', 'Enter', true /* ctrl */, false, false]) : |
| 164 clickDirectoryTreeContextMenuItem(windowId, '/photos', 'rename') | 164 clickDirectoryTreeContextMenuItem(windowId, '/photos', 'rename') |
| 165 ).then(function() { | 165 ).then(function() { |
| 166 return remoteCall.waitForElement(windowId, '.tree-row > input'); | 166 return remoteCall.waitForElement(windowId, '.tree-row > input'); |
| 167 }).then(function() { | 167 }).then(function() { |
| 168 return remoteCall.callRemoteTestUtil( | 168 return remoteCall.callRemoteTestUtil( |
| 169 'inputText', windowId, ['.tree-row > input', newName]); | 169 'inputText', windowId, ['.tree-row > input', newName]); |
| 170 }).then(function() { | 170 }).then(function() { |
| 171 return remoteCall.callRemoteTestUtil( | 171 return remoteCall.callRemoteTestUtil( |
| 172 'fakeKeyDown', windowId, | 172 'fakeKeyDown', windowId, |
| 173 ['.tree-row > input', 'Enter', false, false, false]); | 173 ['.tree-row > input', 'Enter', 'Enter', false, false, false]); |
| 174 }); | 174 }); |
| 175 } | 175 } |
| 176 | 176 |
| 177 /** | 177 /** |
| 178 * Renames directory and confirm current directory is moved to the renamed | 178 * Renames directory and confirm current directory is moved to the renamed |
| 179 * directory. | 179 * directory. |
| 180 */ | 180 */ |
| 181 function renameDirectoryFromDirectoryTreeSuccessCase(useKeyboardShortcut) { | 181 function renameDirectoryFromDirectoryTreeSuccessCase(useKeyboardShortcut) { |
| 182 var windowId; | 182 var windowId; |
| 183 return setupForDirectoryTreeContextMenuTest().then(function(id) { | 183 return setupForDirectoryTreeContextMenuTest().then(function(id) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 return setupForDirectoryTreeContextMenuTest().then(function(id) { | 217 return setupForDirectoryTreeContextMenuTest().then(function(id) { |
| 218 windowId = id; | 218 windowId = id; |
| 219 | 219 |
| 220 if (changeCurrentDirectory) | 220 if (changeCurrentDirectory) |
| 221 return navigateWithDirectoryTree(windowId, '/photos'); | 221 return navigateWithDirectoryTree(windowId, '/photos'); |
| 222 else | 222 else |
| 223 return expandDownloadVolumeInDirectoryTree(windowId); | 223 return expandDownloadVolumeInDirectoryTree(windowId); |
| 224 }).then(function() { | 224 }).then(function() { |
| 225 if (useKeyboardShortcut) { | 225 if (useKeyboardShortcut) { |
| 226 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, | 226 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, |
| 227 ['body', 'U+0045' /* e */, true /* ctrl */, false, false]); | 227 ['body', 'e', 'U+0045' /* e */, true /* ctrl */, false, false]); |
| 228 } else { | 228 } else { |
| 229 return clickDirectoryTreeContextMenuItem( | 229 return clickDirectoryTreeContextMenuItem( |
| 230 windowId, '/photos', 'new-folder'); | 230 windowId, '/photos', 'new-folder'); |
| 231 } | 231 } |
| 232 }).then(function() { | 232 }).then(function() { |
| 233 return remoteCall.waitForElement(windowId, '.tree-row > input'); | 233 return remoteCall.waitForElement(windowId, '.tree-row > input'); |
| 234 }).then(function() { | 234 }).then(function() { |
| 235 return remoteCall.callRemoteTestUtil( | 235 return remoteCall.callRemoteTestUtil( |
| 236 'inputText', windowId, ['.tree-row > input', 'test']); | 236 'inputText', windowId, ['.tree-row > input', 'test']); |
| 237 }).then(function() { | 237 }).then(function() { |
| 238 return remoteCall.callRemoteTestUtil( | 238 return remoteCall.callRemoteTestUtil( |
| 239 'fakeKeyDown', windowId, | 239 'fakeKeyDown', windowId, |
| 240 ['.tree-row > input', 'Enter', false, false, false]); | 240 ['.tree-row > input', 'Enter', 'Enter', false, false, false]); |
| 241 }).then(function() { | 241 }).then(function() { |
| 242 // Confirm that new directory is added to the directory tree. | 242 // Confirm that new directory is added to the directory tree. |
| 243 return remoteCall.waitForElement( | 243 return remoteCall.waitForElement( |
| 244 windowId, '[full-path-for-testing="/photos/test"]'); | 244 windowId, '[full-path-for-testing="/photos/test"]'); |
| 245 }).then(function() { | 245 }).then(function() { |
| 246 // Confirm that current directory is not changed at this timing. | 246 // Confirm that current directory is not changed at this timing. |
| 247 return remoteCall.waitUntilCurrentDirectoryIsChanged( | 247 return remoteCall.waitUntilCurrentDirectoryIsChanged( |
| 248 windowId, changeCurrentDirectory ? '/Downloads/photos' : '/Downloads'); | 248 windowId, changeCurrentDirectory ? '/Downloads/photos' : '/Downloads'); |
| 249 }).then(function() { | 249 }).then(function() { |
| 250 // Confirm that new directory is actually created by navigating to it. | 250 // Confirm that new directory is actually created by navigating to it. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 272 * shortcut. | 272 * shortcut. |
| 273 */ | 273 */ |
| 274 testcase.copyFromDirectoryTreeWithKeyboardShortcut = function() { | 274 testcase.copyFromDirectoryTreeWithKeyboardShortcut = function() { |
| 275 var windowId; | 275 var windowId; |
| 276 testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { | 276 testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { |
| 277 windowId = id; | 277 windowId = id; |
| 278 return navigateWithDirectoryTree(windowId, '/photos'); | 278 return navigateWithDirectoryTree(windowId, '/photos'); |
| 279 }).then(function() { | 279 }).then(function() { |
| 280 // Press Ctrl+C. | 280 // Press Ctrl+C. |
| 281 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, | 281 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, |
| 282 ['body', 'U+0043' /* c */, true /* ctrl */, false, false]); | 282 ['body', 'c', 'U+0043' /* c */, true /* ctrl */, false, false]); |
| 283 }).then(function() { | 283 }).then(function() { |
| 284 return navigateToDestinationDirectoryAndTestPaste(windowId); | 284 return navigateToDestinationDirectoryAndTestPaste(windowId); |
| 285 })); | 285 })); |
| 286 }; | 286 }; |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * Test case for copying a directory from directory tree without changing | 289 * Test case for copying a directory from directory tree without changing |
| 290 * current directory. | 290 * current directory. |
| 291 */ | 291 */ |
| 292 testcase.copyFromDirectoryTreeWithoutChaningCurrentDirectory = function() { | 292 testcase.copyFromDirectoryTreeWithoutChaningCurrentDirectory = function() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 * shortcut. | 325 * shortcut. |
| 326 */ | 326 */ |
| 327 testcase.cutFromDirectoryTreeWithKeyboardShortcut = function() { | 327 testcase.cutFromDirectoryTreeWithKeyboardShortcut = function() { |
| 328 var windowId; | 328 var windowId; |
| 329 testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { | 329 testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { |
| 330 windowId = id; | 330 windowId = id; |
| 331 return navigateWithDirectoryTree(windowId, '/photos'); | 331 return navigateWithDirectoryTree(windowId, '/photos'); |
| 332 }).then(function() { | 332 }).then(function() { |
| 333 // Press Ctrl+X. | 333 // Press Ctrl+X. |
| 334 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, | 334 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, |
| 335 ['body', 'U+0058' /* x */, true /* ctrl */, false, false]); | 335 ['body', 'x', 'U+0058' /* x */, true /* ctrl */, false, false]); |
| 336 }).then(function() { | 336 }).then(function() { |
| 337 return navigateToDestinationDirectoryAndTestPaste(windowId); | 337 return navigateToDestinationDirectoryAndTestPaste(windowId); |
| 338 }).then(function() { | 338 }).then(function() { |
| 339 // Confirm that directory tree is updated. | 339 // Confirm that directory tree is updated. |
| 340 return remoteCall.waitForElementLost( | 340 return remoteCall.waitForElementLost( |
| 341 windowId, '[full-path-for-testing="/photos"]'); | 341 windowId, '[full-path-for-testing="/photos"]'); |
| 342 })); | 342 })); |
| 343 }; | 343 }; |
| 344 | 344 |
| 345 /** | 345 /** |
| (...skipping 19 matching lines...) Expand all Loading... |
| 365 * Test case for pasting into folder from directory tree by using context menu. | 365 * Test case for pasting into folder from directory tree by using context menu. |
| 366 */ | 366 */ |
| 367 testcase.pasteIntoFolderFromDirectoryTreeWithContextMenu = function() { | 367 testcase.pasteIntoFolderFromDirectoryTreeWithContextMenu = function() { |
| 368 var windowId; | 368 var windowId; |
| 369 testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { | 369 testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { |
| 370 // Copy photos directory as a test data. | 370 // Copy photos directory as a test data. |
| 371 windowId = id; | 371 windowId = id; |
| 372 return navigateWithDirectoryTree(windowId, '/photos'); | 372 return navigateWithDirectoryTree(windowId, '/photos'); |
| 373 }).then(function() { | 373 }).then(function() { |
| 374 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, | 374 return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, |
| 375 ['body', 'U+0043' /* c */, true /* ctrl */, false, false]); | 375 ['body', 'c', 'U+0043' /* c */, true /* ctrl */, false, false]); |
| 376 }).then(function() { | 376 }).then(function() { |
| 377 return navigateWithDirectoryTree(windowId, '/destination'); | 377 return navigateWithDirectoryTree(windowId, '/destination'); |
| 378 }).then(function() { | 378 }).then(function() { |
| 379 // Confirm files before paste. | 379 // Confirm files before paste. |
| 380 return remoteCall.waitForFiles(windowId, ITEMS_IN_DEST_DIR_BEFORE_PASTE, | 380 return remoteCall.waitForFiles(windowId, ITEMS_IN_DEST_DIR_BEFORE_PASTE, |
| 381 {ignoreLastModifiedTime: true}); | 381 {ignoreLastModifiedTime: true}); |
| 382 }).then(function() { | 382 }).then(function() { |
| 383 return clickDirectoryTreeContextMenuItem( | 383 return clickDirectoryTreeContextMenuItem( |
| 384 windowId, '/destination', 'paste-into-folder'); | 384 windowId, '/destination', 'paste-into-folder'); |
| 385 }).then(function() { | 385 }).then(function() { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 /** | 507 /** |
| 508 * Test case for creating directory from directory tree without changing current | 508 * Test case for creating directory from directory tree without changing current |
| 509 * directory. | 509 * directory. |
| 510 */ | 510 */ |
| 511 testcase.createDirectoryFromDirectoryTreeWithoutChangingCurrentDirectory = | 511 testcase.createDirectoryFromDirectoryTreeWithoutChangingCurrentDirectory = |
| 512 function() { | 512 function() { |
| 513 testPromise(createDirectoryFromDirectoryTree( | 513 testPromise(createDirectoryFromDirectoryTree( |
| 514 false /* Do not use keyboard shortcut */, | 514 false /* Do not use keyboard shortcut */, |
| 515 false /* Do not change current directory */)) | 515 false /* Do not change current directory */)) |
| 516 }; | 516 }; |
| OLD | NEW |