OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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 'use strict'; | 4 'use strict'; |
5 | 5 |
6 /** | 6 /** |
7 * Mock of chrome.runtime. | 7 * Mock of chrome.runtime. |
8 * @type {Object} | 8 * @type {Object} |
9 * @const | 9 * @const |
10 */ | 10 */ |
(...skipping 10 matching lines...) Expand all Loading... |
21 requestKeepAwake: function() { | 21 requestKeepAwake: function() { |
22 chrome.power.keepAwakeRequested = true; | 22 chrome.power.keepAwakeRequested = true; |
23 }, | 23 }, |
24 releaseKeepAwake: function() { | 24 releaseKeepAwake: function() { |
25 chrome.power.keepAwakeRequested = false; | 25 chrome.power.keepAwakeRequested = false; |
26 }, | 26 }, |
27 keepAwakeRequested: false | 27 keepAwakeRequested: false |
28 }; | 28 }; |
29 | 29 |
30 /** | 30 /** |
31 * Mock of chrome.fileBrowserPrivate. | 31 * Mock of chrome.fileManagerPrivate. |
32 * @type {Object} | 32 * @type {Object} |
33 * @const | 33 * @const |
34 */ | 34 */ |
35 chrome.fileBrowserPrivate = { | 35 chrome.fileManagerPrivate = { |
36 onCopyProgress: { | 36 onCopyProgress: { |
37 addListener: function(callback) { | 37 addListener: function(callback) { |
38 chrome.fileBrowserPrivate.onCopyProgress.listener_ = callback; | 38 chrome.fileManagerPrivate.onCopyProgress.listener_ = callback; |
39 }, | 39 }, |
40 removeListener: function() { | 40 removeListener: function() { |
41 chrome.fileBrowserPrivate.onCopyProgress.listener_ = null; | 41 chrome.fileManagerPrivate.onCopyProgress.listener_ = null; |
42 }, | 42 }, |
43 listener_: null | 43 listener_: null |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 /** | 47 /** |
48 * Reports the result of promise to the test system. | 48 * Reports the result of promise to the test system. |
49 * @param {Promise} promise Promise to be fulfilled or rejected. | 49 * @param {Promise} promise Promise to be fulfilled or rejected. |
50 * @param {function(boolean:hasError)} callback Callback to be passed true on | 50 * @param {function(boolean:hasError)} callback Callback to be passed true on |
51 * error. | 51 * error. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 */ | 236 */ |
237 function testCopy(callback) { | 237 function testCopy(callback) { |
238 // Prepare entries and their resolver. | 238 // Prepare entries and their resolver. |
239 var fileSystem = createTestFileSystem('testVolume', { | 239 var fileSystem = createTestFileSystem('testVolume', { |
240 '/': DIRECTORY_SIZE, | 240 '/': DIRECTORY_SIZE, |
241 '/test.txt': 10, | 241 '/test.txt': 10, |
242 }); | 242 }); |
243 window.webkitResolveLocalFileSystemURL = | 243 window.webkitResolveLocalFileSystemURL = |
244 resolveTestFileSystemURL.bind(null, fileSystem); | 244 resolveTestFileSystemURL.bind(null, fileSystem); |
245 | 245 |
246 chrome.fileBrowserPrivate.startCopy = | 246 chrome.fileManagerPrivate.startCopy = |
247 function(source, destination, newName, callback) { | 247 function(source, destination, newName, callback) { |
248 var makeStatus = function(type) { | 248 var makeStatus = function(type) { |
249 return {type: type, sourceUrl: source, destinationUrl: destination}; | 249 return {type: type, sourceUrl: source, destinationUrl: destination}; |
250 }; | 250 }; |
251 callback(1); | 251 callback(1); |
252 var listener = chrome.fileBrowserPrivate.onCopyProgress.listener_; | 252 var listener = chrome.fileManagerPrivate.onCopyProgress.listener_; |
253 listener(1, makeStatus('begin_copy_entry')); | 253 listener(1, makeStatus('begin_copy_entry')); |
254 listener(1, makeStatus('progress')); | 254 listener(1, makeStatus('progress')); |
255 var newPath = joinPath('/', newName); | 255 var newPath = joinPath('/', newName); |
256 fileSystem.entries[newPath] = | 256 fileSystem.entries[newPath] = |
257 fileSystem.entries['/test.txt'].clone(newPath); | 257 fileSystem.entries['/test.txt'].clone(newPath); |
258 listener(1, makeStatus('end_copy_entry')); | 258 listener(1, makeStatus('end_copy_entry')); |
259 listener(1, makeStatus('success')); | 259 listener(1, makeStatus('success')); |
260 }; | 260 }; |
261 | 261 |
262 // Observing manager's events. | 262 // Observing manager's events. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 * error. | 389 * error. |
390 */ | 390 */ |
391 function testZip(callback) { | 391 function testZip(callback) { |
392 // Prepare entries and their resolver. | 392 // Prepare entries and their resolver. |
393 var fileSystem = createTestFileSystem('testVolume', { | 393 var fileSystem = createTestFileSystem('testVolume', { |
394 '/': DIRECTORY_SIZE, | 394 '/': DIRECTORY_SIZE, |
395 '/test.txt': 10, | 395 '/test.txt': 10, |
396 }); | 396 }); |
397 window.webkitResolveLocalFileSystemURL = | 397 window.webkitResolveLocalFileSystemURL = |
398 resolveTestFileSystemURL.bind(null, fileSystem); | 398 resolveTestFileSystemURL.bind(null, fileSystem); |
399 chrome.fileBrowserPrivate.zipSelection = | 399 chrome.fileManagerPrivate.zipSelection = |
400 function(parentURL, sources, newName, success, error) { | 400 function(parentURL, sources, newName, success, error) { |
401 var newPath = joinPath('/', newName); | 401 var newPath = joinPath('/', newName); |
402 var newEntry = new MockFileEntry(fileSystem, newPath, {size: 10}); | 402 var newEntry = new MockFileEntry(fileSystem, newPath, {size: 10}); |
403 fileSystem.entries[newPath] = newEntry; | 403 fileSystem.entries[newPath] = newEntry; |
404 success(newEntry); | 404 success(newEntry); |
405 }; | 405 }; |
406 | 406 |
407 // Observing manager's events. | 407 // Observing manager's events. |
408 reportPromise(waitForEvents(fileOperationManager).then(function(events) { | 408 reportPromise(waitForEvents(fileOperationManager).then(function(events) { |
409 assertEquals('copy-progress', events[0].type); | 409 assertEquals('copy-progress', events[0].type); |
(...skipping 14 matching lines...) Expand all Loading... |
424 assertTrue(events.some(function(event) { | 424 assertTrue(events.some(function(event) { |
425 return event.type === 'entries-changed' && | 425 return event.type === 'entries-changed' && |
426 event.entries[0].fullPath === '/test.zip'; | 426 event.entries[0].fullPath === '/test.zip'; |
427 })); | 427 })); |
428 }), callback); | 428 }), callback); |
429 | 429 |
430 fileOperationManager.zipSelection( | 430 fileOperationManager.zipSelection( |
431 fileSystem.entries['/'], | 431 fileSystem.entries['/'], |
432 [fileSystem.entries['/test.txt']]); | 432 [fileSystem.entries['/test.txt']]); |
433 } | 433 } |
OLD | NEW |