Skip to content

Commit

Permalink
Files: Add integration tests Breadcrumbs related features
Browse files Browse the repository at this point in the history
The following features have to be supported by the new breadcrumbs, so
adding tests to ensure they still work when the new breadcrumbs is
enabled by default.

Files app supports the keyboard shortcut to navigate to parent folder
using Backspace key.

Search within My Drive is always across the whole Drive, so the
breadcrumbs should display "My Drive" even if the search was initiated
in a sub-folder.

Bug: b:228114099
Change-Id: I4a112679421e8f7fcdb91bad3c7472eee506fb08
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3806042
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: Ben Reich <benreich@chromium.org>
Commit-Queue: Ben Reich <benreich@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1032417}
  • Loading branch information
Luciano Pacheco authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent 9e0f4e5 commit 183db82
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 6 deletions.
7 changes: 7 additions & 0 deletions chrome/browser/ash/file_manager/file_manager_browsertest.cc
Expand Up @@ -1132,6 +1132,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("driveClickFirstSearchResult").FilesSwa(),
TestCase("drivePressEnterToSearch"),
TestCase("drivePressEnterToSearch").FilesSwa(),
TestCase("driveSearchAlwaysDisplaysMyDrive"),
TestCase("driveSearchAlwaysDisplaysMyDrive").FilesSwa(),
TestCase("drivePressClearSearch"),
TestCase("drivePressClearSearch").FilesSwa(),
TestCase("drivePressCtrlAFromSearch"),
Expand Down Expand Up @@ -1753,6 +1755,11 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("myFilesToolbarDelete"),
TestCase("myFilesToolbarDelete").FilesSwa()));

WRAPPED_INSTANTIATE_TEST_SUITE_P(
Navigation, /* navigation.js */
FilesAppBrowserTest,
::testing::Values(TestCase("navigateToParent")));

WRAPPED_INSTANTIATE_TEST_SUITE_P(
InstallLinuxPackageDialog, /* install_linux_package_dialog.js */
FilesAppBrowserTest,
Expand Down
Expand Up @@ -27,6 +27,7 @@ import './keyboard_operations.js';
import './metadata.js';
import './metrics.js';
import './my_files.js';
import './navigation.js';
import './office.js';
import './open_audio_media_app.js';
import './open_image_media_app.js';
Expand Down
52 changes: 46 additions & 6 deletions ui/file_manager/integration_tests/file_manager/drive_specific.js
Expand Up @@ -38,6 +38,9 @@ const ENABLE_DOCS_OFFLINE_MESSAGE =
'Enable Google Docs Offline to make Docs, Sheets and Slides ' +
'available offline.';

/** The query selector for the search box input field. */
const searchBox = '#search-box cr-input';

/**
* Returns the steps to start a search for 'hello' and wait for the
* autocomplete results to appear.
Expand Down Expand Up @@ -236,30 +239,67 @@ testcase.drivePressEnterToSearch = async () => {
return appId;
};

/**
* Tests that the breadcrumbs always shows "My Drive" when searching inside any
* folder in Drive.
*/
testcase.driveSearchAlwaysDisplaysMyDrive = async () => {
// Open Files app on Drive.
const appId =
await setupAndWaitUntilReady(RootPath.DRIVE, [], BASIC_DRIVE_ENTRY_SET);

// Start the search from a sub-folder.
await navigateWithDirectoryTree(appId, '/My Drive/photos');

// Search the text.
remoteCall.typeSearchText(appId, 'hello');

// Wait for the auto complete list to appear;
await remoteCall.waitForSearchAutoComplete(appId);

// Send Enter to perform the search.
const enterKey = ['Enter', false, false, false];
await remoteCall.fakeKeyDown(appId, searchBox, ...enterKey);

// Wait for the result in the file list.
await remoteCall.waitForFiles(
appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET));

// When displaying the search result the breadcrumbs should always display "My
// drive".
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/My Drive');

return appId;
};

