From ad1b834583e75bcf2e0d9a727479f1f1603067ce Mon Sep 17 00:00:00 2001 From: yawano Date: Thu, 2 Jul 2015 19:33:45 -0700 Subject: [PATCH] Run canExecute before executing delete command. Previously canExecute is not explicitly called when delete button in the toolbar is clicked. This CL changes it to call the method to update the avalability of delete command properly. BUG=506472 TEST=browser_tests:Delete/FileManagerBrowserTest.Test/1 Review URL: https://codereview.chromium.org/1211083005 Cr-Commit-Position: refs/heads/master@{#337274} --- .../file_manager/file_manager_browsertest.cc | 3 +- .../foreground/js/toolbar_controller.js | 1 + .../integration_tests/file_manager/delete.js | 48 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc index 134dc3e6dae9..588d5d91e627 100644 --- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc @@ -161,7 +161,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( FileManagerBrowserTest, ::testing::Values( TestParameter(NOT_IN_GUEST_MODE, - "deleteMenuItemIsDisabledWhenNoItemIsSelected"))); + "deleteMenuItemIsDisabledWhenNoItemIsSelected"), + TestParameter(NOT_IN_GUEST_MODE, "deleteOneItemFromToolbar"))); // Fails on official build. http://crbug.com/429294 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD) 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 97cac5f5faac..2f2ddb18ebcf 100644 --- a/ui/file_manager/file_manager/foreground/js/toolbar_controller.js +++ b/ui/file_manager/file_manager/foreground/js/toolbar_controller.js @@ -170,6 +170,7 @@ ToolbarController.prototype.onCancelSelectionButtonClicked_ = function() { */ ToolbarController.prototype.onDeleteButtonClicked_ = function() { this.deleteButton_.blur(); + this.deleteCommand_.canExecuteChange(this.listContainer_.currentList); this.deleteCommand_.execute(this.listContainer_.currentList); } diff --git a/ui/file_manager/integration_tests/file_manager/delete.js b/ui/file_manager/integration_tests/file_manager/delete.js index 685ec1897787..7acc779339f1 100644 --- a/ui/file_manager/integration_tests/file_manager/delete.js +++ b/ui/file_manager/integration_tests/file_manager/delete.js @@ -24,3 +24,51 @@ testcase.deleteMenuItemIsDisabledWhenNoItemIsSelected = function() { }); })); }; + +// Delete one entry from toolbar. +testcase.deleteOneItemFromToolbar = function() { + var beforeDeletion = TestEntryInfo.getExpectedRows([ + ENTRIES.photos, + ENTRIES.hello, + ENTRIES.world, + ENTRIES.desktop, + ENTRIES.beautiful + ]); + + var afterDeletion = TestEntryInfo.getExpectedRows([ + ENTRIES.photos, + ENTRIES.hello, + ENTRIES.world, + ENTRIES.beautiful + ]); + + testPromise(setupAndWaitUntilReady(null, RootPath.DOWNALOD).then( + function(windowId) { + // Confirm entries in the directory before the deletion. + return remoteCall.waitForFiles(windowId, beforeDeletion + ).then(function() { + // Select My Desktop Background.png + return remoteCall.callRemoteTestUtil( + 'selectFile', windowId, ['My Desktop Background.png']); + }).then(function(result) { + chrome.test.assertTrue(result); + + // Click delete button in the toolbar. + return remoteCall.callRemoteTestUtil( + 'fakeMouseClick', windowId, ['button#delete-button']); + }).then(function(result) { + chrome.test.assertTrue(result); + + // Confirm that the confirmation dialog is shown. + return remoteCall.waitForElement( + windowId, '.cr-dialog-container.shown'); + }).then(function() { + // Press delete button. + return remoteCall.callRemoteTestUtil( + 'fakeMouseClick', windowId, ['button.cr-dialog-ok']); + }).then(function() { + // Confirm the file is removed. + return remoteCall.waitForFiles(windowId, afterDeletion); + }); + })); +}; -- 2.11.4.GIT