Commit f50f771d authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Update file manager gear menu items on directory change

When there is a forced directory change (e.g. through unplugging a usb),
if the gear menu is currently open, the menu items do not update their
status with the new directory. This can cause, for example, the 'Format
device' item to still be active. This change forces an update on
directory change.

Modify the formatDialogGearMenu test to test this behaviour too.

Bug: 1007566
Change-Id: I8158a2630e6711fb9b8e371faf7f689325043cdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859810
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710702}
parent 17116919
......@@ -15,6 +15,9 @@ class GearMenuController {
constructor(
gearButton, toggleRipple, gearMenu, providersMenu, directoryModel,
commandHandler, providersModel) {
/** @private @const {!cr.ui.MultiMenuButton} */
this.gearButton_ = gearButton;
/** @private @const {!FilesToggleRipple} */
this.toggleRipple_ = toggleRipple;
......@@ -95,6 +98,10 @@ class GearMenuController {
if (event.volumeChanged) {
this.refreshRemainingSpace_(true);
} // Show loading caption.
if (this.gearButton_.isMenuShown()) {
this.gearButton_.menu.updateCommands(this.gearButton_);
}
}
/**
......
......@@ -261,9 +261,8 @@ testcase.formatDialogGearMenu = async () => {
'focus', appId, ['#directory-tree']),
'focus failed: #directory-tree');
// Click on the USB's directory tree entry.
const treeQuery = `#directory-tree [entry-label="fake-usb"]`;
await remoteCall.waitAndClickElement(appId, treeQuery);
// Navigate to the USB via the directory tree.
await navigateWithDirectoryTree(appId, '/fake-usb');
// Click on the gear menu button.
await remoteCall.waitAndClickElement(appId, '#gear-button:not([hidden])');
......@@ -303,4 +302,23 @@ testcase.formatDialogGearMenu = async () => {
const title2 = await remoteCall.waitForElement(
appId, ['files-format-dialog', 'cr-dialog[open] div[slot="title"]']);
chrome.test.assertEq('Format fake-usb', title2.text.trim());
// Click cancel button.
await remoteCall.waitAndClickElement(appId, cancelButtonQuery);
// Click on the gear menu button.
await remoteCall.waitAndClickElement(appId, '#gear-button:not([hidden])');
// Ensure the format menu item has appeared.
await remoteCall.waitForElement(
appId, '#gear-menu-format:not([disabled]):not([hidden])');
// Unmount the USB.
await sendTestMessage({name: 'unmountUsb'});
// Ensure the file manager has navigated back to My files.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/My files');
// Ensure the format menu item has disappeared.
await remoteCall.waitForElement(appId, '#gear-menu-format[disabled][hidden]');
};
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