Skip to content

Commit

Permalink
[M106] Files app: Fix new breadcrumbs with Shared with me
Browse files Browse the repository at this point in the history
"Shared with me" uses the drive search code. The new breadcrumbs +
change directory using the Store was in a infinite loop when trying to
clear the search during the "change directory".

This CL fixes by only try to clear the search if the store has a search.

Also tested the fix manually in the DUT.

(cherry picked from commit f40efc2)

Test: browser_tests --gtest_filter="*breadcrumbNavigateBackToSharedWithMe*"
Bug: 1354004
Change-Id: I1f517e01587b31cd2f0f73ee3e009a2d5d559b95
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3841134
Commit-Queue: Ben Reich <benreich@chromium.org>
Reviewed-by: Ben Reich <benreich@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1036945}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3848901
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5249@{#28}
Cr-Branched-From: 4f7bea5-refs/heads/main@{#1036826}
  • Loading branch information
Luciano Pacheco authored and Chromium LUCI CQ committed Aug 23, 2022
1 parent 50c4f41 commit b29a892
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions chrome/browser/ash/file_manager/file_manager_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("breadcrumbsEliderMenuItemClick").FilesSwa(),
TestCase("breadcrumbsEliderMenuItemTabLeft"),
TestCase("breadcrumbsEliderMenuItemTabLeft").FilesSwa(),
TestCase("breadcrumbNavigateBackToSharedWithMe"),
TestCase("breadcrumbNavigateBackToSharedWithMe").FilesSwa(),
TestCase("breadcrumbsEliderMenuItemTabRight"),
TestCase("breadcrumbsEliderMenuItemTabRight").FilesSwa()));

Expand Down
3 changes: 3 additions & 0 deletions ui/file_manager/file_manager/externs/ts/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class Store {

/** @param {!StoreObserver} observer */
usubscribe(observer) {}

/** @return {!State} */
getState() {}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,9 @@ export class DirectoryModel extends EventTarget {
this.onSearchCompleted_ = null;
}

this.store_.dispatch(searchAction({}));
if (this.store_.getState()?.search?.query) {
this.store_.dispatch(searchAction({}));
}
}

/**
Expand Down
35 changes: 35 additions & 0 deletions ui/file_manager/integration_tests/file_manager/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,38 @@ testcase.breadcrumbsDontExceedAvailableViewport = async () => {
}
});
};

/**
* Test that navigating back from a sub-folder in Google Drive> Shared With Me
* using the breadcrumbs.
* Internally Shared With Me uses some of the Drive Search code, this confused
* the DirectoryModel clearing the search state in the Store.
*/
testcase.breadcrumbNavigateBackToSharedWithMe = async () => {
// Open Files app on Drive containing "Shared with me" file entries.
const sharedSubFolderName = ENTRIES.sharedWithMeDirectory.nameText;
const appId = await setupAndWaitUntilReady(
RootPath.DRIVE, [], [ENTRIES.sharedWithMeDirectory, ENTRIES.hello]);

// Navigate to Shared with me.
await remoteCall.waitAndClickElement(
appId, '#directory-tree [entry-label="Shared with me"]');

// Wait until the breadcrumb path is updated.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me');

// Navigate to the directory within Shared with me.
await remoteCall.waitUntilSelected(appId, sharedSubFolderName);
await remoteCall.fakeKeyDown(
appId, '#file-list', 'Enter', false, false, false);

await remoteCall.waitUntilCurrentDirectoryIsChanged(
appId, `/Shared with me/${sharedSubFolderName}`);

// Navigate back using breadcrumb.
await remoteCall.waitAndClickElement(
appId, ['xf-breadcrumb', 'button[id="first"]']);

// Wait until the breadcrumb path is updated.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me');
};

0 comments on commit b29a892

Please sign in to comment.