Chromium Code Reviews| 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()); |
| } |