OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 class ProfileManagerTest : public testing::Test { | 84 class ProfileManagerTest : public testing::Test { |
85 protected: | 85 protected: |
86 class MockObserver { | 86 class MockObserver { |
87 public: | 87 public: |
88 MOCK_METHOD2(OnProfileCreated, | 88 MOCK_METHOD2(OnProfileCreated, |
89 void(Profile* profile, Profile::CreateStatus status)); | 89 void(Profile* profile, Profile::CreateStatus status)); |
90 }; | 90 }; |
91 | 91 |
92 ProfileManagerTest() | 92 ProfileManagerTest() |
93 : local_state_(static_cast<TestingBrowserProcess*>(g_browser_process)), | 93 : local_state_(TestingBrowserProcess::GetGlobal()), |
94 extension_event_router_forwarder_(new extensions::EventRouterForwarder), | 94 extension_event_router_forwarder_(new extensions::EventRouterForwarder), |
95 ui_thread_(BrowserThread::UI, &message_loop_), | 95 ui_thread_(BrowserThread::UI, &message_loop_), |
96 db_thread_(BrowserThread::DB, &message_loop_), | 96 db_thread_(BrowserThread::DB, &message_loop_), |
97 file_thread_(BrowserThread::FILE, &message_loop_), | 97 file_thread_(BrowserThread::FILE, &message_loop_), |
98 io_thread_(local_state_.Get(), g_browser_process->policy_service(), | 98 io_thread_(local_state_.Get(), g_browser_process->policy_service(), |
99 NULL, extension_event_router_forwarder_) { | 99 NULL, extension_event_router_forwarder_) { |
100 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
101 base::SystemMonitor::AllocateSystemIOPorts(); | 101 base::SystemMonitor::AllocateSystemIOPorts(); |
102 #endif | 102 #endif |
103 system_monitor_dummy_.reset(new base::SystemMonitor); | 103 system_monitor_dummy_.reset(new base::SystemMonitor); |
104 static_cast<TestingBrowserProcess*>(g_browser_process)->SetIOThread( | 104 TestingBrowserProcess::GetGlobal()->SetIOThread(&io_thread_); |
105 &io_thread_); | |
106 } | 105 } |
107 | 106 |
108 virtual void SetUp() { | 107 virtual void SetUp() { |
109 // Create a new temporary directory, and store the path | 108 // Create a new temporary directory, and store the path |
110 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 109 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
111 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( | 110 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
112 new testing::ProfileManager(temp_dir_.path())); | 111 new testing::ProfileManager(temp_dir_.path())); |
113 | 112 |
114 #if defined(OS_CHROMEOS) | 113 #if defined(OS_CHROMEOS) |
115 CommandLine* cl = CommandLine::ForCurrentProcess(); | 114 CommandLine* cl = CommandLine::ForCurrentProcess(); |
116 cl->AppendSwitch(switches::kTestType); | 115 cl->AppendSwitch(switches::kTestType); |
117 #endif | 116 #endif |
118 } | 117 } |
119 | 118 |
120 virtual void TearDown() { | 119 virtual void TearDown() { |
121 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( | 120 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
122 NULL); | |
123 message_loop_.RunUntilIdle(); | 121 message_loop_.RunUntilIdle(); |
124 } | 122 } |
125 | 123 |
126 #if defined(OS_CHROMEOS) | 124 #if defined(OS_CHROMEOS) |
127 // Do not change order of stub_cros_enabler_, which needs to be constructed | 125 // Do not change order of stub_cros_enabler_, which needs to be constructed |
128 // before io_thread_ which requires CrosLibrary to be initialized to construct | 126 // before io_thread_ which requires CrosLibrary to be initialized to construct |
129 // its data member pref_proxy_config_tracker_ on ChromeOS. | 127 // its data member pref_proxy_config_tracker_ on ChromeOS. |
130 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; | 128 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; |
131 #endif | 129 #endif |
132 | 130 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1)); | 218 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1)); |
221 profile2->CreateBookmarkModel(true); | 219 profile2->CreateBookmarkModel(true); |
222 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2)); | 220 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2)); |
223 profile2->CreateHistoryService(true, false); | 221 profile2->CreateHistoryService(true, false); |
224 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2, | 222 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2, |
225 Profile::EXPLICIT_ACCESS)); | 223 Profile::EXPLICIT_ACCESS)); |
226 | 224 |
227 // Make sure any pending tasks run before we destroy the profiles. | 225 // Make sure any pending tasks run before we destroy the profiles. |
228 message_loop_.RunUntilIdle(); | 226 message_loop_.RunUntilIdle(); |
229 | 227 |
230 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( | 228 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
231 NULL); | |
232 | 229 |
233 // Make sure history cleans up correctly. | 230 // Make sure history cleans up correctly. |
234 message_loop_.RunUntilIdle(); | 231 message_loop_.RunUntilIdle(); |
235 } | 232 } |
236 | 233 |
237 MATCHER(NotFail, "Profile creation failure status is not reported.") { | 234 MATCHER(NotFail, "Profile creation failure status is not reported.") { |
238 return arg == Profile::CREATE_STATUS_CREATED || | 235 return arg == Profile::CREATE_STATUS_CREATED || |
239 arg == Profile::CREATE_STATUS_INITIALIZED; | 236 arg == Profile::CREATE_STATUS_INITIALIZED; |
240 } | 237 } |
241 | 238 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 browser2b.reset(); | 589 browser2b.reset(); |
593 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 590 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
594 ASSERT_EQ(1U, last_opened_profiles.size()); | 591 ASSERT_EQ(1U, last_opened_profiles.size()); |
595 EXPECT_EQ(profile1, last_opened_profiles[0]); | 592 EXPECT_EQ(profile1, last_opened_profiles[0]); |
596 | 593 |
597 browser1.reset(); | 594 browser1.reset(); |
598 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 595 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
599 ASSERT_EQ(0U, last_opened_profiles.size()); | 596 ASSERT_EQ(0U, last_opened_profiles.size()); |
600 } | 597 } |
601 #endif // !defined(OS_ANDROID) | 598 #endif // !defined(OS_ANDROID) |
OLD | NEW |