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

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

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager(
122 NULL); 122 NULL);
123 message_loop_.RunAllPending(); 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
133 // The path to temporary directory used to contain the test operations. 133 // The path to temporary directory used to contain the test operations.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 Profile::EXPLICIT_ACCESS)); 218 Profile::EXPLICIT_ACCESS));
219 profile1->CreateBookmarkModel(true); 219 profile1->CreateBookmarkModel(true);
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_.RunAllPending(); 228 message_loop_.RunUntilIdle();
229 229
230 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( 230 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager(
231 NULL); 231 NULL);
232 232
233 // Make sure history cleans up correctly. 233 // Make sure history cleans up correctly.
234 message_loop_.RunAllPending(); 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
242 // Tests asynchronous profile creation mechanism. 242 // Tests asynchronous profile creation mechanism.
243 TEST_F(ProfileManagerTest, DISABLED_CreateProfileAsync) { 243 TEST_F(ProfileManagerTest, DISABLED_CreateProfileAsync) {
244 FilePath dest_path = 244 FilePath dest_path =
245 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile")); 245 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile"));
246 246
247 MockObserver mock_observer; 247 MockObserver mock_observer;
248 EXPECT_CALL(mock_observer, OnProfileCreated( 248 EXPECT_CALL(mock_observer, OnProfileCreated(
249 testing::NotNull(), NotFail())).Times(testing::AtLeast(1)); 249 testing::NotNull(), NotFail())).Times(testing::AtLeast(1));
250 250
251 g_browser_process->profile_manager()->CreateProfileAsync(dest_path, 251 g_browser_process->profile_manager()->CreateProfileAsync(dest_path,
252 base::Bind(&MockObserver::OnProfileCreated, 252 base::Bind(&MockObserver::OnProfileCreated,
253 base::Unretained(&mock_observer)), string16(), string16()); 253 base::Unretained(&mock_observer)), string16(), string16());
254 254
255 message_loop_.RunAllPending(); 255 message_loop_.RunUntilIdle();
256 } 256 }
257 257
258 MATCHER(SameNotNull, "The same non-NULL value for all calls.") { 258 MATCHER(SameNotNull, "The same non-NULL value for all calls.") {
259 if (!g_created_profile) 259 if (!g_created_profile)
260 g_created_profile = arg; 260 g_created_profile = arg;
261 return arg != NULL && arg == g_created_profile; 261 return arg != NULL && arg == g_created_profile;
262 } 262 }
263 263
264 TEST_F(ProfileManagerTest, CreateProfileAsyncMultipleRequests) { 264 TEST_F(ProfileManagerTest, CreateProfileAsyncMultipleRequests) {
265 FilePath dest_path = 265 FilePath dest_path =
(...skipping 19 matching lines...) Expand all
285 string16(), string16()); 285 string16(), string16());
286 profile_manager->CreateProfileAsync(dest_path, 286 profile_manager->CreateProfileAsync(dest_path,
287 base::Bind(&MockObserver::OnProfileCreated, 287 base::Bind(&MockObserver::OnProfileCreated,
288 base::Unretained(&mock_observer2)), 288 base::Unretained(&mock_observer2)),
289 string16(), string16()); 289 string16(), string16());
290 profile_manager->CreateProfileAsync(dest_path, 290 profile_manager->CreateProfileAsync(dest_path,
291 base::Bind(&MockObserver::OnProfileCreated, 291 base::Bind(&MockObserver::OnProfileCreated,
292 base::Unretained(&mock_observer3)), 292 base::Unretained(&mock_observer3)),
293 string16(), string16()); 293 string16(), string16());
294 294
295 message_loop_.RunAllPending(); 295 message_loop_.RunUntilIdle();
296 } 296 }
297 297
298 TEST_F(ProfileManagerTest, CreateProfilesAsync) { 298 TEST_F(ProfileManagerTest, CreateProfilesAsync) {
299 FilePath dest_path1 = 299 FilePath dest_path1 =
300 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 1")); 300 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 1"));
301 FilePath dest_path2 = 301 FilePath dest_path2 =
302 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 2")); 302 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 2"));
303 303
304 MockObserver mock_observer; 304 MockObserver mock_observer;
305 EXPECT_CALL(mock_observer, OnProfileCreated( 305 EXPECT_CALL(mock_observer, OnProfileCreated(
306 testing::NotNull(), NotFail())).Times(testing::AtLeast(3)); 306 testing::NotNull(), NotFail())).Times(testing::AtLeast(3));
307 307
308 ProfileManager* profile_manager = g_browser_process->profile_manager(); 308 ProfileManager* profile_manager = g_browser_process->profile_manager();
309 309
310 profile_manager->CreateProfileAsync(dest_path1, 310 profile_manager->CreateProfileAsync(dest_path1,
311 base::Bind(&MockObserver::OnProfileCreated, 311 base::Bind(&MockObserver::OnProfileCreated,
312 base::Unretained(&mock_observer)), string16(), string16()); 312 base::Unretained(&mock_observer)), string16(), string16());
313 profile_manager->CreateProfileAsync(dest_path2, 313 profile_manager->CreateProfileAsync(dest_path2,
314 base::Bind(&MockObserver::OnProfileCreated, 314 base::Bind(&MockObserver::OnProfileCreated,
315 base::Unretained(&mock_observer)), string16(), string16()); 315 base::Unretained(&mock_observer)), string16(), string16());
316 316
317 message_loop_.RunAllPending(); 317 message_loop_.RunUntilIdle();
318 } 318 }
319 319
320 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { 320 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) {
321 ProfileManager* profile_manager = g_browser_process->profile_manager(); 321 ProfileManager* profile_manager = g_browser_process->profile_manager();
322 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 322 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
323 323
324 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); 324 EXPECT_EQ(0u, cache.GetNumberOfProfiles());
325 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"), 325 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"),
326 ASCIIToUTF16("name_1"), string16(), 0); 326 ASCIIToUTF16("name_1"), string16(), 0);
327 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_2"), 327 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_2"),
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 browser2b.reset(); 559 browser2b.reset();
560 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 560 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
561 ASSERT_EQ(1U, last_opened_profiles.size()); 561 ASSERT_EQ(1U, last_opened_profiles.size());
562 EXPECT_EQ(profile1, last_opened_profiles[0]); 562 EXPECT_EQ(profile1, last_opened_profiles[0]);
563 563
564 browser1.reset(); 564 browser1.reset();
565 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 565 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
566 ASSERT_EQ(0U, last_opened_profiles.size()); 566 ASSERT_EQ(0U, last_opened_profiles.size());
567 } 567 }
568 #endif // !defined(OS_ANDROID) 568 #endif // !defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698