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

Files app: Generate more JS modules in //u/f/f/f/j/

In //ui/file_manager/file_manager/foreground/js/:
- crossover_search_utils.js
- fake_android_app_list_model.js
- folder_shortcuts_data_model.js
- mock_directory_model.js
- mock_folder_shortcut_data_model.js
- navigation_list_model.js
- navigation_list_model_unittest.m.js

Bug: 1133186
Change-Id: Iad47cc51481146319fd06c08973544cfd23c609d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612546
Commit-Queue: Jeremie Boulic <jboulic@google.com>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840487}
parent 064a6218
......@@ -218,7 +218,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, MultiMetadataProvider) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, NavigationListModelTest) {
RunTestURL("foreground/js/navigation_list_model_unittest_gen.html");
RunTestURL("foreground/js/navigation_list_model_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ProvidersModel) {
......
......@@ -889,6 +889,7 @@ js_library("volume_info_impl.m") {
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js:assert.m",
]
visibility += [ "//ui/file_manager/file_manager/foreground/js:navigation_list_model_unittest.m" ]
extra_deps = [ ":modulize" ]
}
......
......@@ -30,10 +30,16 @@ js_type_check("closure_compile_jsmodules") {
deps = [
":android_app_list_model.m",
":constants.m",
":crossover_search_utils.m",
":directory_contents.m",
":directory_model.m",
":fake_android_app_list_model.m",
":file_list_model.m",
":file_watcher.m",
":folder_shortcuts_data_model.m",
":mock_directory_model.m",
":mock_folder_shortcut_data_model.m",
":navigation_list_model.m",
":thumbnail_loader.m",
]
}
......@@ -199,6 +205,16 @@ js_library("fake_android_app_list_model") {
deps = [ ":android_app_list_model" ]
}
js_library("fake_android_app_list_model.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/fake_android_app_list_model.m.js" ]
deps = [
":android_app_list_model.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_library("mock_directory_model") {
testonly = true
deps = [
......@@ -209,6 +225,18 @@ js_library("mock_directory_model") {
]
}
js_library("mock_directory_model.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/mock_directory_model.m.js" ]
deps = [
":directory_contents.m",
":directory_model.m",
"//ui/file_manager/externs:files_app_entry_interfaces.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_library("mock_folder_shortcut_data_model") {
testonly = true
deps = [
......@@ -218,6 +246,17 @@ js_library("mock_folder_shortcut_data_model") {
]
}
js_library("mock_folder_shortcut_data_model.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/mock_folder_shortcut_data_model.m.js" ]
deps = [
":folder_shortcuts_data_model.m",
"//ui/file_manager/file_manager/common/js:mock_entry.m",
"//ui/webui/resources/js/cr/ui:array_data_model.m",
]
extra_deps = [ ":modulize" ]
}
js_library("mock_navigation_list_model") {
testonly = true
deps = [ ":navigation_list_model" ]
......@@ -270,6 +309,16 @@ js_library("constants.m") {
js_library("crossover_search_utils") {
}
js_library("crossover_search_utils.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/crossover_search_utils.m.js" ]
deps = [
":directory_model.m",
":navigation_list_model.m",
]
extra_deps = [ ":modulize" ]
}
js_library("crostini_controller") {
deps = [
":directory_model",
......@@ -639,6 +688,20 @@ js_library("folder_shortcuts_data_model") {
]
}
js_library("folder_shortcuts_data_model.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.m.js" ]
deps = [
"//ui/file_manager/base/js:filtered_volume_manager.m",
"//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/file_manager/common/js:async_util.m",
"//ui/file_manager/file_manager/common/js:metrics.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_library("gear_menu_controller") {
deps = [
":directory_model",
......@@ -781,15 +844,45 @@ js_library("navigation_list_model") {
]
}
js_unittest("navigation_list_model_unittest") {
js_library("navigation_list_model.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/navigation_list_model.m.js" ]
deps = [
":fake_android_app_list_model",
":mock_directory_model",
":mock_folder_shortcut_data_model",
":navigation_list_model",
"//ui/file_manager/base/js:mock_chrome",
"//ui/file_manager/base/js:test_error_reporting",
"//ui/file_manager/file_manager/background/js:mock_volume_manager",
":android_app_list_model.m",
":directory_model.m",
":folder_shortcuts_data_model.m",
"//chrome/test/data/webui:chai_assert",
"//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",
"//ui/file_manager/file_manager/common/js:files_app_entry_types.m",
"//ui/file_manager/file_manager/common/js:trash.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_unittest("navigation_list_model_unittest.m") {
deps = [
":android_app_list_model.m",
":directory_model.m",
":fake_android_app_list_model.m",
":mock_directory_model.m",
":mock_folder_shortcut_data_model.m",
":navigation_list_model.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:files_app_entry_interfaces.m",
"//ui/file_manager/file_manager/background/js:mock_volume_manager.m",
"//ui/file_manager/file_manager/background/js:volume_info_impl.m",
"//ui/file_manager/file_manager/common/js:files_app_entry_types.m",
"//ui/file_manager/file_manager/common/js:mock_entry.m",
"//ui/file_manager/file_manager/common/js:util.m",
]
}
......@@ -976,6 +1069,7 @@ js_test_gen_html("js_test_gen_html_modules") {
deps = [
":directory_contents_unittest.m",
":file_list_model_unittest.m",
":navigation_list_model_unittest.m",
":thumbnail_loader_unittest.m",
]
js_module = true
......@@ -998,7 +1092,6 @@ js_test_gen_html("js_test_gen_html") {
":file_type_filters_controller_unittest",
":import_controller_unittest",
":list_thumbnail_loader_unittest",
":navigation_list_model_unittest",
":providers_model_unittest",
":spinner_controller_unittest",
":task_controller_unittest",
......@@ -1015,6 +1108,12 @@ js_modulizer("modulize") {
"directory_contents.js",
"file_list_model.js",
"file_watcher.js",
"crossover_search_utils.js",
"navigation_list_model.js",
"folder_shortcuts_data_model.js",
"mock_directory_model.js",
"fake_android_app_list_model.js",
"mock_folder_shortcut_data_model.js",
]
namespace_rewrites = cr_namespace_rewrites
......
......@@ -2,6 +2,16 @@
// 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.
*/
// clang-format off
// #import {DirectoryModel} from './directory_model.m.js';
// #import {NavigationModelItemType, NavigationListModel, NavigationModelFakeItem, NavigationModelVolumeItem} from './navigation_list_model.m.js';
// clang-format on
/**
* Namespace for crossover search utility functions.
* @namespace
......@@ -58,3 +68,6 @@ crossoverSearchUtils.findQueryMatchedDirectoryEntry =
}
return null;
};
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {crossoverSearchUtils};
......@@ -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 {AndroidAppListModel} from './android_app_list_model.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// clang-format on
/**
* @param {!Array<string>} appNames List app names to be added.
* @returns {!AndroidAppListModel} fake for unittests.
*/
function createFakeAndroidAppListModel(appNames) {
/* #export */ function createFakeAndroidAppListModel(appNames) {
/**
* AndroidAppListModel fake.
*/
......
......@@ -2,6 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {FilteredVolumeManager} from '../../../base/js/filtered_volume_manager.m.js';
// #import {util} from '../../common/js/util.m.js';
// #import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
// #import {AsyncUtil} from '../../common/js/async_util.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// #import {metrics} from '../../common/js/metrics.m.js';
// clang-format on
/**
* The drive mount path used in the storage. It must be '/drive'.
* @type {string}
......@@ -13,7 +22,7 @@ const STORED_DRIVE_MOUNT_PATH = '/drive';
* object with additional methods for the folder shortcut feature.
* This uses chrome.storage as backend. Items are always sorted by URL.
*/
class FolderShortcutsDataModel extends cr.EventTarget {
/* #export */ class FolderShortcutsDataModel extends cr.EventTarget {
/**
* @param {!FilteredVolumeManager} volumeManager Volume manager instance.
*/
......
......@@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {FilesAppDirEntry, FakeEntry} from '../../../externs/files_app_entry_interfaces.m.js';
// #import {DirectoryModel} from './directory_model.m.js';
// #import {FileFilter} from './directory_contents.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// clang-format on
/**
* @returns {!FileFilter} fake for unittests.
*/
......@@ -26,7 +33,7 @@ function createFakeFileFilter() {
/**
* @returns {!DirectoryModel} fake for unittests.
*/
function createFakeDirectoryModel() {
/* #export */ function createFakeDirectoryModel() {
/**
* DirectoryModel fake.
*/
......
......@@ -2,12 +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 {MockEntry} from '../../common/js/mock_entry.m.js';
// #import {FolderShortcutsDataModel} from './folder_shortcuts_data_model.m.js';
// #import {ArrayDataModel} from 'chrome://resources/js/cr/ui/array_data_model.m.js';
// clang-format on
/* #ignore */ 'use strict';
/**
* Mock FolderShortcutDataModel.
*/
class MockFolderShortcutDataModel extends cr.ui.ArrayDataModel {
/* #export */ class MockFolderShortcutDataModel extends cr.ui.ArrayDataModel {
/**
* @param {!Array} array
*/
......
......@@ -2,10 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {FolderShortcutsDataModel} from './folder_shortcuts_data_model.m.js';
// #import {DirectoryModel} from './directory_model.m.js';
// #import {AndroidAppListModel} from './android_app_list_model.m.js';
// #import {VolumeManager} from '../../../externs/volume_manager.m.js';
// #import {FilesAppEntry, FakeEntry} from '../../../externs/files_app_entry_interfaces.m.js';
// #import {VolumeInfo} from '../../../externs/volume_info.m.js';
// #import {TrashRootEntry} from '../../common/js/trash.m.js';
// #import {util, str} from '../../common/js/util.m.js';
// #import {FakeEntryImpl, VolumeEntry, EntryList} from '../../common/js/files_app_entry_types.m.js';
// #import {assertNotReached} from 'chrome://resources/js/assert.m.js';
// #import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// #import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
// clang-format on
/**
* @enum {string}
*/
const NavigationModelItemType = {
/* #export */ const NavigationModelItemType = {
SHORTCUT: 'shortcut',
VOLUME: 'volume',
RECENT: 'recent',
......@@ -28,7 +44,7 @@ const NavigationModelItemType = {
* - ANDROID_APPS: ANDROID picker apps.
* @enum {string}
*/
const NavigationSection = {
/* #export */ const NavigationSection = {
TOP: 'top',
MY_FILES: 'my_files',
REMOVABLE: 'removable',
......@@ -39,7 +55,7 @@ const NavigationSection = {
/**
* Base item of NavigationListModel. Should not be created directly.
*/
class NavigationModelItem {
/* #export */ class NavigationModelItem {
/**
* @param {string} label
* @param {NavigationModelItemType} type
......@@ -88,7 +104,7 @@ class NavigationModelItem {
/**
* Item of NavigationListModel for shortcuts.
*/
class NavigationModelShortcutItem extends NavigationModelItem {
/* #export */ class NavigationModelShortcutItem extends NavigationModelItem {
/**
* @param {string} label Label.
* @param {!DirectoryEntry} entry Entry. Cannot be null.
......@@ -106,7 +122,7 @@ class NavigationModelShortcutItem extends NavigationModelItem {
/**
* Item of NavigationListModel for Android apps.
*/
class NavigationModelAndroidAppItem extends NavigationModelItem {
/* #export */ class NavigationModelAndroidAppItem extends NavigationModelItem {
/**
* @param {!chrome.fileManagerPrivate.AndroidApp} androidApp Android app.
* Cannot be null.
......@@ -127,7 +143,7 @@ class NavigationModelAndroidAppItem extends NavigationModelItem {
/**
* Item of NavigationListModel for volumes.
*/
class NavigationModelVolumeItem extends NavigationModelItem {
/* #export */ class NavigationModelVolumeItem extends NavigationModelItem {
/**
* @param {string} label Label.
* @param {!VolumeInfo} volumeInfo Volume info for the volume. Cannot be null.
......@@ -148,7 +164,7 @@ class NavigationModelVolumeItem extends NavigationModelItem {
/**
* Item of NavigationListModel for a fake item such as Recent or Linux files.
*/
class NavigationModelFakeItem extends NavigationModelItem {
/* #export */ class NavigationModelFakeItem extends NavigationModelItem {
/**
* @param {string} label Label on the menu button.
* @param {NavigationModelItemType} type
......@@ -167,7 +183,7 @@ class NavigationModelFakeItem extends NavigationModelItem {
/**
* A navigation list model. This model combines multiple models.
*/
class NavigationListModel extends cr.EventTarget {
/* #export */ class NavigationListModel extends cr.EventTarget {
/**
* @param {!VolumeManager} volumeManager VolumeManager instance.
* @param {!FolderShortcutsDataModel} shortcutListModel The list of folder
......
......@@ -2,7 +2,27 @@
// 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 {assertEquals, assertTrue} from 'chrome://test/chai_assert.js';
import {MockCommandLinePrivate} from '../../../base/js/mock_chrome.m.js';
import {reportPromise, waitUntil} from '../../../base/js/test_error_reporting.m.js';
import {VolumeManagerCommon} from '../../../base/js/volume_manager_types.m.js';
import {FilesAppEntry} from '../../../externs/files_app_entry_interfaces.m.js';
import {MockVolumeManager} from '../../background/js/mock_volume_manager.m.js';
import {VolumeInfoImpl} from '../../background/js/volume_info_impl.m.js';
import { EntryList,FakeEntryImpl} from '../../common/js/files_app_entry_types.m.js';
import { MockFileEntry,MockFileSystem} from '../../common/js/mock_entry.m.js';
import {util} from '../../common/js/util.m.js';
import {AndroidAppListModel} from './android_app_list_model.m.js';
import {DirectoryModel} from './directory_model.m.js';
import {createFakeAndroidAppListModel} from './fake_android_app_list_model.m.js';
import {createFakeDirectoryModel} from './mock_directory_model.m.js';
import {MockFolderShortcutDataModel} from './mock_folder_shortcut_data_model.m.js';
import { NavigationListModel, NavigationModelAndroidAppItem,NavigationModelFakeItem, NavigationModelItemType, NavigationModelShortcutItem, NavigationModelVolumeItem, NavigationSection} from './navigation_list_model.m.js';
// clang-format on
/**
* Mock Recent fake entry.
......@@ -36,7 +56,7 @@ let drive;
let hoge;
// Setup the test components.
function setUp() {
export function setUp() {
// Mock LoadTimeData strings.
window.loadTimeData.data = {
MY_FILES_ROOT_LABEL: 'My files',
......@@ -68,7 +88,7 @@ function setUp() {
/**
* Tests model.
*/
function testModel() {
export function testModel() {
const volumeManager = new MockVolumeManager();
const shortcutListModel = new MockFolderShortcutDataModel(
......@@ -124,7 +144,7 @@ function testModel() {
/**
* Tests model with no Recents, Linux files, Play files.
*/
function testNoRecentOrLinuxFiles() {
export function testNoRecentOrLinuxFiles() {
const volumeManager = new MockVolumeManager();
const shortcutListModel = new MockFolderShortcutDataModel(
......@@ -148,7 +168,7 @@ function testNoRecentOrLinuxFiles() {
/**
* Tests adding and removing shortcuts.
*/
function testAddAndRemoveShortcuts() {
export function testAddAndRemoveShortcuts() {
const volumeManager = new MockVolumeManager();
const shortcutListModel = new MockFolderShortcutDataModel(
......@@ -211,7 +231,7 @@ function testAddAndRemoveShortcuts() {
/**
* Tests testAddAndRemoveVolumes test with SinglePartitionFormat flag is on.
*/
function testAddAndRemoveVolumesWhenSinglePartitionOn() {
export function testAddAndRemoveVolumesWhenSinglePartitionOn() {
window.loadTimeData.data_['FILES_SINGLE_PARTITION_FORMAT_ENABLED'] = true;
testAddAndRemoveVolumes();
}
......@@ -219,7 +239,7 @@ function testAddAndRemoveVolumesWhenSinglePartitionOn() {
/**
* Tests adding and removing volumes.
*/
function testAddAndRemoveVolumes() {
export function testAddAndRemoveVolumes() {
const volumeManager = new MockVolumeManager();
const shortcutListModel = new MockFolderShortcutDataModel(
......@@ -321,7 +341,7 @@ function testAddAndRemoveVolumes() {
/**
* Tests testOrderAndNestItems test with SinglePartitionFormat flag is on.
*/
function testOrderAndNestItemsWhenSinglePartitionOn() {
export function testOrderAndNestItemsWhenSinglePartitionOn() {
window.loadTimeData.data_['FILES_SINGLE_PARTITION_FORMAT_ENABLED'] = true;
testOrderAndNestItems();
}
......@@ -332,7 +352,7 @@ function testOrderAndNestItemsWhenSinglePartitionOn() {
* 2. manages NavigationSection for the relevant volumes.
* 3. keeps MTP/Archive/Removable volumes on the original order.
*/
function testOrderAndNestItems() {
export function testOrderAndNestItems() {
const volumeManager = new MockVolumeManager();
const shortcutListModel = new MockFolderShortcutDataModel([
......@@ -502,7 +522,7 @@ function testOrderAndNestItems() {
/**
* Tests model with My files enabled.
*/
function testMyFilesVolumeEnabled(callback) {
export function testMyFilesVolumeEnabled(callback) {
const volumeManager = new MockVolumeManager();
// Item 1 of the volume info list should have Downloads volume type.
assertEquals(
......@@ -574,7 +594,7 @@ function testMyFilesVolumeEnabled(callback) {
* Tests that adding a new partition to the same grouped USB will add the
* partition to the grouping.
*/
function testMultipleUsbPartitionsGrouping() {
export function testMultipleUsbPartitionsGrouping() {
const shortcutListModel = new MockFolderShortcutDataModel([]);
const recentItem = null;
const volumeManager = new MockVolumeManager();
......
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