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

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

Issue 10384106: Extract StartupTabs and startup types from StartupBrowserCreator. (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/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/browser/ui/startup/startup_tab.h"
10 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 15
15 namespace protector { 16 namespace protector {
16 17
17 namespace { 18 namespace {
18 19
19 const char kStartupUrl1[] = "http://google.com"; 20 const char kStartupUrl1[] = "http://google.com";
(...skipping 15 matching lines...) Expand all
35 } 36 }
36 37
37 virtual void SetUp() OVERRIDE { 38 virtual void SetUp() OVERRIDE {
38 // Ensure initial session startup pref. 39 // Ensure initial session startup pref.
39 SessionStartupPref::SetStartupPref(&profile_, initial_startup_pref_); 40 SessionStartupPref::SetStartupPref(&profile_, initial_startup_pref_);
40 } 41 }
41 42
42 protected: 43 protected:
43 TestingProfile profile_; 44 TestingProfile profile_;
44 SessionStartupPref initial_startup_pref_; 45 SessionStartupPref initial_startup_pref_;
45 PinnedTabCodec::Tabs empty_pinned_tabs_; 46 StartupTabs empty_pinned_tabs_;
46 }; 47 };
47 48
48 TEST_F(SessionStartupChangeTest, InitAndApply) { 49 TEST_F(SessionStartupChangeTest, InitAndApply) {
49 // Create a change and apply it. 50 // Create a change and apply it.
50 SessionStartupPref backup_startup_pref(SessionStartupPref::LAST); 51 SessionStartupPref backup_startup_pref(SessionStartupPref::LAST);
51 scoped_ptr<BaseSettingChange> change( 52 scoped_ptr<BaseSettingChange> change(
52 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_, 53 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_,
53 backup_startup_pref, empty_pinned_tabs_)); 54 backup_startup_pref, empty_pinned_tabs_));
54 ASSERT_TRUE(change->Init(&profile_)); 55 ASSERT_TRUE(change->Init(&profile_));
55 // Setting is initially reverted to backup. 56 // Setting is initially reverted to backup.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 SessionStartupPref backup_startup_pref(SessionStartupPref::DEFAULT); 97 SessionStartupPref backup_startup_pref(SessionStartupPref::DEFAULT);
97 scoped_ptr<BaseSettingChange> change( 98 scoped_ptr<BaseSettingChange> change(
98 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_, 99 CreateSessionStartupChange(initial_startup_pref_, empty_pinned_tabs_,
99 backup_startup_pref, empty_pinned_tabs_)); 100 backup_startup_pref, empty_pinned_tabs_));
100 ASSERT_TRUE(change->Init(&profile_)); 101 ASSERT_TRUE(change->Init(&profile_));
101 EXPECT_EQ(open_ntp_caption, change->GetApplyButtonText()); 102 EXPECT_EQ(open_ntp_caption, change->GetApplyButtonText());
102 EXPECT_EQ(GURL(), change->GetNewSettingURL()); 103 EXPECT_EQ(GURL(), change->GetNewSettingURL());
103 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName()); 104 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName());
104 105
105 // Pinned tabs count as startup URLs as well. 106 // Pinned tabs count as startup URLs as well.
106 PinnedTabCodec::Tabs new_pinned_tabs; 107 StartupTabs new_pinned_tabs;
107 StartupBrowserCreator::LaunchWithProfile::Tab pinned_tab; 108 StartupTab pinned_tab;
108 pinned_tab.url = GURL(kStartupUrl3); 109 pinned_tab.url = GURL(kStartupUrl3);
109 new_pinned_tabs.push_back(pinned_tab); 110 new_pinned_tabs.push_back(pinned_tab);
110 change.reset( 111 change.reset(
111 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs, 112 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs,
112 backup_startup_pref, empty_pinned_tabs_)); 113 backup_startup_pref, empty_pinned_tabs_));
113 ASSERT_TRUE(change->Init(&profile_)); 114 ASSERT_TRUE(change->Init(&profile_));
114 EXPECT_EQ(open_url3_etc_caption, change->GetApplyButtonText()); 115 EXPECT_EQ(open_url3_etc_caption, change->GetApplyButtonText());
115 EXPECT_EQ(GURL(kStartupUrl3), change->GetNewSettingURL()); 116 EXPECT_EQ(GURL(kStartupUrl3), change->GetNewSettingURL());
116 EXPECT_EQ(UTF8ToUTF16(kStartupHost3), change->GetApplyDisplayName().second); 117 EXPECT_EQ(UTF8ToUTF16(kStartupHost3), change->GetApplyDisplayName().second);
117 118
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 change.reset( 182 change.reset(
182 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs, 183 CreateSessionStartupChange(initial_startup_pref_, new_pinned_tabs,
183 backup_startup_pref, empty_pinned_tabs_)); 184 backup_startup_pref, empty_pinned_tabs_));
184 ASSERT_TRUE(change->Init(&profile_)); 185 ASSERT_TRUE(change->Init(&profile_));
185 EXPECT_EQ(open_url3_etc_caption, change->GetApplyButtonText()); 186 EXPECT_EQ(open_url3_etc_caption, change->GetApplyButtonText());
186 EXPECT_EQ(GURL(kStartupUrl3), change->GetNewSettingURL()); 187 EXPECT_EQ(GURL(kStartupUrl3), change->GetNewSettingURL());
187 EXPECT_EQ(UTF8ToUTF16(kStartupHost3), change->GetApplyDisplayName().second); 188 EXPECT_EQ(UTF8ToUTF16(kStartupHost3), change->GetApplyDisplayName().second);
188 } 189 }
189 190
190 } // namespace protector 191 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/session_startup_change.cc ('k') | chrome/browser/tabs/pinned_tab_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698