Chromium Code Reviews| Index: chrome/test/data/file_manager/unit_tests/mocks/mock_file_operation_manager.js |
| diff --git a/chrome/test/data/file_manager/unit_tests/mocks/mock_file_operation_manager.js b/chrome/test/data/file_manager/unit_tests/mocks/mock_file_operation_manager.js |
| index 6d34d7daabe74af1853ff06c9465ccaf24320476..572f3702363bc836cabd1defd589f1118aff4d53 100644 |
| --- a/chrome/test/data/file_manager/unit_tests/mocks/mock_file_operation_manager.js |
| +++ b/chrome/test/data/file_manager/unit_tests/mocks/mock_file_operation_manager.js |
| @@ -7,6 +7,7 @@ |
| /** |
| * Mock class of FileOperationManager. |
| * @constructor |
| + * @extends {cr.EventTarget} |
| */ |
| function MockFileOperationManager() { |
| cr.EventTarget.call(this); |
| @@ -16,6 +17,12 @@ function MockFileOperationManager() { |
| * @type {Event} |
| */ |
| this.cancelEvent = null; |
| + |
| + /** @type {!Array<string>} */ |
|
hirono
2014/12/04 04:44:24
!Array.<string>
Maybe @const and @private?
Ben Kwa
2014/12/04 07:43:49
Regarding the {Foo.<Bar>} vs {Foo<Bar>} syntax, th
Ben Kwa
2014/12/04 19:53:01
Acknowledged- sticking with {Foo<Bar>}, as discuss
|
| + this.generatedTaskIds = []; |
| + |
| + /** @type {Function|undefined} */ |
|
hirono
2014/12/04 04:44:24
Please assign null, and update the type annotation
Ben Kwa
2014/12/04 19:53:01
Done.
|
| + this.pasteResolver; |
| } |
| MockFileOperationManager.prototype = { |
| @@ -28,3 +35,53 @@ MockFileOperationManager.prototype = { |
| MockFileOperationManager.prototype.requestTaskCancel = function() { |
| this.dispatchEvent(this.cancelEvent); |
| }; |
| + |
| +/** |
| + * @param {Array.<Entry>} sourceEntries Entries of the source files. |
|
hirono
2014/12/04 04:44:24
{!Array.<Entry>} ?
Ben Kwa
2014/12/04 19:53:01
Done.
|
| + * @param {DirectoryEntry} targetEntry The destination entry of the target |
|
hirono
2014/12/04 04:44:24
{!DirectoryEntry} ?
Ben Kwa
2014/12/04 19:53:01
Done.
|
| + * directory. |
| + * @param {boolean} isMove True if the operation is "move", otherwise (i.e. |
| + * if the operation is "copy") false. |
| + * @param {string=} opt_taskId If the corresponding item has already created |
| + * at another places, we need to specify the ID of the item. If the |
| + * item is not created, FileOperationManager generates new ID. |
| + */ |
| +MockFileOperationManager.prototype.paste = function( |
| + sourceEntries, targetEntry, isMove, opt_taskId) { |
| + if (this.pasteResolver) { |
| + this.pasteResolver.call(this, { |
| + sourceEntries: sourceEntries, |
| + targetEntry: targetEntry, |
| + isMove: isMove, |
| + opt_taskId: opt_taskId |
| + }); |
| + } |
| +}; |
| + |
| +/** |
| + * @return {Promise<Object>} A promise that is resolved the next time #paste is |
|
hirono
2014/12/04 04:44:24
Promise.<Object>
Ben Kwa
2014/12/04 19:53:01
Acknowledged.
|
| + * called. The Object contains the arguments that #paste was called with. |
| + */ |
| +MockFileOperationManager.prototype.whenPasteCalled = function() { |
| + return new Promise(function(resolve, reject) { |
| + this.pasteResolver = resolve; |
|
hirono
2014/12/04 04:44:24
Please ensure this.pasteResolver == null.
Ben Kwa
2014/12/04 19:53:01
Done.
|
| + }.bind(this)); |
| +}; |
| + |
| +/** |
| + * Generates a unique task Id. |
| + * @return {string} |
| + */ |
| +MockFileOperationManager.prototype.generateTaskId = function() { |
| + var newTaskId = 'task' + this.generatedTaskIds.length; |
| + this.generatedTaskIds.push(newTaskId); |
| + return newTaskId; |
| +}; |
| + |
| +/** |
| + * @return {boolean} Whether or not the given task ID belongs to a task |
| + * generated by this manager. |
| + */ |
| +MockFileOperationManager.prototype.isKnownTaskId = function(id) { |
| + return this.generatedTaskIds.indexOf(id) != -1; |
|
hirono
2014/12/04 04:44:24
nit: We prefer !==
Ben Kwa
2014/12/04 19:53:01
Done.
|
| +}; |