Chromium Code Reviews| 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/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 "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 "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 16 namespace first_run { | |
| 17 | |
| 15 class FirstRunTest : public testing::Test { | 18 class FirstRunTest : public testing::Test { |
| 16 protected: | 19 protected: |
| 17 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} | 20 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} |
| 18 virtual ~FirstRunTest() {} | 21 virtual ~FirstRunTest() {} |
| 19 | 22 |
| 20 virtual void SetUp() OVERRIDE { | 23 virtual void SetUp() OVERRIDE { |
| 21 first_run::internal::GetFirstRunSentinelFilePath(&sentinel_path_); | 24 internal::GetFirstRunSentinelFilePath(&sentinel_path_); |
| 22 } | 25 } |
| 23 | 26 |
| 24 base::FilePath sentinel_path_; | 27 base::FilePath sentinel_path_; |
| 25 | 28 |
| 26 private: | 29 private: |
| 27 base::ScopedPathOverride user_data_dir_override_; | 30 base::ScopedPathOverride user_data_dir_override_; |
| 28 | 31 |
| 29 DISALLOW_COPY_AND_ASSIGN(FirstRunTest); | 32 DISALLOW_COPY_AND_ASSIGN(FirstRunTest); |
| 30 }; | 33 }; |
| 31 | 34 |
| 32 TEST_F(FirstRunTest, RemoveSentinel) { | 35 TEST_F(FirstRunTest, RemoveSentinel) { |
| 33 EXPECT_TRUE(first_run::CreateSentinel()); | 36 EXPECT_TRUE(CreateSentinel()); |
| 34 EXPECT_TRUE(file_util::PathExists(sentinel_path_)); | 37 EXPECT_TRUE(file_util::PathExists(sentinel_path_)); |
| 35 | 38 |
| 36 EXPECT_TRUE(first_run::RemoveSentinel()); | 39 EXPECT_TRUE(RemoveSentinel()); |
| 37 EXPECT_FALSE(file_util::PathExists(sentinel_path_)); | 40 EXPECT_FALSE(file_util::PathExists(sentinel_path_)); |
| 38 } | 41 } |
| 42 | |
| 43 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_VariationsSeed) { | |
| 44 installer::MasterPreferences install_prefs("{ \"variations_seed\":\"xyz\" }"); | |
| 45 | |
| 46 MasterPrefs out_prefs; | |
| 47 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); | |
| 48 EXPECT_EQ("xyz", out_prefs.variations_seed); | |
| 49 } | |
| 50 | |
| 51 TEST_F(FirstRunTest, SetupMasterPrefsFromInstallPrefs_NoVariationsSeed) { | |
| 52 installer::MasterPreferences install_prefs("{ }"); | |
| 53 | |
| 54 MasterPrefs out_prefs; | |
| 55 internal::SetupMasterPrefsFromInstallPrefs(install_prefs, &out_prefs); | |
| 56 EXPECT_EQ("", out_prefs.variations_seed); | |
|
SteveT
2013/02/12 02:12:30
nit:
std::string()
instead of
""
?
Alexei Svitkine (slow)
2013/02/13 23:58:36
Even better: .empty()
Done.
| |
| 57 } | |
| 58 | |
| 59 } // namespace first_run | |
| OLD | NEW |