/**
* Tests that pressing the clear search button announces an a11y message and
* shows all files/folders.
*/
testcase.drivePressClearSearch = async () => {
const appId = await testcase.drivePressEnterToSearch();
const appId = await testcase.driveSearchAlwaysDisplaysMyDrive();

// Click on the clear search button.
await remoteCall.waitAndClickElement(appId, '#search-box cr-input .clear');

// Wait for fil list to display all files.
await remoteCall.waitForFiles(
appId, TestEntryInfo.getExpectedRows(BASIC_DRIVE_ENTRY_SET));
await remoteCall.waitForFiles(appId, []);

// Check that a11y message for clearing the search term has been issued.
const a11yMessages =
await remoteCall.callRemoteTestUtil('getA11yAnnounces', appId, []);
chrome.test.assertEq(2, a11yMessages.length, 'Missing a11y message');
chrome.test.assertEq(
'Search text cleared, showing all files and folders.', a11yMessages[1]);

// The breadcrumbs should return back to the previous original folder.
await remoteCall.waitUntilCurrentDirectoryIsChanged(
appId, '/My Drive/photos');
};

/**
* Tests that pinning multiple files affects the pin action of individual files.
* Tests that pinning multiple files affects the pin action of individual
* files.
*/
testcase.drivePinMultiple = async () => {
const appId = await setupAndWaitUntilReady(RootPath.DRIVE);
Expand Down Expand Up @@ -492,8 +532,8 @@ testcase.drivePinToggleUpdatesInFakeEntries = async () => {
};

/**
* Tests that pressing Ctrl+A (select all files) from the search box doesn't put
* the Files App into check-select mode (crbug.com/849253).
* Tests that pressing Ctrl+A (select all files) from the search box doesn't
* put the Files App into check-select mode (crbug.com/849253).
*/
testcase.drivePressCtrlAFromSearch = async () => {
// Open Files app on Drive.
Expand Down
26 changes: 26 additions & 0 deletions ui/file_manager/integration_tests/file_manager/navigation.js
@@ -0,0 +1,26 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {ENTRIES, RootPath} from '../test_util.js';
import {testcase} from '../testcase.js';

import {remoteCall, setupAndWaitUntilReady} from './background.js';

/** Tests that the Backspace key navigates to parent directory. */
testcase.navigateToParent = async () => {
// Open Files app on local Downloads.
const appId =
await setupAndWaitUntilReady(RootPath.DOWNLOADS, [ENTRIES.beautiful], []);

// It should start in Downloads.
await remoteCall.waitUntilCurrentDirectoryIsChanged(
appId, '/My files/Downloads');

// Send the Backspace key to the file list.
const backspaceKey = ['#file-list', 'Backspace', false, false, false];
await remoteCall.fakeKeyDown(appId, ...backspaceKey);

// It should navigate to the parent.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/My files');
};
35 changes: 35 additions & 0 deletions ui/file_manager/integration_tests/remote_call.js
Expand Up @@ -939,4 +939,39 @@ export class RemoteCallFilesApp extends RemoteCall {
chrome.test.assertTrue(
await this.callRemoteTestUtil('disableBannersForTesting', appId, []));
}

/**
* Sends text to the search box in the Files app.
* @param {string} appId App window Id
* @param {string} text The text to type in the search box.
*/
async typeSearchText(appId, text) {
const searchBoxInput = ['#search-box cr-input'];

// Focus the search box.
await this.waitAndClickElement(appId, '#search-button');

// Input the text.
await this.inputText(appId, searchBoxInput, text);

// Notify the element of the input.
chrome.test.assertTrue(await this.callRemoteTestUtil(
'fakeEvent', appId, ['#search-box cr-input', 'input']));
}

/**
* Waits for the search box auto complete list to appear.
* @param {string} appId
* @return {!Promise<!Array<string>>} Array of the names in the auto complete
* list.
*/
async waitForSearchAutoComplete(appId) {
// Wait for the list to appear.
await this.waitForElement(appId, '#autocomplete-list li');

// Return the result.
const elements = await this.callRemoteTestUtil(
'deepQueryAllElements', appId, ['#autocomplete-list li']);
return elements.map((element) => element.text);
}
}

0 comments on commit 183db82

Please sign in to comment.