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" |
11 #include "chrome/browser/ui/browser_commands.h" | |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/webui/signin/login_ui_test_utils.h" | 13 #include "chrome/browser/ui/webui/signin/login_ui_test_utils.h" |
13 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 14 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
17 #include "components/signin/core/common/profile_management_switches.h" | 18 #include "components/signin/core/common/profile_management_switches.h" |
18 #include "content/public/browser/host_zoom_map.h" | 19 #include "content/public/browser/host_zoom_map.h" |
19 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
20 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 | 162 |
162 double old_zoom_level = zoom_controller->GetZoomLevel(); | 163 double old_zoom_level = zoom_controller->GetZoomLevel(); |
163 double new_zoom_level = old_zoom_level + 0.5; | 164 double new_zoom_level = old_zoom_level + 0.5; |
164 | 165 |
165 // The following attempt to change the zoom level for an error page should | 166 // The following attempt to change the zoom level for an error page should |
166 // fail. | 167 // fail. |
167 zoom_controller->SetZoomLevel(new_zoom_level); | 168 zoom_controller->SetZoomLevel(new_zoom_level); |
168 EXPECT_FLOAT_EQ(new_zoom_level, zoom_controller->GetZoomLevel()); | 169 EXPECT_FLOAT_EQ(new_zoom_level, zoom_controller->GetZoomLevel()); |
169 } | 170 } |
170 | 171 |
172 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, | |
173 ErrorPagesCanZoomAfterTabRestore) { | |
174 // This url is meant to cause a network error page to be loaded. It assumes | |
Charlie Reis
2015/02/18 23:53:04
nit: Drop "It assumes"
(There were two instances
wjmaclean
2015/02/19 13:24:38
Ooops, missed that!
Done.
| |
175 // Tests can't reach the network, so this test should continue | |
176 // to work even if the domain listed is someday registered. | |
177 GURL url("http://kjfhkjsdf.com"); | |
178 | |
179 TabStripModel* tab_strip = browser()->tab_strip_model(); | |
180 ASSERT_TRUE(tab_strip); | |
181 | |
182 ui_test_utils::NavigateToURLWithDisposition( | |
183 browser(), url, NEW_FOREGROUND_TAB, | |
184 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
185 { | |
186 content::WebContents* web_contents = tab_strip->GetActiveWebContents(); | |
187 | |
188 EXPECT_EQ( | |
189 content::PAGE_TYPE_ERROR, | |
190 web_contents->GetController().GetLastCommittedEntry()->GetPageType()); | |
191 | |
192 content::WebContentsDestroyedWatcher destroyed_watcher(web_contents); | |
193 tab_strip->CloseWebContentsAt(tab_strip->active_index(), | |
194 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | |
195 destroyed_watcher.Wait(); | |
196 } | |
197 EXPECT_EQ(1, tab_strip->count()); | |
198 | |
199 content::WebContentsAddedObserver new_web_contents_observer; | |
200 chrome::RestoreTab(browser()); | |
201 content::WebContents* web_contents = | |
202 new_web_contents_observer.GetWebContents(); | |
203 content::WaitForLoadStop(web_contents); | |
204 | |
205 EXPECT_EQ(2, tab_strip->count()); | |
206 | |
207 EXPECT_EQ( | |
208 content::PAGE_TYPE_ERROR, | |
209 web_contents->GetController().GetLastCommittedEntry()->GetPageType()); | |
210 | |
211 ZoomController* zoom_controller = | |
212 ZoomController::FromWebContents(web_contents); | |
213 | |
214 double old_zoom_level = zoom_controller->GetZoomLevel(); | |
215 double new_zoom_level = old_zoom_level + 0.5; | |
216 | |
217 // The following attempt to change the zoom level for an error page should | |
218 // fail. | |
219 zoom_controller->SetZoomLevel(new_zoom_level); | |
220 EXPECT_FLOAT_EQ(new_zoom_level, zoom_controller->GetZoomLevel()); | |
221 } | |
222 | |
171 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, Observe) { | 223 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, Observe) { |
172 content::WebContents* web_contents = | 224 content::WebContents* web_contents = |
173 browser()->tab_strip_model()->GetActiveWebContents(); | 225 browser()->tab_strip_model()->GetActiveWebContents(); |
174 | 226 |
175 double new_zoom_level = 1.0; | 227 double new_zoom_level = 1.0; |
176 // When the event is initiated from HostZoomMap, the old zoom level is not | 228 // When the event is initiated from HostZoomMap, the old zoom level is not |
177 // available. | 229 // available. |
178 ZoomController::ZoomChangedEventData zoom_change_data( | 230 ZoomController::ZoomChangedEventData zoom_change_data( |
179 web_contents, | 231 web_contents, |
180 new_zoom_level, | 232 new_zoom_level, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 web_contents, | 314 web_contents, |
263 old_zoom_level, | 315 old_zoom_level, |
264 new_zoom_level, | 316 new_zoom_level, |
265 ZoomController::ZOOM_MODE_DEFAULT, | 317 ZoomController::ZOOM_MODE_DEFAULT, |
266 true); // We have a non-empty host, so this will be 'true'. | 318 true); // We have a non-empty host, so this will be 'true'. |
267 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); | 319 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); |
268 zoom_controller->SetZoomLevel(new_zoom_level); | 320 zoom_controller->SetZoomLevel(new_zoom_level); |
269 zoom_change_watcher.Wait(); | 321 zoom_change_watcher.Wait(); |
270 } | 322 } |
271 #endif // !defined(OS_CHROMEOS) | 323 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |