| 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/zoom/zoom_controller.h" | 9 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 10 #include "chrome/browser/ui/zoom/zoom_observer.h" | 10 #include "chrome/browser/ui/zoom/zoom_observer.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 web_contents(), | 63 web_contents(), |
| 64 zoom_level, | 64 zoom_level, |
| 65 zoom_level, | 65 zoom_level, |
| 66 ZoomController::ZOOM_MODE_DEFAULT, | 66 ZoomController::ZOOM_MODE_DEFAULT, |
| 67 false); | 67 false); |
| 68 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data)).Times(1); | 68 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data)).Times(1); |
| 69 zoom_controller_->DidNavigateMainFrame(content::LoadCommittedDetails(), | 69 zoom_controller_->DidNavigateMainFrame(content::LoadCommittedDetails(), |
| 70 content::FrameNavigateParams()); | 70 content::FrameNavigateParams()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 TEST_F(ZoomControllerTest, Observe) { | |
| 74 double new_zoom_level = 110.0; | |
| 75 // When the event is initiated from HostZoomMap, the old zoom level is not | |
| 76 // available. | |
| 77 ZoomController::ZoomChangedEventData zoom_change_data( | |
| 78 web_contents(), | |
| 79 new_zoom_level, | |
| 80 new_zoom_level, | |
| 81 ZoomController::ZOOM_MODE_DEFAULT, | |
| 82 false); | |
| 83 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data)).Times(1); | |
| 84 | |
| 85 content::HostZoomMap* host_zoom_map = | |
| 86 content::HostZoomMap::GetDefaultForBrowserContext( | |
| 87 web_contents()->GetBrowserContext()); | |
| 88 | |
| 89 host_zoom_map->SetZoomLevelForHost(std::string(), new_zoom_level); | |
| 90 } | |
| 91 | |
| 92 TEST_F(ZoomControllerTest, Observe_ZoomController) { | 73 TEST_F(ZoomControllerTest, Observe_ZoomController) { |
| 93 double old_zoom_level = zoom_controller_->GetZoomLevel(); | 74 double old_zoom_level = zoom_controller_->GetZoomLevel(); |
| 94 double new_zoom_level = 110.0; | 75 double new_zoom_level = 110.0; |
| 95 | 76 |
| 96 NavigateAndCommit(GURL("about:blank")); | 77 NavigateAndCommit(GURL("about:blank")); |
| 97 | 78 |
| 98 ZoomController::ZoomChangedEventData zoom_change_data1( | 79 ZoomController::ZoomChangedEventData zoom_change_data1( |
| 99 web_contents(), | 80 web_contents(), |
| 100 old_zoom_level, | 81 old_zoom_level, |
| 101 old_zoom_level, | 82 old_zoom_level, |
| 102 ZoomController::ZOOM_MODE_ISOLATED, | 83 ZoomController::ZOOM_MODE_ISOLATED, |
| 103 true /* can_show_bubble */); | 84 true /* can_show_bubble */); |
| 104 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data1)).Times(1); | 85 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data1)).Times(1); |
| 105 | 86 |
| 106 zoom_controller_->SetZoomMode(ZoomController::ZOOM_MODE_ISOLATED); | 87 zoom_controller_->SetZoomMode(ZoomController::ZOOM_MODE_ISOLATED); |
| 107 | 88 |
| 108 ZoomController::ZoomChangedEventData zoom_change_data2( | 89 ZoomController::ZoomChangedEventData zoom_change_data2( |
| 109 web_contents(), | 90 web_contents(), |
| 110 old_zoom_level, | 91 old_zoom_level, |
| 111 new_zoom_level, | 92 new_zoom_level, |
| 112 ZoomController::ZOOM_MODE_ISOLATED, | 93 ZoomController::ZOOM_MODE_ISOLATED, |
| 113 true /* can_show_bubble */); | 94 true /* can_show_bubble */); |
| 114 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data2)).Times(1); | 95 EXPECT_CALL(zoom_observer_, OnZoomChanged(zoom_change_data2)).Times(1); |
| 115 | 96 |
| 116 zoom_controller_->SetZoomLevel(new_zoom_level); | 97 zoom_controller_->SetZoomLevel(new_zoom_level); |
| 117 } | 98 } |
| OLD | NEW |