| Index: chrome/browser/first_run/first_run_unittest.cc
|
| diff --git a/chrome/browser/first_run/first_run_unittest.cc b/chrome/browser/first_run/first_run_unittest.cc
|
| index 47d5d20cce3a8ddac9a7322d883e0a00443a1eda..55090f9e28a2400da2b4447c034a0c02ba9def64 100644
|
| --- a/chrome/browser/first_run/first_run_unittest.cc
|
| +++ b/chrome/browser/first_run/first_run_unittest.cc
|
| @@ -5,13 +5,16 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/files/file_util.h"
|
| #include "base/macros.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/test/scoped_path_override.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/first_run/first_run.h"
|
| #include "chrome/browser/first_run/first_run_internal.h"
|
| #include "chrome/common/chrome_paths.h"
|
| +#include "chrome/common/url_constants.h"
|
| #include "chrome/installer/util/master_preferences.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "url/gurl.h"
|
|
|
| namespace first_run {
|
|
|
| @@ -86,4 +89,71 @@ TEST_F(FirstRunTest,
|
| EXPECT_FALSE(out_prefs.welcome_page_on_os_upgrade_enabled);
|
| }
|
|
|
| +TEST_F(FirstRunTest, ProcessMasterPrefsTabs) {
|
| + std::vector<GURL> input;
|
| + input.push_back(GURL(base::ASCIIToUTF16("https://new_tab_page")));
|
| + input.push_back(GURL(base::ASCIIToUTF16("https://www.google.com")));
|
| + input.push_back(GURL(base::ASCIIToUTF16("https://welcome_page")));
|
| + std::vector<GURL> output = ProcessMasterPrefsTabs(input);
|
| + ASSERT_EQ(3U, output.size());
|
| + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL).host(), output[0].host());
|
| + EXPECT_EQ("www.google.com", output[1].host());
|
| + EXPECT_EQ(GetWelcomePageURL().host(), output[2].host());
|
| +}
|
| +
|
| +// No flags, no sentinel present. Welcome should be surfaced.
|
| +TEST_F(FirstRunTest, GetOnboardingTabs_StandardFirstRun) {
|
| + FirstRunSystemStatus status;
|
| + status.os_class = FirstRunSystemStatus::OperatingSystemClass::STANDARD;
|
| + status.is_sentinel_present = false;
|
| + status.is_force_flag_on = false;
|
| + status.is_suppress_flag_on = false;
|
| +
|
| + std::vector<GURL> output = GetOnboardingTabs(status);
|
| +
|
| + ASSERT_EQ(1U, output.size());
|
| + EXPECT_EQ(GetWelcomePageURL().host(), output[0].host());
|
| +}
|
| +
|
| +// Sentinel present, no flags. Nothing should be shown.
|
| +TEST_F(FirstRunTest, GetOnboardingTabs_StandardWithSentinel) {
|
| + FirstRunSystemStatus status;
|
| + status.os_class = FirstRunSystemStatus::OperatingSystemClass::STANDARD;
|
| + status.is_sentinel_present = true;
|
| + status.is_force_flag_on = false;
|
| + status.is_suppress_flag_on = true;
|
| +
|
| + std::vector<GURL> output = GetOnboardingTabs(status);
|
| +
|
| + EXPECT_EQ(0U, output.size());
|
| +}
|
| +
|
| +// Even without sentinel, the suppress flag means no tabs come back.
|
| +TEST_F(FirstRunTest, GetOnboardingTabs_StandardSuppressed) {
|
| + FirstRunSystemStatus status;
|
| + status.os_class = FirstRunSystemStatus::OperatingSystemClass::STANDARD;
|
| + status.is_sentinel_present = false;
|
| + status.is_force_flag_on = false;
|
| + status.is_suppress_flag_on = true;
|
| +
|
| + std::vector<GURL> output = GetOnboardingTabs(status);
|
| +
|
| + EXPECT_EQ(0U, output.size());
|
| +}
|
| +
|
| +// Force First Run flag overrides both the presence of the sentinel file and
|
| +// the suppress flag, and the welcome page is still shown.
|
| +TEST_F(FirstRunTest, GetOnboardingTabs_StandardForced) {
|
| + FirstRunSystemStatus status;
|
| + status.os_class = FirstRunSystemStatus::OperatingSystemClass::STANDARD;
|
| + status.is_sentinel_present = true;
|
| + status.is_force_flag_on = true;
|
| + status.is_suppress_flag_on = true;
|
| +
|
| + std::vector<GURL> output = GetOnboardingTabs(status);
|
| +
|
| + ASSERT_EQ(1U, output.size());
|
| + EXPECT_EQ(GetWelcomePageURL().host(), output[0].host());
|
| +}
|
| +
|
| } // namespace first_run
|
|
|