Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: content/browser/host_zoom_map_impl_browsertest.cc

Issue 1804023002: Fix page zoom to be frame-centric for out-of-process frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use WeakPtr for PostTask on UI thread. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "content/browser/host_zoom_map_impl.h" 5 #include "content/browser/host_zoom_map_impl.h"
6 6
7 #include "content/public/browser/render_process_host.h" 7 #include "content/public/browser/render_process_host.h"
8 #include "content/public/browser/render_view_host.h" 8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/test/content_browser_test.h" 10 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h"
11 #include "content/shell/browser/shell.h" 12 #include "content/shell/browser/shell.h"
13 #include "net/dns/mock_host_resolver.h"
12 #include "url/gurl.h" 14 #include "url/gurl.h"
13 15
14 namespace content { 16 namespace content {
15 17
16 class HostZoomMapImplBrowserTest : public ContentBrowserTest { 18 class HostZoomMapImplBrowserTest : public ContentBrowserTest {
19 protected:
20 void SetUpOnMainThread() override {
21 host_resolver()->AddRule("*", "127.0.0.1");
22 ASSERT_TRUE(embedded_test_server()->Start());
23 }
17 }; 24 };
18 25
19 void RunTestForURL(const GURL& url, 26 void RunTestForURL(const GURL& url,
20 Shell* shell, 27 Shell* shell,
21 double host_zoom_level, 28 double host_zoom_level,
22 double temp_zoom_level) { 29 double temp_zoom_level) {
23 shell->LoadURL(url); 30 shell->LoadURL(url);
24 WebContents* web_contents = shell->web_contents(); 31 WebContents* web_contents = shell->web_contents();
25 32
26 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( 33 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
(...skipping 17 matching lines...) Expand all
44 // web_contents. 51 // web_contents.
45 host_zoom_map->ClearTemporaryZoomLevel(render_process_id, view_id); 52 host_zoom_map->ClearTemporaryZoomLevel(render_process_id, view_id);
46 } 53 }
47 54
48 // Test to make sure that GetZoomForView() works properly for zoom levels 55 // Test to make sure that GetZoomForView() works properly for zoom levels
49 // stored by host value, and can distinguish temporary zoom levels from 56 // stored by host value, and can distinguish temporary zoom levels from
50 // these. 57 // these.
51 IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, GetZoomForView_Host) { 58 IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, GetZoomForView_Host) {
52 GURL url("http://abc.com"); 59 GURL url("http://abc.com");
53 60
61 // We must navigate so the WebContents has a committed entry.
62 EXPECT_TRUE(NavigateToURL(shell(), url));
alexmos 2016/04/05 18:00:53 It seems RunTestForURL will now redundantly naviga
wjmaclean 2016/04/05 20:22:00 Hmmm, I missed that ... I'll remove it from RunTes
63
54 HostZoomMap* host_zoom_map = 64 HostZoomMap* host_zoom_map =
55 HostZoomMap::GetForWebContents(shell()->web_contents()); 65 HostZoomMap::GetForWebContents(shell()->web_contents());
56 66
57 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel(); 67 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel();
58 double host_zoom_level = default_zoom_level + 1.0; 68 double host_zoom_level = default_zoom_level + 1.0;
59 double temp_zoom_level = default_zoom_level + 2.0; 69 double temp_zoom_level = default_zoom_level + 2.0;
60 70
61 host_zoom_map->SetZoomLevelForHost(url.host(), host_zoom_level); 71 host_zoom_map->SetZoomLevelForHost(url.host(), host_zoom_level);
62 72
63 RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level); 73 RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level);
64 } 74 }
65 75
66 // Test to make sure that GetZoomForView() works properly for zoom levels 76 // Test to make sure that GetZoomForView() works properly for zoom levels
67 // stored by host and scheme values, and can distinguish temporary zoom levels 77 // stored by host and scheme values, and can distinguish temporary zoom levels
68 // from these. 78 // from these.
69 IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, 79 IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest,
70 GetZoomForView_HostAndScheme) { 80 GetZoomForView_HostAndScheme) {
71 GURL url("http://abc.com"); 81 GURL url("http://abc.com");
72 82
83 // We must navigate so the WebContents has a committed entry.
84 EXPECT_TRUE(NavigateToURL(shell(), url));
85
73 HostZoomMap* host_zoom_map = 86 HostZoomMap* host_zoom_map =
74 HostZoomMap::GetForWebContents(shell()->web_contents()); 87 HostZoomMap::GetForWebContents(shell()->web_contents());
75 88
76 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel(); 89 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel();
77 double host_zoom_level = default_zoom_level + 1.0; 90 double host_zoom_level = default_zoom_level + 1.0;
78 double temp_zoom_level = default_zoom_level + 2.0; 91 double temp_zoom_level = default_zoom_level + 2.0;
79 92
80 host_zoom_map->SetZoomLevelForHostAndScheme(url.scheme(), url.host(), 93 host_zoom_map->SetZoomLevelForHostAndScheme(url.scheme(), url.host(),
81 host_zoom_level); 94 host_zoom_level);
82 95
83 RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level); 96 RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level);
84 } 97 }
85 98
86 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698