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

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

Issue 805533003: Hook up import history to media scanner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert manifest.json. Created 6 years 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/media_scanner_unittest.js
diff --git a/ui/file_manager/file_manager/background/js/media_scanner_unittest.js b/ui/file_manager/file_manager/background/js/media_scanner_unittest.js
index 861091164065817970f054bd289d17aa2fae6fa1..0a80117e6b662e836c32acf72ac5f5f84ab91348 100644
--- a/ui/file_manager/file_manager/background/js/media_scanner_unittest.js
+++ b/ui/file_manager/file_manager/background/js/media_scanner_unittest.js
@@ -3,29 +3,30 @@
// found in the LICENSE file.
/**
- * Dummy private APIs.
+ * Stub out the metrics package.
+ * @type {!Object.<!string, !Function>}
*/
-var chrome;
+var metrics = {
+ recordTime: function() {},
+ recordValue: function() {}
+};
-/**
- * Callbacks registered by setTimeout.
- * @type {Array.<function>}
- */
-var timeoutCallbacks;
-
-
-/**
- * @type {!importer.DefaultMediaScanner}
- */
+/** @type {!importer.DefaultMediaScanner} */
var scanner;
+/** @type {!importer.TestImportHistory} */
+var importHistory;
+
// Set up the test components.
function setUp() {
- scanner = new importer.DefaultMediaScanner();
+
+ importHistory = new importer.TestImportHistory();
+ scanner = new importer.DefaultMediaScanner(importHistory);
}
/**
* Creates a subdirectory within a temporary file system for testing.
+ *
* @param {string} directoryName Name of the test directory to create. Must be
* unique within this test suite.
*/
@@ -34,7 +35,7 @@ function makeTestFileSystemRoot(directoryName) {
return new Promise(function(resolve, reject) {
window.webkitRequestFileSystem(
window.TEMPORARY,
- 1024*1024,
+ 1024 * 1024,
resolve,
reject);
});
@@ -145,6 +146,39 @@ function testSingleLevel(callback) {
callback);
}
+/**
+ * Verifies that scanning ignores previously imported entries.
+ */
+function testIgnoresPreviousImports(callback) {
+ importHistory.importedPaths[
+ '/testIgnoresPreviousImports/oldimage1234.jpg'] =
+ [importer.Destination.GOOGLE_DRIVE];
+ var filenames = [
+ 'oldimage1234.jpg',
+ 'foo.jpg',
+ 'bar.gif',
+ 'baz.avi'
+ ];
+ var expectedFiles = [
+ '/testIgnoresPreviousImports/foo.jpg',
+ '/testIgnoresPreviousImports/bar.gif',
+ '/testIgnoresPreviousImports/baz.avi'
+ ];
+ reportPromise(
+ makeTestFileSystemRoot('testIgnoresPreviousImports')
+ .then(populateDir.bind(null, filenames))
+ .then(
+ /**
+ * Scans the directory.
+ * @param {!DirectoryEntry} root
+ */
+ function(root) {
+ return scanner.scan([root]).whenFinished();
+ })
+ .then(assertResults.bind(null, expectedFiles)),
+ callback);
+}
+
function testMultiLevel(callback) {
var filenames = [
'foo.jpg',

Powered by Google App Engine
This is Rietveld 408576698