| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 }, | 121 }, |
| 122 // Verify the result. | 122 // Verify the result. |
| 123 function(fileList) { | 123 function(fileList) { |
| 124 chrome.test.assertFalse(isFilePresent(directoryName, fileList)); | 124 chrome.test.assertFalse(isFilePresent(directoryName, fileList)); |
| 125 checkIfNoErrorsOccured(this.next); | 125 checkIfNoErrorsOccured(this.next); |
| 126 } | 126 } |
| 127 ]); | 127 ]); |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * Adds check of chrome.test to the end of the given promise. | |
| 132 * @param {Promise} promise Promise. | |
| 133 */ | |
| 134 function testPromise(promise) { | |
| 135 promise.then(function() { | |
| 136 return new Promise(checkIfNoErrorsOccured); | |
| 137 }).then(chrome.test.callbackPass(function() { | |
| 138 // The callbacPass is necessary to avoid prematurely finishing tests. | |
| 139 // Don't put chrome.test.succeed() here to avoid doubled success log. | |
| 140 }), function(error) { | |
| 141 chrome.test.fail(error.stack || error); | |
| 142 }); | |
| 143 }; | |
| 144 | |
| 145 /** | |
| 146 * Test for creating new folder. | |
| 147 * @param {string} path Initial path. | |
| 148 * @param {Array.<TestEntryInfo>} initialEntrySet Initial set of entries. | |
| 149 * @return {Promise} Promise to be fulfilled on success. | |
| 150 */ | |
| 151 function createNewFolder(path, initialEntrySet) { | |
| 152 var windowId; | |
| 153 // Open window. | |
| 154 return new Promise(function(callback) { | |
| 155 setupAndWaitUntilReady(null, path, callback); | |
| 156 }).then(function(inWindowId) { | |
| 157 windowId = inWindowId; | |
| 158 // Push Ctrl + E. | |
| 159 return callRemoteTestUtil('fakeKeyDown', | |
| 160 windowId, | |
| 161 // Ctrl + E | |
| 162 ['#file-list', 'U+0045', true]); | |
| 163 }).then(function() { | |
| 164 // Wait for rename text field. | |
| 165 return waitForElement(windowId, 'input.rename'); | |
| 166 }).then(function() { | |
| 167 // Type new folder name. | |
| 168 return callRemoteTestUtil( | |
| 169 'inputText', windowId, ['input.rename', 'Test Folder Name']); | |
| 170 }).then(function() { | |
| 171 // Push Enter. | |
| 172 return callRemoteTestUtil('fakeKeyDown', | |
| 173 windowId, | |
| 174 ['input.rename', 'Enter', false]); | |
| 175 }).then(function() { | |
| 176 return waitForElementLost(windowId, 'input.rename'); | |
| 177 }).then(function() { | |
| 178 var expectedEntryRows = TestEntryInfo.getExpectedRows(initialEntrySet); | |
| 179 expectedEntryRows.push(['Test Folder Name', '--', 'Folder', '']); | |
| 180 // Wait for the new folder. | |
| 181 return waitForFiles(windowId, | |
| 182 expectedEntryRows, | |
| 183 {ignoreLastModifiedTime: true}); | |
| 184 }); | |
| 185 }; | |
| 186 | |
| 187 /** | |
| 188 * Renames a file. | 131 * Renames a file. |
| 189 * @param {string} windowId ID of the window. | 132 * @param {string} windowId ID of the window. |
| 190 * @param {string} oldName Old name of a file. | 133 * @param {string} oldName Old name of a file. |
| 191 * @param {string} newName New name of a file. | 134 * @param {string} newName New name of a file. |
| 192 * @return {Promise} Promise to be fulfilled on success. | 135 * @return {Promise} Promise to be fulfilled on success. |
| 193 */ | 136 */ |
| 194 function renameFile(windowId, oldName, newName) { | 137 function renameFile(windowId, oldName, newName) { |
| 195 return callRemoteTestUtil('selectFile', windowId, [oldName]).then(function() { | 138 return callRemoteTestUtil('selectFile', windowId, [oldName]).then(function() { |
| 196 // Push Ctrl+Enter. | 139 // Push Ctrl+Enter. |
| 197 return fakeKeyDown(windowId, '#detail-table', 'Enter', true); | 140 return fakeKeyDown(windowId, '#detail-table', 'Enter', true); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 }; | 209 }; |
| 267 | 210 |
| 268 testcase.keyboardCopyDrive = function() { | 211 testcase.keyboardCopyDrive = function() { |
| 269 keyboardCopy(RootPath.DRIVE); | 212 keyboardCopy(RootPath.DRIVE); |
| 270 }; | 213 }; |
| 271 | 214 |
| 272 testcase.keyboardDeleteDrive = function() { | 215 testcase.keyboardDeleteDrive = function() { |
| 273 keyboardDelete(RootPath.DRIVE); | 216 keyboardDelete(RootPath.DRIVE); |
| 274 }; | 217 }; |
| 275 | 218 |
| 276 testcase.createNewFolderDownloads = function() { | 219 testcase.createNewFolderAndCheckFocus = function() { |
| 277 testPromise(createNewFolder(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET)); | |
| 278 }; | |
| 279 | |
| 280 testcase.createNewFolderDrive = function() { | |
| 281 testPromise(createNewFolder(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET)); | |
| 282 }; | 220 }; |
| 283 | 221 |
| 284 testcase.renameFileDownloads = function() { | 222 testcase.renameFileDownloads = function() { |
| 285 testPromise(testRenameFile(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET)); | 223 testPromise(testRenameFile(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET)); |
| 286 }; | 224 }; |
| 287 | 225 |
| 288 testcase.renameFileDrive = function() { | 226 testcase.renameFileDrive = function() { |
| 289 testPromise(testRenameFile(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET)); | 227 testPromise(testRenameFile(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET)); |
| 290 }; | 228 }; |
| OLD | NEW |