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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 waitForFileListChange(appId, fileListBefore.length).then(this.next); | 120 waitForFileListChange(appId, fileListBefore.length).then(this.next); |
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 /** |
| 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 chrome.test.succeed(); |
| 139 }), function(error) { |
| 140 chrome.test.fail(error.stack || error); |
| 141 }); |
| 142 }; |
| 143 |
| 144 /** |
| 145 * Test for creating new folder. |
| 146 * @param {string} path Initial path. |
| 147 * @param {Array.<TestEntryInfo>} initialEntrySet Initial set of entries. |
| 148 * @return {Promise} Promise to be fulfilled on success. |
| 149 */ |
| 150 function createNewFolder(path, initialEntrySet) { |
| 151 var windowId; |
| 152 // Open window. |
| 153 return new Promise(function(callback) { |
| 154 setupAndWaitUntilReady(null, path, callback); |
| 155 }).then(function(inWindowId) { |
| 156 windowId = inWindowId; |
| 157 // Push Ctrl + E. |
| 158 return callRemoteTestUtil('fakeKeyDown', |
| 159 windowId, |
| 160 // Ctrl + E |
| 161 ['#file-list', 'U+0045', true]); |
| 162 }).then(function() { |
| 163 // Wait for rename text field. |
| 164 return waitForElement(windowId, 'input.rename'); |
| 165 }).then(function() { |
| 166 // Type new folder name. |
| 167 return callRemoteTestUtil( |
| 168 'inputText', windowId, ['input.rename', 'Test Folder Name']); |
| 169 }).then(function() { |
| 170 // Push Enter. |
| 171 return callRemoteTestUtil('fakeKeyDown', |
| 172 windowId, |
| 173 ['input.rename', 'Enter', false]); |
| 174 }).then(function() { |
| 175 return waitForElementLost(windowId, 'input.rename'); |
| 176 }).then(function() { |
| 177 var expectedEntryRows = TestEntryInfo.getExpectedRows(initialEntrySet); |
| 178 expectedEntryRows.push(['Test Folder Name', '--', 'Folder', '']); |
| 179 // Wait for the new folder. |
| 180 return waitForFiles(windowId, |
| 181 expectedEntryRows, |
| 182 {ignoreLastModifiedTime: true}); |
| 183 }); |
| 184 }; |
| 185 |
130 testcase.keyboardCopyDownloads = function() { | 186 testcase.keyboardCopyDownloads = function() { |
131 keyboardCopy(RootPath.DOWNLOADS); | 187 keyboardCopy(RootPath.DOWNLOADS); |
132 }; | 188 }; |
133 | 189 |
134 testcase.keyboardDeleteDownloads = function() { | 190 testcase.keyboardDeleteDownloads = function() { |
135 keyboardDelete(RootPath.DOWNLOADS); | 191 keyboardDelete(RootPath.DOWNLOADS); |
136 }; | 192 }; |
137 | 193 |
138 testcase.keyboardCopyDrive = function() { | 194 testcase.keyboardCopyDrive = function() { |
139 keyboardCopy(RootPath.DRIVE); | 195 keyboardCopy(RootPath.DRIVE); |
140 }; | 196 }; |
141 | 197 |
142 testcase.keyboardDeleteDrive = function() { | 198 testcase.keyboardDeleteDrive = function() { |
143 keyboardDelete(RootPath.DRIVE); | 199 keyboardDelete(RootPath.DRIVE); |
144 }; | 200 }; |
| 201 |
| 202 testcase.createNewFolderDownloads = function() { |
| 203 testPromise(createNewFolder(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET)); |
| 204 }; |
| 205 |
| 206 testcase.createNewFolderDrive = function() { |
| 207 testPromise(createNewFolder(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET)); |
| 208 }; |
OLD | NEW |