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 |