Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7541)

Unified Diff: chrome/browser/ui/browser_unittest.cc

Issue 1877373003: Disable zoom-in and zoom-out buttons in toolbar menu for a crashed page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/views/toolbar/app_menu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_unittest.cc
diff --git a/chrome/browser/ui/browser_unittest.cc b/chrome/browser/ui/browser_unittest.cc
index e8d6bd56b7099458528590b8d154ceec18034162..dce7320fe62ef92e17beddb926a01602e0d07434 100644
--- a/chrome/browser/ui/browser_unittest.cc
+++ b/chrome/browser/ui/browser_unittest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/browser_with_test_window_test.h"
+#include "components/ui/zoom/zoom_controller.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
@@ -87,6 +88,37 @@ TEST_F(BrowserUnitTest, DisablePrintOnCrashedTab) {
EXPECT_FALSE(chrome::CanPrint(browser()));
}
+// Ensure the zoom-in and zoom-out commands get disabled when a tab crashes.
+TEST_F(BrowserUnitTest, DisableZoomOnCrashedTab) {
+ TabStripModel* tab_strip_model = browser()->tab_strip_model();
+
+ WebContents* contents = CreateTestWebContents();
+ tab_strip_model->AppendWebContents(contents, true);
+ WebContentsTester::For(contents)->NavigateAndCommit(GURL("about:blank"));
+ ui_zoom::ZoomController* zoom_controller =
+ ui_zoom::ZoomController::FromWebContents(contents);
+ EXPECT_TRUE(zoom_controller->SetZoomLevel(zoom_controller->
+ GetDefaultZoomLevel()));
+
+ CommandUpdater* command_updater =
+ browser()->command_controller()->command_updater();
+
+ EXPECT_TRUE(zoom_controller->IsAtDefaultZoom());
+ EXPECT_FALSE(contents->IsCrashed());
+ EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ZOOM_PLUS));
+ EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ZOOM_MINUS));
+ EXPECT_TRUE(chrome::CanZoomIn(contents));
+ EXPECT_TRUE(chrome::CanZoomOut(contents));
+
+ contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
+
+ EXPECT_TRUE(contents->IsCrashed());
+ EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_ZOOM_PLUS));
+ EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_ZOOM_MINUS));
+ EXPECT_FALSE(chrome::CanZoomIn(contents));
+ EXPECT_FALSE(chrome::CanZoomOut(contents));
+}
+
class BrowserBookmarkBarTest : public BrowserWithTestWindowTest {
public:
BrowserBookmarkBarTest() {}
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/views/toolbar/app_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698