Commit 21027a57 authored by Jérémie Boulic's avatar Jérémie Boulic Committed by Chromium LUCI CQ

[Files app] Generate modules for importer_common.js and dependencies

Convert the following JS files in
//ui/file_manager/file_manager/common/js:
- test_importer_common.js
- unittest_util.js
- importer_common.js
- importer_common_unittest.js

Bug: 1133186
Change-Id: I3c4ae19a4d2a5a6b56087f6bc0390b7c1dbd3252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2579932
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835630}
parent 0bf3d71d
...@@ -161,7 +161,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) { ...@@ -161,7 +161,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImporterCommonTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImporterCommonTest) {
RunTestURL("common/js/importer_common_unittest_gen.html"); RunTestURL("common/js/importer_common_unittest.m_gen.html");
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportHistoryTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportHistoryTest) {
......
...@@ -60,7 +60,6 @@ group("unit_test_data") { ...@@ -60,7 +60,6 @@ group("unit_test_data") {
"base/js:js_test_gen_html", "base/js:js_test_gen_html",
"file_manager/background/js:js_test_gen_html", "file_manager/background/js:js_test_gen_html",
"file_manager/background/js:js_test_gen_html_modules", "file_manager/background/js:js_test_gen_html_modules",
"file_manager/common/js:js_test_gen_html",
"file_manager/common/js:js_test_gen_html_modules", "file_manager/common/js:js_test_gen_html_modules",
"file_manager/foreground/elements:js_test_gen_html_modules", "file_manager/foreground/elements:js_test_gen_html_modules",
"file_manager/foreground/js:js_test_gen_html", "file_manager/foreground/js:js_test_gen_html",
...@@ -225,8 +224,8 @@ generate_grd("build_grd") { ...@@ -225,8 +224,8 @@ generate_grd("build_grd") {
] ]
deps = [ deps = [
"file_manager:build_static_grdp",
"audio_player:build_static_grdp", "audio_player:build_static_grdp",
"file_manager:build_static_grdp",
"//ui/file_manager/audio_player/js:build", "//ui/file_manager/audio_player/js:build",
"//ui/file_manager/audio_player/js:build_background", "//ui/file_manager/audio_player/js:build_background",
"//ui/file_manager/audio_player/js:build_worker", "//ui/file_manager/audio_player/js:build_worker",
......
...@@ -17,7 +17,7 @@ group("closure_compile") { ...@@ -17,7 +17,7 @@ group("closure_compile") {
":closure_compile_jsmodules", ":closure_compile_jsmodules",
":closure_compile_module", ":closure_compile_module",
":js_test_gen_html_modules_type_check_auto", ":js_test_gen_html_modules_type_check_auto",
":js_test_gen_html_type_check_auto", ":test_support_modules_type_check",
":test_support_type_check", ":test_support_type_check",
] ]
} }
...@@ -47,6 +47,7 @@ js_type_check("closure_compile_jsmodules") { ...@@ -47,6 +47,7 @@ js_type_check("closure_compile_jsmodules") {
":file_operation_common.m", ":file_operation_common.m",
":file_type.m", ":file_type.m",
":files_app_entry_types.m", ":files_app_entry_types.m",
":importer_common.m",
":lru_cache.m", ":lru_cache.m",
":metrics.m", ":metrics.m",
":metrics_base.m", ":metrics_base.m",
...@@ -64,6 +65,19 @@ js_type_check("test_support_type_check") { ...@@ -64,6 +65,19 @@ js_type_check("test_support_type_check") {
] ]
} }
js_type_check("test_support_modules_type_check") {
uses_js_modules = true
testonly = true
deps = [
":test_importer_common.m",
":unittest_util.m",
]
closure_flags =
strict_error_checking_closure_args +
[ "browser_resolver_prefix_replacements=\"chrome://test/=./\"" ]
}
js_library("async_util") { js_library("async_util") {
} }
...@@ -160,6 +174,21 @@ js_library("importer_common") { ...@@ -160,6 +174,21 @@ js_library("importer_common") {
] ]
} }
js_library("importer_common.m") {
sources = [
"$root_gen_dir/ui/file_manager/file_manager/common/js/importer_common.m.js",
]
deps = [
":file_type.m",
"//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/externs:files_app_entry_interfaces.m",
"//ui/file_manager/externs:volume_info.m",
"//ui/file_manager/externs:volume_manager.m",
]
extra_deps = [ ":modulize" ]
}
js_library("test_importer_common") { js_library("test_importer_common") {
testonly = true testonly = true
deps = [ deps = [
...@@ -172,13 +201,26 @@ js_library("test_importer_common") { ...@@ -172,13 +201,26 @@ js_library("test_importer_common") {
visibility = [ "//ui/file_manager/file_manager/*" ] visibility = [ "//ui/file_manager/file_manager/*" ]
} }
js_unittest("importer_common_unittest") { js_library("test_importer_common.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/common/js/test_importer_common.m.js" ]
deps = [ deps = [
":mock_entry", ":importer_common.m",
":test_importer_common", ":unittest_util.m",
":util", ]
"//ui/file_manager/base/js:mock_chrome",
"//ui/file_manager/file_manager/background/js:mock_volume_manager", extra_deps = [ ":modulize" ]
}
js_unittest("importer_common_unittest.m") {
deps = [
":mock_entry.m",
":test_importer_common.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:mock_chrome.m",
"//ui/file_manager/base/js:test_error_reporting.m",
"//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/externs:volume_info.m",
"//ui/file_manager/file_manager/background/js:mock_volume_manager.m",
] ]
} }
...@@ -287,6 +329,15 @@ js_library("unittest_util") { ...@@ -287,6 +329,15 @@ js_library("unittest_util") {
externs_list = [ "$externs_path/command_line_private.js" ] externs_list = [ "$externs_path/command_line_private.js" ]
} }
js_library("unittest_util.m") {
sources = [
"$root_gen_dir/ui/file_manager/file_manager/common/js/unittest_util.m.js",
]
deps = [ "//chrome/test/data/webui:chai_assert" ]
extra_deps = [ ":modulize" ]
}
js_library("util") { js_library("util") {
deps = [ deps = [
":files_app_entry_types", ":files_app_entry_types",
...@@ -353,6 +404,7 @@ js_test_gen_html("js_test_gen_html_modules") { ...@@ -353,6 +404,7 @@ js_test_gen_html("js_test_gen_html_modules") {
deps = [ deps = [
":file_type_unittest.m", ":file_type_unittest.m",
":files_app_entry_types_unittest.m", ":files_app_entry_types_unittest.m",
":importer_common_unittest.m",
":lru_cache_unittest.m", ":lru_cache_unittest.m",
":util_unittest.m", ":util_unittest.m",
] ]
...@@ -366,10 +418,6 @@ js_test_gen_html("js_test_gen_html_modules") { ...@@ -366,10 +418,6 @@ js_test_gen_html("js_test_gen_html_modules") {
] ]
} }
js_test_gen_html("js_test_gen_html") {
deps = [ ":importer_common_unittest" ]
}
js_modulizer("modulize") { js_modulizer("modulize") {
input_files = [ input_files = [
"async_util.js", "async_util.js",
...@@ -382,6 +430,9 @@ js_modulizer("modulize") { ...@@ -382,6 +430,9 @@ js_modulizer("modulize") {
"mock_entry.js", "mock_entry.js",
"util.js", "util.js",
"trash.js", "trash.js",
"importer_common.js",
"test_importer_common.js",
"unittest_util.js",
] ]
namespace_rewrites = cr_namespace_rewrites namespace_rewrites = cr_namespace_rewrites
......
...@@ -2,7 +2,21 @@ ...@@ -2,7 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/**
* @fileoverview
* @suppress {uselessCode} Temporary suppress because of the line exporting.
*/
// clang-format off
// #import {FilesAppEntry} from '../../../externs/files_app_entry_interfaces.m.js';
// #import {VolumeInfo} from '../../../externs/volume_info.m.js';
// #import {VolumeManager} from '../../../externs/volume_manager.m.js';
// #import {FileType} from './file_type.m.js';
// #import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
// clang-format on
// Namespace // Namespace
// eslint-disable-next-line no-var
var importer = importer || {}; var importer = importer || {};
importer.TaskQueue = importer.TaskQueue || {}; importer.TaskQueue = importer.TaskQueue || {};
...@@ -172,7 +186,7 @@ importer.isBeneathMediaDir = (entry, volumeManager) => { ...@@ -172,7 +186,7 @@ importer.isBeneathMediaDir = (entry, volumeManager) => {
* @return {boolean} * @return {boolean}
*/ */
importer.isEligibleVolume = volumeInfo => { importer.isEligibleVolume = volumeInfo => {
return !!volumeInfo && return !!volumeInfo && !!volumeInfo.volumeType &&
importer.ELIGIBLE_VOLUME_TYPES_.indexOf(volumeInfo.volumeType) !== -1; importer.ELIGIBLE_VOLUME_TYPES_.indexOf(volumeInfo.volumeType) !== -1;
}; };
...@@ -969,3 +983,6 @@ importer.ChromeLocalStorage = class { ...@@ -969,3 +983,6 @@ importer.ChromeLocalStorage = class {
/** @private @const {!importer.ChromeLocalStorage} */ /** @private @const {!importer.ChromeLocalStorage} */
importer.ChromeLocalStorage.INSTANCE_ = new importer.ChromeLocalStorage(); importer.ChromeLocalStorage.INSTANCE_ = new importer.ChromeLocalStorage();
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {importer};
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import {assertEquals, assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import {MockChromeStorageAPI, MockCommandLinePrivate} from '../../../base/js/mock_chrome.m.js';
import {reportPromise} from '../../../base/js/test_error_reporting.m.js';
import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
import {VolumeInfo} from '../../../externs/volume_info.m.js';
import {MockVolumeManager} from '../../background/js/mock_volume_manager.m.js';
import {MockDirectoryEntry, MockFileEntry} from './mock_entry.m.js';
import {importer} from './test_importer_common.m.js';
/** @type {!MockVolumeManager} */ /** @type {!MockVolumeManager} */
let volumeManager; let volumeManager;
...@@ -27,7 +38,7 @@ let sdFileEntry; ...@@ -27,7 +38,7 @@ let sdFileEntry;
let driveFileEntry; let driveFileEntry;
// Set up the test components. // Set up the test components.
function setUp() { export function setUp() {
window.loadTimeData.getString = id => id; window.loadTimeData.getString = id => id;
new MockCommandLinePrivate(); new MockCommandLinePrivate();
new MockChromeStorageAPI(); new MockChromeStorageAPI();
...@@ -48,7 +59,7 @@ function setUp() { ...@@ -48,7 +59,7 @@ function setUp() {
driveFileEntry = createFileEntry(driveVolume, '/someotherfile.jpg'); driveFileEntry = createFileEntry(driveVolume, '/someotherfile.jpg');
} }
function testIsEligibleType() { export function testIsEligibleType() {
assertTrue(importer.isEligibleType(cameraFileEntry)); assertTrue(importer.isEligibleType(cameraFileEntry));
assertTrue(importer.isEligibleType(rawFileEntry)); assertTrue(importer.isEligibleType(rawFileEntry));
...@@ -56,26 +67,26 @@ function testIsEligibleType() { ...@@ -56,26 +67,26 @@ function testIsEligibleType() {
assertTrue(importer.isEligibleType(driveFileEntry)); assertTrue(importer.isEligibleType(driveFileEntry));
} }
function testIsEligibleVolume() { export function testIsEligibleVolume() {
assertTrue(importer.isEligibleVolume(cameraVolume)); assertTrue(importer.isEligibleVolume(cameraVolume));
assertTrue(importer.isEligibleVolume(sdVolume)); assertTrue(importer.isEligibleVolume(sdVolume));
assertFalse(importer.isEligibleVolume(driveVolume)); assertFalse(importer.isEligibleVolume(driveVolume));
} }
function testIsEligibleEntry() { export function testIsEligibleEntry() {
assertTrue(importer.isEligibleEntry(volumeManager, cameraFileEntry)); assertTrue(importer.isEligibleEntry(volumeManager, cameraFileEntry));
assertTrue(importer.isEligibleEntry(volumeManager, sdFileEntry)); assertTrue(importer.isEligibleEntry(volumeManager, sdFileEntry));
assertTrue(importer.isEligibleEntry(volumeManager, rawFileEntry)); assertTrue(importer.isEligibleEntry(volumeManager, rawFileEntry));
assertFalse(importer.isEligibleEntry(volumeManager, driveFileEntry)); assertFalse(importer.isEligibleEntry(volumeManager, driveFileEntry));
} }
function testIsMediaDirectory() { export function testIsMediaDirectory() {
['/DCIM', '/DCIM/', '/dcim', '/dcim/', '/MP_ROOT/'].forEach(assertIsMediaDir); ['/DCIM', '/DCIM/', '/dcim', '/dcim/', '/MP_ROOT/'].forEach(assertIsMediaDir);
['/blabbity/DCIM', '/blabbity/dcim', '/blabbity-blab'].forEach( ['/blabbity/DCIM', '/blabbity/dcim', '/blabbity-blab'].forEach(
assertIsNotMediaDir); assertIsNotMediaDir);
} }
function testResolver_Resolve(callback) { export function testResolver_Resolve(callback) {
const resolver = new importer.Resolver(); const resolver = new importer.Resolver();
assertFalse(resolver.settled); assertFalse(resolver.settled);
resolver.resolve(1); resolver.resolve(1);
...@@ -87,7 +98,7 @@ function testResolver_Resolve(callback) { ...@@ -87,7 +98,7 @@ function testResolver_Resolve(callback) {
reportPromise(resolver.promise, callback); reportPromise(resolver.promise, callback);
} }
function testResolver_Reject(callback) { export function testResolver_Reject(callback) {
const resolver = new importer.Resolver(); const resolver = new importer.Resolver();
assertFalse(resolver.settled); assertFalse(resolver.settled);
resolver.reject('ouch'); resolver.reject('ouch');
...@@ -98,7 +109,7 @@ function testResolver_Reject(callback) { ...@@ -98,7 +109,7 @@ function testResolver_Reject(callback) {
}); });
} }
function testGetMachineId_Persisted(callback) { export function testGetMachineId_Persisted(callback) {
const promise = importer.getMachineId().then(firstMachineId => { const promise = importer.getMachineId().then(firstMachineId => {
assertTrue(100000 <= firstMachineId <= 9999999); assertTrue(100000 <= firstMachineId <= 9999999);
importer.getMachineId().then(secondMachineId => { importer.getMachineId().then(secondMachineId => {
...@@ -108,13 +119,13 @@ function testGetMachineId_Persisted(callback) { ...@@ -108,13 +119,13 @@ function testGetMachineId_Persisted(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testPhotosApp_DefaultDisabled(callback) { export function testPhotosApp_DefaultDisabled(callback) {
const promise = importer.isPhotosAppImportEnabled().then(assertFalse); const promise = importer.isPhotosAppImportEnabled().then(assertFalse);
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testPhotosApp_ImportEnabled(callback) { export function testPhotosApp_ImportEnabled(callback) {
const promise = importer.handlePhotosAppMessage(true).then(() => { const promise = importer.handlePhotosAppMessage(true).then(() => {
return importer.isPhotosAppImportEnabled().then(assertTrue); return importer.isPhotosAppImportEnabled().then(assertTrue);
}); });
...@@ -122,7 +133,7 @@ function testPhotosApp_ImportEnabled(callback) { ...@@ -122,7 +133,7 @@ function testPhotosApp_ImportEnabled(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testPhotosApp_ImportDisabled(callback) { export function testPhotosApp_ImportDisabled(callback) {
const promise = importer.handlePhotosAppMessage(false).then(() => { const promise = importer.handlePhotosAppMessage(false).then(() => {
return importer.isPhotosAppImportEnabled().then(assertFalse); return importer.isPhotosAppImportEnabled().then(assertFalse);
}); });
...@@ -130,7 +141,7 @@ function testPhotosApp_ImportDisabled(callback) { ...@@ -130,7 +141,7 @@ function testPhotosApp_ImportDisabled(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testHistoryFilename(callback) { export function testHistoryFilename(callback) {
const promise = importer.getHistoryFilename().then(firstName => { const promise = importer.getHistoryFilename().then(firstName => {
assertTrue(!!firstName && firstName.length > 10); assertTrue(!!firstName && firstName.length > 10);
importer.getHistoryFilename().then(secondName => { importer.getHistoryFilename().then(secondName => {
...@@ -141,7 +152,7 @@ function testHistoryFilename(callback) { ...@@ -141,7 +152,7 @@ function testHistoryFilename(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testLocalStorageWrapper(callback) { export function testLocalStorageWrapper(callback) {
const storage = new importer.ChromeLocalStorage(); const storage = new importer.ChromeLocalStorage();
const promise = const promise =
Promise Promise
...@@ -161,7 +172,7 @@ function testLocalStorageWrapper(callback) { ...@@ -161,7 +172,7 @@ function testLocalStorageWrapper(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testRotateLogs(callback) { export function testRotateLogs(callback) {
let fileName; let fileName;
const fileFactory = namePromise => { const fileFactory = namePromise => {
return namePromise.then(name => { return namePromise.then(name => {
...@@ -195,7 +206,7 @@ function testRotateLogs(callback) { ...@@ -195,7 +206,7 @@ function testRotateLogs(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testRotateLogs_RemembersInitialActiveLog(callback) { export function testRotateLogs_RemembersInitialActiveLog(callback) {
const nextLogId = 1; const nextLogId = 1;
// Should not be called. // Should not be called.
...@@ -213,7 +224,7 @@ function testRotateLogs_RemembersInitialActiveLog(callback) { ...@@ -213,7 +224,7 @@ function testRotateLogs_RemembersInitialActiveLog(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testDeflateAppUrl() { export function testDeflateAppUrl() {
const url = 'filesystem:chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj' + const url = 'filesystem:chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj' +
'/external/removable/USB%20Drive/DCIM/derekkind2.jpg'; '/external/removable/USB%20Drive/DCIM/derekkind2.jpg';
const deflated = importer.deflateAppUrl(url); const deflated = importer.deflateAppUrl(url);
...@@ -234,7 +245,7 @@ function testDeflateAppUrl() { ...@@ -234,7 +245,7 @@ function testDeflateAppUrl() {
'Deflated then inflated URLs must match original URL.'); 'Deflated then inflated URLs must match original URL.');
} }
function testHasMediaDirectory(callback) { export function testHasMediaDirectory(callback) {
const dir = createDirectoryEntry(sdVolume, '/DCIM'); const dir = createDirectoryEntry(sdVolume, '/DCIM');
const promise = importer.hasMediaDirectory(sdVolume.fileSystem.root) const promise = importer.hasMediaDirectory(sdVolume.fileSystem.root)
.then(assertTrue.bind(null)); .then(assertTrue.bind(null));
......
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Shared cloud importer namespace /**
var importer = importer || {}; * @fileoverview
* @suppress {uselessCode} Temporary suppress because of the line exporting.
*/
// Shared cloud importer namespace.
// #import {importer} from './importer_common.m.js';
// #import {TestCallRecorder} from './unittest_util.m.js';
/** /**
* Sets up a logger for use in unit tests. The test logger doesn't attempt to * Sets up a logger for use in unit tests. The test logger doesn't attempt to
...@@ -68,3 +75,6 @@ importer.TestLogger = class { ...@@ -68,3 +75,6 @@ importer.TestLogger = class {
}; };
} }
}; };
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {importer};
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {assertTrue, assertEquals} from 'chrome://test/chai_assert.js';
/** /**
* Asserts that two lists contain the same set of Entries. Entries are deemed * Asserts that two lists contain the same set of Entries. Entries are deemed
* to be the same if they point to the same full path. * to be the same if they point to the same full path.
...@@ -9,7 +11,7 @@ ...@@ -9,7 +11,7 @@
* @param {!Array<!FileEntry>} expected * @param {!Array<!FileEntry>} expected
* @param {!Array<!FileEntry>} actual * @param {!Array<!FileEntry>} actual
*/ */
function assertFileEntryListEquals(expected, actual) { /* #export */ function assertFileEntryListEquals(expected, actual) {
const entryToPath = entry => { const entryToPath = entry => {
assertTrue(entry.isFile); assertTrue(entry.isFile);
return entry.fullPath; return entry.fullPath;
...@@ -24,7 +26,7 @@ function assertFileEntryListEquals(expected, actual) { ...@@ -24,7 +26,7 @@ function assertFileEntryListEquals(expected, actual) {
* @param {!Array<string>} expectedPaths * @param {!Array<string>} expectedPaths
* @param {!Array<!FileEntry>} fileEntries * @param {!Array<!FileEntry>} fileEntries
*/ */
function assertFileEntryPathsEqual(expectedPaths, fileEntries) { /* #export */ function assertFileEntryPathsEqual(expectedPaths, fileEntries) {
assertEquals(expectedPaths.length, fileEntries.length); assertEquals(expectedPaths.length, fileEntries.length);
const entryToPath = entry => { const entryToPath = entry => {
...@@ -53,7 +55,7 @@ function assertFileEntryPathsEqual(expectedPaths, fileEntries) { ...@@ -53,7 +55,7 @@ function assertFileEntryPathsEqual(expectedPaths, fileEntries) {
* assertEquals(recorder.getListCall()[0], 'hammy'); * assertEquals(recorder.getListCall()[0], 'hammy');
* </pre> * </pre>
*/ */
class TestCallRecorder { /* #export */ class TestCallRecorder {
constructor() { constructor() {
/** @private {!Array<!Arguments>} */ /** @private {!Array<!Arguments>} */
this.calls_ = []; this.calls_ = [];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment