Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/ui/zoom/zoom_controller.h" | 5 #include "components/ui/zoom/zoom_controller.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 | 265 |
| 266 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, PerTabModeResetSendsEvent) { | 266 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, PerTabModeResetSendsEvent) { |
| 267 TestResetOnNavigation(ZoomController::ZOOM_MODE_ISOLATED); | 267 TestResetOnNavigation(ZoomController::ZOOM_MODE_ISOLATED); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Regression test: crbug.com/450909. | 270 // Regression test: crbug.com/450909. |
| 271 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, NavigationResetsManualMode) { | 271 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, NavigationResetsManualMode) { |
| 272 TestResetOnNavigation(ZoomController::ZOOM_MODE_MANUAL); | 272 TestResetOnNavigation(ZoomController::ZOOM_MODE_MANUAL); |
| 273 } | 273 } |
| 274 | 274 |
| 275 #if !defined(OS_CHROMEOS) | 275 #if !defined(OS_CHROMEOS) |
|
achuithb
2015/11/05 22:36:50
Do you know why this is?
| |
| 276 // Regression test: crbug.com/438979. | 276 // Regression test: crbug.com/438979. |
| 277 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, | 277 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, |
| 278 SettingsZoomAfterSigninWorks) { | 278 SettingsZoomAfterSigninWorks) { |
| 279 GURL signin_url( | 279 GURL signin_url( |
| 280 std::string(chrome::kChromeUIChromeSigninURL).append("?source=0")); | 280 std::string(chrome::kChromeUIChromeSigninURL).append("?source=0")); |
| 281 // We open the signin page in a new tab so that the ZoomController is | 281 // We open the signin page in a new tab so that the ZoomController is |
| 282 // created against the HostZoomMap of the special StoragePartition that | 282 // created against the HostZoomMap of the special StoragePartition that |
| 283 // backs the signin page. When we subsequently navigate away from the | 283 // backs the signin page. When we subsequently navigate away from the |
| 284 // signin page, the HostZoomMap changes, and we need to test that the | 284 // signin page, the HostZoomMap changes, and we need to test that the |
| 285 // ZoomController correctly detects this. | 285 // ZoomController correctly detects this. |
| 286 ui_test_utils::NavigateToURLWithDisposition( | 286 ui_test_utils::NavigateToURLWithDisposition( |
| 287 browser(), signin_url, NEW_FOREGROUND_TAB, | 287 browser(), signin_url, NEW_FOREGROUND_TAB, |
| 288 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 288 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 289 login_ui_test_utils::WaitUntilUIReady(browser()); | 289 login_ui_test_utils::WaitUntilUIReady(browser()); |
| 290 content::WebContents* web_contents = | 290 content::WebContents* web_contents = |
| 291 browser()->tab_strip_model()->GetActiveWebContents(); | 291 browser()->tab_strip_model()->GetActiveWebContents(); |
| 292 EXPECT_NE( | 292 EXPECT_NE( |
| 293 content::PAGE_TYPE_ERROR, | 293 content::PAGE_TYPE_ERROR, |
| 294 web_contents->GetController().GetLastCommittedEntry()->GetPageType()); | 294 web_contents->GetController().GetLastCommittedEntry()->GetPageType()); |
| 295 | 295 |
| 296 EXPECT_EQ(signin_url, web_contents->GetLastCommittedURL()); | 296 EXPECT_EQ(signin_url, web_contents->GetLastCommittedURL()); |
| 297 ZoomController* zoom_controller = | 297 ZoomController* zoom_controller = |
| 298 ZoomController::FromWebContents(web_contents); | 298 ZoomController::FromWebContents(web_contents); |
| 299 | 299 |
| 300 content::HostZoomMap* host_zoom_map_signin = | |
| 301 content::HostZoomMap::GetForWebContents(web_contents); | |
| 302 | |
| 303 GURL settings_url(chrome::kChromeUISettingsURL); | 300 GURL settings_url(chrome::kChromeUISettingsURL); |
| 304 ui_test_utils::NavigateToURL(browser(), settings_url); | 301 ui_test_utils::NavigateToURL(browser(), settings_url); |
| 305 EXPECT_NE( | 302 EXPECT_NE( |
| 306 content::PAGE_TYPE_ERROR, | 303 content::PAGE_TYPE_ERROR, |
| 307 web_contents->GetController().GetLastCommittedEntry()->GetPageType()); | 304 web_contents->GetController().GetLastCommittedEntry()->GetPageType()); |
| 308 | 305 |
| 309 // Verify new tab was created. | 306 // Verify new tab was created. |
| 310 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 307 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 311 // Verify that the settings page is using the same WebContents. | 308 // Verify that the settings page is using the same WebContents. |
| 312 EXPECT_EQ(web_contents, browser()->tab_strip_model()->GetActiveWebContents()); | 309 EXPECT_EQ(web_contents, browser()->tab_strip_model()->GetActiveWebContents()); |
| 313 // TODO(wjmaclean): figure out why this next line fails, i.e. why does this | 310 // TODO(wjmaclean): figure out why this next line fails, i.e. why does this |
| 314 // test not properly trigger a navigation to the settings page. | 311 // test not properly trigger a navigation to the settings page. |
| 315 EXPECT_EQ(settings_url, web_contents->GetLastCommittedURL()); | 312 EXPECT_EQ(settings_url, web_contents->GetLastCommittedURL()); |
| 316 EXPECT_EQ(zoom_controller, ZoomController::FromWebContents(web_contents)); | 313 EXPECT_EQ(zoom_controller, ZoomController::FromWebContents(web_contents)); |
| 317 | 314 |
| 318 // For the webview based sign-in code, the sign in page uses the default host | |
| 319 // zoom map. | |
| 320 if (!switches::IsEnableWebviewBasedSignin()) { | |
| 321 // We expect the navigation from the chrome sign in page to the settings | |
| 322 // page to invoke a storage partition switch, and thus a different | |
| 323 // HostZoomMap for the web_contents. | |
| 324 content::HostZoomMap* host_zoom_map_settings = | |
| 325 content::HostZoomMap::GetForWebContents(web_contents); | |
| 326 EXPECT_NE(host_zoom_map_signin, host_zoom_map_settings); | |
| 327 } | |
| 328 | |
| 329 // If we zoom the new page, it should still generate a ZoomController event. | 315 // If we zoom the new page, it should still generate a ZoomController event. |
| 330 double old_zoom_level = zoom_controller->GetZoomLevel(); | 316 double old_zoom_level = zoom_controller->GetZoomLevel(); |
| 331 double new_zoom_level = old_zoom_level + 0.5; | 317 double new_zoom_level = old_zoom_level + 0.5; |
| 332 | 318 |
| 333 ZoomController::ZoomChangedEventData zoom_change_data( | 319 ZoomController::ZoomChangedEventData zoom_change_data( |
| 334 web_contents, | 320 web_contents, |
| 335 old_zoom_level, | 321 old_zoom_level, |
| 336 new_zoom_level, | 322 new_zoom_level, |
| 337 ZoomController::ZOOM_MODE_DEFAULT, | 323 ZoomController::ZOOM_MODE_DEFAULT, |
| 338 true); // We have a non-empty host, so this will be 'true'. | 324 true); // We have a non-empty host, so this will be 'true'. |
| 339 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); | 325 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); |
| 340 zoom_controller->SetZoomLevel(new_zoom_level); | 326 zoom_controller->SetZoomLevel(new_zoom_level); |
| 341 zoom_change_watcher.Wait(); | 327 zoom_change_watcher.Wait(); |
| 342 } | 328 } |
| 343 #endif // !defined(OS_CHROMEOS) | 329 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |