Commit 5d857eab authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Fix breadcrumb when renaming parent.

When a folder is renamed all its children entries in the DirectoryTree
gets stale, because their |fullPath| property are outdated.

Change DirectoryTreeNamingController to force update the renamed
folder's children, so they have the new |fullPath|. This fix the linked
bug because when navigating to children folder the breadcrumbs is
generated based on |fullPath|.

Bug: 885328
Change-Id: I02c39d5289454243d2996d765d5631e17e08b31e
Reviewed-on: https://chromium-review.googlesource.com/1233274
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592355}
parent 0c48b7b7
......@@ -367,6 +367,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("dirPasteWithoutChangingCurrent"),
TestCase("dirRenameWithContextMenu"),
TestCase("dirRenameWithContextMenu").InGuestMode(),
TestCase("dirRenameUpdateChildrenBreadcrumbs"),
TestCase("dirRenameWithKeyboard"),
TestCase("dirRenameWithKeyboard").InGuestMode(),
TestCase("dirRenameWithoutChangingCurrent"),
......
......@@ -185,6 +185,8 @@ DirectoryTreeNamingController.prototype.performRename_ = function(
label.textContent = newName;
this.currentDirectoryItem_.entry = newEntry;
this.currentDirectoryItem_.updateSubDirectories(
true /* recursive */);
this.detach_();
......
......@@ -399,6 +399,70 @@ testcase.dirRenameWithContextMenu = function() {
false /* do not use keyboard shortcut */));
};
/**
* Tests that a child folder breadcrumbs is updated when renaming its parent
* folder. crbug.com/885328.
*/
testcase.dirRenameUpdateChildrenBreadcrumbs = function() {
let appId;
testPromise(
setupAndWaitUntilReady(null, RootPath.DOWNLOADS)
.then(function(results) {
appId = results.windowId;
// Add child-folder inside /photos/
return new addEntries(['local'], [new TestEntryInfo({
type: EntryType.DIRECTORY,
targetPath: 'photos/child-folder',
lastModifiedTime: 'Jan 1, 1980, 11:59 PM',
nameText: 'child-folder',
sizeText: '--',
typeText: 'Folder'
})]);
})
.then(function() {
// Navigate to child folder.
return remoteCall.navigateWithDirectoryTree(
appId, '/photos/child-folder', 'Downloads');
})
.then(function() {
// Rename parent folder.
return clickDirectoryTreeContextMenuItem(appId, '/photos', 'rename')
.then(function() {
return remoteCall.waitForElement(appId, '.tree-row > input');
})
.then(function() {
return remoteCall.callRemoteTestUtil(
'inputText', appId, ['.tree-row > input', 'photos-new']);
})
.then(function() {
const enterKey = [
'.tree-row > input', 'Enter', 'Enter', false, false, false
];
return remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, enterKey);
})
.then(function(result) {
chrome.test.assertTrue(result, 'Enter key failed');
});
})
.then(function() {
// Confirm that current directory is now /Downloads, because it
// can't find the previously selected folder
// /Downloads/photos/child-folder, since its path/parent has been
// renamed.
return remoteCall.waitUntilCurrentDirectoryIsChanged(
appId, '/Downloads');
})
.then(function() {
// Navigate to child-folder using the new path.
// |navigateWithDirectoryTree| already checks for breadcrumbs to
// match the path.
return remoteCall.navigateWithDirectoryTree(
appId, '/photos-new/child-folder', 'Downloads');
}));
};
/**
* Tests renaming folder with the keyboard shortcut.
*/
......
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