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

Side by Side Diff: content/browser/host_zoom_map_content_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: Add test, remove incorrect comment. 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
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 HostZoomMapContentBrowserTest : public ContentBrowserTest {
Charlie Reis 2015/02/12 21:51:41 nit: We should probably name this file host_zoom_m
wjmaclean 2015/02/13 15:57:53 Done.
17 };
18
19 void RunTestForURL(const GURL& url,
20 Shell* shell,
21 double zoom_level_1,
22 double zoom_level_2) {
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 EXPECT_DOUBLE_EQ(zoom_level_1, host_zoom_map->GetZoomLevelForView(
33 url, render_process_id, view_id));
34
35 host_zoom_map->SetTemporaryZoomLevel(render_process_id, view_id,
36 zoom_level_2);
37 EXPECT_DOUBLE_EQ(zoom_level_2, host_zoom_map->GetZoomLevelForView(
38 url, render_process_id, view_id));
39 // Clear the temporary zoom level in case subsequent test calls use the same
40 // web_contents.
41 host_zoom_map->ClearTemporaryZoomLevel(render_process_id, view_id);
42 }
43
44 IN_PROC_BROWSER_TEST_F(HostZoomMapContentBrowserTest, GetZoomForView) {
Charlie Reis 2015/02/12 21:51:41 This test does seem to be covering a lot of the in
wjmaclean 2015/02/13 15:57:53 Done.
45 GURL url1("http://abc.com");
46 GURL url2("http://def.com");
47
48 HostZoomMap* host_zoom_map =
49 HostZoomMap::GetForWebContents(shell()->web_contents());
50
51 double default_zoom_level = host_zoom_map->GetDefaultZoomLevel();
52 double zoom_level_1 = default_zoom_level + 1.0;
53 double zoom_level_2 = default_zoom_level + 2.0;
54
55 host_zoom_map->SetZoomLevelForHost(url1.host(), zoom_level_1);
56 host_zoom_map->SetZoomLevelForHostAndScheme(url2.scheme(), url2.host(),
57 zoom_level_1);
58
59 RunTestForURL(url1, shell(), zoom_level_1, zoom_level_2);
60 RunTestForURL(url2, shell(), zoom_level_1, zoom_level_2);
61 }
62
63 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/host_zoom_map_impl.h » ('j') | content/browser/host_zoom_map_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698