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_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/ui/startup/startup_tab_provider.h" | 8 #include "chrome/browser/ui/startup/startup_tab_provider.h" |
9 #include "chrome/common/url_constants.cc" | 9 #include "chrome/common/url_constants.cc" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // Bits for FakeStartupTabProvider options. | 14 // Bits for FakeStartupTabProvider options. |
15 constexpr uint32_t kOnboardingTabs = 1 << 0; | 15 constexpr uint32_t kOnboardingTabs = 1 << 0; |
16 constexpr uint32_t kDistributionFirstRunTabs = 1 << 1; | 16 constexpr uint32_t kDistributionFirstRunTabs = 1 << 1; |
17 constexpr uint32_t kResetTriggerTabs = 1 << 2; | 17 constexpr uint32_t kResetTriggerTabs = 1 << 2; |
18 constexpr uint32_t kPinnedTabs = 1 << 3; | 18 constexpr uint32_t kPinnedTabs = 1 << 3; |
19 constexpr uint32_t kPreferencesTabs = 1 << 4; | 19 constexpr uint32_t kPreferencesTabs = 1 << 4; |
20 constexpr uint32_t kNewTabPageTabs = 1 << 5; | 20 constexpr uint32_t kNewTabPageTabs = 1 << 5; |
21 | 21 |
22 class FakeStartupTabProvider : public StartupTabProvider { | 22 class FakeStartupTabProvider : public StartupTabProvider { |
23 public: | 23 public: |
24 // For each option passed, the corresponding adder below will add a sentinel | 24 // For each option passed, the corresponding adder below will add a sentinel |
25 // tab and return true. For options not passed, the adder will return false. | 25 // tab and return true. For options not passed, the adder will return false. |
26 explicit FakeStartupTabProvider(uint32_t options) : options_(options) {} | 26 explicit FakeStartupTabProvider(uint32_t options) : options_(options) {} |
27 | 27 |
28 StartupTabs GetOnboardingTabs() const override { | 28 StartupTabs GetOnboardingTabs(Profile* profile) const override { |
29 StartupTabs tabs; | 29 StartupTabs tabs; |
30 if (options_ & kOnboardingTabs) | 30 if (options_ & kOnboardingTabs) |
31 tabs.emplace_back(GURL("https://onboarding"), false); | 31 tabs.emplace_back(GURL("https://onboarding"), false); |
32 return tabs; | 32 return tabs; |
33 } | 33 } |
34 | 34 |
35 StartupTabs GetDistributionFirstRunTabs( | 35 StartupTabs GetDistributionFirstRunTabs( |
36 StartupBrowserCreator* browser_creator) const override { | 36 StartupBrowserCreator* browser_creator) const override { |
37 StartupTabs tabs; | 37 StartupTabs tabs; |
38 if (options_ & kDistributionFirstRunTabs) | 38 if (options_ & kDistributionFirstRunTabs) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 base::FilePath(), base::CommandLine(base::CommandLine::NO_PROGRAM), | 179 base::FilePath(), base::CommandLine(base::CommandLine::NO_PROGRAM), |
180 chrome::startup::IS_FIRST_RUN); | 180 chrome::startup::IS_FIRST_RUN); |
181 | 181 |
182 StartupTabs output = impl.DetermineStartupTabs(provider_allows_ntp, | 182 StartupTabs output = impl.DetermineStartupTabs(provider_allows_ntp, |
183 StartupTabs(), false, false); | 183 StartupTabs(), false, false); |
184 ASSERT_EQ(3U, output.size()); | 184 ASSERT_EQ(3U, output.size()); |
185 EXPECT_EQ("reset-trigger", output[0].url.host()); | 185 EXPECT_EQ("reset-trigger", output[0].url.host()); |
186 EXPECT_EQ("new-tab", output[1].url.host()); | 186 EXPECT_EQ("new-tab", output[1].url.host()); |
187 EXPECT_EQ("pinned", output[2].url.host()); | 187 EXPECT_EQ("pinned", output[2].url.host()); |
188 } | 188 } |
OLD | NEW |