| OLD | NEW |
| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 ASSERT_TRUE(output.empty()); | 191 ASSERT_TRUE(output.empty()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 TEST(StartupTabProviderTest, CheckPinnedTabPolicy) { | 194 TEST(StartupTabProviderTest, CheckPinnedTabPolicy) { |
| 195 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)}; | 195 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)}; |
| 196 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT); | 196 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT); |
| 197 SessionStartupPref pref_urls(SessionStartupPref::Type::URLS); | 197 SessionStartupPref pref_urls(SessionStartupPref::Type::URLS); |
| 198 | 198 |
| 199 StartupTabs output = | 199 StartupTabs output = |
| 200 StartupTabProviderImpl::CheckPinnedTabPolicy(pref_default, pinned); | 200 StartupTabProviderImpl::CheckPinnedTabPolicy(pref_default, pinned, false); |
| 201 | 201 |
| 202 ASSERT_EQ(1U, output.size()); | 202 ASSERT_EQ(1U, output.size()); |
| 203 EXPECT_EQ("www.google.com", output[0].url.host()); | 203 EXPECT_EQ("www.google.com", output[0].url.host()); |
| 204 | 204 |
| 205 output = StartupTabProviderImpl::CheckPinnedTabPolicy(pref_urls, pinned); | 205 output = StartupTabProviderImpl::CheckPinnedTabPolicy(pref_urls, pinned, false
); |
| 206 | 206 |
| 207 ASSERT_EQ(1U, output.size()); | 207 ASSERT_EQ(1U, output.size()); |
| 208 EXPECT_EQ("www.google.com", output[0].url.host()); | 208 EXPECT_EQ("www.google.com", output[0].url.host()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 TEST(StartupTabProviderTest, CheckPinnedTabPolicy_Negative) { | 211 TEST(StartupTabProviderTest, CheckPinnedTabPolicy_Negative) { |
| 212 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)}; | 212 StartupTabs pinned = {StartupTab(GURL("https://www.google.com"), true)}; |
| 213 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); | 213 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); |
| 214 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT); |
| 214 | 215 |
| 216 // Session restore preference should block reading pinned tabs. |
| 215 StartupTabs output = | 217 StartupTabs output = |
| 216 StartupTabProviderImpl::CheckPinnedTabPolicy(pref_last, pinned); | 218 StartupTabProviderImpl::CheckPinnedTabPolicy(pref_last, pinned, false); |
| 219 |
| 220 ASSERT_TRUE(output.empty()); |
| 221 |
| 222 // Pinned tabs are not added when this profile already has a nonempty tabbed |
| 223 // browser open. |
| 224 output = |
| 225 StartupTabProviderImpl::CheckPinnedTabPolicy(pref_default, pinned, true); |
| 217 | 226 |
| 218 ASSERT_TRUE(output.empty()); | 227 ASSERT_TRUE(output.empty()); |
| 219 } | 228 } |
| 220 | 229 |
| 221 TEST(StartupTabProviderTest, CheckPreferencesTabPolicy) { | 230 TEST(StartupTabProviderTest, CheckPreferencesTabPolicy) { |
| 222 SessionStartupPref pref(SessionStartupPref::Type::URLS); | 231 SessionStartupPref pref(SessionStartupPref::Type::URLS); |
| 223 pref.urls = {GURL(base::ASCIIToUTF16("https://www.google.com"))}; | 232 pref.urls = {GURL(base::ASCIIToUTF16("https://www.google.com"))}; |
| 224 | 233 |
| 225 StartupTabs output = | 234 StartupTabs output = |
| 226 StartupTabProviderImpl::CheckPreferencesTabPolicy(pref, false); | 235 StartupTabProviderImpl::CheckPreferencesTabPolicy(pref, false); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 282 } |
| 274 | 283 |
| 275 TEST(StartupTabProviderTest, CheckNewTabPageTabPolicy_Negative) { | 284 TEST(StartupTabProviderTest, CheckNewTabPageTabPolicy_Negative) { |
| 276 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); | 285 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); |
| 277 | 286 |
| 278 StartupTabs output = | 287 StartupTabs output = |
| 279 StartupTabProviderImpl::CheckNewTabPageTabPolicy(pref_last); | 288 StartupTabProviderImpl::CheckNewTabPageTabPolicy(pref_last); |
| 280 | 289 |
| 281 ASSERT_TRUE(output.empty()); | 290 ASSERT_TRUE(output.empty()); |
| 282 } | 291 } |
| OLD | NEW |