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

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: Address comments; patch for landing. 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..cdb5bd6d3d4329ae7ca8bfe9310a3a026243d73d 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"
@@ -35,6 +36,8 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "url/gurl.h"
+using content::HostZoomMap;
+
namespace {
class ZoomLevelChangeObserver {
@@ -341,3 +344,58 @@ 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 inherits zoom level at construction.
+// 3. Change of zoom level doesn't propagate from child to parent.
+// 4. Change of zoom level propagates from parent to child.
+IN_PROC_BROWSER_TEST_F(HostZoomMapBrowserTest,
+ OffTheRecordProfileHostZoomMap) {
+ // 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.";
+ base::RunLoop().RunUntilIdle();
+}
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('k') | chrome/browser/profiles/off_the_record_profile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698