| 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',
|
|
|