| 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..f2335ad635ef3dce4c61b8c0adb4a28df9d2fa67 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,9 @@ TestMediaScanner.prototype.assertScanCount = function(expected) {
|
| * @param {!Array.<!FileEntry>} fileEntries
|
| */
|
| function TestScanResult(fileEntries) {
|
| + /** @private {number} */
|
| + this.scanId_ = ++TestScanResult.lastId_;
|
| +
|
| /**
|
| * List of file entries found while scanning.
|
| * @type {!Array.<!FileEntry>}
|
| @@ -133,6 +145,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 +162,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 +192,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 */
|
|
|