Commit 02f925b2 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

[Files app] UI test refactor the file list refresh logic

Change the UI tests to use keyboard shortcut instead of refresh button
to refresh the file list, because the button can be disabled since
CL:1608962.

Remove some debugging logs that aren't needed anymore.

Format some lines in test_util.js.

Bug: 961244
Change-Id: I92d6feef37278ea16dd0396c3e08550a57491c52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610662
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659379}
parent 78e2216a
......@@ -2663,7 +2663,6 @@ CommandHandler.COMMANDS_['refresh'] = /** @type {Command} */ ({
const volumeInfo = currentDirEntry &&
fileManager.volumeManager.getVolumeInfo(currentDirEntry);
event.canExecute = volumeInfo && !volumeInfo.watchable;
console.log('****** refresh command canExecute: ' + event.canExecute);
event.command.setHidden(
!event.canExecute ||
fileManager.directoryModel.getFileListSelection().getCheckSelectMode());
......
......@@ -135,8 +135,6 @@ class ToolbarController {
updateCurrentDirectoryButtons_() {
const volumeInfo = this.directoryModel_.getCurrentVolumeInfo();
this.refreshCommand_.disabled = !!volumeInfo && volumeInfo.watchable;
console.log(
'****** toolbar controller.disabled: ' + this.refreshCommand_.disabled);
this.refreshCommand_.setHidden(
volumeInfo && volumeInfo.watchable ||
this.directoryModel_.getFileListSelection().getCheckSelectMode());
......
......@@ -50,7 +50,7 @@ crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => {
// Add '/A', and '/A/hello.txt', refresh, 'A' is shown.
test.addEntries([test.ENTRIES.directoryA, test.ENTRIES.helloInA], [], []);
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
test.refreshFileList();
await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
[test.ENTRIES.directoryA, test.ENTRIES.linuxFiles]));
......
......@@ -8,7 +8,8 @@
var test = test || {};
// Update paths for testing.
constants.FILES_QUICK_VIEW_HTML = 'test/gen/foreground/elements/files_quick_view.html';
constants.FILES_QUICK_VIEW_HTML =
'test/gen/foreground/elements/files_quick_view.html';
constants.DRIVE_WELCOME_CSS = FILE_MANAGER_ROOT + constants.DRIVE_WELCOME_CSS;
test.FILE_MANAGER_EXTENSION_ID = 'hhaomjibdihmijegdhdafkllkbggdgoj';
......@@ -78,15 +79,9 @@ test.SharedOption = {
* @param {string} typeText Type name to be shown in the type column.
* @constructor
*/
test.TestEntryInfo = function(type,
sourceFileName,
targetPath,
mimeType,
sharedOption,
lastModifiedTime,
nameText,
sizeText,
typeText) {
test.TestEntryInfo = function(
type, sourceFileName, targetPath, mimeType, sharedOption, lastModifiedTime,
nameText, sizeText, typeText) {
this.type = type;
this.sourceFileName = sourceFileName || '';
this.targetPath = targetPath;
......@@ -284,7 +279,7 @@ test.BASIC_DRIVE_ENTRY_SET = [
test.ENTRIES.photos,
test.ENTRIES.unsupported,
test.ENTRIES.testDocument,
test.ENTRIES.testSharedDocument
test.ENTRIES.testSharedDocument,
];
/**
......@@ -333,11 +328,15 @@ test.pending = function(message, var_args) {
var args = arguments;
var formattedMessage = message.replace(/%[sdj]/g, function(pattern) {
var arg = args[index++];
switch(pattern) {
case '%s': return String(arg);
case '%d': return Number(arg);
case '%j': return JSON.stringify(arg);
default: return pattern;
switch (pattern) {
case '%s':
return String(arg);
case '%d':
return Number(arg);
case '%j':
return JSON.stringify(arg);
default:
return pattern;
}
});
var pendingMarker = Object.create(test.pending.prototype);
......@@ -572,7 +571,7 @@ test.setupAndWaitUntilReady =
if (!myFiles.parentElement.hasAttribute('selected')) {
assertTrue(test.fakeMouseClick(myFilesElement), 'click MyFiles');
}
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
test.refreshFileList();
const filesShown = entriesMyFiles.concat([test.ENTRIES.linuxFiles]);
return test.waitForFiles(test.TestEntryInfo.getExpectedRows(filesShown));
};
......@@ -584,3 +583,13 @@ test.setupAndWaitUntilReady =
test.done = function(opt_failed) {
window.endTests(!opt_failed);
};
/**
* Forces current directory to rescan the entries, which refreshes the file
* list.
*/
test.refreshFileList = function() {
assertTrue(
test.fakeKeyDown('#file-list', 'b', true, false, false),
'refresh file list failed');
};
......@@ -57,10 +57,7 @@ pluginVm.testLabelIconContextMenu = async (done) => {
await test.setupAndWaitUntilReady([], [], []);
test.addEntries(
[test.ENTRIES.pluginVm, test.ENTRIES.photosInPluginVm], [], []);
console.log('**** refreshing file list...');
assertTrue(
test.fakeKeyDown('#file-list', 'b', true, false, false),
'refresh file list');
test.refreshFileList();
await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
[test.ENTRIES.pluginVm, test.ENTRIES.linuxFiles]));
......
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