Commit d53f818f authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Fix My files not updating directory tree recursively

Fix issue where My files doesn't propagate updates in the directory tree
when folders are displayed or hidden.

Test: Integration test and checked that it fails without the fix.
Bug: 864453
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I2e7cee1b0d34bccb7d417d650ede04b9bd5aa6fd
Reviewed-on: https://chromium-review.googlesource.com/1141454Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575958}
parent fe7b0602
......@@ -486,11 +486,11 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
WRAPPED_INSTANTIATE_TEST_CASE_P(
MyFiles, /* my_files.js */
FilesAppBrowserTest,
::testing::Values(
TestCase("showMyFiles"),
TestCase("hideSearchButton"),
TestCase("myFilesDisplaysAndOpensEntries"),
TestCase("directoryTreeRefresh")));
::testing::Values(TestCase("showMyFiles"),
TestCase("hideSearchButton"),
TestCase("myFilesDisplaysAndOpensEntries"),
TestCase("directoryTreeRefresh"),
TestCase("myFilesUpdatesChildren")));
// Structure to describe an account info.
struct TestAccountInfo {
......
......@@ -1631,7 +1631,7 @@ DirectoryTree.prototype.updateSubElementsFromList = function(recursive) {
// them to re-draw. It only needs to update the first level of children,
// so it doesn't need to be recursive.
if (currentItem instanceof EntryListItem)
currentItem.updateSubDirectories(false);
currentItem.updateSubDirectories(true);
} else {
var modelItem = this.dataModel.item(modelIndex);
if (modelItem) {
......
......@@ -231,3 +231,97 @@ testcase.myFilesDisplaysAndOpensEntries = function() {
},
]);
};
/**
* Tests My files updating its children recursively.
*
* If it doesn't update its children recursively it can cause directory tree to
* not show or hide sub-folders crbug.com/864453.
*/
testcase.myFilesUpdatesChildren = function() {
let appId;
const downloadsQuery = '#directory-tree [entry-label="Downloads"]';
const hiddenFolder = new TestEntryInfo({
type: EntryType.DIRECTORY,
targetPath: '.hidden-folder',
lastModifiedTime: 'Sep 4, 1998, 12:34 PM',
nameText: '.hidden-folder',
sizeText: '--',
typeText: 'Folder'
});
StepsRunner.run([
// Add a hidden folder.
function() {
// It can't be added via setupAndWaitUntilReady, because it isn't
// displayed and that function waits all entries to be displayed.
addEntries(['local'], [hiddenFolder], this.next);
},
// Open Files app on local Downloads.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.beautiful], []);
},
// Select Downloads folder.
function(results) {
appId = results.windowId;
const isDriveQuery = false;
remoteCall.callRemoteTestUtil(
'selectInDirectoryTree', appId, [downloadsQuery, isDriveQuery],
this.next);
},
// Wait for gear menu to be displayed.
function() {
remoteCall.waitForElement(appId, '#gear-button').then(this.next);
},
// Open the gear menu by clicking the gear button.
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for menu to not be hidden.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// Wait for menu item to appear.
function(result) {
remoteCall
.waitForElement(
appId, '#gear-menu-toggle-hidden-files:not([disabled])')
.then(this.next);
},
// Wait for menu item to appear.
function(result) {
remoteCall
.waitForElement(
appId, '#gear-menu-toggle-hidden-files:not([checked])')
.then(this.next);
},
// Click the menu item.
function(results) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-menu-toggle-hidden-files'],
this.next);
},
// Check the hidden folder to be displayed in RHS.
function(result) {
remoteCall
.waitForFiles(
appId,
TestEntryInfo.getExpectedRows([hiddenFolder, ENTRIES.beautiful]),
{ignoreFileSize: true, ignoreLastModifiedTime: true})
.then(this.next);
},
// Check the hidden folder to be displayed in LHS.
function() {
// Children of Downloads and named ".hidden-folder".
const hiddenFolderTreeQuery = downloadsQuery +
' .tree-children .tree-item[entry-label=".hidden-folder"]';
remoteCall.waitForElement(appId, hiddenFolderTreeQuery).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
};
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