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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: darin feedback Created 8 years, 6 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 "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/run_loop.h"
14 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 17 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
18 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/content_settings/host_content_settings_map.h" 20 #include "chrome/browser/content_settings/host_content_settings_map.h"
20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 21 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
21 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_special_storage_policy.h" 23 #include "chrome/browser/extensions/extension_special_storage_policy.h"
23 #include "chrome/browser/extensions/extension_system.h" 24 #include "chrome/browser/extensions/extension_system.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 372
372 void TestingProfile::CreateWebDataService() { 373 void TestingProfile::CreateWebDataService() {
373 WebDataServiceFactory::GetInstance()->SetTestingFactory( 374 WebDataServiceFactory::GetInstance()->SetTestingFactory(
374 this, BuildWebDataService); 375 this, BuildWebDataService);
375 } 376 }
376 377
377 void TestingProfile::BlockUntilBookmarkModelLoaded() { 378 void TestingProfile::BlockUntilBookmarkModelLoaded() {
378 DCHECK(GetBookmarkModel()); 379 DCHECK(GetBookmarkModel());
379 if (GetBookmarkModel()->IsLoaded()) 380 if (GetBookmarkModel()->IsLoaded())
380 return; 381 return;
381 BookmarkLoadObserver observer; 382 base::RunLoop run_loop;
383 BookmarkLoadObserver observer(run_loop.AsWeakPtr());
382 GetBookmarkModel()->AddObserver(&observer); 384 GetBookmarkModel()->AddObserver(&observer);
383 MessageLoop::current()->Run(); 385 run_loop.Run();
384 GetBookmarkModel()->RemoveObserver(&observer); 386 GetBookmarkModel()->RemoveObserver(&observer);
385 DCHECK(GetBookmarkModel()->IsLoaded()); 387 DCHECK(GetBookmarkModel()->IsLoaded());
386 } 388 }
387 389
388 // TODO(phajdan.jr): Doesn't this hang if Top Sites are already loaded? 390 // TODO(phajdan.jr): Doesn't this hang if Top Sites are already loaded?
389 void TestingProfile::BlockUntilTopSitesLoaded() { 391 void TestingProfile::BlockUntilTopSitesLoaded() {
390 ui_test_utils::WindowedNotificationObserver top_sites_loaded_observer( 392 ui_test_utils::WindowedNotificationObserver top_sites_loaded_observer(
391 chrome::NOTIFICATION_TOP_SITES_LOADED, 393 chrome::NOTIFICATION_TOP_SITES_LOADED,
392 content::NotificationService::AllSources()); 394 content::NotificationService::AllSources());
393 if (!GetHistoryService(Profile::EXPLICIT_ACCESS)) 395 if (!GetHistoryService(Profile::EXPLICIT_ACCESS))
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 714 }
713 715
714 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { 716 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) {
715 return true; 717 return true;
716 } 718 }
717 719
718 base::Callback<ChromeURLDataManagerBackend*(void)> 720 base::Callback<ChromeURLDataManagerBackend*(void)>
719 TestingProfile::GetChromeURLDataManagerBackendGetter() const { 721 TestingProfile::GetChromeURLDataManagerBackendGetter() const {
720 return base::Callback<ChromeURLDataManagerBackend*(void)>(); 722 return base::Callback<ChromeURLDataManagerBackend*(void)>();
721 } 723 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698