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

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

Issue 885653003: Files.app: Add deduplication code for imports to Google Drive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback. Created 5 years, 11 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_import_handler.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_import_handler_unittest.js
diff --git a/ui/file_manager/file_manager/background/js/media_import_handler_unittest.js b/ui/file_manager/file_manager/background/js/media_import_handler_unittest.js
index d6ab975fc5cc95d75e6414be9386bcd751fa2739..3c0eeb36558f757a063ebf3596e4cf95f4e47e3f 100644
--- a/ui/file_manager/file_manager/background/js/media_import_handler_unittest.js
+++ b/ui/file_manager/file_manager/background/js/media_import_handler_unittest.js
@@ -201,6 +201,65 @@ function testImportCancellation(callback) {
scanResult.finalize();
}
+function testImportWithDuplicates(callback) {
+ var media = setupFileSystem([
+ '/DCIM/photos0/IMG00001.jpg',
+ '/DCIM/photos0/IMG00002.jpg',
+ '/DCIM/photos0/IMG00003.jpg',
+ '/DCIM/photos1/IMG00004.jpg',
+ '/DCIM/photos1/IMG00005.jpg',
+ '/DCIM/photos1/IMG00006.jpg'
+ ]);
+
+ /** @const {number} */
+ var EXPECTED_COPY_COUNT = 3;
+
+ var scanResult = new TestScanResult(media);
+ var importTask =
+ mediaImporter.importFromScanResult(scanResult, destinationFactory);
+ var whenImportDone = new Promise(
+ function(resolve, reject) {
+ importTask.addObserver(
+ /**
+ * @param {!importer.TaskQueue.UpdateType} updateType
+ * @param {!importer.TaskQueue.Task} task
+ */
+ function(updateType, task) {
+ switch (updateType) {
+ case importer.TaskQueue.UpdateType.SUCCESS:
+ resolve();
+ break;
+ case importer.TaskQueue.UpdateType.ERROR:
+ reject(new Error(importer.TaskQueue.UpdateType.ERROR));
+ break;
+ }
+ });
+ });
+
+ // Simulate a known number of new imports followed by a bunch of duplicate
+ // imports.
+ var copyCount = 0;
+ importTask.addObserver(function(updateType) {
+ if (updateType ===
+ importer.MediaImportHandler.ImportTask.UpdateType.ENTRY_CHANGED) {
+ copyCount++;
+ if (copyCount === EXPECTED_COPY_COUNT) {
+ duplicateFinder.returnValue = true;
+ }
+ }
+ });
+
+ reportPromise(
+ whenImportDone.then(
+ function() {
+ var copiedEntries = destinationFileSystem.root.getAllChildren();
+ assertEquals(EXPECTED_COPY_COUNT, copiedEntries.length);
+ }),
+ callback);
+
+ scanResult.finalize();
+}
+
/**
* @param {!Array.<string>} fileNames
* @return {!Array.<!Entry>}
« no previous file with comments | « ui/file_manager/file_manager/background/js/media_import_handler.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698