Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Unified Diff: ui/file_manager/file_manager/background/js/mock_media_scanner.js

Issue 1045663002: Cancel scans when directory changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 */

Powered by Google App Engine
This is Rietveld 408576698