Commit 5a1718f8 authored by Giovanni Panaro's avatar Giovanni Panaro Committed by Commit Bot

The expand icon no longer appears in the file manager if the child

directory is hidden unless show hidden files is checked.

Bug: 1119701
Change-Id: I35a5ce9ce867570d29e549c04f456519a08e0365
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432444
Commit-Queue: Giovanni Panaro <tsrwebgl@gmail.com>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811497}
parent acdea310
......@@ -558,7 +558,11 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("directoryTreeExpandHorizontalScroll"),
TestCase("directoryTreeExpandHorizontalScrollRTL"),
TestCase("directoryTreeVerticalScroll"),
TestCase("directoryTreeExpandFolder")));
TestCase("directoryTreeExpandFolder"),
TestCase(
"directoryTreeExpandFolderWithHiddenFileAndShowHiddenFilesOff"),
TestCase(
"directoryTreeExpandFolderWithHiddenFileAndShowHiddenFilesOn")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
DirectoryTreeContextMenu, /* directory_tree_context_menu.js */
......
......@@ -695,8 +695,10 @@ class DirectoryItem extends TreeItem {
}
for (let i = 0; i < results.length; i++) {
if (results[i].isDirectory) {
// Once the first directory is found we can stop reading.
const entry = results[i];
// If the entry is a directory and is not filtered, the parent
// directory should be marked as having children
if (entry.isDirectory && this.fileFilter_.filter(entry)) {
this.hasChildren = true;
return;
}
......
......@@ -251,27 +251,28 @@
chrome.test.assertTrue(notScrolled, 'Tree should not scroll left');
};
/**
* Creates a folder test entry from a folder |path|.
* @param {string} path The folder path.
* @return {!TestEntryInfo}
*/
function createFolderTestEntry(path) {
const name = path.split('/').pop();
return new TestEntryInfo({
targetPath: path,
nameText: name,
type: EntryType.DIRECTORY,
lastModifiedTime: 'Dec 28, 1962, 10:42 PM',
sizeText: '--',
typeText: 'Folder',
});
}
/**
* Tests that the directory tree does not horizontally scroll when expanding
* nested folder items when the text direction is RTL.
*/
testcase.directoryTreeExpandHorizontalScrollRTL = async () => {
/**
* Creates a folder test entry from a folder |path|.
* @param {string} path The folder path.
* @return {!TestEntryInfo}
*/
function createFolderTestEntry(path) {
const name = path.split('/').pop();
return new TestEntryInfo({
targetPath: path,
nameText: name,
type: EntryType.DIRECTORY,
lastModifiedTime: 'Dec 28, 1962, 10:42 PM',
sizeText: '--',
typeText: 'Folder',
});
}
// Build an array of nested folder test entries.
const nestedFolderTestEntries = [];
......@@ -396,4 +397,61 @@
const testTime = Date.now() - start;
console.log(`[measurement] Test time: ${testTime}ms`);
};
/**
* Tests to ensure expand icon does not show up if show hidden files is off
* and a directory only contains hidden directories.
*/
testcase.directoryTreeExpandFolderWithHiddenFileAndShowHiddenFilesOff =
async () => {
// Populate a normal folder entry with a hidden folder inside.
const entries = [
createFolderTestEntry('normal-folder'),
createFolderTestEntry('normal-folder/.hidden-folder'),
];
// Opens FilesApp on downloads.
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, entries, []);
// Expand all sub-directories in downloads.
await recursiveExpand(appId, '/My files/Downloads');
// Target the non-hidden folder.
const normalFolder = '#directory-tree [entry-label="normal-folder"]';
const response = await remoteCall.waitForElement(appId, normalFolder);
// Assert that the expand icon will not show up.
chrome.test.assertTrue(response.attributes['has-children'] === 'false');
};
/**
* Tests to ensure expand icon shows up if show hidden files
* is on and a directory only contains hidden directories.
*/
testcase.directoryTreeExpandFolderWithHiddenFileAndShowHiddenFilesOn =
async () => {
// Populate a normal folder entry with a hidden folder inside.
const entries = [
createFolderTestEntry('normal-folder'),
createFolderTestEntry('normal-folder/.hidden-folder'),
];
// Opens FilesApp on downloads.
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, entries, []);
// Enable show hidden files.
await remoteCall.waitAndClickElement(appId, '#gear-button');
await remoteCall.waitAndClickElement(
appId,
'#gear-menu-toggle-hidden-files' +
':not([checked]):not([hidden])');
// Expand all sub-directories in Downloads.
await recursiveExpand(appId, '/My files/Downloads');
// Assert that the expand icon shows up.
const normalFolder =
'#directory-tree [entry-label="normal-folder"][has-children="true"]';
await remoteCall.waitForElement(appId, normalFolder);
};
})();
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