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

Unified 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: Fix indents, add test 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/host_zoom_map_impl_browsertest.cc
diff --git a/content/browser/host_zoom_map_impl_browsertest.cc b/content/browser/host_zoom_map_impl_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fbfdc3c62e54886f54c3c429c3dfd4062217baa8
--- /dev/null
+++ b/content/browser/host_zoom_map_impl_browsertest.cc
@@ -0,0 +1,86 @@
+// 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 HostZoomMapImplBrowserTest : public ContentBrowserTest {
+};
+
+void RunTestForURL(const GURL& url,
+ Shell* shell,
+ double host_zoom_level,
+ double temp_zoom_level) {
+ 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();
+
+ // Assume caller has set the zoom level to |host_zoom_level| using
+ // either a host or host+scheme entry in the HostZoomMap prior to
+ // calling this function.
+ EXPECT_DOUBLE_EQ(host_zoom_level, host_zoom_map->GetZoomLevelForView(
+ url, render_process_id, view_id));
+
+ // Make sure that GetZoomLevelForView() works for temporary zoom levels.
+ host_zoom_map->SetTemporaryZoomLevel(render_process_id, view_id,
+ temp_zoom_level);
+ EXPECT_DOUBLE_EQ(temp_zoom_level, 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);
+}
+
+// Test to make sure that GetZoomForView() works properly for zoom levels
+// stored by host value, and can distinguish temporary zoom levels from
+// these.
+IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, GetZoomForView_Host) {
+ GURL url("http://abc.com");
+
+ HostZoomMap* host_zoom_map =
+ HostZoomMap::GetForWebContents(shell()->web_contents());
+
+ double default_zoom_level = host_zoom_map->GetDefaultZoomLevel();
+ double host_zoom_level = default_zoom_level + 1.0;
+ double temp_zoom_level = default_zoom_level + 2.0;
+
+ host_zoom_map->SetZoomLevelForHost(url.host(), host_zoom_level);
+
+ RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level);
+}
+
+// Test to make sure that GetZoomForView() works properly for zoom levels
+// stored by host and scheme values, and can distinguish temporary zoom levels
+// from these.
+IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest,
+ GetZoomForView_HostAndScheme) {
+ GURL url("http://abc.com");
+
+ HostZoomMap* host_zoom_map =
+ HostZoomMap::GetForWebContents(shell()->web_contents());
+
+ double default_zoom_level = host_zoom_map->GetDefaultZoomLevel();
+ double host_zoom_level = default_zoom_level + 1.0;
+ double temp_zoom_level = default_zoom_level + 2.0;
+
+ host_zoom_map->SetZoomLevelForHostAndScheme(url.scheme(), url.host(),
+ host_zoom_level);
+
+ RunTestForURL(url, shell(), host_zoom_level, temp_zoom_level);
+}
+
+} // namespace content
« 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