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

Unified Diff: chrome/browser/profiles/host_zoom_map_browsertest.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Perhaps HostZoomLevelContextDeleter was needed after all ... Created 6 years, 1 month 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
Index: chrome/browser/profiles/host_zoom_map_browsertest.cc
diff --git a/chrome/browser/profiles/host_zoom_map_browsertest.cc b/chrome/browser/profiles/host_zoom_map_browsertest.cc
index 15c32ce49e6868dd25c1c84a5bb1512a70496390..0d924cc02f4b8a421e170f9b140d128ce9dcb5c9 100644
--- a/chrome/browser/profiles/host_zoom_map_browsertest.cc
+++ b/chrome/browser/profiles/host_zoom_map_browsertest.cc
@@ -19,6 +19,7 @@
#include "base/values.h"
#include "chrome/browser/chrome_page_zoom.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
@@ -341,3 +342,60 @@ IN_PROC_BROWSER_TEST_F(HostZoomMapMigrationBrowserTest,
EXPECT_EQ(0.0, profile_prefs->GetDouble(prefs::kDefaultZoomLevelDeprecated));
}
+// Test four things:
+// 1. Host zoom maps of parent profile and child profile are different.
+// 2. Child host zoom map inherites zoom level at construction.
Charlie Reis 2014/11/04 23:43:16 nit: inherits
wjmaclean 2014/11/05 21:55:42 Done. Ahh, the dangers of transferring comments w
+// 3. Change of zoom level doesn't propagate from child to parent.
+// 4. Change of zoom level propagate from parent to child.
Charlie Reis 2014/11/04 23:43:16 nit: propagates
wjmaclean 2014/11/05 21:55:42 Done.
+IN_PROC_BROWSER_TEST_F(HostZoomMapBrowserTest,
+ OffTheRecordProfileHostZoomMap) {
+ using content::HostZoomMap;
Charlie Reis 2014/11/04 23:43:16 Is it common to do this within a test or block? I
wjmaclean 2014/11/05 21:55:42 Done.
+
+ // Constants for test case.
+ const std::string host("example.com");
+ const double zoom_level_25 = 2.5;
+ const double zoom_level_30 = 3.0;
+ const double zoom_level_40 = 4.0;
+
+ Profile* parent_profile = browser()->profile();
+ Profile* child_profile =
+ static_cast<ProfileImpl*>(parent_profile)->GetOffTheRecordProfile();
+ HostZoomMap* parent_zoom_map =
+ HostZoomMap::GetDefaultForBrowserContext(parent_profile);
+ ASSERT_TRUE(parent_zoom_map);
+
+ parent_zoom_map->SetZoomLevelForHost(host, zoom_level_25);
+ ASSERT_EQ(parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
+ zoom_level_25);
+
+ // Prepare child host zoom map.
+ HostZoomMap* child_zoom_map =
+ HostZoomMap::GetDefaultForBrowserContext(child_profile);
+ ASSERT_TRUE(child_zoom_map);
+
+ // Verify.
+ EXPECT_NE(parent_zoom_map, child_zoom_map);
+
+ EXPECT_EQ(parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
+ child_zoom_map->GetZoomLevelForHostAndScheme("http", host)) <<
+ "Child must inherit from parent.";
+
+ child_zoom_map->SetZoomLevelForHost(host, zoom_level_30);
+ ASSERT_EQ(
+ child_zoom_map->GetZoomLevelForHostAndScheme("http", host),
+ zoom_level_30);
+
+ EXPECT_NE(parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
+ child_zoom_map->GetZoomLevelForHostAndScheme("http", host)) <<
+ "Child change must not propagate to parent.";
+
+ parent_zoom_map->SetZoomLevelForHost(host, zoom_level_40);
+ ASSERT_EQ(
+ parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
+ zoom_level_40);
+
+ EXPECT_EQ(parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
+ child_zoom_map->GetZoomLevelForHostAndScheme("http", host)) <<
+ "Parent change should propagate to child.";
Charlie Reis 2014/11/04 23:43:16 Huh. I was surprised that this was Chrome's behav
wjmaclean 2014/11/05 21:55:42 Acknowledged.
+ base::RunLoop().RunUntilIdle();
+}

Powered by Google App Engine
This is Rietveld 408576698