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();
......
// Copyright 2014 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';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {assertEquals, assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import {installMockChrome, MockChromeStorageAPI} 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 {importer} from '../../common/js/importer_common.m.js';
import {metrics} from '../../common/js/metrics.m.js';
import {MockFileSystem} from '../../common/js/mock_entry.m.js';
import {DeviceHandler} from './device_handler.m.js';
import {MockProgressCenter} from './mock_progress_center.m.js';
import {MockVolumeManager} from './mock_volume_manager.m.js';
/** @type {!MockVolumeManager} */
let volumeManager;
......@@ -17,16 +31,16 @@ let mockChrome;
/**
* Mock metrics.
* @type {!Object}
* @param {string} name
* @param {*} value
* @param {Array<*>|number=} opt_validValues
*/
window.metrics = {
recordEnum: function() {},
};
metrics.recordEnum = function(name, value, opt_validValues) {};
// Set up the test components.
function setUp() {
export function setUp() {
// Set up string assets.
window.loadTimeData.data = {
loadTimeData.data = {
DEVICE_UNSUPPORTED_MESSAGE: 'DEVICE_UNSUPPORTED: $1',
DEVICE_UNKNOWN_MESSAGE: 'DEVICE_UNKNOWN: $1',
MULTIPART_DEVICE_UNSUPPORTED_MESSAGE: 'MULTIPART_DEVICE_UNSUPPORTED: $1',
......@@ -34,13 +48,13 @@ function setUp() {
FORMAT_SUCCESS_MESSAGE: 'FORMAT_SUCCESS_MESSAGE: $1',
FORMAT_FAILURE_MESSAGE: 'FORMAT_FAILURE_MESSAGE: $1',
};
window.loadTimeData.getString = id => {
return window.loadTimeData.data_[id] || id;
loadTimeData.getString = id => {
return loadTimeData.data_[id] || id;
};
window.loadTimeData.getBoolean = id => {
loadTimeData.getBoolean = id => {
return id === 'ARC_USB_STORAGE_UI_ENABLED' ? true : false;
};
window.loadTimeData.valueExists = id => {
loadTimeData.valueExists = id => {
return id === 'ARC_USB_STORAGE_UI_ENABLED';
};
......@@ -57,7 +71,7 @@ function setUpInIncognitoContext() {
mockChrome.extension.inIncognitoContext = true;
}
function testGoodDevice(callback) {
export function testGoodDevice(callback) {
// Turn off ARC so that the notification won't show the "OPEN SETTINGS"
// button.
mockChrome.fileManagerPrivate.arcEnabledPref = false;
......@@ -85,7 +99,7 @@ function testGoodDevice(callback) {
callback);
}
function testGoodDeviceWithAllowPlayStoreMessage(callback) {
export function testGoodDeviceWithAllowPlayStoreMessage(callback) {
// Turn on ARC so that the notification shows the "OPEN SETTINGS" button.
mockChrome.fileManagerPrivate.arcEnabledPref = true;
// Turn off the ARC pref so that the notification shows the "Allow Play Store
......@@ -117,7 +131,7 @@ function testGoodDeviceWithAllowPlayStoreMessage(callback) {
callback);
}
function testGoodDeviceWithPlayStoreAppsHaveAccessMessage(callback) {
export function testGoodDeviceWithPlayStoreAppsHaveAccessMessage(callback) {
// Turn on ARC so that the notification shows the "OPEN SETTINGS" button.
mockChrome.fileManagerPrivate.arcEnabledPref = true;
// Turn on the ARC pref so that the notification shows the "Play Store apps
......@@ -152,7 +166,7 @@ function testGoodDeviceWithPlayStoreAppsHaveAccessMessage(callback) {
callback);
}
function testRemovableMediaDeviceWithImportEnabled(callback) {
export function testRemovableMediaDeviceWithImportEnabled(callback) {
const storage = new MockChromeStorageAPI();
setupFileSystem(VolumeManagerCommon.VolumeType.REMOVABLE, 'blabbity', [
......@@ -182,7 +196,7 @@ function testRemovableMediaDeviceWithImportEnabled(callback) {
callback);
}
function testMtpMediaDeviceWithImportEnabled(callback) {
export function testMtpMediaDeviceWithImportEnabled(callback) {
const storage = new MockChromeStorageAPI();
setupFileSystem(VolumeManagerCommon.VolumeType.MTP, 'blabbity', [
......@@ -212,7 +226,7 @@ function testMtpMediaDeviceWithImportEnabled(callback) {
callback);
}
function testGoodDeviceNotNavigated() {
export function testGoodDeviceNotNavigated() {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'success',
......@@ -229,7 +243,7 @@ function testGoodDeviceNotNavigated() {
assertFalse(mockChrome.notifications.resolver.settled);
}
function testGoodDeviceWithBadParent(callback) {
export function testGoodDeviceWithBadParent(callback) {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'error_internal',
......@@ -252,7 +266,7 @@ function testGoodDeviceWithBadParent(callback) {
callback);
}
function testGoodDeviceWithBadParent_DuplicateMount(callback) {
export function testGoodDeviceWithBadParent_DuplicateMount(callback) {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'success',
......@@ -289,7 +303,7 @@ function testGoodDeviceWithBadParent_DuplicateMount(callback) {
callback);
}
function testUnsupportedDevice(callback) {
export function testUnsupportedDevice(callback) {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'error_unsupported_filesystem',
......@@ -312,7 +326,7 @@ function testUnsupportedDevice(callback) {
callback);
}
function testUnknownDevice(callback) {
export function testUnknownDevice(callback) {
// Emulate adding a device which has unknown filesystem.
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
......@@ -337,7 +351,7 @@ function testUnknownDevice(callback) {
callback);
}
function testUnknownReadonlyDevice(callback) {
export function testUnknownReadonlyDevice(callback) {
// Emulate adding a device which has unknown filesystem but is read-only.
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
......@@ -362,7 +376,7 @@ function testUnknownReadonlyDevice(callback) {
callback);
}
function testUnsupportedWithUnknownParentReplacesNotification() {
export function testUnsupportedWithUnknownParentReplacesNotification() {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'error_internal',
......@@ -397,7 +411,7 @@ function testUnsupportedWithUnknownParentReplacesNotification() {
mockChrome.notifications.items['deviceFail:/device/path'].message);
}
function testMountPartialSuccess(callback) {
export function testMountPartialSuccess(callback) {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'success',
......@@ -441,7 +455,7 @@ function testMountPartialSuccess(callback) {
callback);
}
function testUnknown(callback) {
export function testUnknown(callback) {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'error_unknown',
......@@ -464,7 +478,7 @@ function testUnknown(callback) {
callback);
}
function testNonASCIILabel(callback) {
export function testNonASCIILabel(callback) {
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
status: 'error_internal',
......@@ -488,7 +502,7 @@ function testNonASCIILabel(callback) {
callback);
}
function testMulitpleFail() {
export function testMulitpleFail() {
// The first parent error.
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
......@@ -559,7 +573,7 @@ function testMulitpleFail() {
mockChrome.notifications.items['deviceFail:/device/path'].message);
}
function testDisabledDevice() {
export function testDisabledDevice() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'disabled', devicePath: '/device/path'});
assertEquals(1, Object.keys(mockChrome.notifications.items).length);
......@@ -572,7 +586,7 @@ function testDisabledDevice() {
assertEquals(0, Object.keys(mockChrome.notifications.items).length);
}
function testFormatSucceeded() {
export function testFormatSucceeded() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'format_start', devicePath: '/device/path', deviceLabel: 'label'});
assertEquals(1, progressCenter.getItemCount());
......@@ -591,7 +605,7 @@ function testFormatSucceeded() {
progressCenter.getItemById('format:/device/path').message);
}
function testFormatFailed() {
export function testFormatFailed() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'format_start', devicePath: '/device/path', deviceLabel: 'label'});
assertEquals(1, progressCenter.getItemCount());
......@@ -607,7 +621,7 @@ function testFormatFailed() {
progressCenter.getItemById('format:/device/path').message);
}
function testPartitionSucceeded() {
export function testPartitionSucceeded() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'partition_start',
devicePath: '/device/path',
......@@ -623,7 +637,7 @@ function testPartitionSucceeded() {
assertEquals(0, progressCenter.getItemCount());
}
function testPartitionFailed() {
export function testPartitionFailed() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'partition_start',
devicePath: '/device/path',
......@@ -642,7 +656,7 @@ function testPartitionFailed() {
progressCenter.getItemById('partition:/device/path').message);
}
function testRenameSucceeded() {
export function testRenameSucceeded() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'rename_start', devicePath: '/device/path'});
assertEquals(0, Object.keys(mockChrome.notifications.items).length);
......@@ -652,7 +666,7 @@ function testRenameSucceeded() {
assertEquals(0, Object.keys(mockChrome.notifications.items).length);
}
function testRenameFailed() {
export function testRenameFailed() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'rename_start', devicePath: '/device/path'});
assertEquals(0, Object.keys(mockChrome.notifications.items).length);
......@@ -665,7 +679,7 @@ function testRenameFailed() {
mockChrome.notifications.items['renameFail:/device/path'].message);
}
function testDeviceHardUnplugged() {
export function testDeviceHardUnplugged() {
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'hard_unplugged', devicePath: '/device/path'});
assertEquals(1, Object.keys(mockChrome.notifications.items).length);
......@@ -674,7 +688,7 @@ function testDeviceHardUnplugged() {
mockChrome.notifications.items['hardUnplugged:/device/path'].message);
}
function testNotificationClicked(callback) {
export function testNotificationClicked(callback) {
const devicePath = '/device/path';
const notificationId = 'deviceNavigation:' + devicePath;
......@@ -697,7 +711,7 @@ function testNotificationClicked(callback) {
callback);
}
function testMiscMessagesInIncognito() {
export function testMiscMessagesInIncognito() {
setUpInIncognitoContext();
mockChrome.fileManagerPrivate.onDeviceChanged.dispatch(
{type: 'format_start', devicePath: '/device/path', deviceLabel: 'label'});
......@@ -705,7 +719,7 @@ function testMiscMessagesInIncognito() {
assertEquals(0, progressCenter.getItemCount());
}
function testMountCompleteInIncognito() {
export function testMountCompleteInIncognito() {
setUpInIncognitoContext();
mockChrome.fileManagerPrivate.onMountCompleted.dispatch({
eventType: 'mount',
......
......@@ -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