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

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

Issue 10261002: [protector] Homepage UI polishing. (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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/protector/base_setting_change.h" 9 #include "chrome/browser/protector/base_setting_change.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "grit/generated_resources.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/base/l10n/l10n_util.h"
13 15
14 namespace protector { 16 namespace protector {
15 17
16 namespace { 18 namespace {
17 19
18 std::string kHomepage1 = "http://google.com/"; 20 std::string kHomepage1 = "http://google.com/";
19 std::string kHomepage2 = "http://example.com/"; 21 std::string kHomepage2 = "http://example.com/";
20 22
21 } 23 }
22 24
(...skipping 30 matching lines...) Expand all
53 CreateHomepageChange(kHomepage1, false, true, kHomepage2, false, true)); 55 CreateHomepageChange(kHomepage1, false, true, kHomepage2, false, true));
54 ASSERT_TRUE(change->Init(&profile_)); 56 ASSERT_TRUE(change->Init(&profile_));
55 // Setting is initially reverted to backup. 57 // Setting is initially reverted to backup.
56 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage)); 58 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage));
57 59
58 change->Discard(NULL); // |browser| is unused. 60 change->Discard(NULL); // |browser| is unused.
59 // Nothing changed by Discard. 61 // Nothing changed by Discard.
60 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage)); 62 EXPECT_EQ(kHomepage2, prefs_->GetString(prefs::kHomePage));
61 } 63 }
62 64
65 TEST_F(HomepageChangeTest, DiscardButtonCaptions) {
66 // NTP -> NTP.
67 scoped_ptr<BaseSettingChange> change(
68 CreateHomepageChange(kHomepage1, true, true, kHomepage2, true, true));
69 ASSERT_TRUE(change->Init(&profile_));
70 string16 generic_caption(l10n_util::GetStringUTF16(IDS_KEEP_SETTING));
71 EXPECT_EQ(generic_caption, change->GetDiscardButtonText());
72
73 // NTP -> NTP.
74 change.reset(
75 CreateHomepageChange("", false, true, kHomepage2, true, true));
76 ASSERT_TRUE(change->Init(&profile_));
77 EXPECT_EQ(generic_caption, change->GetDiscardButtonText());
78
79 // NTP -> NTP.
whywhat 2012/04/29 16:24:15 The comments before the last three sections are id
Ivan Korotkov 2012/05/02 11:17:26 You're right, they'd better be separated. NTP can
whywhat 2012/05/02 11:23:48 My point is that the comments should explain this
Ivan Korotkov 2012/05/02 11:29:40 Done.
80 change.reset(
81 CreateHomepageChange(kHomepage1, true, true, "", false, true));
82 ASSERT_TRUE(change->Init(&profile_));
83 EXPECT_EQ(generic_caption, change->GetDiscardButtonText());
84
85 // NTP -> kHomepage2.
86 change.reset(
87 CreateHomepageChange(kHomepage1, true, true, kHomepage2, false, true));
88 ASSERT_TRUE(change->Init(&profile_));
89 EXPECT_NE(generic_caption, change->GetDiscardButtonText());
90
91 // kHomepage1 -> NTP.
92 change.reset(
93 CreateHomepageChange(kHomepage1, false, true, kHomepage2, true, true));
94 ASSERT_TRUE(change->Init(&profile_));
95 EXPECT_NE(generic_caption, change->GetDiscardButtonText());
96
97 // kHomepage1 -> kHomepage1.
98 change.reset(
99 CreateHomepageChange(kHomepage1, false, true, kHomepage1, false, true));
100 ASSERT_TRUE(change->Init(&profile_));
101 EXPECT_EQ(generic_caption, change->GetDiscardButtonText());
102 }
103
63 } // namespace protector 104 } // namespace protector
OLDNEW
« chrome/browser/protector/homepage_change.cc ('K') | « chrome/browser/protector/homepage_change.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698