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

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

Issue 9748016: [protector] Added UI for invalid Preferences backup case. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix unit-test. Created 8 years, 9 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/protector/prefs_backup_invalid_change_unittest.cc
diff --git a/chrome/browser/protector/prefs_backup_invalid_change_unittest.cc b/chrome/browser/protector/prefs_backup_invalid_change_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2ac7e5d3ba54afc14c4bc0e1d23369037e29b489
--- /dev/null
+++ b/chrome/browser/protector/prefs_backup_invalid_change_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/prefs/session_startup_pref.h"
+#include "chrome/browser/protector/base_setting_change.h"
+#include "chrome/test/base/testing_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace protector {
+
+namespace {
+
+const char kStartupUrl[] = "http://example.com/";
+
+} // namespace
+
+class PrefsBackupInvalidChangeTest : public testing::Test {
+ protected:
+ TestingProfile profile_;
+};
+
+// Test that correct default values are applied by Init.
+TEST_F(PrefsBackupInvalidChangeTest, Defaults) {
+ SessionStartupPref startup_pref(SessionStartupPref::URLS);
+ startup_pref.urls.push_back(GURL(kStartupUrl));
+ SessionStartupPref::SetStartupPref(&profile_, startup_pref);
+
+ scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
+ change->Init(&profile_);
+
+ SessionStartupPref new_startup_pref =
+ SessionStartupPref::GetStartupPref(&profile_);
+ // Startup type should be reset to default.
+ EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), new_startup_pref.type);
+ // Startup URLs should be left unchanged.
+ EXPECT_EQ(1UL, new_startup_pref.urls.size());
+ EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
+}
+
+// Test that "restore last session" setting is not changed by Init.
+TEST_F(PrefsBackupInvalidChangeTest, DefaultsWithSessionRestore) {
+ SessionStartupPref startup_pref(SessionStartupPref::LAST);
+ startup_pref.urls.push_back(GURL(kStartupUrl));
+ SessionStartupPref::SetStartupPref(&profile_, startup_pref);
+
+ scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
+ change->Init(&profile_);
+
+ SessionStartupPref new_startup_pref =
+ SessionStartupPref::GetStartupPref(&profile_);
+ // Both startup type and startup URLs should be left unchanged.
+ EXPECT_EQ(SessionStartupPref::LAST, new_startup_pref.type);
+ EXPECT_EQ(1UL, new_startup_pref.urls.size());
+ EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
+}
+
+} // namespace protector
« no previous file with comments | « chrome/browser/protector/prefs_backup_invalid_change.cc ('k') | chrome/browser/protector/protected_prefs_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698