Commit 841de257 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Rescan selection on action invalidation

This is done to notify the pinned toggle to update when toggling the
pinned state of a file.

Fixed: 1141665
Change-Id: I9d273f849ad870b0fb8277a5e21ffbdd5cf7ea28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519230
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823916}
parent ae3a3f04
...@@ -648,6 +648,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -648,6 +648,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("drivePinMultiple"), TestCase("drivePinMultiple"),
TestCase("drivePinHosted"), TestCase("drivePinHosted"),
TestCase("drivePinFileMobileNetwork"), TestCase("drivePinFileMobileNetwork"),
TestCase("drivePinToggleUpdatesInFakeEntries"),
TestCase("driveClickFirstSearchResult"), TestCase("driveClickFirstSearchResult"),
TestCase("drivePressEnterToSearch"), TestCase("drivePressEnterToSearch"),
TestCase("drivePressClearSearch"), TestCase("drivePressClearSearch"),
......
...@@ -272,8 +272,10 @@ class ActionsController { ...@@ -272,8 +272,10 @@ class ActionsController {
this.volumeManager_, this.metadataModel_, this.shortcutsModel_, this.volumeManager_, this.metadataModel_, this.shortcutsModel_,
this.driveSyncHandler_, this.ui_, entries); this.driveSyncHandler_, this.ui_, entries);
actionsModel.addEventListener( actionsModel.addEventListener('invalidated', () => {
'invalidated', this.clearLocalCache_.bind(this, key), {once: true}); this.clearLocalCache_(key);
this.selectionHandler_.onFileSelectionChanged();
}, {once: true});
// Once it's initialized, move to readyModels_ so we don't have to construct // Once it's initialized, move to readyModels_ so we don't have to construct
// and initialized again. // and initialized again.
......
...@@ -384,6 +384,52 @@ testcase.drivePinFileMobileNetwork = async () => { ...@@ -384,6 +384,52 @@ testcase.drivePinFileMobileNetwork = async () => {
}); });
}; };
/**
* Tests that the pinned toggle in the toolbar updates on pinned state changes
* within fake entries.
*/
testcase.drivePinToggleUpdatesInFakeEntries = async () => {
const appId = await setupAndWaitUntilReady(RootPath.DRIVE);
// Navigate to the Offline fake entry.
await navigateWithDirectoryTree(appId, '/Offline');
// Bring up the context menu for test.txt.
await remoteCall.waitAndRightClick(
appId, '#file-list [file-name="test.txt"]');
// The pinned toggle should update to be checked.
await remoteCall.waitForElement(appId, '#pinned-toggle[checked]');
// Unpin the file.
await remoteCall.waitAndClickElement(
appId,
'#file-context-menu:not([hidden]) ' +
'[command="#toggle-pinned"][checked]');
// The pinned toggle should change to be unchecked.
await remoteCall.waitForElement(appId, '#pinned-toggle:not([checked])');
// Navigate to the Shared with me fake entry.
await navigateWithDirectoryTree(appId, '/Shared with me');
// Bring up the context menu for test.txt.
await remoteCall.waitAndRightClick(
appId, '#file-list [file-name="test.txt"]');
// The pinned toggle should remain unchecked.
await remoteCall.waitForElement(appId, '#pinned-toggle:not([checked])');
// Pin the file.
await remoteCall.waitAndClickElement(
appId,
'#file-context-menu:not([hidden]) ' +
'[command="#toggle-pinned"]:not([checked])');
// The pinned toggle should change to be checked.
await remoteCall.waitForElement(appId, '#pinned-toggle[checked]');
};
/** /**
* Tests that pressing Ctrl+A (select all files) from the search box doesn't put * Tests that pressing Ctrl+A (select all files) from the search box doesn't put
* the Files App into check-select mode (crbug.com/849253). * the Files App into check-select mode (crbug.com/849253).
......
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