Chromium Code Reviews| Index: ui/file_manager/file_manager/background/js/mock_media_scanner.js |
| diff --git a/ui/file_manager/file_manager/background/js/mock_media_scanner.js b/ui/file_manager/file_manager/background/js/mock_media_scanner.js |
| index ddc26da980adaa75e81cee0bf5cbb2328721766f..27913b2cd08c26c8c2b130458897aaf9e8e1d1cd 100644 |
| --- a/ui/file_manager/file_manager/background/js/mock_media_scanner.js |
| +++ b/ui/file_manager/file_manager/background/js/mock_media_scanner.js |
| @@ -103,6 +103,15 @@ TestMediaScanner.prototype.assertScanCount = function(expected) { |
| }; |
| /** |
| + * Asserts that the last scan was canceled. Fails if no |
| + * scan exists. |
| + */ |
| +TestMediaScanner.prototype.assertLastScanCanceled = function() { |
| + assertTrue(this.scans_.length > 0); |
| + assertTrue(this.scans_[this.scans_.length - 1].canceled()); |
| +}; |
| + |
| +/** |
| * importer.MediaScanner and importer.ScanResult test double. |
| * |
| * @constructor |
| @@ -112,6 +121,8 @@ TestMediaScanner.prototype.assertScanCount = function(expected) { |
| * @param {!Array.<!FileEntry>} fileEntries |
| */ |
| function TestScanResult(fileEntries) { |
| + |
|
mtomasz
2015/04/01 03:55:40
nit: Remove \n
Steve McKay
2015/04/01 04:00:13
Done.
|
| + this.scanId_ = ++TestScanResult.lastId_; |
| /** |
|
mtomasz
2015/04/01 03:55:40
nit: Add \n
Steve McKay
2015/04/01 04:00:13
Done.
|
| * List of file entries found while scanning. |
| * @type {!Array.<!FileEntry>} |
| @@ -133,6 +144,9 @@ function TestScanResult(fileEntries) { |
| /** @type {boolean} */ |
| this.settled_ = false; |
| + /** @private {boolean} */ |
| + this.canceled_ = false; |
| + |
| /** @type {!Promise.<!importer.ScanResult>} */ |
| this.whenFinal_ = new Promise( |
| function(resolve, reject) { |
| @@ -147,6 +161,15 @@ function TestScanResult(fileEntries) { |
| }.bind(this)); |
| } |
| +/** @private {number} */ |
| +TestScanResult.lastId_ = 0; |
| + |
| +/** @struct */ |
| +TestScanResult.prototype = { |
| + /** @return {string} */ |
| + get name() { return 'TestScanResult(' + this.scanId_ + ')' } |
| +}; |
| + |
| /** @override */ |
| TestScanResult.prototype.getFileEntries = function() { |
| return this.fileEntries; |
| @@ -168,8 +191,13 @@ TestScanResult.prototype.isFinal = function() { |
| }; |
| /** @override */ |
| -TestScanResult.prototype.isInvalidated = function() { |
| - return false; |
| +TestScanResult.prototype.cancel = function() { |
| + this.canceled_ = true; |
| +}; |
| + |
| +/** @override */ |
| +TestScanResult.prototype.canceled = function() { |
| + return this.canceled_; |
| }; |
| /** @override */ |