Skip to content

Commit

Permalink
[Files F2] Enable FileDisplay/Search/ZipFiles tests for new tree
Browse files Browse the repository at this point in the history
* Update PageObject's `getItemIconType` to `getItemVolumeType`,
  use the test attribute to get the value.
* For some icon name differences between old/new tree regarding
  the EntryList items, cater them in the PageObject.
* For fake items inside Drive, use QueryByLabel instead of
  QueryByType, because we don't have a volume type for fake
  items.

Bug: b:301341566 b:307656688 b:307657930
Test: browser_tests --gtest_filter="FileDisplay/*"
Test: browser_tests --gtest_filter="Search/*"
Test: browser_tests --gtest_filter="ZipFiles/*"
Change-Id: If1e5891035e3c8d7f403a09ffd05193f6c58ead7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4975685
Reviewed-by: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Wenbo Jie <wenbojie@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1216721}
  • Loading branch information
PinkyJie authored and Chromium LUCI CQ committed Oct 29, 2023
1 parent 264c759 commit 5598553
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 33 deletions.
33 changes: 16 additions & 17 deletions chrome/browser/ash/file_manager/file_manager_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
.NewDirectoryTree()
.FeatureIds({"screenplay-ade01078-3b79-41d2-953e-e22a544a28b3"}),
// TODO(b/301341566): enable the tests
// TestCase("fileDisplayUsbPartition").NewDirectoryTree(),
// TestCase("fileDisplayUsbPartition")
// .EnableSinglePartitionFormat()
// .NewDirectoryTree(),
// TestCase("fileDisplayUsbPartitionSort").NewDirectoryTree(),
// TestCase("fileDisplayPartitionFileTable").NewDirectoryTree(),
TestCase("fileDisplayUsbPartition").NewDirectoryTree(),
TestCase("fileDisplayUsbPartition")
.EnableSinglePartitionFormat()
.NewDirectoryTree(),
TestCase("fileDisplayUsbPartitionSort").NewDirectoryTree(),
TestCase("fileDisplayPartitionFileTable").NewDirectoryTree(),
// TestCase("fileDisplayWithoutVolumesThenMountDownloads")
// .DontMountVolumes()
// .NewDirectoryTree(),
Expand All @@ -355,17 +355,17 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
// .DontMountVolumes()
// .NewDirectoryTree(),
TestCase("fileDisplayWithHiddenVolume").NewDirectoryTree(),
// TestCase("fileDisplayMountWithFakeItemSelected").NewDirectoryTree(),
// TestCase("fileDisplayUnmountDriveWithSharedWithMeSelected")
// .NewDirectoryTree(),
// TestCase("fileDisplayCheckReadOnlyIconOnFakeDirectory")
// .NewDirectoryTree(),
TestCase("fileDisplayMountWithFakeItemSelected").NewDirectoryTree(),
TestCase("fileDisplayUnmountDriveWithSharedWithMeSelected")
.NewDirectoryTree(),
TestCase("fileDisplayCheckReadOnlyIconOnFakeDirectory")
.NewDirectoryTree(),
TestCase("fileDisplayCheckNoReadOnlyIconOnLinuxFiles")
.NewDirectoryTree(),
TestCase("fileDisplayCheckNoReadOnlyIconOnGuestOs").NewDirectoryTree(),
// TestCase("fileDisplayUnmountRemovableRoot").NewDirectoryTree(),
// TestCase("fileDisplayUnmountFirstPartition").NewDirectoryTree(),
// TestCase("fileDisplayUnmountLastPartition").NewDirectoryTree(),
TestCase("fileDisplayUnmountRemovableRoot").NewDirectoryTree(),
TestCase("fileDisplayUnmountFirstPartition").NewDirectoryTree(),
TestCase("fileDisplayUnmountLastPartition").NewDirectoryTree(),
// Section end - browser tests for new directory tree
TestCase("fileDisplayDownloads")
.FeatureIds({"screenplay-ade01078-3b79-41d2-953e-e22a544a28b3"}),
Expand Down Expand Up @@ -465,8 +465,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
::testing::Values(
TestCase("zipFileOpenUsb").NewDirectoryTree(),
TestCase("zipCreateFileUsb").NewDirectoryTree(),
// TODO(b/307657930): enable the test
// TestCase("zipExtractFromReadOnly").NewDirectoryTree(),
TestCase("zipExtractFromReadOnly").NewDirectoryTree(),
// Section end - browser tests for new directory tree
TestCase("zipFileOpenDownloads"),
TestCase("zipFileOpenDownloads").InGuestMode(),
Expand Down Expand Up @@ -2004,7 +2003,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("searchDriveWithRecencyOptions").NewDirectoryTree(),
TestCase("searchDriveWithTypeOptions").NewDirectoryTree(),
TestCase("searchRemovableDevice").NewDirectoryTree(),
// TestCase("searchPartitionedRemovableDevice").NewDirectoryTree(),
TestCase("searchPartitionedRemovableDevice").NewDirectoryTree(),
TestCase("resetSearchOptionsOnFolderChange").NewDirectoryTree(),
TestCase("searchFromMyFiles").NewDirectoryTree(),
TestCase("searchHierarchy").NewDirectoryTree(),
Expand Down
17 changes: 8 additions & 9 deletions ui/file_manager/integration_tests/file_manager/file_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ testcase.fileDisplayUsbPartition = async () => {
// Wait for removable partition-1 to appear in the directory tree.
const partitionOne = await directoryTree.waitForItemByLabel('partition-1');
chrome.test.assertEq(
'removable', directoryTree.getItemIconType(partitionOne));
'removable', directoryTree.getItemVolumeType(partitionOne));

// Wait for removable partition-2 to appear in the directory tree.
const partitionTwo = await directoryTree.waitForItemByLabel('partition-2');
chrome.test.assertEq(
'removable', directoryTree.getItemIconType(partitionTwo));
'removable', directoryTree.getItemVolumeType(partitionTwo));

