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

Files app: Generate JS module for <files-password-dialog> and its test

Bug: 1133186
Change-Id: Ifc81fa000fa91a69e8eed2450b9d8fbe4c61dd7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2576859
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834622}
parent 5e0eeff1
......@@ -107,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesMessage) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesPasswordDialog) {
RunTestURL("foreground/elements/files_password_dialog_unittest_gen.html");
RunTestURL("foreground/elements/files_password_dialog_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesToast) {
......
......@@ -61,6 +61,7 @@ js_type_check("closure_compile_jsmodules") {
":files_message.m",
":files_metadata_box.m",
":files_metadata_entry.m",
":files_password_dialog.m",
":files_quick_view.m",
":files_ripple.m",
":files_safe_media.m",
......@@ -223,12 +224,26 @@ js_library("files_password_dialog") {
]
}
js_unittest("files_password_dialog_unittest") {
js_unittest("files_password_dialog_unittest.m") {
deps = [
":files_password_dialog",
"//ui/file_manager/base/js:test_error_reporting",
"//ui/webui/resources/js:webui_resource_test",
":files_password_dialog.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:test_error_reporting.m",
"//ui/webui/resources/js:assert.m",
]
}
js_library("files_password_dialog.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/elements/files_password_dialog.m.js" ]
deps = [
"//ui/file_manager/file_manager/common/js:async_util.m",
"//ui/webui/resources/cr_elements/cr_button:cr_button.m",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/cr_elements/cr_input:cr_input.m",
"//ui/webui/resources/js:load_time_data.m",
]
extra_deps = [ ":modulize" ]
}
js_library("files_quick_view") {
......@@ -411,10 +426,7 @@ js_unittest("files_xf_elements_unittest") {
}
js_test_gen_html("js_test_gen_html") {
deps = [
":files_password_dialog_unittest",
":files_xf_elements_unittest",
]
deps = [ ":files_xf_elements_unittest" ]
html_import = true
}
......@@ -439,6 +451,7 @@ js_modulizer("modulize") {
input_files = [
"files_message.js",
"files_spinner.js",
"files_password_dialog.js",
]
}
......@@ -446,6 +459,7 @@ js_test_gen_html("js_test_gen_html_modules") {
is_polymer3 = true
deps = [
":files_message_unittest.m",
":files_password_dialog_unittest.m",
":files_toast_unittest.m",
":files_tooltip_unittest.m",
]
......
......@@ -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 {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
// #import {AsyncUtil} from '../../common/js/async_util.m.js';
/**
* FilesPasswordDialog template.
* @const @type {string}
......@@ -54,7 +57,7 @@ const filesPasswordDialogTemplate = `
* FilesPasswordDialog.USER_CANCELLED.
* @extends HTMLElement
*/
class FilesPasswordDialog extends HTMLElement {
/* #export */ class FilesPasswordDialog extends HTMLElement {
constructor() {
/*
* Create element content.
......
......@@ -2,6 +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 "chrome://resources/cr_elements/cr_button/cr_button.m.js";
import "chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js";
import "chrome://resources/cr_elements/cr_input/cr_input.m.js";
import {assert} from 'chrome://resources/js/assert.m.js';
import {assertEquals, assertFalse, assertNotReached} from 'chrome://test/chai_assert.js';
import {waitUntil} from '../../../base/js/test_error_reporting.m.js';
import {FilesPasswordDialog} from './files_password_dialog.m.js';
// clang-format on
/** @type {!FilesPasswordDialog} */
let passwordDialog;
/** @type {!CrDialogElement} */
......@@ -15,22 +26,10 @@ let cancel;
/** @type {!CrButtonElement} */
let unlock;
/**
* TODO(lucmult): Remove this when converting to JS modules.
* @suppress {checkTypes}
*/
chrome.fileManagerPrivate = {
FormatFileSystemType: {
VFAT: 'vfat',
EXFAT: 'exfat',
NTFS: 'ntfs',
},
};
/**
* Mock LoadTimeData strings.
*/
function setUpPage() {
export function setUpPage() {
window.loadTimeData.getString = id => {
switch (id) {
case 'PASSWORD_DIALOG_INVALID':
......@@ -44,7 +43,7 @@ function setUpPage() {
/**
* Adds a FilesPasswordDialog element to the page.
*/
function setUp() {
export function setUp() {
document.body.innerHTML =
`<files-password-dialog id="test-files-password-dialog" hidden>
</files-password-dialog>`;
......@@ -71,7 +70,7 @@ function setUp() {
* The askForPassword method should return a promise that is rejected with
* FilesPasswordDialog.USER_CANCELLED.
*/
async function testSingleArchiveCancelPasswordPrompt(done) {
export async function testSingleArchiveCancelPasswordPrompt(done) {
// Check that the dialog is closed.
assertFalse(dialog.open);
......@@ -116,7 +115,7 @@ async function testSingleArchiveCancelPasswordPrompt(done) {
* method should return a promise that resolves with the expected input
* password.
*/
async function testUnlockSingleArchive(done) {
export async function testUnlockSingleArchive(done) {
// Check that the dialog is closed.
assertFalse(dialog.open);
......@@ -152,7 +151,7 @@ async function testUnlockSingleArchive(done) {
* Tests opening the password dialog with an 'Invalid password' message. This
* message is displayed when a wrong password was previously entered.
*/
async function testDialogWithWrongPassword(done) {
export async function testDialogWithWrongPassword(done) {
// Check that the dialog is closed.
assertFalse(dialog.open);
......@@ -178,7 +177,7 @@ async function testDialogWithWrongPassword(done) {
/**
* Tests cancel functionality for multiple encrypted archives.
*/
async function testCancelMultiplePasswordPrompts(done) {
export async function testCancelMultiplePasswordPrompts(done) {
// Check that the dialog is closed.
assertFalse(dialog.open);
......@@ -240,7 +239,7 @@ async function testCancelMultiplePasswordPrompts(done) {
/**
* Tests unlock functionality for multiple encrypted archives.
*/
async function testUnlockMultipleArchives(done) {
export async function testUnlockMultipleArchives(done) {
// Check that the dialog is closed.
assertFalse(dialog.open);
......
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