Commit efc32dd3 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Chromium LUCI CQ

Files app: Generate JS module for background page

Generate JS module for //ui/file_manager/file_manager/background/js/
* device_handler.js
* device_handler_unittest.m.js
* device_handler_unittest.m.js
* launcher.js
* launcher_search.js
* progress_center.js
* volume_manger_unittest.m.js

Bug: 1133186
Change-Id: Ib0ffb982f727a76692ceb0ba320269f7ffe9279d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612548
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840504}
parent 0ac57cc1
......@@ -42,7 +42,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, Crostini) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DeviceHandlerTest) {
RunTestURL("background/js/device_handler_unittest_gen.html");
RunTestURL("background/js/device_handler_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DirectoryContentsTest) {
......@@ -254,5 +254,5 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, UtilTest) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, VolumeManagerTest) {
RunTestURL("background/js/volume_manager_unittest_gen.html");
RunTestURL("background/js/volume_manager_unittest.m_gen.html");
}
......@@ -58,7 +58,6 @@ group("unit_test_data") {
testonly = true
deps = [
"base/js:js_test_gen_html",
"file_manager/background/js:js_test_gen_html",
"file_manager/background/js:js_test_gen_html_modules",
"file_manager/common/js:js_test_gen_html_modules",
"file_manager/foreground/elements:js_test_gen_html_modules",
......
......@@ -27,7 +27,6 @@ group("closure_compile") {
":closure_compile_jsmodules",
":closure_compile_module",
":js_test_gen_html_modules_type_check_auto",
":js_test_gen_html_type_check_auto",
":test_support_modules_type_check",
":test_support_type_check",
]
......@@ -77,6 +76,7 @@ js_type_check("closure_compile_jsmodules") {
":app_windows.m",
":background_base.m",
":crostini.m",
":device_handler.m",
":drive_sync_handler.m",
":duplicate_finder.m",
":entry_location_impl.m",
......@@ -84,6 +84,8 @@ js_type_check("closure_compile_jsmodules") {
":file_operation_manager.m",
":file_operation_util.m",
":import_history.m",
":launcher.m",
":launcher_search.m",
":media_import_handler.m",
":media_scanner.m",
":metadata_proxy.m",
......@@ -91,6 +93,7 @@ js_type_check("closure_compile_jsmodules") {
":mock_file_operation_manager.m",
":mock_progress_center.m",
":mount_metrics.m",
":progress_center.m",
":task_queue.m",
":test_util_base.m",
":trash.m",
......@@ -316,14 +319,38 @@ js_library("device_handler") {
]
}
js_unittest("device_handler_unittest") {
js_library("device_handler.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/device_handler.m.js" ]
deps = [
":device_handler",
":mock_progress_center",
":mock_volume_manager",
"//ui/file_manager/base/js:mock_chrome",
"//ui/file_manager/base/js:test_error_reporting",
"//ui/file_manager/file_manager/common/js:test_importer_common",
":volume_manager_factory.m",
"//ui/file_manager/externs:volume_info.m",
"//ui/file_manager/externs:volume_manager.m",
"//ui/file_manager/externs/background:progress_center.m",
"//ui/file_manager/file_manager/common/js:async_util.m",
"//ui/file_manager/file_manager/common/js:importer_common.m",
"//ui/file_manager/file_manager/common/js:metrics.m",
"//ui/file_manager/file_manager/common/js:progress_center_common.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_unittest("device_handler_unittest.m") {
deps = [
":device_handler.m",
":mock_progress_center.m",
":mock_volume_manager.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/common/js:importer_common.m",
"//ui/file_manager/file_manager/common/js:metrics.m",
"//ui/file_manager/file_manager/common/js:mock_entry.m",
"//ui/webui/resources/js:load_time_data.m",
]
}
......@@ -637,6 +664,18 @@ js_library("launcher") {
]
}
js_library("launcher.m") {
sources = [
"$root_gen_dir/ui/file_manager/file_manager/background/js/launcher.m.js",
]
deps = [
":app_window_wrapper.m",
"//ui/file_manager/file_manager/common/js:util.m",
]
extra_deps = [ ":modulize" ]
}
js_library("launcher_search") {
deps = [
":launcher",
......@@ -646,6 +685,20 @@ js_library("launcher_search") {
]
}
js_library("launcher_search.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/launcher_search.m.js" ]
deps = [
":launcher.m",
":volume_manager_factory.m",
"//ui/file_manager/file_manager/common/js:file_type.m",
"//ui/file_manager/file_manager/common/js:util.m",
]
externs_list = [ "//ui/file_manager/externs/launcher_search_provider.js" ]
extra_deps = [ ":modulize" ]
}
js_library("media_import_handler") {
deps = [
":drive_sync_handler",
......@@ -834,6 +887,19 @@ js_library("progress_center") {
]
}
js_library("progress_center.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/progress_center.m.js" ]
deps = [
"//ui/file_manager/externs:progress_center_panel.m",
"//ui/file_manager/externs/background:progress_center.m",
"//ui/file_manager/file_manager/common/js:async_util.m",
"//ui/file_manager/file_manager/common/js:progress_center_common.m",
"//ui/file_manager/file_manager/common/js:util.m",
]
extra_deps = [ ":modulize" ]
}
js_library("runtime_loaded_test_util") {
# TODO(tapted): Move this target to //ui/file_manager/base. It is used in the
# background page of all |related_apps|, but loaded at runtime by
......@@ -1071,12 +1137,18 @@ js_library("volume_manager_factory.m") {
extra_deps = [ ":modulize" ]
}
js_unittest("volume_manager_unittest") {
js_unittest("volume_manager_unittest.m") {
deps = [
":volume_manager_factory",
"//ui/file_manager/base/js:mock_chrome",
"//ui/file_manager/base/js:test_error_reporting",
"//ui/file_manager/file_manager/common/js:mock_entry",
":volume_info_impl.m",
":volume_manager_factory.m",
":volume_manager_impl.m",
":volume_manager_util.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/file_manager/common/js:mock_entry.m",
"//ui/webui/resources/js:load_time_data.m",
]
}
......@@ -1104,6 +1176,7 @@ js_library("volume_manager_util.m") {
js_test_gen_html("js_test_gen_html_modules") {
deps = [
":crostini_unittest.m",
":device_handler_unittest.m",
":drive_sync_handler_unittest.m",
":duplicate_finder_unittest.m",
":file_operation_handler_unittest.m",
......@@ -1115,6 +1188,7 @@ js_test_gen_html("js_test_gen_html_modules") {
":mount_metrics_unittest.m",
":task_queue_unittest.m",
":trash_unittest.m",
":volume_manager_unittest.m",
]
js_module = true
......@@ -1127,13 +1201,6 @@ js_test_gen_html("js_test_gen_html_modules") {
]
}
js_test_gen_html("js_test_gen_html") {
deps = [
":device_handler_unittest",
":volume_manager_unittest",
]
}
js_modulizer("modulize") {
input_files = [
"metadata_proxy.js",
......@@ -1166,6 +1233,10 @@ js_modulizer("modulize") {
"file_operation_handler.js",
"file_operation_manager.js",
"trash.js",
"progress_center.js",
"device_handler.js",
"launcher.js",
"launcher_search.js",
]
namespace_rewrites = cr_namespace_rewrites
......
......@@ -2,8 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {metrics} from '../../common/js/metrics.m.js';
// #import {AsyncUtil} from '../../common/js/async_util.m.js';
// #import {importer} from '../../common/js/importer_common.m.js';
// #import {volumeManagerFactory} from './volume_manager_factory.m.js';
// #import {ProgressCenterItem, ProgressItemType, ProgressItemState} from '../../common/js/progress_center_common.m.js';
// #import {util, strf, str} from '../../common/js/util.m.js';
// #import {VolumeInfo} from '../../../externs/volume_info.m.js';
// #import {VolumeManager} from '../../../externs/volume_manager.m.js';
// #import {ProgressCenter} from '../../../externs/background/progress_center.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// clang-format on
/** Handler of device event. */
class DeviceHandler extends cr.EventTarget {
/* #export */ class DeviceHandler extends cr.EventTarget {
/** @param {!ProgressCenter} progressCenter */
constructor(progressCenter) {
super();
......
......@@ -2,6 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview
* @suppress {uselessCode} Temporary suppress because of the line exporting.
*/
// #import {AppWindowWrapper} from './app_window_wrapper.m.js';
// #import {util} from '../../common/js/util.m.js';
/**
* @type {!Object}
*/
......@@ -12,7 +20,7 @@ var launcher = {};
* Type of a Files app's instance launch.
* @enum {number}
*/
const LaunchType = {
/* #export */ const LaunchType = {
ALWAYS_CREATE: 0,
FOCUS_ANY_OR_CREATE: 1,
FOCUS_SAME_OR_CREATE: 2
......@@ -174,3 +182,6 @@ launcher.launchFileManager = async (opt_appState, opt_id, opt_type) => {
appWindow.rawAppWindow.focus();
return appId;
};
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {launcher};
......@@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import {FileType} from '../../common/js/file_type.m.js';
// #import {launcher, LaunchType} from './launcher.m.js';
// #import {util} from '../../common/js/util.m.js';
// #import {volumeManagerFactory} from './volume_manager_factory.m.js';
/**
* Provides drive search results to chrome launcher.
*/
class LauncherSearch {
/* #export */ class LauncherSearch {
constructor() {
// Launcher search provider is restricted to dev channel at now.
if (!chrome.launcherSearchProvider) {
......
......@@ -2,12 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {ProgressCenterPanelInterface} from '../../../externs/progress_center_panel.m.js';
// #import {ProgressCenter} from '../../../externs/background/progress_center.m.js';
// #import {str} from '../../common/js/util.m.js';
// #import {AsyncUtil} from '../../common/js/async_util.m.js';
// #import {ProgressItemState, ProgressCenterItem} from '../../common/js/progress_center_common.m.js';
// clang-format on
/**
* Implementation of {ProgressCenter} at the background page.
* @implements {ProgressCenter}
* @final
*/
class ProgressCenterImpl {
/* #export */ class ProgressCenterImpl {
constructor() {
/**
* Current items managed by the progress center.
......
......@@ -2,12 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {assertEquals, assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import {installMockChrome, MockCommandLinePrivate} from '../../../base/js/mock_chrome.m.js';
import {assertRejected, reportPromise} from '../../../base/js/test_error_reporting.m.js';
import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
import {MockDirectoryEntry, MockFileEntry, MockFileSystem} from '../../common/js/mock_entry.m.js';
import {VolumeInfoImpl} from './volume_info_impl.m.js';
import {volumeManagerFactory} from './volume_manager_factory.m.js';
import {VolumeManagerImpl} from './volume_manager_impl.m.js';
import {volumeManagerUtil} from './volume_manager_util.m.js';
let mockChrome;
let createVolumeInfoOriginal;
function setUp() {
window.loadTimeData.getString = id => id;
window.loadTimeData.data = {};
export function setUp() {
loadTimeData.getString = id => id;
loadTimeData.data = {};
// Set up mock of chrome.fileManagerPrivate APIs.
mockChrome = {
......@@ -133,7 +146,7 @@ function setUp() {
createVolumeInfoOriginal = volumeManagerUtil.createVolumeInfo;
}
function tearDown() {
export function tearDown() {
volumeManagerFactory.revokeInstanceForTesting();
// To avoid a closure warning assigning to |chrome|, tearDown() does not
// balance the call to installMockChrome() here.
......@@ -156,7 +169,7 @@ function getMockProfile() {
};
}
function testGetVolumeInfo(callback) {
export function testGetVolumeInfo(callback) {
reportPromise(
volumeManagerFactory.getInstance().then(volumeManager => {
const entry = MockFileEntry.create(
......@@ -170,7 +183,7 @@ function testGetVolumeInfo(callback) {
callback);
}
function testGetDriveConnectionState(callback) {
export function testGetDriveConnectionState(callback) {
reportPromise(
volumeManagerFactory.getInstance().then(volumeManager => {
// Default connection state is online
......@@ -195,7 +208,7 @@ function testGetDriveConnectionState(callback) {
callback);
}
function testMountArchiveAndUnmount(callback) {
export function testMountArchiveAndUnmount(callback) {
const test = async () => {
// Set states of mock fileManagerPrivate APIs.
const mountSourcePath = '/usr/local/home/test/Downloads/foobar.zip';
......@@ -246,7 +259,7 @@ function testMountArchiveAndUnmount(callback) {
reportPromise(test(), callback);
}
function testGetCurrentProfileVolumeInfo(callback) {
export function testGetCurrentProfileVolumeInfo(callback) {
reportPromise(
volumeManagerFactory.getInstance().then(volumeManager => {
const volumeInfo = volumeManager.getCurrentProfileVolumeInfo(
......@@ -260,7 +273,7 @@ function testGetCurrentProfileVolumeInfo(callback) {
callback);
}
function testGetLocationInfo(callback) {
export function testGetLocationInfo(callback) {
reportPromise(
volumeManagerFactory.getInstance().then(volumeManager => {
const downloadEntry = MockFileEntry.create(
......@@ -398,7 +411,7 @@ function testGetLocationInfo(callback) {
callback);
}
function testWhenReady(callback) {
export function testWhenReady(callback) {
volumeManagerFactory.getInstance().then((volumeManager) => {
const promiseBeforeAdd = volumeManager.whenVolumeInfoReady('volumeId');
const volumeInfo = new VolumeInfoImpl(
......@@ -432,7 +445,7 @@ function testWhenReady(callback) {
});
}
function testDriveMountedDuringInitialization(callback) {
export function testDriveMountedDuringInitialization(callback) {
const test = async () => {
const sendVolumeMetadataListPromise = new Promise(resolve => {
chrome.fileManagerPrivate.getVolumeMetadataList = resolve;
......@@ -471,7 +484,7 @@ function testDriveMountedDuringInitialization(callback) {
reportPromise(test(), callback);
}
function testErrorPropagatedDuringInitialization(done) {
export function testErrorPropagatedDuringInitialization(done) {
chrome.fileManagerPrivate.getVolumeMetadataList = () => {
throw new Error('Dummy error for test purpose');
};
......@@ -483,7 +496,7 @@ function testErrorPropagatedDuringInitialization(done) {
* Tests that an error initializing one volume doesn't stop other volumes to be
* initialized. crbug.com/1041340
*/
async function testErrorInitializingVolume(done) {
export async function testErrorInitializingVolume(done) {
// Confirm that a Drive volume is on faked getVolumeMetadataList().
assertTrue(
chrome.fileManagerPrivate.volumeMetadataList_.some(volumeMetadata => {
......@@ -522,7 +535,7 @@ async function testErrorInitializingVolume(done) {
* Tests VolumeInfoImpl doesn't raise exception if null is passed for
* filesystem. crbug.com/1041340
*/
async function testDriveWithNullFilesystem(done) {
export async function testDriveWithNullFilesystem(done) {
// Get Drive volume metadata from faked getVolumeMetadataList().
const driveVolumeMetadata =
chrome.fileManagerPrivate.volumeMetadataList_.find(volumeMetadata => {
......
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