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) { ...@@ -107,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesMessage) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesPasswordDialog) { 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) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesToast) {
......
...@@ -61,6 +61,7 @@ js_type_check("closure_compile_jsmodules") { ...@@ -61,6 +61,7 @@ js_type_check("closure_compile_jsmodules") {
":files_message.m", ":files_message.m",
":files_metadata_box.m", ":files_metadata_box.m",
":files_metadata_entry.m", ":files_metadata_entry.m",
":files_password_dialog.m",
":files_quick_view.m", ":files_quick_view.m",
":files_ripple.m", ":files_ripple.m",
":files_safe_media.m", ":files_safe_media.m",
...@@ -223,12 +224,26 @@ js_library("files_password_dialog") { ...@@ -223,12 +224,26 @@ js_library("files_password_dialog") {
] ]
} }
js_unittest("files_password_dialog_unittest") { js_unittest("files_password_dialog_unittest.m") {
deps = [ deps = [
":files_password_dialog", ":files_password_dialog.m",
"//ui/file_manager/base/js:test_error_reporting", "//chrome/test/data/webui:chai_assert",
"//ui/webui/resources/js:webui_resource_test", "//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") { js_library("files_quick_view") {
...@@ -411,10 +426,7 @@ js_unittest("files_xf_elements_unittest") { ...@@ -411,10 +426,7 @@ js_unittest("files_xf_elements_unittest") {
} }
js_test_gen_html("js_test_gen_html") { js_test_gen_html("js_test_gen_html") {
deps = [ deps = [ ":files_xf_elements_unittest" ]
":files_password_dialog_unittest",
":files_xf_elements_unittest",
]
html_import = true html_import = true
} }
...@@ -439,6 +451,7 @@ js_modulizer("modulize") { ...@@ -439,6 +451,7 @@ js_modulizer("modulize") {
input_files = [ input_files = [
"files_message.js", "files_message.js",
"files_spinner.js", "files_spinner.js",
"files_password_dialog.js",
] ]
} }
...@@ -446,6 +459,7 @@ js_test_gen_html("js_test_gen_html_modules") { ...@@ -446,6 +459,7 @@ js_test_gen_html("js_test_gen_html_modules") {
is_polymer3 = true is_polymer3 = true
deps = [ deps = [
":files_message_unittest.m", ":files_message_unittest.m",
":files_password_dialog_unittest.m",
":files_toast_unittest.m", ":files_toast_unittest.m",
":files_tooltip_unittest.m", ":files_tooltip_unittest.m",
] ]
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// 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 {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
// #import {AsyncUtil} from '../../common/js/async_util.m.js';
/** /**
* FilesPasswordDialog template. * FilesPasswordDialog template.
* @const @type {string} * @const @type {string}
...@@ -54,7 +57,7 @@ const filesPasswordDialogTemplate = ` ...@@ -54,7 +57,7 @@ const filesPasswordDialogTemplate = `
* FilesPasswordDialog.USER_CANCELLED. * FilesPasswordDialog.USER_CANCELLED.
* @extends HTMLElement * @extends HTMLElement
*/ */
class FilesPasswordDialog extends HTMLElement { /* #export */ class FilesPasswordDialog extends HTMLElement {
constructor() { constructor() {
/* /*
* Create element content. * Create element content.
......
...@@ -2,6 +2,17 @@ ...@@ -2,6 +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.
// 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} */ /** @type {!FilesPasswordDialog} */
let passwordDialog; let passwordDialog;
/** @type {!CrDialogElement} */ /** @type {!CrDialogElement} */
...@@ -15,22 +26,10 @@ let cancel; ...@@ -15,22 +26,10 @@ let cancel;
/** @type {!CrButtonElement} */ /** @type {!CrButtonElement} */
let unlock; 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. * Mock LoadTimeData strings.
*/ */
function setUpPage() { export function setUpPage() {
window.loadTimeData.getString = id => { window.loadTimeData.getString = id => {
switch (id) { switch (id) {
case 'PASSWORD_DIALOG_INVALID': case 'PASSWORD_DIALOG_INVALID':
...@@ -44,7 +43,7 @@ function setUpPage() { ...@@ -44,7 +43,7 @@ function setUpPage() {
/** /**
* Adds a FilesPasswordDialog element to the page. * Adds a FilesPasswordDialog element to the page.
*/ */
function setUp() { export function setUp() {
document.body.innerHTML = document.body.innerHTML =
`<files-password-dialog id="test-files-password-dialog" hidden> `<files-password-dialog id="test-files-password-dialog" hidden>
</files-password-dialog>`; </files-password-dialog>`;
...@@ -71,7 +70,7 @@ function setUp() { ...@@ -71,7 +70,7 @@ function setUp() {
* The askForPassword method should return a promise that is rejected with * The askForPassword method should return a promise that is rejected with
* FilesPasswordDialog.USER_CANCELLED. * FilesPasswordDialog.USER_CANCELLED.
*/ */
async function testSingleArchiveCancelPasswordPrompt(done) { export async function testSingleArchiveCancelPasswordPrompt(done) {
// Check that the dialog is closed. // Check that the dialog is closed.
assertFalse(dialog.open); assertFalse(dialog.open);
...@@ -116,7 +115,7 @@ async function testSingleArchiveCancelPasswordPrompt(done) { ...@@ -116,7 +115,7 @@ async function testSingleArchiveCancelPasswordPrompt(done) {
* method should return a promise that resolves with the expected input * method should return a promise that resolves with the expected input
* password. * password.
*/ */
async function testUnlockSingleArchive(done) { export async function testUnlockSingleArchive(done) {
// Check that the dialog is closed. // Check that the dialog is closed.
assertFalse(dialog.open); assertFalse(dialog.open);
...@@ -152,7 +151,7 @@ async function testUnlockSingleArchive(done) { ...@@ -152,7 +151,7 @@ async function testUnlockSingleArchive(done) {
* Tests opening the password dialog with an 'Invalid password' message. This * Tests opening the password dialog with an 'Invalid password' message. This
* message is displayed when a wrong password was previously entered. * 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. // Check that the dialog is closed.
assertFalse(dialog.open); assertFalse(dialog.open);
...@@ -178,7 +177,7 @@ async function testDialogWithWrongPassword(done) { ...@@ -178,7 +177,7 @@ async function testDialogWithWrongPassword(done) {
/** /**
* Tests cancel functionality for multiple encrypted archives. * Tests cancel functionality for multiple encrypted archives.
*/ */
async function testCancelMultiplePasswordPrompts(done) { export async function testCancelMultiplePasswordPrompts(done) {
// Check that the dialog is closed. // Check that the dialog is closed.
assertFalse(dialog.open); assertFalse(dialog.open);
...@@ -240,7 +239,7 @@ async function testCancelMultiplePasswordPrompts(done) { ...@@ -240,7 +239,7 @@ async function testCancelMultiplePasswordPrompts(done) {
/** /**
* Tests unlock functionality for multiple encrypted archives. * Tests unlock functionality for multiple encrypted archives.
*/ */
async function testUnlockMultipleArchives(done) { export async function testUnlockMultipleArchives(done) {
// Check that the dialog is closed. // Check that the dialog is closed.
assertFalse(dialog.open); 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