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

Side by Side Diff: chrome/browser/ui/startup/startup_tab_provider_unittest.cc

Issue 2709393006: Do not show pinned tabs on multiple instances (Closed)
Patch Set: pkasting nit Created 3 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
« no previous file with comments | « chrome/browser/ui/startup/startup_tab_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/startup/startup_tab_provider.h" 5 #include "chrome/browser/ui/startup/startup_tab_provider.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 StartupTabProviderImpl::GetResetTriggerTabsForState(false); 192 StartupTabProviderImpl::GetResetTriggerTabsForState(false);
193 193
194 ASSERT_TRUE(output.empty()); 194 ASSERT_TRUE(output.empty());
195 } 195 }
196 196
197 TEST(StartupTabProviderTest, GetPinnedTabsForState) { 197 TEST(StartupTabProviderTest, GetPinnedTabsForState) {
198 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)}; 198 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)};
199 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT); 199 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT);
200 SessionStartupPref pref_urls(SessionStartupPref::Type::URLS); 200 SessionStartupPref pref_urls(SessionStartupPref::Type::URLS);
201 201
202 StartupTabs output = 202 StartupTabs output = StartupTabProviderImpl::GetPinnedTabsForState(
203 StartupTabProviderImpl::GetPinnedTabsForState(pref_default, pinned); 203 pref_default, pinned, false);
204 204
205 ASSERT_EQ(1U, output.size()); 205 ASSERT_EQ(1U, output.size());
206 EXPECT_EQ("www.google.com", output[0].url.host()); 206 EXPECT_EQ("www.google.com", output[0].url.host());
207 207
208 output = StartupTabProviderImpl::GetPinnedTabsForState(pref_urls, pinned); 208 output =
209 StartupTabProviderImpl::GetPinnedTabsForState(pref_urls, pinned, false);
209 210
210 ASSERT_EQ(1U, output.size()); 211 ASSERT_EQ(1U, output.size());
211 EXPECT_EQ("www.google.com", output[0].url.host()); 212 EXPECT_EQ("www.google.com", output[0].url.host());
212 } 213 }
213 214
214 TEST(StartupTabProviderTest, GetPinnedTabsForState_Negative) { 215 TEST(StartupTabProviderTest, GetPinnedTabsForState_Negative) {
215 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)}; 216 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)};
216 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); 217 SessionStartupPref pref_last(SessionStartupPref::Type::LAST);
218 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT);
217 219
220 // Session restore preference should block reading pinned tabs.
218 StartupTabs output = 221 StartupTabs output =
219 StartupTabProviderImpl::GetPinnedTabsForState(pref_last, pinned); 222 StartupTabProviderImpl::GetPinnedTabsForState(pref_last, pinned, false);
223
224 ASSERT_TRUE(output.empty());
225
226 // Pinned tabs are not added when this profile already has a nonempty tabbed
227 // browser open.
228 output =
229 StartupTabProviderImpl::GetPinnedTabsForState(pref_default, pinned, true);
220 230
221 ASSERT_TRUE(output.empty()); 231 ASSERT_TRUE(output.empty());
222 } 232 }
223 233
224 TEST(StartupTabProviderTest, GetPreferencesTabsForState) { 234 TEST(StartupTabProviderTest, GetPreferencesTabsForState) {
225 SessionStartupPref pref(SessionStartupPref::Type::URLS); 235 SessionStartupPref pref(SessionStartupPref::Type::URLS);
226 pref.urls = {GURL(base::ASCIIToUTF16("https://www.google.com"))}; 236 pref.urls = {GURL(base::ASCIIToUTF16("https://www.google.com"))};
227 237
228 StartupTabs output = 238 StartupTabs output =
229 StartupTabProviderImpl::GetPreferencesTabsForState(pref, false); 239 StartupTabProviderImpl::GetPreferencesTabsForState(pref, false);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 286 }
277 287
278 TEST(StartupTabProviderTest, GetNewTabPageTabsForState_Negative) { 288 TEST(StartupTabProviderTest, GetNewTabPageTabsForState_Negative) {
279 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); 289 SessionStartupPref pref_last(SessionStartupPref::Type::LAST);
280 290
281 StartupTabs output = 291 StartupTabs output =
282 StartupTabProviderImpl::GetNewTabPageTabsForState(pref_last); 292 StartupTabProviderImpl::GetNewTabPageTabsForState(pref_last);
283 293
284 ASSERT_TRUE(output.empty()); 294 ASSERT_TRUE(output.empty());
285 } 295 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_tab_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698