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

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

Issue 980603003: Move content deduplication into the scan process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review comments. Created 5 years, 10 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/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 6e1630af77d4610ddd193f42fca3b63d626eaf64..77069304d0fb01d51022575a7fe987b3876daedd 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
@@ -20,16 +20,32 @@ var importHistory;
/** @type {!importer.TestDirectoryWatcher} */
var watcher;
+/**
+ * @type {function(!FileEntry, !importer.Destination):
+ * !Promise<!importer.Disposition>}
+ */
+var dispositionChecker;
+
// Set up the test components.
function setUp() {
+
importHistory = new importer.TestImportHistory();
+ // This is the default disposition checker.
+ // Tests can replace this at runtime if they
+ // want specialized behaviors.
+ dispositionChecker = function() {
+ return Promise.resolve(importer.Disposition.ORIGINAL);
+ };
+
scanner = new importer.DefaultMediaScanner(
/** @param {!FileEntry} entry */
function(entry) {
return Promise.resolve(entry.name);
},
- importHistory,
+ function(entry, destination) {
+ return dispositionChecker(entry, destination);
+ },
function(callback) {
watcher = new TestDirectoryWatcher(callback);
return watcher;
@@ -160,11 +176,25 @@ function testIgnoresPreviousImports(callback) {
'/testIgnoresPreviousImports/oldimage1234.jpg'] =
[importer.Destination.GOOGLE_DRIVE];
var filenames = [
- 'oldimage1234.jpg',
+ 'oldimage1234.jpg', // a history duplicate
+ 'driveimage1234.jpg', // a content duplicate
'foo.jpg',
'bar.gif',
'baz.avi'
];
+
+ // Replace the default dispositionChecker with a function
+ // that treats our dupes accordingly.
+ dispositionChecker = function(entry, destination) {
+ if (entry.name === filenames[0]) {
+ return Promise.resolve(importer.Disposition.HISTORY_DUPLICATE);
+ }
+ if (entry.name === filenames[1]) {
+ return Promise.resolve(importer.Disposition.CONTENT_DUPLICATE);
+ }
+ return Promise.resolve(importer.Disposition.ORIGINAL);
+ };
+
var expectedFiles = [
'/testIgnoresPreviousImports/foo.jpg',
'/testIgnoresPreviousImports/bar.gif',
@@ -270,7 +300,7 @@ function testMultipleDirectories(callback) {
callback);
}
-function testDedupesFiles(callback) {
+function testDedupesFilesInScanResult(callback) {
var filenames = [
[
'a',

Powered by Google App Engine
This is Rietveld 408576698