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

Unified Diff: chrome/browser/content_settings/host_content_settings_map_unittest.cc

Issue 2158743002: Register a pref to control migration status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_scoping_type
Patch Set: add some comments to test Created 4 years, 5 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
Index: chrome/browser/content_settings/host_content_settings_map_unittest.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index ee7029cd6e3c42171b8a51a084bdbaf57cf28339..3f64748e1111ec5572bbfe9640bd23a018f396c8 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -1426,7 +1426,7 @@ TEST_F(HostContentSettingsMapTest, MigrateDomainScopedSettings) {
"https://[*.]example.com:443");
EXPECT_TRUE(settings[1].primary_pattern.ToString() == "*");
- host_content_settings_map->MigrateDomainScopedSettings();
+ host_content_settings_map->MigrateDomainScopedSettings(false);
// After migration, settings only affect origins.
EXPECT_EQ(
@@ -1464,6 +1464,36 @@ TEST_F(HostContentSettingsMapTest, MigrateDomainScopedSettings) {
EXPECT_TRUE(settings[1].primary_pattern.ToString() == "*");
}
+TEST_F(HostContentSettingsMapTest, DomainToOriginMigrationStatus) {
+ TestingProfile profile;
+ PrefService* prefs = profile.GetPrefs();
+
+ HostContentSettingsMap* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(&profile);
+
+ // Initial state is NOT_MIGRATED.
+ EXPECT_EQ(0, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
+
+ // Do migration on HostContentSettingsMap construction will change the state
+ // to MIGRATED_BEFORE_SYNC.
+ host_content_settings_map->MigrateDomainScopedSettings(false);
+ EXPECT_EQ(1, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
raymes 2016/07/21 00:58:54 Rather than checking the value of the pref (which
lshang 2016/07/22 01:33:06 Done.
+
+ // Another call on HostContentSettingsMap construction to do migration will
+ // not change the state(i.e. migration code don't acturally get executed).
+ host_content_settings_map->MigrateDomainScopedSettings(false);
+ EXPECT_EQ(1, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
+
+ // Do migration after sync will change the state to MIGRATED_AFTER_SYNC.
+ host_content_settings_map->MigrateDomainScopedSettings(true);
+ EXPECT_EQ(2, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
+
+ // Another call after sync to do migration will not change the state
+ // (i.e. migration has finished, won't get executed anymore).
+ host_content_settings_map->MigrateDomainScopedSettings(true);
+ EXPECT_EQ(2, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
+}
+
TEST_F(HostContentSettingsMapTest, InvalidPattern) {
// This is a regression test for crbug.com/618529, which fixed a memory leak
// when a website setting was set under a URL that mapped to an invalid

Powered by Google App Engine
This is Rietveld 408576698