Commit eaa0c3a3 authored by blundell@chromium.org's avatar blundell@chromium.org

Eliminate BrowserThread dependency from WebDataAutofillServiceTest.

This CL replaces the usage of content::BrowserThread by base::Thread in a
straightforward fashion. It also removes now-unneeded includes and DEPS
temporary allowances relating to core Autofill test code.

BUG=303083
R=joi@chromium.org

Review URL: https://codereview.chromium.org/190213003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255944 0039d316-1c4b-4281-b951-d872f2087c98
parent 57bf534e
......@@ -8,40 +8,3 @@ include_rules = [
"+third_party/libjingle",
"+third_party/libphonenumber", # For phone number i18n.
]
specific_include_rules = {
'autofill_test_utils\.cc': [
# TODO(blundell): Bring this list to zero.
#
# Do not add to the list of temporarily-allowed dependencies below,
# and please do not introduce more #includes of these files.
"!components/user_prefs/user_prefs.h",
"!content/public/browser/browser_context.h",
],
'.*_[a-z]*test\.cc': [
# TODO(blundell): Bring this list to zero.
#
# Do not add to the list of temporarily-allowed dependencies below,
# and please do not introduce more #includes of these files.
"!components/user_prefs/user_prefs.h",
"!content/public/browser/browser_context.h",
"!content/public/browser/browser_thread.h",
"!content/public/test",
# TODO(joi): Bring this list to zero.
#
# Do not add to the list of temporarily-allowed dependencies below,
# and please do not introduce more #includes of these files.
"!chrome/browser/autofill/autofill_cc_infobar_delegate.h",
"!chrome/browser/autofill/personal_data_manager_factory.h",
"!chrome/browser/password_manager/chrome_password_manager_client.h",
"!chrome/browser/password_manager/password_manager.h",
"!chrome/browser/profiles/profile.h",
"!chrome/browser/sync/profile_sync_service.h",
"!chrome/browser/sync/profile_sync_service_factory.h",
"!chrome/browser/ui/autofill/tab_autofill_manager_delegate.h",
"!chrome/browser/webdata/web_data_service_factory.h",
"!chrome/test/base/chrome_render_view_host_test_harness.h",
"!chrome/test/base/testing_profile.h",
],
}
......@@ -17,7 +17,6 @@
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
#include "components/autofill/core/common/form_data.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
......
......@@ -35,7 +35,6 @@
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/forms_seen_state.h"
#include "components/user_prefs/user_prefs.h"
#include "grit/component_strings.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -18,7 +18,6 @@
#include "components/autofill/core/common/form_field_data.h"
#include "components/encryptor/os_crypt.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.h"
using base::ASCIIToUTF16;
......
......@@ -6,13 +6,11 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/phone_number_i18n.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libphonenumber/src/phonenumber_api.h"
using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
using content::BrowserThread;
namespace autofill {
......
......@@ -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,17 +102,16 @@ 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),
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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment