diff options
author | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 19:03:57 +0000 |
---|---|---|
committer | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 19:03:57 +0000 |
commit | 4c2adcf969a6dd088872fc7b7fee7f7788227518 (patch) | |
tree | ac59a7726434e228d625031b772841b6b6793330 /chrome/browser/protector/protected_prefs_watcher_unittest.cc | |
parent | c45342f046b4cb5edfccd3bde535397fe2cafe80 (diff) | |
download | chromium_src-4c2adcf969a6dd088872fc7b7fee7f7788227518.zip chromium_src-4c2adcf969a6dd088872fc7b7fee7f7788227518.tar.gz chromium_src-4c2adcf969a6dd088872fc7b7fee7f7788227518.tar.bz2 |
[protector] Added UI support for pinned tabs.
Additional changes:
*) Early check for invalid backup.
*) Added backup versioning support.
BUG=114288
TEST=protector.py, ProtectedPrefsWatcherTest.*, SessionStartupChange.*, PinnedTabsCodec.*
Review URL: http://codereview.chromium.org/9808066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/protector/protected_prefs_watcher_unittest.cc')
-rw-r--r-- | chrome/browser/protector/protected_prefs_watcher_unittest.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/chrome/browser/protector/protected_prefs_watcher_unittest.cc b/chrome/browser/protector/protected_prefs_watcher_unittest.cc index 8ad00d9..1977412 100644 --- a/chrome/browser/protector/protected_prefs_watcher_unittest.cc +++ b/chrome/browser/protector/protected_prefs_watcher_unittest.cc @@ -47,6 +47,10 @@ class ProtectedPrefsWatcherTest : public testing::Test { prefs_watcher_->ValidateBackup(); } + void ForceUpdateSignature() { + prefs_watcher_->UpdateBackupSignature(); + } + protected: ProtectedPrefsWatcher* prefs_watcher_; TestingProfile profile_; @@ -135,12 +139,23 @@ TEST_F(ProtectedPrefsWatcherTest, ExtensionPrefChange) { EXPECT_TRUE(IsSignatureValid()); } -TEST_F(ProtectedPrefsWatcherTest, PinnedTabsMigration) { - // Verify that backup for "pinned_tabs" is added if signature is valid. +// Verify that version bigger than 1 is included in the signature. +TEST_F(ProtectedPrefsWatcherTest, VersionIsSigned) { + // Reset version to 1. + prefs_->ClearPref("backup._version"); + // This should make the backup invalid. + EXPECT_FALSE(IsSignatureValid()); - // Store the old signature (without "pinned_tabs"). - std::string old_signature = prefs_->GetString(kBackupSignature); + // "Migrate" the backup back to the latest version. + RevalidateBackup(); + EXPECT_FALSE(prefs_watcher_->is_backup_valid()); + EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber, + prefs_->GetInteger("backup._version")); +} + +// Verify that backup for "pinned_tabs" is added during version 2 migration. +TEST_F(ProtectedPrefsWatcherTest, MigrationToVersion2) { // Add a pinned tab. { ListPrefUpdate pinned_tabs_update(prefs_, prefs::kPinnedTabs); @@ -150,18 +165,19 @@ TEST_F(ProtectedPrefsWatcherTest, PinnedTabsMigration) { tab->SetString("url", "http://example.com/"); pinned_tabs->Append(tab); } - EXPECT_TRUE(prefs_watcher_->is_backup_valid()); scoped_ptr<base::Value> pinned_tabs_copy( prefs_->GetList(prefs::kPinnedTabs)->DeepCopy()); - // Removed "pinned_tabs" from backup and restore old signature. + // Reset version to 1, remove "pinned_tabs" and overwrite the signature. + // Store the old signature (without "pinned_tabs"). + prefs_->ClearPref("backup._version"); prefs_->ClearPref("backup.pinned_tabs"); - EXPECT_FALSE(IsSignatureValid()); - prefs_->SetString(kBackupSignature, old_signature); + ForceUpdateSignature(); EXPECT_TRUE(IsSignatureValid()); + // This will migrate backup to the latest version. RevalidateBackup(); // Now the backup should be valid and "pinned_tabs" is added back. @@ -169,6 +185,8 @@ TEST_F(ProtectedPrefsWatcherTest, PinnedTabsMigration) { EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList("backup.pinned_tabs"))); EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList(prefs::kPinnedTabs))); EXPECT_FALSE(prefs_watcher_->DidPrefChange(prefs::kPinnedTabs)); + EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber, + prefs_->GetInteger("backup._version")); } } // namespace protector |