Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / first_run / first_run_unittest.cc
blob0ec0c08a12dd8354e62e86aeaaef9048be624323
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
3 // found in the LICENSE file.
5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "base/files/file_util.h"
8 #include "base/test/scoped_path_override.h"
9 #include "base/values.h"
10 #include "chrome/browser/first_run/first_run.h"
11 #include "chrome/browser/first_run/first_run_internal.h"
12 #include "chrome/common/chrome_paths.h"
13 #include "chrome/installer/util/master_preferences.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace first_run {
18 class FirstRunTest : public testing::Test {
19 protected:
20 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {}
21 ~FirstRunTest() override {}
23 private:
24 base::ScopedPathOverride user_data_dir_override_;
26 DISALLOW_COPY_AND_ASSIGN(FirstRunTest);
29 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeed) {
30 installer::MasterPreferences install_prefs("{ \"variations_seed\":\"xyz\" }");
31 EXPECT_EQ(1U, install_prefs.master_dictionary().size());
33 MasterPrefs out_prefs;
34 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
35 EXPECT_EQ("xyz", out_prefs.variations_seed);
36 // Variations prefs should have been extracted (removed) from the dictionary.
37 EXPECT_TRUE(install_prefs.master_dictionary().empty());
40 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_NoVariationsSeed) {
41 installer::MasterPreferences install_prefs("{ }");
42 EXPECT_TRUE(install_prefs.master_dictionary().empty());
44 MasterPrefs out_prefs;
45 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
46 EXPECT_TRUE(out_prefs.variations_seed.empty());
47 EXPECT_TRUE(out_prefs.variations_seed_signature.empty());
50 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeedSignature) {
51 installer::MasterPreferences install_prefs(
52 "{ \"variations_seed\":\"xyz\", \"variations_seed_signature\":\"abc\" }");
53 EXPECT_EQ(2U, install_prefs.master_dictionary().size());
55 MasterPrefs out_prefs;
56 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
57 EXPECT_EQ("xyz", out_prefs.variations_seed);
58 EXPECT_EQ("abc", out_prefs.variations_seed_signature);
59 // Variations prefs should have been extracted (removed) from the dictionary.
60 EXPECT_TRUE(install_prefs.master_dictionary().empty());
63 TEST_F(FirstRunTest,
64 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeMissing) {
65 installer::MasterPreferences install_prefs("{\"distribution\":{}}");
66 MasterPrefs out_prefs;
67 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
68 EXPECT_TRUE(out_prefs.welcome_page_on_os_upgrade_enabled);
71 TEST_F(FirstRunTest,
72 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeEnabled) {
73 installer::MasterPreferences install_prefs(
74 "{\"distribution\":{\"welcome_page_on_os_upgrade_enabled\": true}}");
75 MasterPrefs out_prefs;
76 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
77 EXPECT_TRUE(out_prefs.welcome_page_on_os_upgrade_enabled);
80 TEST_F(FirstRunTest,
81 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeDisabled) {
82 installer::MasterPreferences install_prefs(
83 "{\"distribution\":{\"welcome_page_on_os_upgrade_enabled\": false}}");
84 MasterPrefs out_prefs;
85 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
86 EXPECT_FALSE(out_prefs.welcome_page_on_os_upgrade_enabled);
89 } // namespace first_run