Commit 721f64d8 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Fix DirectoryTreeContextMenu tests with flag MyFilesVolume enabled

Fix |expandTreeItemInDirectoryTree| test helper function wait for
folder to expand and set the focus on directory tree, this fixes the
context menu tests that expects the focus in the directory tree to
be able open context menu in the directory tree.

Fix test |fileDisplayComputers| to pass the volume type because it was
trying to expand Downloads volume and the wait for Downloads be
expanded was failing, this test wants to expand Drive to be able to
expand Computers within Drive.

Change some selectors for Downloads to be compatible with MyFilesVolume
flag enabled and disabled.

Bug: 873539
Change-Id: I11ddd230746b8cc0804af818d9924146aa9b6da0
Reviewed-on: https://chromium-review.googlesource.com/c/1351977Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612522}
parent 3d2fb099
...@@ -466,6 +466,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -466,6 +466,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("dirCopyWithKeyboard").InGuestMode(), TestCase("dirCopyWithKeyboard").InGuestMode(),
TestCase("dirCopyWithKeyboard").EnableMyFilesVolume(), TestCase("dirCopyWithKeyboard").EnableMyFilesVolume(),
TestCase("dirCopyWithoutChangingCurrent"), TestCase("dirCopyWithoutChangingCurrent"),
TestCase("dirCopyWithoutChangingCurrent").EnableMyFilesVolume(),
TestCase("dirCutWithContextMenu"), TestCase("dirCutWithContextMenu"),
TestCase("dirCutWithContextMenu").InGuestMode(), TestCase("dirCutWithContextMenu").InGuestMode(),
TestCase("dirCutWithContextMenu").EnableMyFilesVolume(), TestCase("dirCutWithContextMenu").EnableMyFilesVolume(),
...@@ -474,11 +475,14 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -474,11 +475,14 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("dirCutWithKeyboard").EnableMyFilesVolume(), TestCase("dirCutWithKeyboard").EnableMyFilesVolume(),
TestCase("dirPasteWithContextMenu"), TestCase("dirPasteWithContextMenu"),
TestCase("dirPasteWithContextMenu").InGuestMode(), TestCase("dirPasteWithContextMenu").InGuestMode(),
TestCase("dirPasteWithContextMenu").EnableMyFilesVolume(),
TestCase("dirPasteWithoutChangingCurrent"), TestCase("dirPasteWithoutChangingCurrent"),
TestCase("dirPasteWithoutChangingCurrent").EnableMyFilesVolume(),
TestCase("dirRenameWithContextMenu"), TestCase("dirRenameWithContextMenu"),
TestCase("dirRenameWithContextMenu").InGuestMode(), TestCase("dirRenameWithContextMenu").InGuestMode(),
TestCase("dirRenameWithContextMenu").EnableMyFilesVolume(), TestCase("dirRenameWithContextMenu").EnableMyFilesVolume(),
TestCase("dirRenameUpdateChildrenBreadcrumbs"), TestCase("dirRenameUpdateChildrenBreadcrumbs"),
TestCase("dirRenameUpdateChildrenBreadcrumbs").EnableMyFilesVolume(),
TestCase("dirRenameWithKeyboard"), TestCase("dirRenameWithKeyboard"),
TestCase("dirRenameWithKeyboard").InGuestMode(), TestCase("dirRenameWithKeyboard").InGuestMode(),
TestCase("dirRenameWithKeyboard").EnableMyFilesVolume(), TestCase("dirRenameWithKeyboard").EnableMyFilesVolume(),
......
...@@ -167,11 +167,14 @@ function createDirectoryFromDirectoryTree( ...@@ -167,11 +167,14 @@ function createDirectoryFromDirectoryTree(
return setupForDirectoryTreeContextMenuTest().then(function(id) { return setupForDirectoryTreeContextMenuTest().then(function(id) {
windowId = id; windowId = id;
if (changeCurrentDirectory) if (changeCurrentDirectory) {
return remoteCall.navigateWithDirectoryTree( return remoteCall.navigateWithDirectoryTree(
windowId, RootPath.DOWNLOADS_PATH + '/photos', 'My files/Downloads'); windowId, RootPath.DOWNLOADS_PATH + '/photos', 'My files/Downloads');
else } else {
return remoteCall.expandDownloadVolumeInDirectoryTree(windowId); const downloadsQuery =
'#directory-tree [entry-label="My files"] [entry-label="Downloads"]';
return remoteCall.expandDirectoryTreeFor(windowId, downloadsQuery);
}
}).then(function() { }).then(function() {
if (useKeyboardShortcut) { if (useKeyboardShortcut) {
return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId,
...@@ -250,8 +253,10 @@ testcase.dirCopyWithoutChangingCurrent = function() { ...@@ -250,8 +253,10 @@ testcase.dirCopyWithoutChangingCurrent = function() {
var windowId; var windowId;
testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) {
windowId = id; windowId = id;
return remoteCall.expandDownloadVolumeInDirectoryTree(windowId); const downloadsQuery =
}).then(function() { '#directory-tree [entry-label="My files"] [entry-label="Downloads"]';
return remoteCall.expandTreeItemInDirectoryTree(windowId, downloadsQuery);
}).then(function(result) {
return clickDirectoryTreeContextMenuItem( return clickDirectoryTreeContextMenuItem(
windowId, RootPath.DOWNLOADS_PATH + '/photos', 'copy'); windowId, RootPath.DOWNLOADS_PATH + '/photos', 'copy');
}).then(function() { }).then(function() {
...@@ -311,7 +316,9 @@ testcase.dirCutWithoutChangingCurrent = function() { ...@@ -311,7 +316,9 @@ testcase.dirCutWithoutChangingCurrent = function() {
var windowId; var windowId;
testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) {
windowId = id; windowId = id;
return remoteCall.expandDownloadVolumeInDirectoryTree(windowId); const downloadsQuery =
'#directory-tree [entry-label="My files"] [entry-label="Downloads"]';
return remoteCall.expandTreeItemInDirectoryTree(windowId, downloadsQuery);
}).then(function() { }).then(function() {
return clickDirectoryTreeContextMenuItem( return clickDirectoryTreeContextMenuItem(
windowId, RootPath.DOWNLOADS_PATH + '/photos', 'cut'); windowId, RootPath.DOWNLOADS_PATH + '/photos', 'cut');
...@@ -329,6 +336,7 @@ testcase.dirCutWithoutChangingCurrent = function() { ...@@ -329,6 +336,7 @@ testcase.dirCutWithoutChangingCurrent = function() {
*/ */
testcase.dirPasteWithContextMenu = function() { testcase.dirPasteWithContextMenu = function() {
var windowId; var windowId;
const destinationPath = RootPath.DOWNLOADS_PATH + '/destination';
testPromise( testPromise(
setupForDirectoryTreeContextMenuTest() setupForDirectoryTreeContextMenuTest()
.then(function(id) { .then(function(id) {
...@@ -345,7 +353,8 @@ testcase.dirPasteWithContextMenu = function() { ...@@ -345,7 +353,8 @@ testcase.dirPasteWithContextMenu = function() {
}) })
.then(function() { .then(function() {
return remoteCall.navigateWithDirectoryTree( return remoteCall.navigateWithDirectoryTree(
windowId, '/destination', 'My files/Downloads'); windowId, RootPath.DOWNLOADS_PATH + '/destination',
'My files/Downloads');
}) })
.then(function() { .then(function() {
// Confirm files before paste. // Confirm files before paste.
...@@ -368,17 +377,18 @@ testcase.dirPasteWithContextMenu = function() { ...@@ -368,17 +377,18 @@ testcase.dirPasteWithContextMenu = function() {
// Expand the directory tree. // Expand the directory tree.
return remoteCall.waitForElement( return remoteCall.waitForElement(
windowId, windowId,
'[full-path-for-testing="/destination"] .expand-icon'); `[full-path-for-testing="${destinationPath}"] .expand-icon`);
}) })
.then(function() { .then(function() {
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, 'fakeMouseClick', windowId,
['[full-path-for-testing="/destination"] .expand-icon']); [`[full-path-for-testing="${destinationPath}"] .expand-icon`]);
}) })
.then(function() { .then(function() {
// Confirm the copied directory is added to the directory tree. // Confirm the copied directory is added to the directory tree.
return remoteCall.waitForElement( return remoteCall.waitForElement(
windowId, '[full-path-for-testing="/destination/photos"]'); windowId,
`[full-path-for-testing="${destinationPath}/photos"]`);
})); }));
}; };
...@@ -388,13 +398,21 @@ testcase.dirPasteWithContextMenu = function() { ...@@ -388,13 +398,21 @@ testcase.dirPasteWithContextMenu = function() {
testcase.dirPasteWithoutChangingCurrent = function() { testcase.dirPasteWithoutChangingCurrent = function() {
var windowId; var windowId;
const destinationPath = RootPath.DOWNLOADS_PATH + '/destination'; const destinationPath = RootPath.DOWNLOADS_PATH + '/destination';
const downloadsQuery =
'#directory-tree [entry-label="My files"] [entry-label="Downloads"]';
testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) {
windowId = id; windowId = id;
return remoteCall.expandDownloadVolumeInDirectoryTree(windowId); return remoteCall.expandDirectoryTreeFor(windowId, downloadsQuery);
}).then(function() { }).then(function() {
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, 'fakeMouseClick', windowId,
[`[full-path-for-testing="${RootPath.DOWNLOADS_PATH}"] .expand-icon`]); [`${downloadsQuery} .expand-icon`]);
}).then((result) => {
chrome.test.assertTrue(result, 'click on expand icon failed');
return remoteCall.waitForElement(windowId, downloadsQuery + '[expanded]');
}).then(() => {
return remoteCall.callRemoteTestUtil(
'focus', windowId, ['#directory-tree']);
}).then(function(result) { }).then(function(result) {
return clickDirectoryTreeContextMenuItem( return clickDirectoryTreeContextMenuItem(
windowId, RootPath.DOWNLOADS_PATH + '/photos', 'copy'); windowId, RootPath.DOWNLOADS_PATH + '/photos', 'copy');
...@@ -452,7 +470,7 @@ testcase.dirRenameUpdateChildrenBreadcrumbs = function() { ...@@ -452,7 +470,7 @@ testcase.dirRenameUpdateChildrenBreadcrumbs = function() {
.then(function() { .then(function() {
// Rename parent folder. // Rename parent folder.
return clickDirectoryTreeContextMenuItem( return clickDirectoryTreeContextMenuItem(
appId, RootPath.DOWNLOADS_PATH +'/photos', 'rename') appId, RootPath.DOWNLOADS_PATH + '/photos', 'rename')
.then(function() { .then(function() {
return remoteCall.waitForElement(appId, '.tree-row > input'); return remoteCall.waitForElement(appId, '.tree-row > input');
}) })
...@@ -472,12 +490,18 @@ testcase.dirRenameUpdateChildrenBreadcrumbs = function() { ...@@ -472,12 +490,18 @@ testcase.dirRenameUpdateChildrenBreadcrumbs = function() {
}); });
}) })
.then(function() { .then(function() {
// Confirm that current directory is now /Downloads, because it // Confirm that current directory is now My files or /Downloads,
// can't find the previously selected folder // because it can't find the previously selected folder
// /Downloads/photos/child-folder, since its path/parent has been // /Downloads/photos/child-folder, since its path/parent has been
// renamed. // renamed.
let volumeFolder = '/My files/Downloads';
// TODO(lucmult): Remove this conditional once MyFilesVolume is
// rolled out.
if (RootPath.DOWNLOADS_PATH === '/Downloads')
volumeFolder = '/My files';
return remoteCall.waitUntilCurrentDirectoryIsChanged( return remoteCall.waitUntilCurrentDirectoryIsChanged(
appId, '/My files/Downloads'); appId, volumeFolder);
}) })
.then(function() { .then(function() {
// Navigate to child-folder using the new path. // Navigate to child-folder using the new path.
...@@ -504,7 +528,9 @@ testcase.dirRenameWithoutChangingCurrent = function() { ...@@ -504,7 +528,9 @@ testcase.dirRenameWithoutChangingCurrent = function() {
var windowId; var windowId;
testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) { testPromise(setupForDirectoryTreeContextMenuTest().then(function(id) {
windowId = id; windowId = id;
return remoteCall.expandDownloadVolumeInDirectoryTree(windowId); const downloadsQuery =
'#directory-tree [entry-label="My files"] [entry-label="Downloads"]';
return remoteCall.expandDirectoryTreeFor(windowId, downloadsQuery);
}).then(function() { }).then(function() {
return remoteCall.waitForElement( return remoteCall.waitForElement(
windowId, windowId,
......
...@@ -118,15 +118,16 @@ testcase.fileDisplayComputers = async function() { ...@@ -118,15 +118,16 @@ testcase.fileDisplayComputers = async function() {
null, RootPath.DRIVE, null, [], COMPUTERS_ENTRY_SET); null, RootPath.DRIVE, null, [], COMPUTERS_ENTRY_SET);
// Navigate to Comuter Grand Root. // Navigate to Comuter Grand Root.
await remoteCall.navigateWithDirectoryTree(appId, '/Computers', 'Computers'); await remoteCall.navigateWithDirectoryTree(
appId, '/Computers', 'Computers', 'drive');
// Navigiate to a Computer Root. // Navigiate to a Computer Root.
await remoteCall.navigateWithDirectoryTree( await remoteCall.navigateWithDirectoryTree(
appId, '/Computers/Computer A', 'Computers'); appId, '/Computers/Computer A', 'Computers', 'drive');
// Navigiate to a subdirectory under a Computer Root. // Navigiate to a subdirectory under a Computer Root.
await remoteCall.navigateWithDirectoryTree( await remoteCall.navigateWithDirectoryTree(
appId, '/Computers/Computer A/A', 'Computers'); appId, '/Computers/Computer A/A', 'Computers', 'drive');
}; };
......
...@@ -495,16 +495,24 @@ RemoteCallFilesApp.prototype.expandTreeItemInDirectoryTree = function( ...@@ -495,16 +495,24 @@ RemoteCallFilesApp.prototype.expandTreeItemInDirectoryTree = function(
'queryAllElements', windowId, [`${query}[expanded]`]); 'queryAllElements', windowId, [`${query}[expanded]`]);
}) })
.then(elements => { .then(elements => {
// If it's already expanded, do nothing. // If it's already expanded just set the focus on directory tree.
if (elements.length > 0) if (elements.length > 0) {
return; return this.callRemoteTestUtil(
'focus', windowId, ['#directory-tree']);
}
// Expand directory volume and set the focus to directory tree.
// Focus to directory tree. // Focus to directory tree.
return this.callRemoteTestUtil('focus', windowId, ['#directory-tree']) return this
.callRemoteTestUtil(
'fakeMouseClick', windowId, [`${query} .expand-icon`])
.then(() => {
// Wait for the expansion to finish.
return this.waitForElement(windowId, query + '[expanded]');
})
.then(() => { .then(() => {
// Expand directory volume. // Force the focus on directory tree.
return this.callRemoteTestUtil( return this.callRemoteTestUtil(
'fakeMouseClick', windowId, [`${query} .expand-icon`]); 'focus', windowId, ['#directory-tree']);
}); });
}); });
}; };
......
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