| 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 61f8b269eb5eaecb8baed8944d85904e0da98bd1..593c31a6fd21184f6ebb4d9878cc34fb47966013 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));
|
| service->Load();
|
| - TemplateURLServiceTestUtil::BlockTillServiceProcessesRequests();
|
| + run_loop.Run();
|
| +
|
| ASSERT_TRUE(service->loaded());
|
| }
|
|
|
|
|