OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app/chrome_command_ids.h" | 5 #include "chrome/app/chrome_command_ids.h" |
6 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 6 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
7 #include "chrome/browser/ui/browser_command_controller.h" | 7 #include "chrome/browser/ui/browser_command_controller.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0); | 286 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0); |
287 | 287 |
288 // Change the zoom percentage to 100. | 288 // Change the zoom percentage to 100. |
289 ui_zoom::PageZoom::Zoom(first_tab, content::PAGE_ZOOM_RESET); | 289 ui_zoom::PageZoom::Zoom(first_tab, content::PAGE_ZOOM_RESET); |
290 | 290 |
291 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab); | 291 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab); |
292 EXPECT_FLOAT_EQ(100.0f, zoom_controller->GetZoomPercent()); | 292 EXPECT_FLOAT_EQ(100.0f, zoom_controller->GetZoomPercent()); |
293 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); | 293 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); |
294 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); | 294 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); |
295 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); | 295 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); |
| 296 |
| 297 // Changing the page scale factor will re-enable IDC_ZOOM_NORMAL |
| 298 zoom_controller->SetPageScaleFactorIsOneForTesting(false); |
| 299 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); |
296 } | 300 } |
297 | 301 |
298 TEST_F(BrowserCommandsTest, OnZoomLevelChanged) { | 302 TEST_F(BrowserCommandsTest, OnZoomLevelChanged) { |
299 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 303 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
300 | 304 |
301 GURL url("http://www.google.com"); | 305 GURL url("http://www.google.com"); |
302 AddTab(browser(), url); | 306 AddTab(browser(), url); |
303 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0); | 307 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0); |
304 | 308 |
305 // Changing zoom percentage from default should enable all the zoom | 309 // Changing zoom percentage from default should enable all the zoom |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // Change the zoom level. | 368 // Change the zoom level. |
365 ui_zoom::PageZoom::Zoom(tab, content::PAGE_ZOOM_IN); | 369 ui_zoom::PageZoom::Zoom(tab, content::PAGE_ZOOM_IN); |
366 | 370 |
367 EXPECT_FLOAT_EQ(150.0f, zoom_controller->GetZoomPercent()); | 371 EXPECT_FLOAT_EQ(150.0f, zoom_controller->GetZoomPercent()); |
368 | 372 |
369 // Tab no longer at default zoom hence actual size should be enabled. | 373 // Tab no longer at default zoom hence actual size should be enabled. |
370 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); | 374 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); |
371 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); | 375 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); |
372 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); | 376 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); |
373 } | 377 } |
OLD | NEW |