// Check partitions are children of the root label.
const childEntries =
Expand All @@ -318,22 +318,22 @@ testcase.fileDisplayUsbPartition = async () => {

// Wait for USB to appear in the directory tree.
const fakeUsb = await directoryTree.waitForItemByLabel('fake-usb');
chrome.test.assertEq('removable', directoryTree.getItemIconType(fakeUsb));
chrome.test.assertEq('removable', directoryTree.getItemVolumeType(fakeUsb));

if (await isSinglePartitionFormat(appId)) {
// Check unpartitioned USB has single partition as tree child.
const itemEntries =
await directoryTree.getChildItemsByParentLabel('FAKEUSB');
chrome.test.assertEq(1, itemEntries.length);
const childVolumeType = directoryTree.getItemIconType(itemEntries[0]);
const childVolumeType = directoryTree.getItemVolumeType(itemEntries[0]);

chrome.test.assertTrue('removable' == childVolumeType);
} else {
// Check unpartitioned USB does not have partitions as tree children.
const itemEntries =
await directoryTree.getChildItemsByParentLabel('fake-usb');
chrome.test.assertEq(1, itemEntries.length);
const childVolumeType = directoryTree.getItemIconType(itemEntries[0]);
const childVolumeType = directoryTree.getItemVolumeType(itemEntries[0]);
chrome.test.assertTrue('removable' !== childVolumeType);
}
};
Expand Down Expand Up @@ -711,7 +711,6 @@ testcase.fileDisplayWithHiddenVolume = async () => {

/**
* Tests Files app resisting the urge to switch to Downloads when mounts change.
* re-enabling Drive.
*/
testcase.fileDisplayMountWithFakeItemSelected = async () => {
// Open Files app on Drive with the given test files.
Expand All @@ -723,7 +722,7 @@ testcase.fileDisplayMountWithFakeItemSelected = async () => {

// Navigate to My files.
const directoryTree = await DirectoryTreePageObject.create(appId, remoteCall);
await directoryTree.selectGroupRootItemByType('my_files');
await directoryTree.selectItemByLabel('My files');

// Wait for the navigation to complete.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/My files');
Expand All @@ -750,7 +749,7 @@ testcase.fileDisplayUnmountDriveWithSharedWithMeSelected = async () => {

// Navigate to Shared with me.
const directoryTree = await DirectoryTreePageObject.create(appId, remoteCall);
await directoryTree.selectItemByType('drive_shared_with_me');
await directoryTree.selectItemByLabel('Shared with me');

// Wait for the navigation to complete.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me');
Expand Down Expand Up @@ -898,7 +897,7 @@ testcase.fileDisplayCheckReadOnlyIconOnFakeDirectory = async () => {

// Navigate to Shared with me.
const directoryTree = await DirectoryTreePageObject.create(appId, remoteCall);
await directoryTree.selectItemByType('drive_shared_with_me');
await directoryTree.selectItemByLabel('Shared with me');

// Wait for the navigation to complete.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,17 @@ export class DirectoryTreePageObject {
}

/**
* Get the icon type of the tree item.
* Get the volume type of the tree item.
*
* @param {?ElementObject} item The tree item.
* @returns {string}
*/
getItemIconType(item) {
getItemVolumeType(item) {
if (!item) {
chrome.test.fail('Item is not a valid tree item.');
return '';
}
return this.useNewTree_ ? item.attributes['icon'] :
item.attributes['volume-type-for-testing'];
return item.attributes['volume-type-for-testing'];
}

/**
Expand Down Expand Up @@ -1351,6 +1350,15 @@ class DirectoryTreeSelectors_ {
* @return {string}
*/
groupRootItemItselfByType(type) {
// For EntryList, there are some differences between the old/new tree on the
// icon names. Format: <old-tree-icon-name>: <new-tree-icon-name>.
const iconNameMap = {
'drive': 'service_drive',
'removable': 'usb',
};
if (this.useNewTree && type in iconNameMap) {
type = iconNameMap[type];
}
return this.useNewTree ?
`${this.item}[data-navigation-key^="${ENTRY_LIST_PATH_PREFIX}"][icon="${
type}"]` :
Expand Down
4 changes: 2 additions & 2 deletions ui/file_manager/integration_tests/file_manager/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,12 @@ testcase.searchPartitionedRemovableDevice = async () => {
const directoryTree = await DirectoryTreePageObject.create(appId, remoteCall);
const partitionOne = await directoryTree.waitForItemByLabel('partition-1');
chrome.test.assertEq(
'removable', directoryTree.getItemIconType(partitionOne));
'removable', directoryTree.getItemVolumeType(partitionOne));

// Wait for removable partition-2 to appear in the directory tree.
const partitionTwo = await directoryTree.waitForItemByLabel('partition-2');
chrome.test.assertEq(
'removable', directoryTree.getItemIconType(partitionTwo));
'removable', directoryTree.getItemVolumeType(partitionTwo));

// Navigate to the root of the USB.
await directoryTree.selectItemByLabel(getUsbVolumeQuery(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ testcase.zipExtractFromReadOnly = async () => {

// Navigate to Shared with me.
const directoryTree = await DirectoryTreePageObject.create(appId, remoteCall);
await directoryTree.selectItemByType('drive_shared_with_me');
await directoryTree.selectItemByLabel('Shared with me');

// Wait for the navigation to complete.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me');
Expand Down

0 comments on commit 5598553

Please sign in to comment.