OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/scoped_path_override.h" | 9 #include "base/test/scoped_path_override.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/first_run/first_run.h" | 11 #include "chrome/browser/first_run/first_run.h" |
11 #include "chrome/browser/first_run/first_run_internal.h" | 12 #include "chrome/browser/first_run/first_run_internal.h" |
12 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/url_constants.h" |
13 #include "chrome/installer/util/master_preferences.h" | 15 #include "chrome/installer/util/master_preferences.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "url/gurl.h" |
15 | 18 |
16 namespace first_run { | 19 namespace first_run { |
17 | 20 |
18 class FirstRunTest : public testing::Test { | 21 class FirstRunTest : public testing::Test { |
19 protected: | 22 protected: |
20 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} | 23 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} |
21 ~FirstRunTest() override {} | 24 ~FirstRunTest() override {} |
22 | 25 |
23 private: | 26 private: |
24 base::ScopedPathOverride user_data_dir_override_; | 27 base::ScopedPathOverride user_data_dir_override_; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 82 |
80 TEST_F(FirstRunTest, | 83 TEST_F(FirstRunTest, |
81 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeDisabled) { | 84 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeDisabled) { |
82 installer::MasterPreferences install_prefs( | 85 installer::MasterPreferences install_prefs( |
83 "{\"distribution\":{\"welcome_page_on_os_upgrade_enabled\": false}}"); | 86 "{\"distribution\":{\"welcome_page_on_os_upgrade_enabled\": false}}"); |
84 MasterPrefs out_prefs; | 87 MasterPrefs out_prefs; |
85 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); | 88 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); |
86 EXPECT_FALSE(out_prefs.welcome_page_on_os_upgrade_enabled); | 89 EXPECT_FALSE(out_prefs.welcome_page_on_os_upgrade_enabled); |
87 } | 90 } |
88 | 91 |
| 92 TEST_F(FirstRunTest, ProcessMasterPrefsTabs) { |
| 93 std::vector<GURL> input; |
| 94 input.push_back(GURL(base::ASCIIToUTF16("https://new_tab_page"))); |
| 95 input.push_back(GURL(base::ASCIIToUTF16("https://www.google.com"))); |
| 96 input.push_back(GURL(base::ASCIIToUTF16("https://welcome_page"))); |
| 97 std::vector<GURL> output = ProcessMasterPrefsTabs(input); |
| 98 ASSERT_EQ(3U, output.size()); |
| 99 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL).host(), output[0].host()); |
| 100 EXPECT_EQ("www.google.com", output[1].host()); |
| 101 EXPECT_EQ(GetWelcomePageURL().host(), output[2].host()); |
| 102 } |
| 103 |
| 104 TEST_F(FirstRunTest, GetOnboardingTabs_FirstRun) { |
| 105 SetFirstRunForTesting(true); |
| 106 std::vector<GURL> output = GetOnboardingTabs(); |
| 107 if (IsWin10()) { |
| 108 // TODO(tmartino): Update when Win10 is implemented. |
| 109 ASSERT_EQ(0U, output.size()); |
| 110 } else { |
| 111 ASSERT_EQ(1U, output.size()); |
| 112 EXPECT_EQ(GetWelcomePageURL().host(), output[0].host()); |
| 113 } |
| 114 } |
| 115 |
| 116 TEST_F(FirstRunTest, GetOnboardingTabs_SubsequentRun) { |
| 117 SetFirstRunForTesting(false); |
| 118 std::vector<GURL> output = GetOnboardingTabs(); |
| 119 ASSERT_TRUE(output.empty()); |
| 120 } |
| 121 |
89 } // namespace first_run | 122 } // namespace first_run |
OLD | NEW |