Commit 867ac69f authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[directorytree] Expand nested folders and test horizontal scroll

CL:1924341 limited the horizontal scroll of the directorytree to 0, to
resolve issue 1025581, and needs a test of this behavior.

Create a nested tree of test folders. Expand the directory tree to the
last folder, verify the navigation, and that the directory tree is not
horizontally scrolled (directorytree.scrollLeft should be 0). The test
passes with CL:1924341 and fails before that CL (good).

Tbr: anyone
Test: browser_tests --gtest_filter="*TreeExpandHorizontal*"
Bug: 1029019
Change-Id: I609b06ddfc3d18cf24cf5b5c3e4e118c06989c35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1942667Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720078}
parent 172d3740
......@@ -472,6 +472,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
DirectoryTree, /* directory_tree.js */
FilesAppBrowserTest,
::testing::Values(TestCase("directoryTreeHorizontalScroll"),
TestCase("directoryTreeExpandHorizontalScroll"),
TestCase("directoryTreeVerticalScroll")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
......
......@@ -74,4 +74,68 @@
const noScrollLeft = scrolled.scrollLeft === 0;
chrome.test.assertTrue(noScrollLeft, 'Tree should not scroll left');
};
/**
* Tests that the directory tree does not horizontally scroll when expanding
* nested folder items.
*/
testcase.directoryTreeExpandHorizontalScroll = 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: 'Jan 1, 1980, 11:59 PM',
sizeText: '--',
typeText: 'Folder',
});
}
// Build an array of nested folder test entries.
const nestedFolderTestEntries = [];
for (let path = 'nested-folder1', i = 0; i < 6; ++i) {
nestedFolderTestEntries.push(createFolderTestEntry(path));
path += `/nested-folder${i + 1}`;
}
// Open FilesApp on Downloads containing the folder test entries.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, nestedFolderTestEntries, []);
// Verify the directory tree is not horizontally scrolled.
const directoryTree = '#directory-tree';
const original = await remoteCall.waitForElementStyles(
appId, directoryTree, ['scrollLeft']);
chrome.test.assertTrue(original.scrollLeft === 0);
// Shrink the tree to 150px, enough to hide the deep folder names.
const navigationList = '.dialog-navigation-list';
await remoteCall.callRemoteTestUtil(
'setElementStyles', appId, [navigationList, {width: '150px'}]);
// Expand the tree Downloads > nested-folder1 > nested-folder2 ...
const lastFolderPath = nestedFolderTestEntries.pop().targetPath;
await remoteCall.navigateWithDirectoryTree(
appId, '/Downloads/' + lastFolderPath, 'My files');
// Check: the directory tree should be showing the last test entry.
await remoteCall.waitForElement(
appId, '.tree-item[entry-label="nested-folder5"]:not([hidden])');
// Ensure the directory tree scroll event handling is complete.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'requestAnimationFrame', appId, []));
// Check: the directory tree should not be horizontally scrolled.
const scrolled = await remoteCall.waitForElementStyles(
appId, directoryTree, ['scrollLeft']);
const noScrollLeft = scrolled.scrollLeft === 0;
chrome.test.assertTrue(noScrollLeft, 'Tree should not scroll left');
};
})();
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