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

Unified Diff: components/autofill/core/browser/webdata/web_data_service_unittest.cc

Issue 190213003: Eliminate BrowserThread dependency from WebDataAutofillServiceTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « components/autofill/core/browser/phone_number_i18n_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/webdata/web_data_service_unittest.cc
diff --git a/components/autofill/core/browser/webdata/web_data_service_unittest.cc b/components/autofill/core/browser/webdata/web_data_service_unittest.cc
index c29fe77c20d07aefd2bcf08f893ee710d24a5d07..383bd1b036b98da4bedbcd9db0027d1a41b31cf2 100644
--- a/components/autofill/core/browser/webdata/web_data_service_unittest.cc
+++ b/components/autofill/core/browser/webdata/web_data_service_unittest.cc
@@ -6,6 +6,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -16,6 +17,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
+#include "base/threading/thread.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
@@ -30,7 +32,6 @@
#include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database_service.h"
-#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -38,7 +39,6 @@ using base::ASCIIToUTF16;
using base::Time;
using base::TimeDelta;
using base::WaitableEvent;
-using content::BrowserThread;
using testing::_;
using testing::DoDefault;
using testing::ElementsAreArray;
@@ -55,8 +55,6 @@ class AutofillWebDataServiceConsumer: public WebDataServiceConsumer {
virtual void OnWebDataServiceRequestDone(WebDataServiceBase::Handle handle,
const WDTypedResult* result) {
- using content::BrowserThread;
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
handle_ = handle;
const WDResult<T>* wrapped_result =
static_cast<const WDResult<T>*>(result);
@@ -95,9 +93,7 @@ class MockAutofillWebDataServiceObserver
class WebDataServiceTest : public testing::Test {
public:
- WebDataServiceTest()
- : ui_thread_(BrowserThread::UI, &message_loop_),
- db_thread_(BrowserThread::DB) {}
+ WebDataServiceTest() : db_thread_("DBThread") {}
protected:
virtual void SetUp() {
@@ -106,18 +102,17 @@ class WebDataServiceTest : public testing::Test {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB");
- wdbs_ = new WebDatabaseService(
- path,
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB));
+ wdbs_ = new WebDatabaseService(path,
+ base::MessageLoopProxy::current(),
+ db_thread_.message_loop_proxy());
wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable("en-US")));
wdbs_->LoadDatabase();
- wds_ = new AutofillWebDataService(
- wdbs_,
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
- WebDataServiceBase::ProfileErrorCallback());
+ wds_ =
+ new AutofillWebDataService(wdbs_,
+ base::MessageLoopProxy::current(),
+ db_thread_.message_loop_proxy(),
+ WebDataServiceBase::ProfileErrorCallback());
wds_->Init();
}
@@ -136,16 +131,14 @@ class WebDataServiceTest : public testing::Test {
void WaitForDatabaseThread() {
base::WaitableEvent done(false, false);
- BrowserThread::PostTask(
- BrowserThread::DB,
+ db_thread_.message_loop()->PostTask(
FROM_HERE,
base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
done.Wait();
}
base::MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
+ base::Thread db_thread_;
base::FilePath profile_dir_;
scoped_refptr<AutofillWebDataService> wds_;
scoped_refptr<WebDatabaseService> wdbs_;
@@ -172,10 +165,8 @@ class WebDataServiceAutofillTest : public WebDataServiceTest {
void(AutofillWebDataService::*add_observer_func)(
AutofillWebDataServiceObserverOnDBThread*) =
&AutofillWebDataService::AddObserver;
- BrowserThread::PostTask(
- BrowserThread::DB,
- FROM_HERE,
- base::Bind(add_observer_func, wds_, &observer_));
+ db_thread_.message_loop()->PostTask(
+ FROM_HERE, base::Bind(add_observer_func, wds_, &observer_));
WaitForDatabaseThread();
}
@@ -183,10 +174,8 @@ class WebDataServiceAutofillTest : public WebDataServiceTest {
void(AutofillWebDataService::*remove_observer_func)(
AutofillWebDataServiceObserverOnDBThread*) =
&AutofillWebDataService::RemoveObserver;
- BrowserThread::PostTask(
- BrowserThread::DB,
- FROM_HERE,
- base::Bind(remove_observer_func, wds_, &observer_));
+ db_thread_.message_loop()->PostTask(
+ FROM_HERE, base::Bind(remove_observer_func, wds_, &observer_));
WaitForDatabaseThread();
WebDataServiceTest::TearDown();
« no previous file with comments | « components/autofill/core/browser/phone_number_i18n_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698