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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/browser_command_controller.h" 9 #include "chrome/browser/ui/browser_command_controller.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/browser_with_test_window_test.h" 12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "components/ui/zoom/zoom_controller.h"
13 #include "content/public/browser/site_instance.h" 14 #include "content/public/browser/site_instance.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/web_contents_tester.h" 16 #include "content/public/test/web_contents_tester.h"
16 17
17 using content::SiteInstance; 18 using content::SiteInstance;
18 using content::WebContents; 19 using content::WebContents;
19 using content::WebContentsTester; 20 using content::WebContentsTester;
20 21
21 class BrowserUnitTest : public BrowserWithTestWindowTest { 22 class BrowserUnitTest : public BrowserWithTestWindowTest {
22 public: 23 public:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); 81 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT));
81 EXPECT_TRUE(chrome::CanPrint(browser())); 82 EXPECT_TRUE(chrome::CanPrint(browser()));
82 83
83 contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 84 contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
84 85
85 EXPECT_TRUE(contents->IsCrashed()); 86 EXPECT_TRUE(contents->IsCrashed());
86 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_PRINT)); 87 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_PRINT));
87 EXPECT_FALSE(chrome::CanPrint(browser())); 88 EXPECT_FALSE(chrome::CanPrint(browser()));
88 } 89 }
89 90
91 // Ensure the zoom-in and zoom-out commands get disabled when a tab crashes.
92 TEST_F(BrowserUnitTest, DisableZoomOnCrashedTab) {
93 TabStripModel* tab_strip_model = browser()->tab_strip_model();
94
95 WebContents* contents = CreateTestWebContents();
96 tab_strip_model->AppendWebContents(contents, true);
97 WebContentsTester::For(contents)->NavigateAndCommit(GURL("about:blank"));
98 ui_zoom::ZoomController* zoom_controller =
99 ui_zoom::ZoomController::FromWebContents(contents);
100 EXPECT_TRUE(zoom_controller->SetZoomLevel(zoom_controller->
101 GetDefaultZoomLevel()));
102
103 CommandUpdater* command_updater =
104 browser()->command_controller()->command_updater();
105
106 EXPECT_TRUE(zoom_controller->IsAtDefaultZoom());
107 EXPECT_FALSE(contents->IsCrashed());
108 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ZOOM_PLUS));
109 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ZOOM_MINUS));
110 EXPECT_TRUE(chrome::CanZoomIn(contents));
111 EXPECT_TRUE(chrome::CanZoomOut(contents));
112
113 contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
114
115 EXPECT_TRUE(contents->IsCrashed());
116 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_ZOOM_PLUS));
117 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_ZOOM_MINUS));
118 EXPECT_FALSE(chrome::CanZoomIn(contents));
119 EXPECT_FALSE(chrome::CanZoomOut(contents));
120 }
121
90 class BrowserBookmarkBarTest : public BrowserWithTestWindowTest { 122 class BrowserBookmarkBarTest : public BrowserWithTestWindowTest {
91 public: 123 public:
92 BrowserBookmarkBarTest() {} 124 BrowserBookmarkBarTest() {}
93 ~BrowserBookmarkBarTest() override {} 125 ~BrowserBookmarkBarTest() override {}
94 126
95 protected: 127 protected:
96 BookmarkBar::State window_bookmark_bar_state() const { 128 BookmarkBar::State window_bookmark_bar_state() const {
97 return static_cast<BookmarkBarStateTestBrowserWindow*>( 129 return static_cast<BookmarkBarStateTestBrowserWindow*>(
98 browser()->window())->bookmark_bar_state(); 130 browser()->window())->bookmark_bar_state();
99 } 131 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Activate the 1st tab which is NTP. 218 // Activate the 1st tab which is NTP.
187 browser()->tab_strip_model()->ActivateTabAt(0, true); 219 browser()->tab_strip_model()->ActivateTabAt(0, true);
188 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 220 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
189 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); 221 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state());
190 222
191 // Activate the 2nd tab which is non-NTP. 223 // Activate the 2nd tab which is non-NTP.
192 browser()->tab_strip_model()->ActivateTabAt(1, true); 224 browser()->tab_strip_model()->ActivateTabAt(1, true);
193 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 225 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
194 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); 226 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state());
195 } 227 }
OLDNEW
« 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