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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/host_zoom_map_impl.h » ('j') | content/browser/host_zoom_map_impl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/host_zoom_map_content_browsertest.cc
diff --git a/content/browser/host_zoom_map_content_browsertest.cc b/content/browser/host_zoom_map_content_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9c725c6ed2e03c34d4f77ce79c06029e5ee18588
--- /dev/null
+++ b/content/browser/host_zoom_map_content_browsertest.cc
@@ -0,0 +1,63 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/host_zoom_map_impl.h"
+
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/shell/browser/shell.h"
+#include "url/gurl.h"
+
+namespace content {
+
+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.
+};
+
+void RunTestForURL(const GURL& url,
+ Shell* shell,
+ double zoom_level_1,
+ double zoom_level_2) {
+ shell->LoadURL(url);
+ WebContents* web_contents = shell->web_contents();
+
+ HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
+ HostZoomMap::GetForWebContents(web_contents));
+
+ int view_id = web_contents->GetRoutingID();
+ int render_process_id = web_contents->GetRenderProcessHost()->GetID();
+
+ EXPECT_DOUBLE_EQ(zoom_level_1, host_zoom_map->GetZoomLevelForView(
+ url, render_process_id, view_id));
+
+ host_zoom_map->SetTemporaryZoomLevel(render_process_id, view_id,
+ zoom_level_2);
+ EXPECT_DOUBLE_EQ(zoom_level_2, host_zoom_map->GetZoomLevelForView(
+ url, render_process_id, view_id));
+ // Clear the temporary zoom level in case subsequent test calls use the same
+ // web_contents.
+ host_zoom_map->ClearTemporaryZoomLevel(render_process_id, view_id);
+}
+
+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.
+ GURL url1("http://abc.com");
+ GURL url2("http://def.com");
+
+ HostZoomMap* host_zoom_map =
+ HostZoomMap::GetForWebContents(shell()->web_contents());
+
+ double default_zoom_level = host_zoom_map->GetDefaultZoomLevel();
+ double zoom_level_1 = default_zoom_level + 1.0;
+ double zoom_level_2 = default_zoom_level + 2.0;
+
+ host_zoom_map->SetZoomLevelForHost(url1.host(), zoom_level_1);
+ host_zoom_map->SetZoomLevelForHostAndScheme(url2.scheme(), url2.host(),
+ zoom_level_1);
+
+ RunTestForURL(url1, shell(), zoom_level_1, zoom_level_2);
+ RunTestForURL(url2, shell(), zoom_level_1, zoom_level_2);
+}
+
+} // namespace content
« 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