OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "app/system_monitor.h" | |
8 #include "base/command_line.h" | 7 #include "base/command_line.h" |
9 #include "base/file_util.h" | 8 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 10 #include "base/path_service.h" |
12 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "ui/base/system_monitor/system_monitor.h" |
21 | 21 |
22 class ProfileManagerTest : public testing::Test { | 22 class ProfileManagerTest : public testing::Test { |
23 protected: | 23 protected: |
24 ProfileManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_) { | 24 ProfileManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_) { |
25 } | 25 } |
26 | 26 |
27 virtual void SetUp() { | 27 virtual void SetUp() { |
28 // Name a subdirectory of the temp directory. | 28 // Name a subdirectory of the temp directory. |
29 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); | 29 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); |
30 test_dir_ = test_dir_.Append(FILE_PATH_LITERAL("ProfileManagerTest")); | 30 test_dir_ = test_dir_.Append(FILE_PATH_LITERAL("ProfileManagerTest")); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // these cases would trigger DCHECKs. | 68 // these cases would trigger DCHECKs. |
69 | 69 |
70 // The profile already exists when we call CreateProfile. Just load it. | 70 // The profile already exists when we call CreateProfile. Just load it. |
71 profile.reset(ProfileManager::CreateProfile(dest_path)); | 71 profile.reset(ProfileManager::CreateProfile(dest_path)); |
72 ASSERT_TRUE(profile.get()); | 72 ASSERT_TRUE(profile.get()); |
73 #endif | 73 #endif |
74 } | 74 } |
75 | 75 |
76 TEST_F(ProfileManagerTest, DefaultProfileDir) { | 76 TEST_F(ProfileManagerTest, DefaultProfileDir) { |
77 CommandLine *cl = CommandLine::ForCurrentProcess(); | 77 CommandLine *cl = CommandLine::ForCurrentProcess(); |
78 SystemMonitor dummy; | 78 ui::SystemMonitor dummy; |
79 ProfileManager profile_manager; | 79 ProfileManager profile_manager; |
80 std::string profile_dir("my_user"); | 80 std::string profile_dir("my_user"); |
81 | 81 |
82 cl->AppendSwitch(switches::kTestType); | 82 cl->AppendSwitch(switches::kTestType); |
83 | 83 |
84 FilePath expected_default = | 84 FilePath expected_default = |
85 FilePath::FromWStringHack(chrome::kNotSignedInProfile); | 85 FilePath::FromWStringHack(chrome::kNotSignedInProfile); |
86 EXPECT_EQ(expected_default.value(), | 86 EXPECT_EQ(expected_default.value(), |
87 profile_manager.GetCurrentProfileDir().value()); | 87 profile_manager.GetCurrentProfileDir().value()); |
88 } | 88 } |
89 | 89 |
90 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
91 // This functionality only exists on Chrome OS. | 91 // This functionality only exists on Chrome OS. |
92 TEST_F(ProfileManagerTest, LoggedInProfileDir) { | 92 TEST_F(ProfileManagerTest, LoggedInProfileDir) { |
93 CommandLine *cl = CommandLine::ForCurrentProcess(); | 93 CommandLine *cl = CommandLine::ForCurrentProcess(); |
94 SystemMonitor dummy; | 94 ui::SystemMonitor dummy; |
95 ProfileManager profile_manager; | 95 ProfileManager profile_manager; |
96 std::string profile_dir("my_user"); | 96 std::string profile_dir("my_user"); |
97 | 97 |
98 cl->AppendSwitchASCII(switches::kLoginProfile, profile_dir); | 98 cl->AppendSwitchASCII(switches::kLoginProfile, profile_dir); |
99 cl->AppendSwitch(switches::kTestType); | 99 cl->AppendSwitch(switches::kTestType); |
100 | 100 |
101 FilePath expected_default = | 101 FilePath expected_default = |
102 FilePath::FromWStringHack(chrome::kNotSignedInProfile); | 102 FilePath::FromWStringHack(chrome::kNotSignedInProfile); |
103 EXPECT_EQ(expected_default.value(), | 103 EXPECT_EQ(expected_default.value(), |
104 profile_manager.GetCurrentProfileDir().value()); | 104 profile_manager.GetCurrentProfileDir().value()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Force lazy-init of some profile services to simulate use. | 139 // Force lazy-init of some profile services to simulate use. |
140 EXPECT_TRUE(profile1->GetHistoryService(Profile::EXPLICIT_ACCESS)); | 140 EXPECT_TRUE(profile1->GetHistoryService(Profile::EXPLICIT_ACCESS)); |
141 EXPECT_TRUE(profile1->GetBookmarkModel()); | 141 EXPECT_TRUE(profile1->GetBookmarkModel()); |
142 EXPECT_TRUE(profile2->GetBookmarkModel()); | 142 EXPECT_TRUE(profile2->GetBookmarkModel()); |
143 EXPECT_TRUE(profile2->GetHistoryService(Profile::EXPLICIT_ACCESS)); | 143 EXPECT_TRUE(profile2->GetHistoryService(Profile::EXPLICIT_ACCESS)); |
144 profile1.reset(); | 144 profile1.reset(); |
145 profile2.reset(); | 145 profile2.reset(); |
146 // Make sure history cleans up correctly. | 146 // Make sure history cleans up correctly. |
147 message_loop_.RunAllPending(); | 147 message_loop_.RunAllPending(); |
148 } | 148 } |
OLD | NEW |