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

Side by Side Diff: chrome/browser/profiles/profile_manager_unittest.cc

Issue 11759019: Update other unittests to use newly added TestingBrowserProcess::GetGlobal(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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) 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
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(
105 &io_thread_); 105 &io_thread_);
Jay Civelli 2013/01/04 01:17:35 Would that fit on the previous line?
Dan Beam 2013/01/04 01:26:50 Done.
106 } 106 }
107 107
108 virtual void SetUp() { 108 virtual void SetUp() {
109 // Create a new temporary directory, and store the path 109 // Create a new temporary directory, and store the path
110 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 110 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
111 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( 111 TestingBrowserProcess::GetGlobal()->SetProfileManager(
112 new testing::ProfileManager(temp_dir_.path())); 112 new testing::ProfileManager(temp_dir_.path()));
113 113
114 #if defined(OS_CHROMEOS) 114 #if defined(OS_CHROMEOS)
115 CommandLine* cl = CommandLine::ForCurrentProcess(); 115 CommandLine* cl = CommandLine::ForCurrentProcess();
116 cl->AppendSwitch(switches::kTestType); 116 cl->AppendSwitch(switches::kTestType);
117 #endif 117 #endif
118 } 118 }
119 119
120 virtual void TearDown() { 120 virtual void TearDown() {
121 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( 121 TestingBrowserProcess::GetGlobal()->SetProfileManager(
122 NULL); 122 NULL);
Jay Civelli 2013/01/04 01:17:35 Would that fit on the previous line?
Dan Beam 2013/01/04 01:26:50 Done.
123 message_loop_.RunUntilIdle(); 123 message_loop_.RunUntilIdle();
124 } 124 }
125 125
126 #if defined(OS_CHROMEOS) 126 #if defined(OS_CHROMEOS)
127 // Do not change order of stub_cros_enabler_, which needs to be constructed 127 // 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 128 // before io_thread_ which requires CrosLibrary to be initialized to construct
129 // its data member pref_proxy_config_tracker_ on ChromeOS. 129 // its data member pref_proxy_config_tracker_ on ChromeOS.
130 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; 130 chromeos::ScopedStubCrosEnabler stub_cros_enabler_;
131 #endif 131 #endif
132 132
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1)); 220 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1));
221 profile2->CreateBookmarkModel(true); 221 profile2->CreateBookmarkModel(true);
222 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2)); 222 EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2));
223 profile2->CreateHistoryService(true, false); 223 profile2->CreateHistoryService(true, false);
224 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2, 224 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2,
225 Profile::EXPLICIT_ACCESS)); 225 Profile::EXPLICIT_ACCESS));
226 226
227 // Make sure any pending tasks run before we destroy the profiles. 227 // Make sure any pending tasks run before we destroy the profiles.
228 message_loop_.RunUntilIdle(); 228 message_loop_.RunUntilIdle();
229 229
230 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( 230 TestingBrowserProcess::GetGlobal()->SetProfileManager(
231 NULL); 231 NULL);
Jay Civelli 2013/01/04 01:17:35 Would that fit on the previous line?
Dan Beam 2013/01/04 01:26:50 Done.
232 232
233 // Make sure history cleans up correctly. 233 // Make sure history cleans up correctly.
234 message_loop_.RunUntilIdle(); 234 message_loop_.RunUntilIdle();
235 } 235 }
236 236
237 MATCHER(NotFail, "Profile creation failure status is not reported.") { 237 MATCHER(NotFail, "Profile creation failure status is not reported.") {
238 return arg == Profile::CREATE_STATUS_CREATED || 238 return arg == Profile::CREATE_STATUS_CREATED ||
239 arg == Profile::CREATE_STATUS_INITIALIZED; 239 arg == Profile::CREATE_STATUS_INITIALIZED;
240 } 240 }
241 241
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 browser2b.reset(); 592 browser2b.reset();
593 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 593 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
594 ASSERT_EQ(1U, last_opened_profiles.size()); 594 ASSERT_EQ(1U, last_opened_profiles.size());
595 EXPECT_EQ(profile1, last_opened_profiles[0]); 595 EXPECT_EQ(profile1, last_opened_profiles[0]);
596 596
597 browser1.reset(); 597 browser1.reset();
598 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 598 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
599 ASSERT_EQ(0U, last_opened_profiles.size()); 599 ASSERT_EQ(0U, last_opened_profiles.size());
600 } 600 }
601 #endif // !defined(OS_ANDROID) 601 #endif // !defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698