Commit 1411c303 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Select "My Drive" when selecting "Google Drive" with the keyboard.

Bug: 825779
Change-Id: I19fb082887c3383ba6e5d4db43cc20bfab7c999c
Reviewed-on: https://chromium-review.googlesource.com/c/1345376Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609910}
parent 41c36e31
......@@ -317,6 +317,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("keyboardCopyDownloads"),
TestCase("keyboardCopyDrive").DisableDriveFs(),
TestCase("keyboardCopyDrive").EnableDriveFs(),
TestCase("keyboardSelectDriveDirectoryTree"),
TestCase("renameFileDownloads").InGuestMode(),
TestCase("renameFileDownloads"),
TestCase("renameFileDrive").DisableDriveFs(),
......
......@@ -1083,13 +1083,7 @@ DriveVolumeItem.prototype = {
DriveVolumeItem.prototype.handleClick = function(e) {
VolumeItem.prototype.handleClick.call(this, e);
if (!e.target.classList.contains('expand-icon')) {
// If the Drive volume is clicked, select one of the children instead of
// this item itself.
this.volumeInfo_.resolveDisplayRoot((displayRoot) => {
this.searchAndSelectByEntry(displayRoot);
});
}
this.selectDisplayRoot_();
DirectoryItemTreeBaseMethods.recordUMASelectedEntry.call(
this, e, VolumeManagerCommon.RootType.DRIVE_FAKE_ROOT, true);
......@@ -1231,6 +1225,27 @@ DriveVolumeItem.prototype.createComputersGrandRoot_ = function() {
});
};
/**
* Change current entry to the entry corresponding to My Drive.
*/
DriveVolumeItem.prototype.activate = function() {
VolumeItem.prototype.activate.call(this);
this.selectDisplayRoot_();
};
/**
* Select Drive's display root.
*/
DriveVolumeItem.prototype.selectDisplayRoot_ = function() {
if (!this.classList.contains('expand-icon')) {
// If the Drive volume is clicked, select one of the children instead of
// this item itself.
this.volumeInfo_.resolveDisplayRoot((displayRoot) => {
this.searchAndSelectByEntry(displayRoot);
});
}
};
/**
* Retrieves the latest subdirectories and update them on the tree.
* @param {boolean} recursive True if the update is recursively.
......
......@@ -348,3 +348,60 @@ testcase.renameNewFolderDownloads = function() {
testcase.renameNewFolderDrive = function() {
testPromise(testRenameFolder(RootPath.DRIVE, TREEITEM_DRIVE));
};
/**
* Test that selecting "Google Drive" in the directory tree with the keyboard
* expands it and selects "My Drive".
*/
testcase.keyboardSelectDriveDirectoryTree = function() {
let appId = null;
StepsRunner.run([
// Open Files app.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.world],
[ENTRIES.hello]);
},
// Focus the directory tree.
function(result) {
appId = result.windowId;
remoteCall.callRemoteTestUtil('focus', appId, ['#directory-tree'])
.then(this.next);
},
// Select Google Drive in the directory tree; it's the last item.
function() {
return remoteCall
.fakeKeyDown(appId, '#directory-tree', 'End', false, false, false)
.then(this.next);
},
// Ensure it's selected.
function() {
remoteCall.waitForElement(appId, ['.drive-volume [selected]'])
.then(this.next);
},
// Activate it.
function() {
return remoteCall
.fakeKeyDown(
appId, '#directory-tree .drive-volume', 'Enter', false, false,
false)
.then(this.next);
},
// It should have expanded.
function() {
remoteCall
.waitForElement(appId, ['.drive-volume .tree-children[expanded]'])
.then(this.next);
},
// My Drive should be selected.
function() {
remoteCall
.waitForElement(appId, ['[full-path-for-testing="/root"] [selected]'])
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
};
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