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

Files app: Generate JS module for <xf-*>

Generate the JS modules for the following elements:
* <xf-button>
* <xf-circular-progress>
* <xf-display-panel>
* <xf-panel-item>

And their test: files_xf_elements.unittest.m.js.

Bug: 1133186
Change-Id: I22c71f6a6e648c4a1b027ef1766eb4df060f9f93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2576299
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834640}
parent 31aac73f
...@@ -99,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) { ...@@ -99,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesDisplayPanel) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesDisplayPanel) {
RunTestURL("foreground/elements/files_xf_elements_unittest_gen.html"); RunTestURL("foreground/elements/files_xf_elements_unittest.m_gen.html");
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesMessage) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesMessage) {
......
...@@ -62,7 +62,6 @@ group("unit_test_data") { ...@@ -62,7 +62,6 @@ group("unit_test_data") {
"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",
"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",
"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",
"file_manager/foreground/js:js_test_gen_html_modules", "file_manager/foreground/js:js_test_gen_html_modules",
......
...@@ -26,7 +26,6 @@ group("closure_compile") { ...@@ -26,7 +26,6 @@ group("closure_compile") {
":closure_compile_internal", ":closure_compile_internal",
":closure_compile_jsmodules", ":closure_compile_jsmodules",
":js_test_gen_html_modules_type_check_auto", ":js_test_gen_html_modules_type_check_auto",
":js_test_gen_html_type_check_auto",
] ]
} }
...@@ -69,6 +68,10 @@ js_type_check("closure_compile_jsmodules") { ...@@ -69,6 +68,10 @@ js_type_check("closure_compile_jsmodules") {
":files_toast.m", ":files_toast.m",
":files_toggle_ripple.m", ":files_toggle_ripple.m",
":files_tooltip.m", ":files_tooltip.m",
":xf_button.m",
":xf_circular_progress.m",
":xf_display_panel.m",
":xf_panel_item.m",
] ]
} }
...@@ -417,17 +420,16 @@ js_unittest("files_toast_unittest.m") { ...@@ -417,17 +420,16 @@ js_unittest("files_toast_unittest.m") {
] ]
} }
js_unittest("files_xf_elements_unittest") { js_unittest("files_xf_elements_unittest.m") {
deps = [ deps = [
":xf_display_panel", ":xf_display_panel.m",
"//ui/webui/resources/js:assert", "//chrome/test/data/webui:chai_assert",
"//ui/webui/resources/js:webui_resource_test", "//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:load_time_data.m",
] ]
}
js_test_gen_html("js_test_gen_html") { externs_list = [ "$externs_path/file_manager_private.js" ]
deps = [ ":files_xf_elements_unittest" ]
html_import = true
} }
js_library("xf_button") { js_library("xf_button") {
...@@ -437,9 +439,26 @@ js_library("xf_button") { ...@@ -437,9 +439,26 @@ js_library("xf_button") {
] ]
} }
js_library("xf_button.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/elements/xf_button.m.js" ]
deps = [
"//ui/webui/resources/cr_elements/cr_button:cr_button.m",
"//ui/webui/resources/cr_elements/cr_icon_button:cr_icon_button.m",
]
extra_deps = [ ":modulize" ]
}
js_library("xf_circular_progress") { js_library("xf_circular_progress") {
} }
js_library("xf_circular_progress.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/elements/xf_circular_progress.m.js" ]
deps = [ "//ui/webui/resources/js:assert.m" ]
extra_deps = [ ":modulize" ]
}
js_library("xf_display_panel") { js_library("xf_display_panel") {
deps = [ deps = [
":xf_panel_item", ":xf_panel_item",
...@@ -447,11 +466,25 @@ js_library("xf_display_panel") { ...@@ -447,11 +466,25 @@ js_library("xf_display_panel") {
] ]
} }
js_library("xf_display_panel.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/elements/xf_display_panel.m.js" ]
deps = [
":xf_panel_item.m",
"//ui/file_manager/file_manager/common/js:util.m",
]
extra_deps = [ ":modulize" ]
}
js_modulizer("modulize") { js_modulizer("modulize") {
input_files = [ input_files = [
"files_message.js", "files_message.js",
"files_spinner.js", "files_spinner.js",
"files_password_dialog.js", "files_password_dialog.js",
"xf_button.js",
"xf_circular_progress.js",
"xf_panel_item.js",
"xf_display_panel.js",
] ]
} }
...@@ -462,6 +495,7 @@ js_test_gen_html("js_test_gen_html_modules") { ...@@ -462,6 +495,7 @@ js_test_gen_html("js_test_gen_html_modules") {
":files_password_dialog_unittest.m", ":files_password_dialog_unittest.m",
":files_toast_unittest.m", ":files_toast_unittest.m",
":files_tooltip_unittest.m", ":files_tooltip_unittest.m",
":files_xf_elements_unittest.m",
] ]
closure_flags = closure_flags =
...@@ -479,3 +513,15 @@ js_library("xf_panel_item") { ...@@ -479,3 +513,15 @@ js_library("xf_panel_item") {
":xf_circular_progress", ":xf_circular_progress",
] ]
} }
js_library("xf_panel_item.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/elements/xf_panel_item.m.js" ]
deps = [
":xf_button.m",
":xf_circular_progress.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":modulize" ]
}
...@@ -2,17 +2,15 @@ ...@@ -2,17 +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.
/** // clang-format off
* TODO(lucmult): Remove this when converting to JS modules. import {assert} from 'chrome://resources/js/assert.m.js';
* @suppress {checkTypes, constantProperty} import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
*/ import {assertEquals, assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
chrome.fileManagerPrivate = {
FormatFileSystemType: { import {util} from '../../common/js/util.m.js';
VFAT: 'vfat',
EXFAT: 'exfat', import {DisplayPanel} from './xf_display_panel.m.js';
NTFS: 'ntfs', // clang-format on
},
};
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
let displayPanel; let displayPanel;
...@@ -20,7 +18,7 @@ let displayPanel; ...@@ -20,7 +18,7 @@ let displayPanel;
/** /**
* Adds a xf-display-panel element to the test page. * Adds a xf-display-panel element to the test page.
*/ */
function setUp() { export function setUp() {
document.body.innerHTML += document.body.innerHTML +=
'<xf-display-panel id="test-xf-display-panel"></xf-display-panel>'; '<xf-display-panel id="test-xf-display-panel"></xf-display-panel>';
displayPanel = assert(document.querySelector('#test-xf-display-panel')); displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -28,12 +26,12 @@ function setUp() { ...@@ -28,12 +26,12 @@ function setUp() {
const enableFilesTransferDetails = true; const enableFilesTransferDetails = true;
// Mock LoadTimeData strings for transfer details feature. // Mock LoadTimeData strings for transfer details feature.
window.loadTimeData.data = { loadTimeData.data = {
FILES_TRANSFER_DETAILS_ENABLED: enableFilesTransferDetails FILES_TRANSFER_DETAILS_ENABLED: enableFilesTransferDetails
}; };
window.loadTimeData.getString = id => { loadTimeData.getString = id => {
return window.loadTimeData.data_[id] || id; return loadTimeData.data_[id] || id;
}; };
/** @return {boolean} */ /** @return {boolean} */
...@@ -42,7 +40,7 @@ function setUp() { ...@@ -42,7 +40,7 @@ function setUp() {
}; };
} }
function tearDown() { export function tearDown() {
displayPanel.removeAllPanelItems(); displayPanel.removeAllPanelItems();
} }
...@@ -50,7 +48,7 @@ function tearDown() { ...@@ -50,7 +48,7 @@ function tearDown() {
* Tests that adding and removing panels to <xf-display-panel> updates the * Tests that adding and removing panels to <xf-display-panel> updates the
* aria-hidden attribute. * aria-hidden attribute.
*/ */
function testDisplayPanelAriaHidden() { export function testDisplayPanelAriaHidden() {
// Starts without any panel so should be hidden; // Starts without any panel so should be hidden;
assertEquals(displayPanel.getAttribute('aria-hidden'), 'true'); assertEquals(displayPanel.getAttribute('aria-hidden'), 'true');
...@@ -77,7 +75,7 @@ function testDisplayPanelAriaHidden() { ...@@ -77,7 +75,7 @@ function testDisplayPanelAriaHidden() {
assertEquals(displayPanel.getAttribute('aria-hidden'), 'true'); assertEquals(displayPanel.getAttribute('aria-hidden'), 'true');
} }
async function testDisplayPanelAttachPanel(done) { export async function testDisplayPanelAttachPanel(done) {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -115,7 +113,7 @@ async function testDisplayPanelAttachPanel(done) { ...@@ -115,7 +113,7 @@ async function testDisplayPanelAttachPanel(done) {
done(); done();
} }
async function testDisplayPanelChangingPanelTypes(done) { export async function testDisplayPanelChangingPanelTypes(done) {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -210,7 +208,7 @@ async function testDisplayPanelChangingPanelTypes(done) { ...@@ -210,7 +208,7 @@ async function testDisplayPanelChangingPanelTypes(done) {
done(); done();
} }
function testFilesDisplayPanelErrorText() { export function testFilesDisplayPanelErrorText() {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -249,7 +247,7 @@ util.strf = (end, option) => { ...@@ -249,7 +247,7 @@ util.strf = (end, option) => {
return option + end; return option + end;
}; };
function testFilesDisplayPanelErrorMarker() { export function testFilesDisplayPanelErrorMarker() {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -286,7 +284,7 @@ function testFilesDisplayPanelErrorMarker() { ...@@ -286,7 +284,7 @@ function testFilesDisplayPanelErrorMarker() {
'Summary panel error marker property is wrong, should be "hidden"'); 'Summary panel error marker property is wrong, should be "hidden"');
} }
function testFilesDisplayPanelMixedSummary() { export function testFilesDisplayPanelMixedSummary() {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -346,7 +344,7 @@ function testFilesDisplayPanelMixedSummary() { ...@@ -346,7 +344,7 @@ function testFilesDisplayPanelMixedSummary() {
assertEquals('success', summaryPanelItem.status); assertEquals('success', summaryPanelItem.status);
} }
function testFilesDisplayPanelMixedProgress() { export function testFilesDisplayPanelMixedProgress() {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -381,7 +379,7 @@ function testFilesDisplayPanelMixedProgress() { ...@@ -381,7 +379,7 @@ function testFilesDisplayPanelMixedProgress() {
assertEquals('3', summaryPanelItem.progress); assertEquals('3', summaryPanelItem.progress);
} }
function testFilesDisplayPanelCircularProgress() { export function testFilesDisplayPanelCircularProgress() {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -401,7 +399,7 @@ function testFilesDisplayPanelCircularProgress() { ...@@ -401,7 +399,7 @@ function testFilesDisplayPanelCircularProgress() {
assertEquals('4', strokeWidthContainerGroup.getAttribute('stroke-width')); assertEquals('4', strokeWidthContainerGroup.getAttribute('stroke-width'));
} }
async function testFilesDisplayPanelSummaryPanel(done) { export async function testFilesDisplayPanelSummaryPanel(done) {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -462,7 +460,7 @@ async function testFilesDisplayPanelSummaryPanel(done) { ...@@ -462,7 +460,7 @@ async function testFilesDisplayPanelSummaryPanel(done) {
done(); done();
} }
function testFilesDisplayPanelTransferDetails() { export function testFilesDisplayPanelTransferDetails() {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
...@@ -475,7 +473,7 @@ function testFilesDisplayPanelTransferDetails() { ...@@ -475,7 +473,7 @@ function testFilesDisplayPanelTransferDetails() {
assertEquals('detailed-panel', progressPanel.getAttribute('detailed-panel')); assertEquals('detailed-panel', progressPanel.getAttribute('detailed-panel'));
} }
async function testFilesDisplayPanelTransferDetailsSummary(done) { export async function testFilesDisplayPanelTransferDetailsSummary(done) {
// Get the host display panel container element. // Get the host display panel container element.
/** @type {!DisplayPanel|!Element} */ /** @type {!DisplayPanel|!Element} */
const displayPanel = assert(document.querySelector('#test-xf-display-panel')); const displayPanel = assert(document.querySelector('#test-xf-display-panel'));
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/** /**
* A button used inside PanelItem with varying display characteristics. * A button used inside PanelItem with varying display characteristics.
*/ */
class PanelButton extends HTMLElement { /* #export */ class PanelButton extends HTMLElement {
constructor() { constructor() {
super(); super();
this.createElement_(); this.createElement_();
......
...@@ -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 {assert} from 'chrome://resources/js/assert.m.js';
/** /**
* Definition of a circular progress indicator custom element. * Definition of a circular progress indicator custom element.
* The element supports two attributes for control - 'radius' and 'progress'. * The element supports two attributes for control - 'radius' and 'progress'.
...@@ -11,7 +13,7 @@ ...@@ -11,7 +13,7 @@
* element.setAttribute('progress', '50'); to set progress to half complete * element.setAttribute('progress', '50'); to set progress to half complete
* or alternately, set the 'element.progress' JS property for the same result. * or alternately, set the 'element.progress' JS property for the same result.
*/ */
class CircularProgress extends HTMLElement { /* #export */ class CircularProgress extends HTMLElement {
constructor() { constructor() {
super(); super();
const host = document.createElement('template'); const host = document.createElement('template');
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
// 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 {PanelItem} from './xf_panel_item.m.js';
// #import {util} from '../../common/js/util.m.js';
/** /**
* A panel to display a collection of PanelItem. * A panel to display a collection of PanelItem.
* @extends HTMLElement * @extends HTMLElement
*/ */
class DisplayPanel extends HTMLElement { /* #export */ class DisplayPanel extends HTMLElement {
constructor() { constructor() {
super(); super();
this.createElement_(); this.createElement_();
......
...@@ -2,11 +2,17 @@ ...@@ -2,11 +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 {assert} from 'chrome://resources/js/assert.m.js';
// #import {util} from '../../common/js/util.m.js';
// #import {DisplayPanel} from './xf_display_panel.m.js';
// #import './xf_button.m.js';
// #import './xf_circular_progress.m.js';
/** /**
* A panel to display the status or progress of a file operation. * A panel to display the status or progress of a file operation.
* @extends HTMLElement * @extends HTMLElement
*/ */
class PanelItem extends HTMLElement { /* #export */ class PanelItem extends HTMLElement {
constructor() { constructor() {
super(); super();
const host = document.createElement('template'); const host = document.createElement('template');
......
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