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

Side by Side Diff: chrome/browser/protector/homepage_change_unittest.cc

Issue 10066013: [protector] Homepage UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added pyauto tests. 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 unified diff | Download patch | Annotate | Revision Log
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 "base/utf_string_conversions.h"
7 #include "base/values.h"
8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/protector/base_setting_change.h"
10 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace protector {
15
16 namespace {
17
18 std::string kHomepage1 = "http://google.com/";
19 std::string kHomepage2 = "http://example.com/";
20
21 }
22
23 class HomepageChangeTest : public testing::Test {
24 virtual void SetUp() OVERRIDE {
25 prefs_ = profile_.GetPrefs();
26 }
27
28 protected:
29 TestingProfile profile_;
30 PrefService* prefs_;
31 };
32
33 TEST_F(HomepageChangeTest, InitAndApply) {
34 prefs_->SetString(prefs::kHomePage, kHomepage1);
35
36 // Create a change and apply it.
37 scoped_ptr<BaseSettingChange> change(
38 CreateHomepageChange(kHomepage1, false, true, kHomepage2, false, true));
39 ASSERT_TRUE(change->Init(&profile_));
40 // Setting is initially reverted to backup.
41 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage));
42
43 change->Apply(NULL); // |browser| is unused.
44 // New setting active now.
45 EXPECT_EQ(kHomepage1, prefs_->GetString(prefs::kHomePage));
46 }
47
48 TEST_F(HomepageChangeTest, InitAndDiscard) {
49 prefs_->SetString(prefs::kHomePage, kHomepage1);
50
51 // Create a change and apply it.
52 scoped_ptr<BaseSettingChange> change(
53 CreateHomepageChange(kHomepage1, false, true, kHomepage2, false, true));
54 ASSERT_TRUE(change->Init(&profile_));
55 // Setting is initially reverted to backup.
56 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage));
57
58 change->Discard(NULL); // |browser| is unused.
59 // Nothing changed by Discard.
60 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage));
61 }
62
63 } // namespace protector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698