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..e1098014db6a74c77b563caa31bbd3144800208d 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. |
mtomasz
2015/03/05 04:36:53
nit: This could really fit in two lines and be eas
Steve McKay
2015/03/05 21:39:04
Acknowledged.
|
+ // 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; |
@@ -156,15 +172,30 @@ function testSingleLevel(callback) { |
* Verifies that scanning ignores previously imported entries. |
*/ |
function testIgnoresPreviousImports(callback) { |
+ |
mtomasz
2015/03/05 04:36:53
nit: remove.
Steve McKay
2015/03/05 21:39:04
Done.
|
importHistory.importedPaths[ |
'/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 +301,7 @@ function testMultipleDirectories(callback) { |
callback); |
} |
-function testDedupesFiles(callback) { |
+function testDedupesFilesInScanResult(callback) { |
var filenames = [ |
[ |
'a', |