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

Files app: Fix <bread-crumb> as JS modules and its unittest

Now that <bread-crumb> can run as JS modules the <cr-action-menu> works
in the unittest and can be shown/hidden.

Bug: 1133186
Change-Id: I45fe6eecca50499ac4574f57234bb7af30dc4597
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2636903
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@{#844681}
parent f3626a1b
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.m.js';
/**
* @const {string} breadCrumbTemplate
*/
......@@ -452,10 +454,10 @@ const breadCrumbTemplate = `
const menu = /** @type {!CrActionMenuElement} */ (
this.shadowRoot.querySelector('cr-action-menu'));
const top = elider.offsetTop + elider.offsetHeight + 8;
!window.UNIT_TEST && menu.showAt(elider, {top: top});
menu.showAt(elider, {top: top});
// Style drop-down and horizontal position.
const dialog = !window.UNIT_TEST ? menu.getDialog() : {style: {}};
const dialog = menu.getDialog();
dialog.style['left'] = position + 'px';
dialog.style['right'] = position + 'px';
dialog.style['overflow'] = 'hidden auto';
......@@ -484,7 +486,7 @@ const breadCrumbTemplate = `
// Close the drop-down <dialog> if needed.
const menu = this.shadowRoot.querySelector('cr-action-menu');
if (!window.UNIT_TEST && menu.getDialog().hasAttribute('open')) {
if (menu.getDialog().hasAttribute('open')) {
menu.close();
}
}
......
......@@ -7,9 +7,6 @@ import {assertEquals, assertFalse, assertNotEquals, assertTrue} from 'chrome://t
import {BreadCrumb} from './breadcrumb.m.js';
/** @const {boolean} */
window.UNIT_TEST = true;
/**
* Creates new <bread-drumb> element for each test. Asserts it has no initial
* path using the element.path getter.
......@@ -758,6 +755,7 @@ export function testBreadcrumbPartPartsEllipsisElide() {
/**
* Tests that wide text path components in the drop-down menu are rendered
* elided with ellipsis ... an opportunity for adding a tooltip.
* @suppress {accessControls} to be able to access private properties.
*/
export function testBreadcrumbDropDownMenuPathPartsEllipsisElide() {
const element = getBreadCrumb();
......@@ -780,6 +778,9 @@ export function testBreadcrumbDropDownMenuPathPartsEllipsisElide() {
const path = element.parts.join('/');
assertEquals(expect, path + ' ' + getBreadCrumbButtonState());
// Display the dropdown menu.
element.toggleMenu_();
// The wide part button should render its text with ellipsis.
let ellipsis = element.getEllipsisButtons();
assertEquals(1, ellipsis.length);
......
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