Commit 12c3c333 authored by Giovanni Panaro's avatar Giovanni Panaro Committed by Commit Bot

setCheckSelect functionality improvements

In file manager, when the select all command was issued in a directory
where there is only one file and the file was selected, checkSelect
mode would not enable. CheckSelect mode now correctly enables.

Bug: 938273
Change-Id: Ia44814582f5bf2c5e8e8028e77c35b6fdaf88ba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1576434
Commit-Queue: Giovanni Panaro <tsrwebgl@gmail.com>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656285}
parent d67d6bd8
......@@ -294,7 +294,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("fileDisplayUnmountLastPartition"),
TestCase("fileSearchCaseInsensitive"),
TestCase("fileSearchNotFound"),
TestCase("fileDisplayDownloadsWithBlockedFileTaskRunner")));
TestCase("fileDisplayDownloadsWithBlockedFileTaskRunner"),
TestCase("fileDisplayCheckSelectWithFakeItemSelected")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
OpenVideoFiles, /* open_video_files.js */
......
......@@ -29,6 +29,17 @@ class FileListSelectionModel extends cr.ui.ListSelectionModel {
this.isCheckSelectMode_ = enabled;
}
selectAll() {
super.selectAll();
// Force change event when selecting all but with only 1 item, to update the
// UI with select mode.
if (this.isCheckSelectMode_ && this.selectedIndexes.length == 1) {
const e = new Event('change');
e.changes = [];
this.dispatchEvent(e);
}
}
/**
* Gets the check-select mode.
* @return {boolean} True if check-select mode is enabled.
......
......@@ -718,3 +718,24 @@ testcase.fileDisplayDownloadsWithBlockedFileTaskRunner = async () => {
await fileDisplay(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET);
await sendTestMessage({name: 'unblockFileTaskRunner'});
};
/**
* Tests to make sure check-select mode enables when selecting one item
*/
testcase.fileDisplayCheckSelectWithFakeItemSelected = async () => {
// Open files app on Downloads containing ENTRIES.hello.
const appId =
await setupAndWaitUntilReady(RootPath.DOWNLOADS, [ENTRIES.hello], []);
// Select ENTRIES.hello.
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('selectFile', appId, ['hello.txt']));
// Select all.
const ctrlA = ['#file-list', 'a', true, false, false];
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlA));
// Make sure check-select is enabled.
await remoteCall.waitForElement(appId, 'body.check-select');
};
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