| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 GURL url("http://www.google.com"); | 282 GURL url("http://www.google.com"); |
| 283 AddTab(browser(), url); | 283 AddTab(browser(), url); |
| 284 content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0); | 284 content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0); |
| 285 | 285 |
| 286 // Change the zoom percentage to 100. | 286 // Change the zoom percentage to 100. |
| 287 ui_zoom::PageZoom::Zoom(contents1, content::PAGE_ZOOM_RESET); | 287 ui_zoom::PageZoom::Zoom(contents1, content::PAGE_ZOOM_RESET); |
| 288 | 288 |
| 289 ZoomController* zoom_controller = ZoomController::FromWebContents(contents1); | 289 ZoomController* zoom_controller = ZoomController::FromWebContents(contents1); |
| 290 EXPECT_EQ(zoom_controller->GetZoomPercent(), 100.0f); | 290 EXPECT_EQ(zoom_controller->GetZoomPercent(), 100.0f); |
| 291 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); | 291 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); |
| 292 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); | 292 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); |
| 293 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); | 293 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); |
| 294 } | 294 } |
| 295 | 295 |
| 296 TEST_F(BrowserCommandsTest, OnZoomLevelChanged) { | 296 TEST_F(BrowserCommandsTest, OnZoomLevelChanged) { |
| 297 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 297 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
| 298 | 298 |
| 299 GURL url("http://www.google.com"); | 299 GURL url("http://www.google.com"); |
| 300 AddTab(browser(), url); | 300 AddTab(browser(), url); |
| 301 content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0); | 301 content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0); |
| 302 | 302 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 318 GURL url1("http://code.google.com"); | 318 GURL url1("http://code.google.com"); |
| 319 | 319 |
| 320 // Add First tab. | 320 // Add First tab. |
| 321 AddTab(browser(), url); | 321 AddTab(browser(), url); |
| 322 AddTab(browser(), url1); | 322 AddTab(browser(), url1); |
| 323 content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0); | 323 content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0); |
| 324 | 324 |
| 325 ZoomController* zoom_controller = ZoomController::FromWebContents(contents1); | 325 ZoomController* zoom_controller = ZoomController::FromWebContents(contents1); |
| 326 EXPECT_EQ(zoom_controller->GetZoomPercent(), 100.0f); | 326 EXPECT_EQ(zoom_controller->GetZoomPercent(), 100.0f); |
| 327 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); | 327 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); |
| 328 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); | 328 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); |
| 329 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); | 329 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); |
| 330 | 330 |
| 331 // Add Second tab. | 331 // Add Second tab. |
| 332 content::WebContents* contents2 = tab_strip_model->GetWebContentsAt(1); | 332 content::WebContents* contents2 = tab_strip_model->GetWebContentsAt(1); |
| 333 | 333 |
| 334 tab_strip_model->ActivateTabAt(1, true); | 334 tab_strip_model->ActivateTabAt(1, true); |
| 335 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); | 335 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); |
| 336 ui_zoom::PageZoom::Zoom(contents2, content::PAGE_ZOOM_OUT); | 336 ui_zoom::PageZoom::Zoom(contents2, content::PAGE_ZOOM_OUT); |
| 337 | 337 |
| 338 zoom_controller = ZoomController::FromWebContents(contents2); | 338 zoom_controller = ZoomController::FromWebContents(contents2); |
| 339 EXPECT_EQ(zoom_controller->GetZoomPercent(), 90.0f); | 339 EXPECT_EQ(zoom_controller->GetZoomPercent(), 90.0f); |
| 340 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); | 340 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS)); |
| 341 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); | 341 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL)); |
| 342 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); | 342 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS)); |
| 343 } | 343 } |
| OLD | NEW |