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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/extensions/extension_pref_value_map.h" 7 #include "chrome/browser/extensions/extension_pref_value_map.h"
8 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" 8 #include "chrome/browser/extensions/extension_pref_value_map_factory.h"
9 #include "chrome/browser/extensions/extension_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 // Now the backup should be valid and "pinned_tabs" is added back. 183 // Now the backup should be valid and "pinned_tabs" is added back.
184 EXPECT_TRUE(prefs_watcher_->is_backup_valid()); 184 EXPECT_TRUE(prefs_watcher_->is_backup_valid());
185 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList("backup.pinned_tabs"))); 185 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList("backup.pinned_tabs")));
186 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList(prefs::kPinnedTabs))); 186 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList(prefs::kPinnedTabs)));
187 EXPECT_FALSE(prefs_watcher_->DidPrefChange(prefs::kPinnedTabs)); 187 EXPECT_FALSE(prefs_watcher_->DidPrefChange(prefs::kPinnedTabs));
188 EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber, 188 EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber,
189 prefs_->GetInteger("backup._version")); 189 prefs_->GetInteger("backup._version"));
190 } 190 }
191 191
192 // Verify that SessionStartupPref migration doesn't trigger Protector
193 // (version 3 migration).
194 TEST_F(ProtectedPrefsWatcherTest, MigrationToVersion3) {
195 EXPECT_TRUE(prefs_watcher_->is_backup_valid());
196
197 // Bring startup prefs to an old (pre-migration) version.
198 prefs_->SetBoolean(prefs::kHomePageIsNewTabPage, false);
199 prefs_->SetString(prefs::kHomePage, "http://example.com/");
200 prefs_->ClearPref(prefs::kRestoreOnStartupMigrated);
201
202 // Reset version to 2 and overwrite the signature.
203 prefs_->SetInteger("backup._version", 2);
204 ForceUpdateSignature();
205 EXPECT_TRUE(IsSignatureValid());
206
207 // Take down the old instance and create a new ProtectedPrefsWatcher from
208 // current prefs.
209 ProtectorServiceFactory::GetForProfile(&profile_)->
210 StopWatchingPrefsForTesting();
211 scoped_ptr<ProtectedPrefsWatcher> prefs_watcher2(
212 new ProtectedPrefsWatcher(&profile_));
213 EXPECT_TRUE(prefs_watcher2->is_backup_valid());
214
215 // Startup settings shouldn't be reported as changed.
216 EXPECT_FALSE(prefs_watcher2->DidPrefChange(prefs::kRestoreOnStartup));
217 EXPECT_FALSE(prefs_watcher2->DidPrefChange(prefs::kURLsToRestoreOnStartup));
218 EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber,
219 prefs_->GetInteger("backup._version"));
220 }
221
192 } // namespace protector 222 } // namespace protector
OLDNEW
« 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