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

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: cleanup TODOs. merge code. kill more threads. i never get tired of thread carnage. 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 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());
}

Powered by Google App Engine
This is Rietveld 408576698