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

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

Issue 9968007: [protector] Support for collapsing multiple changes into a single one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 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
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/session_startup_pref.h" 8 #include "chrome/browser/prefs/session_startup_pref.h"
9 #include "chrome/browser/protector/base_setting_change.h" 9 #include "chrome/browser/protector/base_setting_change.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 14
15 namespace protector { 15 namespace protector {
16 16
17 namespace { 17 namespace {
18 18
19 const char kStartupUrl1[] = "http://google.com"; 19 const char kStartupUrl1[] = "http://google.com";
20 const char kStartupUrl2[] = "http://example.com"; 20 const char kStartupUrl2[] = "http://example.com";
21 const char kStartupHost1[] = "google.com";
22 const char kStartupHost2[] = "example.com";
23
24 const BaseSettingChange::DisplayName kNoDisplayName(
25 BaseSettingChange::kDefaultNamePriority, string16());
21 26
22 } // namespace 27 } // namespace
23 28
24 class SessionStartupChangeTest : public testing::Test { 29 class SessionStartupChangeTest : public testing::Test {
25 public: 30 public:
26 SessionStartupChangeTest() 31 SessionStartupChangeTest()
27 : initial_startup_pref_(SessionStartupPref::DEFAULT) { 32 : initial_startup_pref_(SessionStartupPref::DEFAULT) {
28 } 33 }
29 34
30 virtual void SetUp() OVERRIDE { 35 virtual void SetUp() OVERRIDE {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 UTF8ToUTF16(GURL(kStartupUrl2).host())); 87 UTF8ToUTF16(GURL(kStartupUrl2).host()));
83 88
84 // Open NTP. 89 // Open NTP.
85 initial_startup_pref_.type = SessionStartupPref::DEFAULT; 90 initial_startup_pref_.type = SessionStartupPref::DEFAULT;
86 SessionStartupPref backup_startup_pref(SessionStartupPref::DEFAULT); 91 SessionStartupPref backup_startup_pref(SessionStartupPref::DEFAULT);
87 scoped_ptr<BaseSettingChange> change( 92 scoped_ptr<BaseSettingChange> change(
88 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_, 93 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_,
89 backup_startup_pref, empty_pinned_tabs_)); 94 backup_startup_pref, empty_pinned_tabs_));
90 ASSERT_TRUE(change->Init(&profile_)); 95 ASSERT_TRUE(change->Init(&profile_));
91 EXPECT_EQ(open_ntp_caption, change->GetApplyButtonText()); 96 EXPECT_EQ(open_ntp_caption, change->GetApplyButtonText());
97 EXPECT_EQ(GURL(), change->GetNewSettingURL());
98 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName());
92 99
93 // Pinned tabs count as startup URLs as well. 100 // Pinned tabs count as startup URLs as well.
94 PinnedTabCodec::Tabs new_pinned_tabs; 101 PinnedTabCodec::Tabs new_pinned_tabs;
95 BrowserInit::LaunchWithProfile::Tab pinned_tab; 102 BrowserInit::LaunchWithProfile::Tab pinned_tab;
96 pinned_tab.url = GURL(kStartupUrl2); 103 pinned_tab.url = GURL(kStartupUrl2);
97 new_pinned_tabs.push_back(pinned_tab); 104 new_pinned_tabs.push_back(pinned_tab);
98 change.reset( 105 change.reset(
99 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs, 106 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs,
100 backup_startup_pref, empty_pinned_tabs_)); 107 backup_startup_pref, empty_pinned_tabs_));
101 ASSERT_TRUE(change->Init(&profile_)); 108 ASSERT_TRUE(change->Init(&profile_));
102 EXPECT_EQ(open_url2_etc_caption, change->GetApplyButtonText()); 109 EXPECT_EQ(open_url2_etc_caption, change->GetApplyButtonText());
110 EXPECT_EQ(GURL(kStartupUrl2), change->GetNewSettingURL());
111 EXPECT_EQ(UTF8ToUTF16(kStartupHost2), change->GetApplyDisplayName().second);
103 112
104 // "Open URLs" with no URLs is the same as "Open NTP". 113 // "Open URLs" with no URLs is the same as "Open NTP".
105 initial_startup_pref_.type = SessionStartupPref::URLS; 114 initial_startup_pref_.type = SessionStartupPref::URLS;
106 change.reset( 115 change.reset(
107 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_, 116 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_,
108 backup_startup_pref, empty_pinned_tabs_)); 117 backup_startup_pref, empty_pinned_tabs_));
109 ASSERT_TRUE(change->Init(&profile_)); 118 ASSERT_TRUE(change->Init(&profile_));
110 EXPECT_EQ(open_ntp_caption, change->GetApplyButtonText()); 119 EXPECT_EQ(open_ntp_caption, change->GetApplyButtonText());
120 EXPECT_EQ(GURL(), change->GetNewSettingURL());
121 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName());
111 122
112 // Single URL. 123 // Single URL.
113 initial_startup_pref_.urls.push_back(GURL(kStartupUrl1)); 124 initial_startup_pref_.urls.push_back(GURL(kStartupUrl1));
114 change.reset( 125 change.reset(
115 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_, 126 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_,
116 backup_startup_pref, empty_pinned_tabs_)); 127 backup_startup_pref, empty_pinned_tabs_));
117 ASSERT_TRUE(change->Init(&profile_)); 128 ASSERT_TRUE(change->Init(&profile_));
118 EXPECT_EQ(open_url1_etc_caption, change->GetApplyButtonText()); 129 EXPECT_EQ(open_url1_etc_caption, change->GetApplyButtonText());
130 EXPECT_EQ(GURL(kStartupUrl1), change->GetNewSettingURL());
131 EXPECT_EQ(UTF8ToUTF16(kStartupHost1), change->GetApplyDisplayName().second);
119 132
120 // Multiple URLs: name of the first one used. 133 // Multiple URLs: name of the first one used.
121 initial_startup_pref_.urls.push_back(GURL(kStartupUrl2)); 134 initial_startup_pref_.urls.push_back(GURL(kStartupUrl2));
122 change.reset( 135 change.reset(
123 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_, 136 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_,
124 backup_startup_pref, empty_pinned_tabs_)); 137 backup_startup_pref, empty_pinned_tabs_));
125 ASSERT_TRUE(change->Init(&profile_)); 138 ASSERT_TRUE(change->Init(&profile_));
126 EXPECT_EQ(open_url1_etc_caption, change->GetApplyButtonText()); 139 EXPECT_EQ(open_url1_etc_caption, change->GetApplyButtonText());
140 EXPECT_EQ(GURL(kStartupUrl1), change->GetNewSettingURL());
141 EXPECT_EQ(UTF8ToUTF16(kStartupHost1), change->GetApplyDisplayName().second);
127 142
128 // Pinned tabs go after the startup URLs. 143 // Pinned tabs go after the startup URLs.
129 change.reset( 144 change.reset(
130 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs, 145 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs,
131 backup_startup_pref, empty_pinned_tabs_)); 146 backup_startup_pref, empty_pinned_tabs_));
132 ASSERT_TRUE(change->Init(&profile_)); 147 ASSERT_TRUE(change->Init(&profile_));
133 EXPECT_EQ(open_url1_etc_caption, change->GetApplyButtonText()); 148 EXPECT_EQ(open_url1_etc_caption, change->GetApplyButtonText());
149 EXPECT_EQ(GURL(kStartupUrl1), change->GetNewSettingURL());
150 EXPECT_EQ(UTF8ToUTF16(kStartupHost1), change->GetApplyDisplayName().second);
134 } 151 }
135 152
136 } // namespace protector 153 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/session_startup_change.cc ('k') | chrome/browser/protector/settings_change_global_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698