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/file_util.h"
8 #include "base/path_service.h"
9 #include "base/test/scoped_path_override.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"
18 class FirstRunTest
: public testing::Test
{
20 FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA
) {}
21 virtual ~FirstRunTest() {}
23 virtual void SetUp() OVERRIDE
{
24 internal::GetFirstRunSentinelFilePath(&sentinel_path_
);
27 base::FilePath sentinel_path_
;
30 base::ScopedPathOverride user_data_dir_override_
;
32 DISALLOW_COPY_AND_ASSIGN(FirstRunTest
);
35 TEST_F(FirstRunTest
, RemoveSentinel
) {
36 EXPECT_TRUE(internal::CreateSentinel());
37 EXPECT_TRUE(base::PathExists(sentinel_path_
));
39 EXPECT_TRUE(RemoveSentinel());
40 EXPECT_FALSE(base::PathExists(sentinel_path_
));
43 TEST_F(FirstRunTest
, SetupMasterPrefsFromInstallPrefs_VariationsSeed
) {
44 installer::MasterPreferences
install_prefs("{ \"variations_seed\":\"xyz\" }");
46 MasterPrefs out_prefs
;
47 internal::SetupMasterPrefsFromInstallPrefs(install_prefs
, &out_prefs
);
48 EXPECT_EQ("xyz", out_prefs
.variations_seed
);
51 TEST_F(FirstRunTest
, SetupMasterPrefsFromInstallPrefs_NoVariationsSeed
) {
52 installer::MasterPreferences
install_prefs("{ }");
54 MasterPrefs out_prefs
;
55 internal::SetupMasterPrefsFromInstallPrefs(install_prefs
, &out_prefs
);
56 EXPECT_TRUE(out_prefs
.variations_seed
.empty());
59 } // namespace first_run