Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: chrome/browser/first_run/first_run_unittest.cc

Issue 2919223002: [Cleanup] Remove the obsolete variations_seed pref. (Closed)
Patch Set: Fix the test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/test/scoped_path_override.h" 8 #include "base/test/scoped_path_override.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/first_run/first_run.h" 10 #include "chrome/browser/first_run/first_run.h"
11 #include "chrome/browser/first_run/first_run_internal.h" 11 #include "chrome/browser/first_run/first_run_internal.h"
12 #include "chrome/common/chrome_paths.h" 12 #include "chrome/common/chrome_paths.h"
13 #include "chrome/installer/util/master_preferences.h" 13 #include "chrome/installer/util/master_preferences.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace first_run { 16 namespace first_run {
17 17
18 class FirstRunTest : public testing::Test { 18 class FirstRunTest : public testing::Test {
19 protected: 19 protected:
20 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} 20 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {}
21 ~FirstRunTest() override {} 21 ~FirstRunTest() override {}
22 22
23 private: 23 private:
24 base::ScopedPathOverride user_data_dir_override_; 24 base::ScopedPathOverride user_data_dir_override_;
25 25
26 DISALLOW_COPY_AND_ASSIGN(FirstRunTest); 26 DISALLOW_COPY_AND_ASSIGN(FirstRunTest);
27 }; 27 };
28 28
29 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeed) { 29 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeed) {
30 installer::MasterPreferences install_prefs("{ \"variations_seed\":\"xyz\" }"); 30 installer::MasterPreferences install_prefs(
31 "{\"variations_compressed_seed\":\"xyz\"}");
31 EXPECT_EQ(1U, install_prefs.master_dictionary().size()); 32 EXPECT_EQ(1U, install_prefs.master_dictionary().size());
32 33
33 MasterPrefs out_prefs; 34 MasterPrefs out_prefs;
34 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); 35 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
35 EXPECT_EQ("xyz", out_prefs.variations_seed); 36 EXPECT_EQ("xyz", out_prefs.compressed_variations_seed);
36 // Variations prefs should have been extracted (removed) from the dictionary. 37 // Variations prefs should have been extracted (removed) from the dictionary.
37 EXPECT_TRUE(install_prefs.master_dictionary().empty()); 38 EXPECT_TRUE(install_prefs.master_dictionary().empty());
38 } 39 }
39 40
40 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_NoVariationsSeed) { 41 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_NoVariationsSeed) {
41 installer::MasterPreferences install_prefs("{ }"); 42 installer::MasterPreferences install_prefs("{ }");
42 EXPECT_TRUE(install_prefs.master_dictionary().empty()); 43 EXPECT_TRUE(install_prefs.master_dictionary().empty());
43 44
44 MasterPrefs out_prefs; 45 MasterPrefs out_prefs;
45 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); 46 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
46 EXPECT_TRUE(out_prefs.variations_seed.empty()); 47 EXPECT_TRUE(out_prefs.compressed_variations_seed.empty());
47 EXPECT_TRUE(out_prefs.variations_seed_signature.empty()); 48 EXPECT_TRUE(out_prefs.variations_seed_signature.empty());
48 } 49 }
49 50
50 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeedSignature) { 51 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeedSignature) {
51 installer::MasterPreferences install_prefs( 52 installer::MasterPreferences install_prefs(
52 "{ \"variations_seed\":\"xyz\", \"variations_seed_signature\":\"abc\" }"); 53 "{\"variations_compressed_seed\":\"xyz\","
54 " \"variations_seed_signature\":\"abc\"}");
53 EXPECT_EQ(2U, install_prefs.master_dictionary().size()); 55 EXPECT_EQ(2U, install_prefs.master_dictionary().size());
54 56
55 MasterPrefs out_prefs; 57 MasterPrefs out_prefs;
56 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); 58 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
57 EXPECT_EQ("xyz", out_prefs.variations_seed); 59 EXPECT_EQ("xyz", out_prefs.compressed_variations_seed);
58 EXPECT_EQ("abc", out_prefs.variations_seed_signature); 60 EXPECT_EQ("abc", out_prefs.variations_seed_signature);
59 // Variations prefs should have been extracted (removed) from the dictionary. 61 // Variations prefs should have been extracted (removed) from the dictionary.
60 EXPECT_TRUE(install_prefs.master_dictionary().empty()); 62 EXPECT_TRUE(install_prefs.master_dictionary().empty());
61 } 63 }
62 64
63 TEST_F(FirstRunTest, 65 TEST_F(FirstRunTest,
64 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeMissing) { 66 SetupMasterPrefsFromInstallPrefs_WelcomePageOnOSUpgradeMissing) {
65 installer::MasterPreferences install_prefs("{\"distribution\":{}}"); 67 installer::MasterPreferences install_prefs("{\"distribution\":{}}");
66 MasterPrefs out_prefs; 68 MasterPrefs out_prefs;
67 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); 69 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 TEST_F(FirstRunTest, DetermineFirstRunState_SuppressSwitch) { 122 TEST_F(FirstRunTest, DetermineFirstRunState_SuppressSwitch) {
121 internal::FirstRunState result = 123 internal::FirstRunState result =
122 internal::DetermineFirstRunState(false, false, true); 124 internal::DetermineFirstRunState(false, false, true);
123 EXPECT_EQ(internal::FIRST_RUN_FALSE, result); 125 EXPECT_EQ(internal::FIRST_RUN_FALSE, result);
124 126
125 result = internal::DetermineFirstRunState(true, false, true); 127 result = internal::DetermineFirstRunState(true, false, true);
126 EXPECT_EQ(internal::FIRST_RUN_FALSE, result); 128 EXPECT_EQ(internal::FIRST_RUN_FALSE, result);
127 } 129 }
128 130
129 } // namespace first_run 131 } // namespace first_run
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698