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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/prefs/session_startup_pref.h"
7 #include "chrome/browser/protector/base_setting_change.h"
8 #include "chrome/test/base/testing_profile.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace protector {
12
13 namespace {
14
15 const char kStartupUrl[] = "http://example.com/";
16
17 } // namespace
18
19 class PrefsBackupInvalidChangeTest : public testing::Test {
20 protected:
21 TestingProfile profile_;
22 };
23
24 // Test that correct default values are applied by Init.
25 TEST_F(PrefsBackupInvalidChangeTest, Defaults) {
26 SessionStartupPref startup_pref(SessionStartupPref::URLS);
27 startup_pref.urls.push_back(GURL(kStartupUrl));
28 SessionStartupPref::SetStartupPref(&profile_, startup_pref);
29
30 scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
31 change->Init(&profile_);
32
33 SessionStartupPref new_startup_pref =
34 SessionStartupPref::GetStartupPref(&profile_);
35 // Startup type should be reset to default.
36 EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), new_startup_pref.type);
37 // Startup URLs should be left unchanged.
38 EXPECT_EQ(1UL, new_startup_pref.urls.size());
39 EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
40 }
41
42 // Test that "restore last session" setting is not changed by Init.
43 TEST_F(PrefsBackupInvalidChangeTest, DefaultsWithSessionRestore) {
44 SessionStartupPref startup_pref(SessionStartupPref::LAST);
45 startup_pref.urls.push_back(GURL(kStartupUrl));
46 SessionStartupPref::SetStartupPref(&profile_, startup_pref);
47
48 scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
49 change->Init(&profile_);
50
51 SessionStartupPref new_startup_pref =
52 SessionStartupPref::GetStartupPref(&profile_);
53 // Both startup type and startup URLs should be left unchanged.
54 EXPECT_EQ(SessionStartupPref::LAST, new_startup_pref.type);
55 EXPECT_EQ(1UL, new_startup_pref.urls.size());
56 EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
57 }
58
59 } // namespace protector
OLDNEW
« 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