Commit cfb4a862 authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Fix "Available Offline" not showing in the file context menu.

If the right click context menu has not been displayed at least once
then some commands are not available in the file select menu.

If the use is clicking through files, we will assume that the menu
context should be FILE_LIST temporarily so that the correct options
appear in the file selection menu.

Added integration test to validate.

Bug: 875466
Change-Id: Idc79f1c25690b6c8bb7f585e0c9261ea4bec3996
Reviewed-on: https://chromium-review.googlesource.com/c/1343812
Commit-Queue: Stuart Langley <slangley@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609919}
parent 4e494a8d
......@@ -477,7 +477,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
WRAPPED_INSTANTIATE_TEST_CASE_P(
DriveSpecific, /* drive_specific.js */
FilesAppBrowserTest,
::testing::Values(TestCase("driveOpenSidebarOffline").DisableDriveFs(),
::testing::Values(
TestCase("driveOpenSidebarOffline").DisableDriveFs(),
TestCase("driveOpenSidebarOffline").EnableDriveFs(),
TestCase("driveOpenSidebarSharedWithMe").DisableDriveFs(),
TestCase("driveOpenSidebarSharedWithMe").EnableDriveFs(),
......@@ -492,7 +493,9 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("drivePressCtrlAFromSearch").DisableDriveFs(),
TestCase("drivePressCtrlAFromSearch").EnableDriveFs(),
TestCase("driveBackupPhotos").DisableDriveFs(),
TestCase("driveBackupPhotos").EnableDriveFs()));
TestCase("driveBackupPhotos").EnableDriveFs(),
TestCase("driveAvailableOfflineGearMenu").DisableDriveFs(),
TestCase("driveAvailableOfflineGearMenu").EnableDriveFs()));
WRAPPED_INSTANTIATE_TEST_CASE_P(
Transfer, /* transfer.js */
......
......@@ -173,7 +173,16 @@ ActionsController.prototype.onSelectionChangeThrottled_ = function() {
if (selection !== this.selectionHandler_.selection)
return;
this.fileListActionsModel_ = actionsModel;
// Before updating the UI we need to ensure that this.menuContext_ has a
// reasonable value or nothing will happen. We will save and restore the
// existing value.
const oldMenuContext = this.menuContext_;
if (this.menuContext_ === ActionsController.Context.UNKNOWN) {
// FILE_LIST should be a reasonable default.
this.menuContext_ = ActionsController.Context.FILE_LIST;
}
this.updateUI_();
this.menuContext_ = oldMenuContext;
}.bind(this));
}.bind(this));
......
......@@ -677,3 +677,54 @@ testcase.driveRecoverDirtyFiles = function() {
},
]);
};
/**
* Verify that "Available Offline" is available from the gear menu for a drive
* file before the context menu has been opened.
*/
testcase.driveAvailableOfflineGearMenu = function() {
const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' +
'cr-menu-item[command="#toggle-pinned"]:not([disabled])';
let appId;
let steps = [
function() {
setupAndWaitUntilReady(null, RootPath.DRIVE, this.next, []);
},
// Select a file in drive.
function(result) {
appId = result.windowId;
remoteCall.callRemoteTestUtil(
'selectFile', appId, ['hello.txt'], this.next);
},
// Wait for the entry to be selected.
function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed');
remoteCall.waitForElement(appId, '.table-row[selected]').then(this.next);
},
// Click on the icon of the file to check select it
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId,
['#file-list .table-row[selected] .detail-checkmark'], this.next);
},
// Ensure gear button is available
function(result) {
remoteCall.waitForElement(appId, '#selection-menu-button')
.then(this.next);
},
// Cick on gear menu and ensure "Avaialble Offline" is shown.
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#selection-menu-button'], this.next);
},
// Check that "Available Offline" is shown in the menu/
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, pinnedMenuQuery).then(this.next);
},
function(result) {
checkIfNoErrorsOccured(this.next);
}
];
StepsRunner.run(steps);
};
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