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

Unified Diff: chrome/browser/protector/protected_prefs_watcher_unittest.cc

Issue 10170046: [protector] Bump Preferences backup version to 3 to mitigate the startup prefs migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | « chrome/browser/protector/protected_prefs_watcher.cc ('k') | chrome/browser/protector/protector_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/protector/protected_prefs_watcher_unittest.cc
diff --git a/chrome/browser/protector/protected_prefs_watcher_unittest.cc b/chrome/browser/protector/protected_prefs_watcher_unittest.cc
index b67f8d9848303f16f23d4377015ffd285946f17e..bf7f1fa2a2a694eebd7fdc6fd0c3502085b9b2ca 100644
--- a/chrome/browser/protector/protected_prefs_watcher_unittest.cc
+++ b/chrome/browser/protector/protected_prefs_watcher_unittest.cc
@@ -189,4 +189,34 @@ TEST_F(ProtectedPrefsWatcherTest, MigrationToVersion2) {
prefs_->GetInteger("backup._version"));
}
+// Verify that SessionStartupPref migration doesn't trigger Protector
+// (version 3 migration).
+TEST_F(ProtectedPrefsWatcherTest, MigrationToVersion3) {
+ EXPECT_TRUE(prefs_watcher_->is_backup_valid());
+
+ // Bring startup prefs to an old (pre-migration) version.
+ prefs_->SetBoolean(prefs::kHomePageIsNewTabPage, false);
+ prefs_->SetString(prefs::kHomePage, "http://example.com/");
+ prefs_->ClearPref(prefs::kRestoreOnStartupMigrated);
+
+ // Reset version to 2 and overwrite the signature.
+ prefs_->SetInteger("backup._version", 2);
+ ForceUpdateSignature();
+ EXPECT_TRUE(IsSignatureValid());
+
+ // Take down the old instance and create a new ProtectedPrefsWatcher from
+ // current prefs.
+ ProtectorServiceFactory::GetForProfile(&profile_)->
+ StopWatchingPrefsForTesting();
+ scoped_ptr<ProtectedPrefsWatcher> prefs_watcher2(
+ new ProtectedPrefsWatcher(&profile_));
+ EXPECT_TRUE(prefs_watcher2->is_backup_valid());
+
+ // Startup settings shouldn't be reported as changed.
+ EXPECT_FALSE(prefs_watcher2->DidPrefChange(prefs::kRestoreOnStartup));
+ EXPECT_FALSE(prefs_watcher2->DidPrefChange(prefs::kURLsToRestoreOnStartup));
+ EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber,
+ prefs_->GetInteger("backup._version"));
+}
+
} // namespace protector
« no previous file with comments | « chrome/browser/protector/protected_prefs_watcher.cc ('k') | chrome/browser/protector/protector_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698