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

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

Issue 2163543005: Check duplicates when scanning selected files for cloud import. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync to head Created 4 years, 5 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
« no previous file with comments | « ui/file_manager/file_manager/background/js/media_scanner.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38527060b12f59c44eb1a861043ceeef975afda9..18dbc64f82b36e7e41c41275798fef9ea7ec768b 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
@@ -142,6 +142,48 @@ function testScanFiles(callback) {
}
/**
+ * Verifies that scanFiles skips duplicated files.
+ */
+function testScanFilesIgnoresPreviousImports(callback) {
+ var filenames = [
+ '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 = [
+ '/testScanFilesIgnoresPreviousImports/foo.jpg',
+ '/testScanFilesIgnoresPreviousImports/bar.gif',
+ '/testScanFilesIgnoresPreviousImports/baz.avi'
+ ];
+ reportPromise(
+ makeTestFileSystemRoot('testScanFilesIgnoresPreviousImports')
+ .then(populateDir.bind(null, filenames))
+ .then(fileOperationUtil.gatherEntriesRecursively)
+ .then(
+ /** @param {!Array<!FileEntry>} files */
+ function(files) {
+ return scanner.scanFiles(files).whenFinal();
+ })
+ .then(assertFilesFound.bind(null, expectedFiles)),
+ callback);
+}
+
+/**
* Verifies that scanning a simple single-level directory structure works.
*/
function testEmptyScanResults(callback) {
« no previous file with comments | « ui/file_manager/file_manager/background/js/media_scanner.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698