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

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

Issue 954943006: Ensure the destination url reported to ImportHistory is correctly encoded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_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 4ef6b3e29b58de00b11fa6e276915da38a2cb53c..173886534f5cd2097a4be1a92d9b191c6eee3824 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
@@ -74,7 +74,7 @@ function setUp() {
importHistory = new importer.TestImportHistory();
mediaScanner = new TestMediaScanner();
- destinationFileSystem = new MockFileSystem(destinationFactory);
+ destinationFileSystem = new MockFileSystem('googleDriveFilesystem');
destinationFactory = Promise.resolve(destinationFileSystem.root);
duplicateFinderFactory = new importer.TestDuplicateFinder.Factory();
@@ -130,6 +130,49 @@ function testImportMedia(callback) {
scanResult.finalize();
}
+function testImportMedia_EmploysEncodedUrls(callback) {
+ var media = setupFileSystem([
+ '/DCIM/photos0/Mom and Dad.jpg',
+ ]);
+
+ var scanResult = new TestScanResult(media);
+ var importTask = mediaImporter.importFromScanResult(
+ scanResult,
+ importer.Destination.GOOGLE_DRIVE,
+ destinationFactory);
+
+ var promise = 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.COMPLETE:
+ resolve(destinationFileSystem.root.getAllChildren());
+ break;
+ case importer.TaskQueue.UpdateType.ERROR:
+ reject('Task failed :(');
+ break;
+ }
+ });
+ })
+ .then(
+ function(copiedEntries) {
+ var expected = 'Mom%20and%20Dad.jpg';
+ var url = copiedEntries[0].toURL();
+ assertTrue(url.length > expected.length);
+ var actual = url.substring(url.length - expected.length);
+ assertEquals(expected, actual);
+ });
+
+ reportPromise(promise, callback);
+
+ scanResult.finalize();
+}
+
// Verifies that when files with duplicate names are imported, that they don't
// overwrite one another.
function testImportMediaWithDuplicateFilenames(callback) {
@@ -390,6 +433,11 @@ function testImportWithDuplicates(callback) {
}
function testImportWithErrors(callback) {
+
+ // Quiet the logger just in this test where we expect errors.
+ // Elsewhere, it's better for errors to be seen by test authors.
+ importer.setupTestLogger().quiet();
+
var media = setupFileSystem([
'/DCIM/photos0/IMG00001.jpg',
'/DCIM/photos0/IMG00002.jpg',

Powered by Google App Engine
This is Rietveld 408576698