Commit 9de4dc8e authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Only open quickview if exactly 1 file is selected.

Always invoke preventDefault() to avoid the default page-down from
triggering.

Bug: 750403
Change-Id: I7b8779a8bd51757192c9c1534f25d9d574ca5cc5
Reviewed-on: https://chromium-review.googlesource.com/c/1348878
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610523}
parent 4cdf84ed
...@@ -446,7 +446,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -446,7 +446,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("openQuickViewUsb"), TestCase("openQuickViewUsb"),
TestCase("openQuickViewMtp"), TestCase("openQuickViewMtp"),
TestCase("pressEnterOnInfoBoxToOpenClose"), TestCase("pressEnterOnInfoBoxToOpenClose"),
TestCase("closeQuickView"))); TestCase("closeQuickView"),
TestCase("cantOpenQuickViewWithMultipleFiles")));
WRAPPED_INSTANTIATE_TEST_CASE_P( WRAPPED_INSTANTIATE_TEST_CASE_P(
DirectoryTreeContextMenu, /* directory_tree_context_menu.js */ DirectoryTreeContextMenu, /* directory_tree_context_menu.js */
......
...@@ -201,10 +201,11 @@ QuickViewController.prototype.onOpenInNewButtonTap_ = function(event) { ...@@ -201,10 +201,11 @@ QuickViewController.prototype.onOpenInNewButtonTap_ = function(event) {
* @private * @private
*/ */
QuickViewController.prototype.onKeyDownToOpen_ = function(event) { QuickViewController.prototype.onKeyDownToOpen_ = function(event) {
if (this.entries_.length == 0)
return;
if (event.key === ' ') { if (event.key === ' ') {
event.preventDefault(); event.preventDefault();
if (this.entries_.length != 1) {
return;
}
event.stopImmediatePropagation(); event.stopImmediatePropagation();
this.display_(QuickViewUma.WayToOpen.SPACE_KEY); this.display_(QuickViewUma.WayToOpen.SPACE_KEY);
} }
......
...@@ -957,3 +957,55 @@ testcase.pressEnterOnInfoBoxToOpenClose = function() { ...@@ -957,3 +957,55 @@ testcase.pressEnterOnInfoBoxToOpenClose = function() {
}, },
]); ]);
}; };
/**
* Tests that Quick View doesn't open with multiple files selected.
*/
testcase.cantOpenQuickViewWithMultipleFiles = function() {
let appId;
StepsRunner.run([
// Open Files app on Downloads containing ENTRIES.hello and ENTRIES.world.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.hello, ENTRIES.world],
[]);
},
// Select all 2 files.
function(results) {
appId = results.windowId;
const ctrlA = ['#file-list', 'a', true, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlA, this.next);
},
// Wait for the files to be selected.
function() {
remoteCall
.waitForElement(
appId,
'#cancel-selection-button-wrapper:not([hidden]):not([disabled])')
.then(this.next);
},
// Attempt to open Quick View via its keyboard shortcut.
function() {
const space = ['#file-list', ' ', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space, this.next);
},
// Wait for it to possibly open.
function() {
window.setTimeout(this.next, 500);
},
// Check Quick View hasn't opened.
function() {
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId, [['#quick-view', '#dialog[open]']])
.then(this.next);
},
function(result) {
chrome.test.assertEq([], result);
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