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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return new Promise(checkIfNoErrorsOccured); | 136 return new Promise(checkIfNoErrorsOccured); |
137 }).then(chrome.test.callbackPass(function() { | 137 }).then(chrome.test.callbackPass(function() { |
138 // The callbacPass is necessary to avoid prematurely finishing tests. | 138 // The callbacPass is necessary to avoid prematurely finishing tests. |
139 // Don't put chrome.test.succeed() here to avoid doubled success log. | 139 // Don't put chrome.test.succeed() here to avoid doubled success log. |
140 }), function(error) { | 140 }), function(error) { |
141 chrome.test.fail(error.stack || error); | 141 chrome.test.fail(error.stack || error); |
142 }); | 142 }); |
143 }; | 143 }; |
144 | 144 |
145 /** | 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. | 146 * Renames a file. |
189 * @param {string} windowId ID of the window. | 147 * @param {string} windowId ID of the window. |
190 * @param {string} oldName Old name of a file. | 148 * @param {string} oldName Old name of a file. |
191 * @param {string} newName New name of a file. | 149 * @param {string} newName New name of a file. |
192 * @return {Promise} Promise to be fulfilled on success. | 150 * @return {Promise} Promise to be fulfilled on success. |
193 */ | 151 */ |
194 function renameFile(windowId, oldName, newName) { | 152 function renameFile(windowId, oldName, newName) { |
195 return callRemoteTestUtil('selectFile', windowId, [oldName]).then(function() { | 153 return callRemoteTestUtil('selectFile', windowId, [oldName]).then(function() { |
196 // Push Ctrl+Enter. | 154 // Push Ctrl+Enter. |
197 return fakeKeyDown(windowId, '#detail-table', 'Enter', true); | 155 return fakeKeyDown(windowId, '#detail-table', 'Enter', true); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 }; | 224 }; |
267 | 225 |
268 testcase.keyboardCopyDrive = function() { | 226 testcase.keyboardCopyDrive = function() { |
269 keyboardCopy(RootPath.DRIVE); | 227 keyboardCopy(RootPath.DRIVE); |
270 }; | 228 }; |
271 | 229 |
272 testcase.keyboardDeleteDrive = function() { | 230 testcase.keyboardDeleteDrive = function() { |
273 keyboardDelete(RootPath.DRIVE); | 231 keyboardDelete(RootPath.DRIVE); |
274 }; | 232 }; |
275 | 233 |
276 testcase.createNewFolderDownloads = function() { | 234 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 }; | 235 }; |
283 | 236 |
284 testcase.renameFileDownloads = function() { | 237 testcase.renameFileDownloads = function() { |
285 testPromise(testRenameFile(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET)); | 238 testPromise(testRenameFile(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET)); |
286 }; | 239 }; |
287 | 240 |
288 testcase.renameFileDrive = function() { | 241 testcase.renameFileDrive = function() { |
289 testPromise(testRenameFile(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET)); | 242 testPromise(testRenameFile(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET)); |
290 }; | 243 }; |
OLD | NEW |