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

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

Issue 208393020: Fix the new First Run sentinel file path determination. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify changes. Created 6 years, 9 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 | Annotate | Revision Log
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/test/scoped_path_override.h" 9 #include "base/test/scoped_path_override.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/first_run/first_run.h" 11 #include "chrome/browser/first_run/first_run.h"
12 #include "chrome/browser/first_run/first_run_internal.h" 12 #include "chrome/browser/first_run/first_run_internal.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/installer/util/master_preferences.h" 14 #include "chrome/installer/util/master_preferences.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace first_run { 17 namespace first_run {
18 18
19 class FirstRunTest : public testing::Test { 19 class FirstRunTest : public testing::Test {
20 protected: 20 protected:
21 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} 21 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {}
22 virtual ~FirstRunTest() {} 22 virtual ~FirstRunTest() {}
23 23
24 virtual void SetUp() OVERRIDE {
25 internal::GetFirstRunSentinelFilePath(&sentinel_path_);
26 }
27
28 base::FilePath sentinel_path_;
29
30 private: 24 private:
31 base::ScopedPathOverride user_data_dir_override_; 25 base::ScopedPathOverride user_data_dir_override_;
32 26
33 DISALLOW_COPY_AND_ASSIGN(FirstRunTest); 27 DISALLOW_COPY_AND_ASSIGN(FirstRunTest);
34 }; 28 };
35 29
36 TEST_F(FirstRunTest, RemoveSentinel) { 30 TEST_F(FirstRunTest, RemoveSentinel) {
31 base::FilePath sentinel_path;
32 EXPECT_TRUE(internal::GetFirstRunSentinelFilePath(&sentinel_path));
33
37 EXPECT_TRUE(internal::CreateSentinel()); 34 EXPECT_TRUE(internal::CreateSentinel());
38 EXPECT_TRUE(base::PathExists(sentinel_path_)); 35 EXPECT_TRUE(base::PathExists(sentinel_path));
39 36
40 EXPECT_TRUE(RemoveSentinel()); 37 EXPECT_TRUE(RemoveSentinel());
41 EXPECT_FALSE(base::PathExists(sentinel_path_)); 38 EXPECT_FALSE(base::PathExists(sentinel_path));
42 } 39 }
43 40
44 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeed) { 41 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeed) {
45 installer::MasterPreferences install_prefs("{ \"variations_seed\":\"xyz\" }"); 42 installer::MasterPreferences install_prefs("{ \"variations_seed\":\"xyz\" }");
46 EXPECT_EQ(1U, install_prefs.master_dictionary().size()); 43 EXPECT_EQ(1U, install_prefs.master_dictionary().size());
47 44
48 MasterPrefs out_prefs; 45 MasterPrefs out_prefs;
49 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); 46 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
50 EXPECT_EQ("xyz", out_prefs.variations_seed); 47 EXPECT_EQ("xyz", out_prefs.variations_seed);
51 // Variations prefs should have been extracted (removed) from the dictionary. 48 // Variations prefs should have been extracted (removed) from the dictionary.
(...skipping 17 matching lines...) Expand all
69 66
70 MasterPrefs out_prefs; 67 MasterPrefs out_prefs;
71 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); 68 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs);
72 EXPECT_EQ("xyz", out_prefs.variations_seed); 69 EXPECT_EQ("xyz", out_prefs.variations_seed);
73 EXPECT_EQ("abc", out_prefs.variations_seed_signature); 70 EXPECT_EQ("abc", out_prefs.variations_seed_signature);
74 // Variations prefs should have been extracted (removed) from the dictionary. 71 // Variations prefs should have been extracted (removed) from the dictionary.
75 EXPECT_TRUE(install_prefs.master_dictionary().empty()); 72 EXPECT_TRUE(install_prefs.master_dictionary().empty());
76 } 73 }
77 74
78 } // namespace first_run 75 } // namespace first_run
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698