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

Files app: Generate JS module for Files app background page

Generate JS modules for most of the mocks in:
//ui/file_manager/file_manager/background/js/

Files in //ui/file_manager/file_manager/background/js/:
crostini.js
mock_crostini.js
crostini_unittest.m.js
mock_drive_sync_handler.js
mock_file_operation_manager.js
mock_progress_center.js

Files in //ui/file_manager/externs/:
progress_center_panel.js
background/crostini.js
background/drive_sync_handler.js
background/file_operation_manager.js
background/progress_center.js

Bug: 1133186
Change-Id: I12d665f413d9965bd5ef5d8db7f93d724fdfbea6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2589234
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836904}
parent 19aeffd4
......@@ -38,7 +38,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ContentMetadataProvider) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, Crostini) {
RunTestURL("background/js/crostini_unittest_gen.html");
RunTestURL("background/js/crostini_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DeviceHandlerTest) {
......
......@@ -64,6 +64,14 @@ js_library("metadata_worker_window.m") {
extra_deps = [ ":modulize" ]
}
js_library("progress_center_panel.m") {
sources =
[ "$root_gen_dir/ui/file_manager/externs/progress_center_panel.m.js" ]
deps = [ "//ui/file_manager/file_manager/common/js:progress_center_common.m" ]
extra_deps = [ ":modulize" ]
}
js_library("volume_manager") {
sources = []
......@@ -118,6 +126,7 @@ js_modulizer("modulize") {
"exif_entry.js",
"files_app_entry_interfaces.js",
"metadata_worker_window.js",
"progress_center_panel.js",
"volume_info.js",
"volume_info_list.js",
"volume_manager.js",
......
......@@ -35,6 +35,49 @@ js_library("background_base.m") {
extra_deps = [ ":modulize" ]
}
js_library("drive_sync_handler.m") {
sources = [
"$root_gen_dir/ui/file_manager/externs/background/drive_sync_handler.m.js",
]
extra_deps = [ ":modulize" ]
}
js_library("crostini.m") {
sources = [ "$root_gen_dir/ui/file_manager/externs/background/crostini.m.js" ]
deps = [ "..:volume_manager.m" ]
extra_deps = [ ":modulize" ]
}
js_library("file_operation_manager.m") {
sources = [ "$root_gen_dir/ui/file_manager/externs/background/file_operation_manager.m.js" ]
deps = [
"..:files_app_entry_interfaces.m",
"..:volume_manager.m",
]
extra_deps = [ ":modulize" ]
}
js_library("progress_center.m") {
sources = [
"$root_gen_dir/ui/file_manager/externs/background/progress_center.m.js",
]
deps = [
"..:progress_center_panel.m",
"//ui/file_manager/file_manager/common/js:progress_center_common.m",
]
extra_deps = [ ":modulize" ]
}
js_modulizer("modulize") {
input_files = [ "background_base.js" ]
input_files = [
"background_base.js",
"crostini.js",
"drive_sync_handler.js",
"file_operation_manager.js",
"progress_center.js",
]
}
......@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import {VolumeManager} from '../volume_manager.m.js';
/**
* Crostini shared path state handler.
*
* @interface
*/
class Crostini {
/* #export */ class Crostini {
/**
* Initialize enabled settings.
* Must be done after loadTimeData is available.
......@@ -66,7 +68,7 @@ class Crostini {
* Returns true if entry can be shared with the specified VM.
* @param {string} vmName
* @param {!Entry} entry
* @param {boolean} persist If path is to be persisted.
* @return {boolean} persist If path is to be persisted.
*/
canSharePath(vmName, entry, persist) {}
}
......@@ -7,9 +7,8 @@
* of this interface must @extends {cr.EventTarget}.
*
* @interface
* @extends {EventTarget}
*/
class DriveSyncHandler extends EventTarget {
/* #export */ class DriveSyncHandler extends EventTarget {
/**
* Returns the completed event name.
* @return {string}
......
......@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import {VolumeManager} from '../volume_manager.m.js';
// #import {FilesAppEntry, FakeEntry} from '../files_app_entry_interfaces.m.js';
/**
* FileOperationManager: manager of file operations. Implementations of this
* interface must @extends {cr.EventTarget} or implement the EventTarget API on
......@@ -9,7 +12,7 @@
*
* @interface
*/
class FileOperationManager extends EventTarget {
/* #export */ class FileOperationManager extends EventTarget {
/**
* Says if there are any tasks in the queue.
* @return {boolean} True, if there are any tasks.
......
......@@ -2,11 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {ProgressCenterItem} from '../../file_manager/common/js/progress_center_common.m.js';
// #import {ProgressCenterPanelInterface} from '../progress_center_panel.m.js';
// clang-format on
/**
* Progress center at the background page.
* @interface
*/
class ProgressCenter {
/* #export */ class ProgressCenter {
/**
* Turns off sending updates when a file operation reaches 'completed' state.
* Used for testing UI that can be ephemeral otherwise.
......
......@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {ProgressCenterItem, ProgressItemState} from '../file_manager/common/js/progress_center_common.m.js';
// clang-format on
/**
* Interface implemented in foreground page that the background page uses to
* send progress event updates to the foreground page, and to receive cancel
* and dismiss events from the foreground page.
* @interface
*/
class ProgressCenterPanelInterface {
/* #export */ class ProgressCenterPanelInterface {
constructor() {
/**
* Callback to be called with the ID of the progress item when the cancel
......
......@@ -76,9 +76,13 @@ js_type_check("closure_compile_jsmodules") {
":app_window_wrapper.m",
":app_windows.m",
":background_base.m",
":crostini.m",
":entry_location_impl.m",
":file_operation_util.m",
":metadata_proxy.m",
":mock_drive_sync_handler.m",
":mock_file_operation_manager.m",
":mock_progress_center.m",
":test_util_base.m",
":volume_info_impl.m",
":volume_info_list_impl.m",
......@@ -91,7 +95,10 @@ js_type_check("closure_compile_jsmodules") {
js_type_check("test_support_modules_type_check") {
testonly = true
uses_js_modules = true
deps = [ ":mock_volume_manager.m" ]
deps = [
":mock_crostini.m",
":mock_volume_manager.m",
]
}
js_type_check("test_support_type_check") {
......@@ -224,6 +231,21 @@ js_library("crostini") {
externs_list = [ "//ui/file_manager/externs/background/crostini.js" ]
}
js_library("crostini.m") {
sources = [
"$root_gen_dir/ui/file_manager/file_manager/background/js/crostini.m.js",
]
deps = [
"//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/externs:volume_manager.m",
"//ui/file_manager/externs/background:crostini.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:load_time_data.m",
]
extra_deps = [ ":modulize" ]
}
js_library("mock_crostini") {
testonly = true
deps = [ ":crostini" ]
......@@ -232,11 +254,27 @@ js_library("mock_crostini") {
visibility = [ "//ui/file_manager/file_manager/*" ]
}
js_unittest("crostini_unittest") {
js_library("mock_crostini.m") {
testonly = true
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/mock_crostini.m.js" ]
deps = [
":mock_crostini",
"//ui/file_manager/file_manager/common/js:mock_entry",
"//ui/webui/resources/js:webui_resource_test",
":crostini.m",
"//ui/file_manager/externs/background:crostini.m",
]
extra_deps = [ ":modulize" ]
}
js_unittest("crostini_unittest.m") {
deps = [
":mock_crostini.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/externs:entry_location.m",
"//ui/file_manager/externs:volume_manager.m",
"//ui/file_manager/externs/background:crostini.m",
"//ui/file_manager/file_manager/common/js:mock_entry.m",
"//ui/webui/resources/js:load_time_data.m",
]
}
......@@ -272,6 +310,16 @@ js_library("mock_drive_sync_handler") {
visibility = [ "//ui/file_manager/file_manager/*" ]
}
js_library("mock_drive_sync_handler.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/mock_drive_sync_handler.m.js" ]
deps = [
"//ui/file_manager/externs/background:drive_sync_handler.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_library("drive_sync_handler") {
deps = [
":progress_center",
......@@ -357,6 +405,17 @@ js_library("mock_file_operation_manager") {
[ "//ui/file_manager/externs/background/file_operation_manager.js" ]
}
js_library("mock_file_operation_manager.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/mock_file_operation_manager.m.js" ]
deps = [
"//ui/file_manager/externs/background:file_operation_manager.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_library("file_operation_manager") {
deps = [
":file_operation_util",
......@@ -563,6 +622,16 @@ js_library("mock_progress_center") {
[ "//ui/file_manager/file_manager/foreground/js:file_tasks_unittest" ]
}
js_library("mock_progress_center.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/mock_progress_center.m.js" ]
deps = [
"//ui/file_manager/externs/background:progress_center.m",
"//ui/file_manager/file_manager/common/js:progress_center_common.m",
]
extra_deps = [ ":modulize" ]
}
js_library("progress_center") {
deps = [
"//ui/file_manager/file_manager/common/js:async_util",
......@@ -799,7 +868,10 @@ js_library("volume_manager_util.m") {
}
js_test_gen_html("js_test_gen_html_modules") {
deps = [ ":metadata_proxy_unittest.m" ]
deps = [
":crostini_unittest.m",
":metadata_proxy_unittest.m",
]
js_module = true
closure_flags =
......@@ -813,7 +885,6 @@ js_test_gen_html("js_test_gen_html_modules") {
js_test_gen_html("js_test_gen_html") {
deps = [
":crostini_unittest",
":device_handler_unittest",
":drive_sync_handler_unittest",
":duplicate_finder_unittest",
......@@ -844,6 +915,11 @@ js_modulizer("modulize") {
"volume_manager_impl.js",
"volume_manager_util.js",
"file_operation_util.js",
"mock_drive_sync_handler.js",
"mock_crostini.js",
"crostini.js",
"mock_file_operation_manager.js",
"mock_progress_center.js",
]
namespace_rewrites = cr_namespace_rewrites
......
......@@ -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 {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
// #import {Crostini} from '../../../externs/background/crostini.m.js';
// #import {VolumeManager} from '../../../externs/volume_manager.m.js';
// clang-format on
/**
* Implementation of Crostini shared path state handler.
*
* @implements {Crostini}
*/
class CrostiniImpl {
/* #export */ class CrostiniImpl {
constructor() {
/**
* True if VM is enabled.
......@@ -189,7 +197,7 @@ class CrostiniImpl {
* Returns true if entry can be shared with the specified VM.
* @param {string} vmName
* @param {!Entry} entry
* @param {boolean} persist If path is to be persisted.
* @return {boolean} persist If path is to be persisted.
*/
canSharePath(vmName, entry, persist) {
if (!this.enabled_[vmName]) {
......
......@@ -2,7 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
// clang-format off
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import { assertFalse,assertTrue} from 'chrome://test/chai_assert.js';
import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
import {Crostini} from '../../../externs/background/crostini.m.js';
import {EntryLocation} from '../../../externs/entry_location.m.js';
import {VolumeManager} from '../../../externs/volume_manager.m.js';
import { MockDirectoryEntry, MockEntry,MockFileSystem} from '../../common/js/mock_entry.m.js';
import {createCrostiniForTest} from './mock_crostini.m.js';
// clang-format on
/**
* Mock metrics.
......@@ -22,15 +33,13 @@ let volumeManager;
let crostini;
// Set up the test components.
function setUp() {
export function setUp() {
// Mock LoadTimeData strings.
window.loadTimeData = {
data: {},
getBoolean: function(key) {
return window.loadTimeData.data[key];
},
getString: id => id,
loadTimeData.data = {};
loadTimeData.getBoolean = function(key) {
return loadTimeData.data_[key];
};
loadTimeData.getString = id => id;
// Create a fake volume manager that provides entry location info.
volumeManager = /** @type {!VolumeManager} */ ({
......@@ -53,15 +62,15 @@ function setUp() {
/**
* Tests init sets crostini and PluginVm enabled status.
*/
function testInitCrostiniPluginVmEnabled() {
window.loadTimeData.data['CROSTINI_ENABLED'] = true;
window.loadTimeData.data['PLUGIN_VM_ENABLED'] = true;
export function testInitCrostiniPluginVmEnabled() {
loadTimeData.data_['CROSTINI_ENABLED'] = true;
loadTimeData.data_['PLUGIN_VM_ENABLED'] = true;
crostini.initEnabled();
assertTrue(crostini.isEnabled('termina'));
assertTrue(crostini.isEnabled('PvmDefault'));
window.loadTimeData.data['CROSTINI_ENABLED'] = false;
window.loadTimeData.data['PLUGIN_VM_ENABLED'] = false;
loadTimeData.data_['CROSTINI_ENABLED'] = false;
loadTimeData.data_['PLUGIN_VM_ENABLED'] = false;
crostini.initEnabled();
assertFalse(crostini.isEnabled('termina'));
assertFalse(crostini.isEnabled('PvmDefault'));
......@@ -70,7 +79,7 @@ function testInitCrostiniPluginVmEnabled() {
/**
* Tests path sharing.
*/
function testIsPathShared() {
export function testIsPathShared() {
const mockFileSystem = new MockFileSystem('volumeId');
const root = MockDirectoryEntry.create(mockFileSystem, '/');
const a = MockDirectoryEntry.create(mockFileSystem, '/a');
......@@ -143,7 +152,7 @@ function testIsPathShared() {
/*
* Tests disallowed and allowed shared paths.
*/
function testCanSharePath() {
export function testCanSharePath() {
crostini.setEnabled('vm', true);
const mockFileSystem = new MockFileSystem('test');
......
......@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
// #import {CrostiniImpl} from './crostini.m.js';
// #import {Crostini} from '../../../externs/background/crostini.m.js';
/* #ignore */ 'use strict';
/**
* Crostini shared path state handler factory for foreground tests. Change it
* to a mock when tests need to override {CrostiniImpl} behavior.
* @return {!Crostini}
*/
function createCrostiniForTest() {
/* #export */ function createCrostiniForTest() {
return new CrostiniImpl();
}
......@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
// clang-format off
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// #import {DriveSyncHandler} from '../../../externs/background/drive_sync_handler.m.js';
// clang-format on
/* #ignore */ 'use strict';
/**
* Mock of DriveSyncHandler.
* @implements {DriveSyncHandler}
*/
class MockDriveSyncHandler extends cr.EventTarget {
/* #export */ class MockDriveSyncHandler extends cr.EventTarget {
constructor() {
super();
......
......@@ -2,13 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
// clang-format off
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// #import {FileOperationManager} from '../../../externs/background/file_operation_manager.m.js';
// clang-format on
/* #ignore */ 'use strict';
/**
* Mock implementation of {FileOperationManager} for tests.
* @implements {FileOperationManager}
*/
class MockFileOperationManager extends cr.EventTarget {
/* #export */ class MockFileOperationManager extends cr.EventTarget {
constructor() {
super();
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/* #ignore */ 'use strict';
// clang-format off
// #import {ProgressCenterItem, ProgressItemState} from '../../common/js/progress_center_common.m.js';
// #import {ProgressCenter} from '../../../externs/background/progress_center.m.js';
// clang-format on
/**
* Mock implementation of {ProgressCenter} for tests.
* @implements {ProgressCenter}
* @final
*/
class MockProgressCenter {
/* #export */ class MockProgressCenter {
constructor() {
/**
* Items stored in the progress center.
......
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