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

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

Issue 809223006: Check temporary zoom status when sending zoom level in navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 10 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
« no previous file with comments | « content/browser/host_zoom_map_impl.cc ('k') | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « content/browser/host_zoom_map_impl.cc ('k') | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698