Chromium Code Reviews| Index: ui/file_manager/file_manager/background/js/duplicate_finder_unittest.js |
| diff --git a/ui/file_manager/file_manager/background/js/duplicate_finder_unittest.js b/ui/file_manager/file_manager/background/js/duplicate_finder_unittest.js |
| index 9efc3009af607ed53d8c17f68628f3c612d131e5..1f97a2140efa5ed900a928458cf63611dcedb851 100644 |
| --- a/ui/file_manager/file_manager/background/js/duplicate_finder_unittest.js |
| +++ b/ui/file_manager/file_manager/background/js/duplicate_finder_unittest.js |
| @@ -23,6 +23,13 @@ var fileUrls = {}; |
| /** @type {!MockFileSystem} */ |
| var fileSystem; |
| +/** @type {!importer.TestImportHistory} */ |
| +var testHistory; |
| + |
| +/** @type {function(!FileEntry, !importer.Destination): |
| + !importer.Disposition} */ |
| +var getDisposition; |
| + |
| // Set up string assets. |
| loadTimeData.data = { |
| CLOUD_IMPORT_ITEMS_REMAINING: '', |
| @@ -68,7 +75,12 @@ function setUp() { |
| } |
| }; |
| - duplicateFinder = new importer.DriveDuplicateFinder(); |
| + testHistory = new importer.TestImportHistory(); |
| + var tracker = new TestTracker(); |
| + duplicateFinder = new importer.DriveDuplicateFinder(tracker); |
| + |
| + getDisposition = importer.DispositionChecker.createChecker( |
| + testHistory, tracker); |
| } |
| // Verifies the correct result when a duplicate exists. |
| @@ -78,7 +90,7 @@ function testCheckDuplicateTrue(callback) { |
| var files = setupHashes(filePaths, fileHashes); |
| reportPromise( |
| - duplicateFinder.checkDuplicate(files[0]) |
| + duplicateFinder.isDuplicate(files[0]) |
| .then( |
| function(isDuplicate) { |
| assertTrue(isDuplicate); |
| @@ -98,7 +110,7 @@ function testCheckDuplicateFalse(callback) { |
| var newFile = fileSystem.entries[newFilePath]; |
| reportPromise( |
| - duplicateFinder.checkDuplicate(newFile) |
| + duplicateFinder.isDuplicate(newFile) |
| .then( |
| function(isDuplicate) { |
| assertFalse(isDuplicate); |
| @@ -106,6 +118,64 @@ function testCheckDuplicateFalse(callback) { |
| callback); |
| }; |
| +// Verifies the correct result when a duplicate doesn't exist. |
|
Ben Kwa
2015/03/05 20:05:10
"when a content duplicate exists."
Steve McKay
2015/03/05 21:39:03
Removed line entirely.
|
| +function testDispositionChecker_ContentDupe(callback) { |
| + var filePaths = ['/foo.txt']; |
| + var fileHashes = ['abc123']; |
| + var files = setupHashes(filePaths, fileHashes); |
| + |
| + reportPromise( |
| + getDisposition(files[0], importer.Destination.GOOGLE_DRIVE) |
| + .then( |
| + function(disposition) { |
| + assertEquals( |
| + importer.Disposition.CONTENT_DUPLICATE, |
| + disposition); |
| + }), |
| + callback); |
| +}; |
| + |
| +// Verifies the correct result when a duplicate doesn't exist. |
|
Ben Kwa
2015/03/05 20:05:10
"when a history duplicate exists."
Steve McKay
2015/03/05 21:39:03
Ditto.
|
| +function testDispositionChecker_HistoryDupe(callback) { |
| + var filePaths = ['/foo.txt']; |
| + var fileHashes = ['abc123']; |
| + var files = setupHashes(filePaths, fileHashes); |
| + |
| + testHistory.importedPaths[ |
|
mtomasz
2015/03/05 04:36:52
nit: Line wrappings look off.
Steve McKay
2015/03/05 21:39:03
Done.
|
| + '/foo.txt'] = |
| + [importer.Destination.GOOGLE_DRIVE]; |
| + |
| + reportPromise( |
| + getDisposition(files[0], importer.Destination.GOOGLE_DRIVE) |
| + .then( |
| + function(disposition) { |
| + assertEquals( |
| + importer.Disposition.HISTORY_DUPLICATE, |
| + disposition); |
| + }), |
| + callback); |
| +}; |
| + |
| +// Verifies the correct result when a duplicate doesn't exist. |
| +function testDispositionChecker_Original(callback) { |
| + var filePaths = ['/foo.txt']; |
| + var fileHashes = ['abc123']; |
| + var files = setupHashes(filePaths, fileHashes); |
| + |
| + // Make another file. |
| + var newFilePath = '/bar.txt'; |
| + fileSystem.populate([newFilePath]); |
| + var newFile = fileSystem.entries[newFilePath]; |
| + |
| + reportPromise( |
| + getDisposition(newFile, importer.Destination.GOOGLE_DRIVE) |
| + .then( |
| + function(disposition) { |
| + assertEquals(importer.Disposition.ORIGINAL, disposition); |
| + }), |
| + callback); |
| +}; |
| + |
| /** |
| * @param {!Array.<string>} filePaths |
| * @param {!Array.<string>} fileHashes |