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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments. merge to ToT. Murder a DB thread and more TestBrowserThreads. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 6fe7fecbbf33076882c346340e1cff9a57b60d88..31cd5b30e05e5ade0f3371411edf6b5ab9ed1070 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -370,8 +370,35 @@ void WaitForBookmarkModelToLoad(Profile* profile) {
void WaitForTemplateURLServiceToLoad(TemplateURLService* service) {
if (service->loaded())
return;
+
+ using content::NotificationDetails;
+ using content::NotificationObserver;
+ using content::NotificationRegistrar;
+ using content::NotificationSource;
+ content::NotificationRegistrar registrar;
+ class LoadedObserver : public NotificationObserver {
+ public:
+ LoadedObserver(base::RunLoop* run_loop) : run_loop_(run_loop) {}
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE {
+ CHECK_EQ(chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, type);
+ run_loop_->Quit();
+ }
+
+ private:
+ base::RunLoop* run_loop_;
+ };
+
+
+ base::RunLoop run_loop;
+ LoadedObserver loaded_observer(&run_loop);
+ registrar.Add(&loaded_observer,
+ chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
+ content::Source<TemplateURLService>(service));
jam 2013/07/12 16:38:34 you can use content::WindowedNotificationObserver
awong 2013/07/16 21:27:28 Done.
service->Load();
- TemplateURLServiceTestUtil::BlockTillServiceProcessesRequests();
+ run_loop.Run();
+
ASSERT_TRUE(service->loaded());
}

Powered by Google App Engine
This is Rietveld 408576698