| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 * Expected files before tests are performed. Entries for Local tests. | 6 * Expected files before tests are performed. Entries for Local tests. |
| 7 * @type {Array.<Array.<string>>} | 7 * @type {Array.<Array.<string>>} |
| 8 * @const | 8 * @const |
| 9 */ | 9 */ |
| 10 var EXPECTED_FILES_BEFORE_LOCAL = [ | 10 var EXPECTED_FILES_BEFORE_LOCAL = [ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 */ | 57 */ |
| 58 function setupAndWaitUntilReady(path, callback) { | 58 function setupAndWaitUntilReady(path, callback) { |
| 59 callRemoteTestUtil('openMainWindow', null, [path], function(appId) { | 59 callRemoteTestUtil('openMainWindow', null, [path], function(appId) { |
| 60 callRemoteTestUtil('waitForFileListChange', appId, [0], function(files) { | 60 callRemoteTestUtil('waitForFileListChange', appId, [0], function(files) { |
| 61 callback(appId, files); | 61 callback(appId, files); |
| 62 }); | 62 }); |
| 63 }); | 63 }); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Verifies if there are no Javascript errors in any of the app windows. |
| 68 * @param {function()} Completion callback. |
| 69 */ |
| 70 function checkIfNoErrorsOccured(callback) { |
| 71 callRemoteTestUtil('getErrorCount', null, [], function(count) { |
| 72 chrome.test.assertEq(0, count); |
| 73 callback(); |
| 74 }); |
| 75 } |
| 76 |
| 77 /** |
| 67 * Expected files shown in "Recent". Directories (e.g. 'photos') are not in this | 78 * Expected files shown in "Recent". Directories (e.g. 'photos') are not in this |
| 68 * list as they are not expected in "Recent". | 79 * list as they are not expected in "Recent". |
| 80 * |
| 69 * @type {Array.<Array.<string>>} | 81 * @type {Array.<Array.<string>>} |
| 70 * @const | 82 * @const |
| 71 */ | 83 */ |
| 72 var EXPECTED_FILES_IN_RECENT = [ | 84 var EXPECTED_FILES_IN_RECENT = [ |
| 73 ['hello.txt', '123 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], | 85 ['hello.txt', '123 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], |
| 74 ['world.mpeg', '1,000 bytes', 'MPEG video', 'Jul 4, 2012 10:35 AM'], | 86 ['world.mpeg', '1,000 bytes', 'MPEG video', 'Jul 4, 2012 10:35 AM'], |
| 75 ['My Desktop Background.png', '1 KB', 'PNG image', 'Jan 18, 2038 1:02 AM'], | 87 ['My Desktop Background.png', '1 KB', 'PNG image', 'Jan 18, 2038 1:02 AM'], |
| 76 ['Test Document.gdoc','--','Google document','Apr 10, 2013 4:20 PM'], | 88 ['Test Document.gdoc','--','Google document','Apr 10, 2013 4:20 PM'], |
| 77 ].sort(); | 89 ].sort(); |
| 78 | 90 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 108 var expectedFilesAfter = | 120 var expectedFilesAfter = |
| 109 expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); | 121 expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); |
| 110 | 122 |
| 111 setupAndWaitUntilReady(path, function(appId, actualFilesBefore) { | 123 setupAndWaitUntilReady(path, function(appId, actualFilesBefore) { |
| 112 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); | 124 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); |
| 113 chrome.test.sendMessage('initial check done', function(reply) { | 125 chrome.test.sendMessage('initial check done', function(reply) { |
| 114 chrome.test.assertEq('file added', reply); | 126 chrome.test.assertEq('file added', reply); |
| 115 callRemoteTestUtil( | 127 callRemoteTestUtil( |
| 116 'waitForFileListChange', | 128 'waitForFileListChange', |
| 117 appId, | 129 appId, |
| 118 [expectedFilesBefore.length], | 130 [expectedFilesBefore.length], function(actualFilesAfter) { |
| 119 chrome.test.callbackPass(function(actualFilesAfter) { | |
| 120 chrome.test.assertEq(expectedFilesAfter, actualFilesAfter); | 131 chrome.test.assertEq(expectedFilesAfter, actualFilesAfter); |
| 121 })); | 132 checkIfNoErrorsOccured(chrome.test.succeed); |
| 133 }); |
| 122 }); | 134 }); |
| 123 }); | 135 }); |
| 124 }; | 136 }; |
| 125 | 137 |
| 126 /** | 138 /** |
| 127 * Tests copying a file to the same directory and waits until the file lists | 139 * Tests copying a file to the same directory and waits until the file lists |
| 128 * changes. | 140 * changes. |
| 129 * | 141 * |
| 130 * @param {string} path Directory path to be tested. | 142 * @param {string} path Directory path to be tested. |
| 131 */ | 143 */ |
| 132 testcase.intermediate.keyboardCopy = function(path) { | 144 testcase.intermediate.keyboardCopy = function(path, callback) { |
| 133 setupAndWaitUntilReady(path, function(appId) { | 145 setupAndWaitUntilReady(path, function(appId) { |
| 134 callRemoteTestUtil('copyFile', appId, ['world.mpeg'], function(result) { | 146 callRemoteTestUtil('copyFile', appId, ['world.mpeg'], function(result) { |
| 135 chrome.test.assertFalse(!result); | 147 chrome.test.assertFalse(!result); |
| 136 callRemoteTestUtil('waitForFileListChange', | 148 callRemoteTestUtil('waitForFileListChange', |
| 137 appId, | 149 appId, |
| 138 [getExpectedFilesBefore(path == '/drive/root').length], | 150 [getExpectedFilesBefore(path == '/drive/root').length], |
| 139 chrome.test.succeed); | 151 checkIfNoErrorsOccured.bind(null, |
| 152 chrome.test.succeed)); |
| 140 }); | 153 }); |
| 141 }); | 154 }); |
| 142 }; | 155 }; |
| 143 | 156 |
| 144 /** | 157 /** |
| 145 * Tests deleting a file and and waits until the file lists changes. | 158 * Tests deleting a file and and waits until the file lists changes. |
| 146 * @param {string} path Directory path to be tested. | 159 * @param {string} path Directory path to be tested. |
| 147 */ | 160 */ |
| 148 testcase.intermediate.keyboardDelete = function(path) { | 161 testcase.intermediate.keyboardDelete = function(path) { |
| 149 setupAndWaitUntilReady(path, function(appId) { | 162 setupAndWaitUntilReady(path, function(appId) { |
| 150 callRemoteTestUtil('deleteFile', appId, ['world.mpeg'], function(result) { | 163 callRemoteTestUtil('deleteFile', appId, ['world.mpeg'], function(result) { |
| 151 chrome.test.assertFalse(!result); | 164 chrome.test.assertFalse(!result); |
| 152 callRemoteTestUtil('waitAndAcceptDialog', appId, [], function() { | 165 callRemoteTestUtil('waitAndAcceptDialog', appId, [], function() { |
| 153 callRemoteTestUtil( | 166 callRemoteTestUtil( |
| 154 'waitForFileListChange', | 167 'waitForFileListChange', |
| 155 appId, | 168 appId, |
| 156 [getExpectedFilesBefore(path == '/drive/root').length], | 169 [getExpectedFilesBefore(path == '/drive/root').length], |
| 157 chrome.test.succeed); | 170 checkIfNoErrorsOccured.bind(null, chrome.test.succeed)); |
| 158 }); | 171 }); |
| 159 }); | 172 }); |
| 160 }); | 173 }); |
| 161 }; | 174 }; |
| 162 | 175 |
| 163 testcase.fileDisplayDownloads = function() { | 176 testcase.fileDisplayDownloads = function() { |
| 164 testcase.intermediate.fileDisplay('/Downloads'); | 177 testcase.intermediate.fileDisplay('/Downloads'); |
| 165 }; | 178 }; |
| 166 | 179 |
| 167 testcase.keyboardCopyDownloads = function() { | 180 testcase.keyboardCopyDownloads = function() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 184 testcase.intermediate.keyboardDelete('/drive/root'); | 197 testcase.intermediate.keyboardDelete('/drive/root'); |
| 185 }; | 198 }; |
| 186 | 199 |
| 187 /** | 200 /** |
| 188 * Tests opening the "Recent" on the sidebar navigation by clicking the icon, | 201 * Tests opening the "Recent" on the sidebar navigation by clicking the icon, |
| 189 * and verifies the directory contents. We test if there are only files, since | 202 * and verifies the directory contents. We test if there are only files, since |
| 190 * directories are not allowed in "Recent". This test is only available for | 203 * directories are not allowed in "Recent". This test is only available for |
| 191 * Drive. | 204 * Drive. |
| 192 */ | 205 */ |
| 193 testcase.openSidebarRecent = function() { | 206 testcase.openSidebarRecent = function() { |
| 194 var onFileListChange = chrome.test.callbackPass(function(actualFilesAfter) { | 207 var onFileListChange = function(actualFilesAfter) { |
| 195 chrome.test.assertEq(EXPECTED_FILES_IN_RECENT, actualFilesAfter); | 208 chrome.test.assertEq(EXPECTED_FILES_IN_RECENT, actualFilesAfter); |
| 196 }); | 209 checkIfNoErrorsOccured(chrome.test.succeed); |
| 210 }; |
| 197 | 211 |
| 198 setupAndWaitUntilReady('/drive/root', function(appId) { | 212 setupAndWaitUntilReady('/drive/root', function(appId) { |
| 199 // Use the icon for a click target. | 213 // Use the icon for a click target. |
| 200 callRemoteTestUtil( | 214 callRemoteTestUtil( |
| 201 'fakeMouseClick', appId, ['[volume-type-icon=drive_recent]'], | 215 'fakeMouseClick', appId, ['[volume-type-icon=drive_recent]'], |
| 202 function(result) { | 216 function(result) { |
| 203 chrome.test.assertFalse(!result); | 217 chrome.test.assertFalse(!result); |
| 204 callRemoteTestUtil( | 218 callRemoteTestUtil( |
| 205 'waitForFileListChange', | 219 'waitForFileListChange', |
| 206 appId, | 220 appId, |
| 207 [getExpectedFilesBefore(true /* isDrive */).length], | 221 [getExpectedFilesBefore(true /* isDrive */).length], |
| 208 onFileListChange); | 222 onFileListChange); |
| 209 }); | 223 }); |
| 210 }); | 224 }); |
| 211 }; | 225 }; |
| 212 | 226 |
| 213 /** | 227 /** |
| 214 * Tests opening the "Offline" on the sidebar navigation by clicking the icon, | 228 * Tests opening the "Offline" on the sidebar navigation by clicking the icon, |
| 215 * and checks contenets of the file list. Only the entries "available offline" | 229 * and checks contenets of the file list. Only the entries "available offline" |
| 216 * should be shown. "Available offline" entires are hosted documents and the | 230 * should be shown. "Available offline" entires are hosted documents and the |
| 217 * entries cached by DriveCache. | 231 * entries cached by DriveCache. |
| 218 */ | 232 */ |
| 219 testcase.openSidebarOffline = function() { | 233 testcase.openSidebarOffline = function() { |
| 220 var onFileListChange = chrome.test.callbackPass(function(actualFilesAfter) { | 234 var onFileListChange = function(actualFilesAfter) { |
| 221 chrome.test.assertEq(EXPECTED_FILES_IN_OFFLINE, actualFilesAfter); | 235 chrome.test.assertEq(EXPECTED_FILES_IN_OFFLINE, actualFilesAfter); |
| 222 }); | 236 checkIfNoErrorsOccured(chrome.test.succeed); |
| 237 }; |
| 223 | 238 |
| 224 setupAndWaitUntilReady('/drive/root/', function(appId) { | 239 setupAndWaitUntilReady('/drive/root/', function(appId) { |
| 225 // Use the icon for a click target. | 240 // Use the icon for a click target. |
| 226 callRemoteTestUtil( | 241 callRemoteTestUtil( |
| 227 'fakeMouseClick', appId, ['[volume-type-icon=drive_offline]'], | 242 'fakeMouseClick', appId, ['[volume-type-icon=drive_offline]'], |
| 228 function(result) { | 243 function(result) { |
| 229 chrome.test.assertFalse(!result); | 244 chrome.test.assertFalse(!result); |
| 230 callRemoteTestUtil( | 245 callRemoteTestUtil( |
| 231 'waitForFileListChange', | 246 'waitForFileListChange', |
| 232 appId, | 247 appId, |
| 233 [getExpectedFilesBefore(true /* isDrive */).length], | 248 [getExpectedFilesBefore(true /* isDrive */).length], |
| 234 onFileListChange); | 249 onFileListChange); |
| 235 }); | 250 }); |
| 236 }); | 251 }); |
| 237 }; | 252 }; |
| 238 | 253 |
| 239 /** | 254 /** |
| 240 * Tests autocomplete with a query 'hello'. This test is only available for | 255 * Tests autocomplete with a query 'hello'. This test is only available for |
| 241 * Drive. | 256 * Drive. |
| 242 */ | 257 */ |
| 243 testcase.autocomplete = function() { | 258 testcase.autocomplete = function() { |
| 244 var EXPECTED_AUTOCOMPLETE_LIST = [ | 259 var EXPECTED_AUTOCOMPLETE_LIST = [ |
| 245 '\'hello\' - search Drive\n', | 260 '\'hello\' - search Drive\n', |
| 246 'hello.txt\n', | 261 'hello.txt\n', |
| 247 ]; | 262 ]; |
| 248 | 263 |
| 249 var onAutocompleteListShown = chrome.test.callbackPass( | 264 var onAutocompleteListShown = function(autocompleteList) { |
| 250 function(autocompleteList) { | 265 chrome.test.assertEq(EXPECTED_AUTOCOMPLETE_LIST, autocompleteList); |
| 251 chrome.test.assertEq(EXPECTED_AUTOCOMPLETE_LIST, autocompleteList); | 266 checkIfNoErrorsOccured(chrome.test.succeed); |
| 252 }); | 267 }; |
| 253 | 268 |
| 254 setupAndWaitUntilReady('/drive/root', function(appId, list) { | 269 setupAndWaitUntilReady('/drive/root', function(appId, list) { |
| 255 callRemoteTestUtil('performAutocompleteAndWait', | 270 callRemoteTestUtil('performAutocompleteAndWait', |
| 256 appId, | 271 appId, |
| 257 ['hello', EXPECTED_AUTOCOMPLETE_LIST.length], | 272 ['hello', EXPECTED_AUTOCOMPLETE_LIST.length], |
| 258 onAutocompleteListShown); | 273 onAutocompleteListShown); |
| 259 }); | 274 }); |
| 260 }; | 275 }; |
| OLD | NEW |