[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: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659379}
diff --git a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js
index 8aa90ef..2a46822 100644
--- a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js
+++ b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js
@@ -2663,7 +2663,6 @@
     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());
diff --git a/ui/file_manager/file_manager/foreground/js/toolbar_controller.js b/ui/file_manager/file_manager/foreground/js/toolbar_controller.js
index 02b6a30..e514651 100644
--- a/ui/file_manager/file_manager/foreground/js/toolbar_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/toolbar_controller.js
@@ -135,8 +135,6 @@
   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());
diff --git a/ui/file_manager/file_manager/test/crostini_tasks.js b/ui/file_manager/file_manager/test/crostini_tasks.js
index a2f5bef..50b0bae 100644
--- a/ui/file_manager/file_manager/test/crostini_tasks.js
+++ b/ui/file_manager/file_manager/test/crostini_tasks.js
@@ -50,7 +50,7 @@
 
   // 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]));
 
diff --git a/ui/file_manager/file_manager/test/js/test_util.js b/ui/file_manager/file_manager/test/js/test_util.js
index 9328787..ba62bc7 100644
--- a/ui/file_manager/file_manager/test/js/test_util.js
+++ b/ui/file_manager/file_manager/test/js/test_util.js
@@ -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 @@
  * @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.ENTRIES.photos,
   test.ENTRIES.unsupported,
   test.ENTRIES.testDocument,
-  test.ENTRIES.testSharedDocument
+  test.ENTRIES.testSharedDocument,
 ];
 
 /**
@@ -333,11 +328,15 @@
   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 @@
   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.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');
+};
diff --git a/ui/file_manager/file_manager/test/plugin_vm.js b/ui/file_manager/file_manager/test/plugin_vm.js
index ef68d2d..1bb4c84 100644
--- a/ui/file_manager/file_manager/test/plugin_vm.js
+++ b/ui/file_manager/file_manager/test/plugin_vm.js
@@ -57,10 +57,7 @@
   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]));