Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/host_zoom_map_impl.h" | |
| 6 | |
| 7 #include "content/public/browser/render_process_host.h" | |
| 8 #include "content/public/browser/render_view_host.h" | |
| 9 #include "content/public/browser/web_contents.h" | |
| 10 #include "content/public/test/content_browser_test.h" | |
| 11 #include "content/shell/browser/shell.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class HostZoomMapImplBrowserTest : public ContentBrowserTest { | |
| 17 }; | |
| 18 | |
| 19 void RunTestForURL(const GURL& url, | |
| 20 Shell* shell, | |
| 21 double host_zoom_level, | |
| 22 double temp_zoom_level) { | |
| 23 shell->LoadURL(url); | |
| 24 WebContents* web_contents = shell->web_contents(); | |
| 25 | |
| 26 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( | |
| 27 HostZoomMap::GetForWebContents(web_contents)); | |
| 28 | |
| 29 int view_id = web_contents->GetRoutingID(); | |
| 30 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | |
| 31 | |
| 32 // Assume caller has set the zoom level to |host_zoom_level| using | |
| 33 // either a host or host+scheme entry in the HostZoomMap prior to | |
| 34 // calling this function. | |
| 35 EXPECT_DOUBLE_EQ(host_zoom_level, host_zoom_map->GetZoomLevelForView( | |
| 36 url, render_process_id, view_id)); | |
|
Charlie Reis
2015/02/13 20:47:08
nit: Wrong indent.
wjmaclean
2015/02/13 21:01:15
Done.
| |
| 37 | |
| 38 // Make sure that GetZoomLevelForView() works for temporary zoom levels. | |
| 39 host_zoom_map->SetTemporaryZoomLevel(render_process_id, view_id, | |
| 40 temp_zoom_level); | |
| 41 EXPECT_DOUBLE_EQ(temp_zoom_level, host_zoom_map->GetZoomLevelForView( | |
| 42 url, render_process_id, view_id)); | |
|
Charlie Reis
2015/02/13 20:47:08
nit: Wrong indent.
wjmaclean
2015/02/13 21:01:15
Done.
| |
| 43 // Clear the temporary zoom level in case subsequent test calls use the same | |
| 44 // web_contents. | |
| 45 host_zoom_map->ClearTemporaryZoomLevel(render_process_id, view_id); | |
| 46 } | |
| 47 | |
| 48 IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, GetZoomForView_Host) { | |
|
Charlie Reis
2015/02/13 20:47:08
nit: Comment.
wjmaclean
2015/02/13 21:01:15
Done.
| |
| 49 GURL url("http://abc.com"); | |
| 50 | |
| 51 HostZoomMap* host_zoom_map = | |
| 52 HostZoomMap::GetForWebContents(shell()->web_contents()); | |
| 53 | |
| 54 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel(); | |
| 55 double host_zoom_level = default_zoom_level + 1.0; | |
| 56 double temp_zoom_level = default_zoom_level + 2.0; | |
| 57 | |
| 58 host_zoom_map->SetZoomLevelForHost(url.host(), host_zoom_level); | |
| 59 | |
| 60 RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level); | |
| 61 } | |
| 62 | |
| 63 IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, | |
|
Charlie Reis
2015/02/13 20:47:08
nit: Comment.
wjmaclean
2015/02/13 21:01:15
Done.
| |
| 64 GetZoomForView_HostAndScheme) { | |
| 65 GURL url("http://abc.com"); | |
| 66 | |
| 67 HostZoomMap* host_zoom_map = | |
| 68 HostZoomMap::GetForWebContents(shell()->web_contents()); | |
| 69 | |
| 70 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel(); | |
| 71 double host_zoom_level = default_zoom_level + 1.0; | |
| 72 double temp_zoom_level = default_zoom_level + 2.0; | |
| 73 | |
| 74 host_zoom_map->SetZoomLevelForHostAndScheme(url.scheme(), url.host(), | |
| 75 host_zoom_level); | |
| 76 | |
| 77 RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level); | |
| 78 } | |
| 79 | |
| 80 } // namespace content | |
| OLD | NEW |