Commit d2317876 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[dragdrop] Add directory tree item drag drop .accepts class test

Tests that dragging a file over a directory tree item that can accept a
drop adds CSS class .accepts to that tree item.

Also: check that the drag hover causes the file-list to navigate to the
hovered tree item's directory.

Bug: 1002394
Change-Id: I4def2bfd5621b9043d615c0706cc273fc9eb16ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2275576
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784396}
parent 696386f2
......@@ -623,6 +623,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("transferBetweenTeamDrives").FilesNg(),
TestCase("transferDragDropActiveLeave"),
TestCase("transferDragDropActiveDrop"),
TestCase("transferDragDropTreeItemAccepts").FilesNg(),
TestCase("transferDragAndDrop"),
TestCase("transferDragAndHover"),
TestCase("transferFromDownloadsToDownloads"),
......
......@@ -589,6 +589,60 @@ testcase.transferDragDropActiveDrop = async () => {
await remoteCall.waitForElementLost(appId, htmlDragDropActive);
};
/**
* Tests that dragging a file over a directory tree item that can accept the
* drop changes the class of that tree item to 'accepts'.
*/
testcase.transferDragDropTreeItemAccepts = async () => {
const entries = [ENTRIES.hello, ENTRIES.photos];
// Open files app.
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, entries, []);
// The drag has to start in the file list column "name" text, otherwise it
// starts a drag-selection instead of a drag operation.
const source =
`#file-list li[file-name="${ENTRIES.photos.nameText}"] .entry-name`;
// Select the source file.
await remoteCall.waitAndClickElement(appId, source);
// Wait for the directory tree target.
const target = '#directory-tree [entry-label="My files"]';
await remoteCall.waitForElement(appId, target);
// Drag the source and hover it over the target.
const skipDrop = true;
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil(
'fakeDragAndDrop', appId, [source, target, skipDrop]),
'fakeDragAndDrop failed');
// Check: drag hovering should navigate the file list.
await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/My files');
// Check: the target should have accepts class.
const willAcceptDrop = '#directory-tree [entry-label="My files"].accepts';
await remoteCall.waitForElement(appId, willAcceptDrop);
// Check: the target should not have denies class.
const willDenyDrop = '#directory-tree [entry-label="My files"].denies';
await remoteCall.waitForElementLost(appId, willDenyDrop);
// Send a dragleave event to the target to end drag-drop operations.
const dragLeave = true;
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil(
'fakeDragLeaveOrDrop', appId, ['#file-list', target, dragLeave]),
'fakeDragLeaveOrDrop failed');
// Check: the target should not have accepts class.
await remoteCall.waitForElementLost(appId, willAcceptDrop);
// Check: the target should not have denies class.
await remoteCall.waitForElementLost(appId, willDenyDrop);
};
/**
* Tests that we can drag a file from #file-list to #directory-tree.
* It copies the file from Downloads to Downloads/photos.
......
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