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} */ ({ ...@@ -2663,7 +2663,6 @@ CommandHandler.COMMANDS_['refresh'] = /** @type {Command} */ ({
const volumeInfo = currentDirEntry && const volumeInfo = currentDirEntry &&
fileManager.volumeManager.getVolumeInfo(currentDirEntry); fileManager.volumeManager.getVolumeInfo(currentDirEntry);
event.canExecute = volumeInfo && !volumeInfo.watchable; event.canExecute = volumeInfo && !volumeInfo.watchable;
console.log('****** refresh command canExecute: ' + event.canExecute);
event.command.setHidden( event.command.setHidden(
!event.canExecute || !event.canExecute ||
fileManager.directoryModel.getFileListSelection().getCheckSelectMode()); fileManager.directoryModel.getFileListSelection().getCheckSelectMode());
......
...@@ -135,8 +135,6 @@ class ToolbarController { ...@@ -135,8 +135,6 @@ class ToolbarController {
updateCurrentDirectoryButtons_() { updateCurrentDirectoryButtons_() {
const volumeInfo = this.directoryModel_.getCurrentVolumeInfo(); const volumeInfo = this.directoryModel_.getCurrentVolumeInfo();
this.refreshCommand_.disabled = !!volumeInfo && volumeInfo.watchable; this.refreshCommand_.disabled = !!volumeInfo && volumeInfo.watchable;
console.log(
'****** toolbar controller.disabled: ' + this.refreshCommand_.disabled);
this.refreshCommand_.setHidden( this.refreshCommand_.setHidden(
volumeInfo && volumeInfo.watchable || volumeInfo && volumeInfo.watchable ||
this.directoryModel_.getFileListSelection().getCheckSelectMode()); this.directoryModel_.getFileListSelection().getCheckSelectMode());
......
...@@ -50,7 +50,7 @@ crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => { ...@@ -50,7 +50,7 @@ crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => {
// Add '/A', and '/A/hello.txt', refresh, 'A' is shown. // Add '/A', and '/A/hello.txt', refresh, 'A' is shown.
test.addEntries([test.ENTRIES.directoryA, test.ENTRIES.helloInA], [], []); test.addEntries([test.ENTRIES.directoryA, test.ENTRIES.helloInA], [], []);
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh'); test.refreshFileList();
await test.waitForFiles(test.TestEntryInfo.getExpectedRows( await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
[test.ENTRIES.directoryA, test.ENTRIES.linuxFiles])); [test.ENTRIES.directoryA, test.ENTRIES.linuxFiles]));
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
var test = test || {}; var test = test || {};
// Update paths for testing. // 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; constants.DRIVE_WELCOME_CSS = FILE_MANAGER_ROOT + constants.DRIVE_WELCOME_CSS;
test.FILE_MANAGER_EXTENSION_ID = 'hhaomjibdihmijegdhdafkllkbggdgoj'; test.FILE_MANAGER_EXTENSION_ID = 'hhaomjibdihmijegdhdafkllkbggdgoj';
...@@ -78,15 +79,9 @@ test.SharedOption = { ...@@ -78,15 +79,9 @@ test.SharedOption = {
* @param {string} typeText Type name to be shown in the type column. * @param {string} typeText Type name to be shown in the type column.
* @constructor * @constructor
*/ */
test.TestEntryInfo = function(type, test.TestEntryInfo = function(
sourceFileName, type, sourceFileName, targetPath, mimeType, sharedOption, lastModifiedTime,
targetPath, nameText, sizeText, typeText) {
mimeType,
sharedOption,
lastModifiedTime,
nameText,
sizeText,
typeText) {
this.type = type; this.type = type;
this.sourceFileName = sourceFileName || ''; this.sourceFileName = sourceFileName || '';
this.targetPath = targetPath; this.targetPath = targetPath;
...@@ -284,7 +279,7 @@ test.BASIC_DRIVE_ENTRY_SET = [ ...@@ -284,7 +279,7 @@ test.BASIC_DRIVE_ENTRY_SET = [
test.ENTRIES.photos, test.ENTRIES.photos,
test.ENTRIES.unsupported, test.ENTRIES.unsupported,
test.ENTRIES.testDocument, test.ENTRIES.testDocument,
test.ENTRIES.testSharedDocument test.ENTRIES.testSharedDocument,
]; ];
/** /**
...@@ -333,11 +328,15 @@ test.pending = function(message, var_args) { ...@@ -333,11 +328,15 @@ test.pending = function(message, var_args) {
var args = arguments; var args = arguments;
var formattedMessage = message.replace(/%[sdj]/g, function(pattern) { var formattedMessage = message.replace(/%[sdj]/g, function(pattern) {
var arg = args[index++]; var arg = args[index++];
switch(pattern) { switch (pattern) {
case '%s': return String(arg); case '%s':
case '%d': return Number(arg); return String(arg);
case '%j': return JSON.stringify(arg); case '%d':
default: return pattern; return Number(arg);
case '%j':
return JSON.stringify(arg);
default:
return pattern;
} }
}); });
var pendingMarker = Object.create(test.pending.prototype); var pendingMarker = Object.create(test.pending.prototype);
...@@ -572,7 +571,7 @@ test.setupAndWaitUntilReady = ...@@ -572,7 +571,7 @@ test.setupAndWaitUntilReady =
if (!myFiles.parentElement.hasAttribute('selected')) { if (!myFiles.parentElement.hasAttribute('selected')) {
assertTrue(test.fakeMouseClick(myFilesElement), 'click MyFiles'); assertTrue(test.fakeMouseClick(myFilesElement), 'click MyFiles');
} }
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh'); test.refreshFileList();
const filesShown = entriesMyFiles.concat([test.ENTRIES.linuxFiles]); const filesShown = entriesMyFiles.concat([test.ENTRIES.linuxFiles]);
return test.waitForFiles(test.TestEntryInfo.getExpectedRows(filesShown)); return test.waitForFiles(test.TestEntryInfo.getExpectedRows(filesShown));
}; };
...@@ -584,3 +583,13 @@ test.setupAndWaitUntilReady = ...@@ -584,3 +583,13 @@ test.setupAndWaitUntilReady =
test.done = function(opt_failed) { test.done = function(opt_failed) {
window.endTests(!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) => { ...@@ -57,10 +57,7 @@ pluginVm.testLabelIconContextMenu = async (done) => {
await test.setupAndWaitUntilReady([], [], []); await test.setupAndWaitUntilReady([], [], []);
test.addEntries( test.addEntries(
[test.ENTRIES.pluginVm, test.ENTRIES.photosInPluginVm], [], []); [test.ENTRIES.pluginVm, test.ENTRIES.photosInPluginVm], [], []);
console.log('**** refreshing file list...'); test.refreshFileList();
assertTrue(
test.fakeKeyDown('#file-list', 'b', true, false, false),
'refresh file list');
await test.waitForFiles(test.TestEntryInfo.getExpectedRows( await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
[test.ENTRIES.pluginVm, test.ENTRIES.linuxFiles])); [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