Index: chrome/browser/signin/token_service_unittest.cc |
=================================================================== |
--- chrome/browser/signin/token_service_unittest.cc (revision 136877) |
+++ chrome/browser/signin/token_service_unittest.cc (working copy) |
@@ -13,6 +13,7 @@ |
#include "base/synchronization/waitable_event.h" |
#include "chrome/browser/password_manager/encryptor.h" |
#include "chrome/browser/signin/token_service_factory.h" |
+#include "chrome/browser/webdata/web_data_service_factory.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/net/gaia/mock_url_fetcher_factory.h" |
@@ -72,7 +73,8 @@ |
ASSERT_TRUE(db_thread_.Start()); |
profile_.reset(new TestingProfile()); |
- profile_->CreateWebDataService(false); |
+ profile_->CreateWebDataService(); |
+ |
WaitForDBLoadCompletion(); |
service_ = TokenServiceFactory::GetForProfile(profile_.get()); |
@@ -89,6 +91,12 @@ |
if (profile_.get()) { |
profile_.reset(NULL); |
} |
+ // Schedule another task on the DB thread to notify us that it's safe to |
+ // carry on with the test. |
+ base::WaitableEvent done(false, false); |
+ BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
+ base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
+ done.Wait(); |
db_thread_.Stop(); |
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
@@ -96,6 +104,10 @@ |
} |
void TokenServiceTestHarness::WaitForDBLoadCompletion() { |
+ // Force the loading of the WebDataService. |
+ WebDataServiceFactory::GetForProfile(profile_.get(), |
+ Profile::IMPLICIT_ACCESS); |
+ |
// The WebDB does all work on the DB thread. This will add an event |
// to the end of the DB thread, so when we reach this task, all DB |
// operations should be complete. |