Commit fd970f53 authored by joi@chromium.org's avatar joi@chromium.org

Fix most tests in //components/autofill/content to not depend on //chrome.

BUG=140037

Review URL: https://chromiumcodereview.appspot.com/17465003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207859 0039d316-1c4b-4281-b951-d872f2087c98
parent e2926253
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/infobars/confirm_infobar_delegate.h" #include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
......
...@@ -18,29 +18,19 @@ include_rules = [ ...@@ -18,29 +18,19 @@ include_rules = [
specific_include_rules = { specific_include_rules = {
'.*_[a-z]*test\.cc': [ '.*_[a-z]*test\.cc': [
"+content/public/test", "+content/public/test",
],
# TODO(joi, kaiwang): Bring this list to zero. # TODO(joi): Removing these dependencies needs to wait until some
# # other things (AutofillWebData::FromBrowserContext and a few other
# Do not add to the list of temporarily-allowed dependencies below, # things) move out of being built in //chrome. If we break the
# and please do not introduce more #includes of these files. # dependency on ChromeRenderViewHostTestHarness now (by switching to
"!chrome/browser/autofill/autofill_cc_infobar_delegate.h", # content::RenderViewHostTestHarness) but leave the test running in
"!chrome/browser/autofill/personal_data_manager_factory.h", # the 'unit_tests' target, it will fail at runtime trying to cast a
"!chrome/browser/password_manager/encryptor.h", # plain BrowserContext to a Profile. If on the other hand we move it
"!chrome/browser/password_manager/password_manager.h", # to the 'components_unittests' target, it will at this point fail
"!chrome/browser/password_manager/password_manager_delegate_impl.h", # to build due to a few link-time dependencies.
"!chrome/browser/profiles/profile.h", 'autocheckout_manager_unittest.cc': [
"!chrome/browser/sync/profile_sync_service.h", "!chrome/test/base/chrome_render_view_host_test_harness.h",
"!chrome/browser/sync/profile_sync_service_factory.h", "!chrome/test/base/testing_profile.h",
"!chrome/browser/translate/translate_infobar_delegate.h",
"!chrome/browser/translate/translate_manager.h",
"!chrome/browser/ui/autofill/tab_autofill_manager_delegate.h",
"!chrome/browser/ui/browser.h",
"!chrome/browser/ui/browser_tabstrip.h",
"!chrome/browser/ui/browser_window.h",
"!chrome/browser/ui/tabs/tab_strip_model.h",
"!chrome/browser/webdata/web_data_service.h",
"!chrome/browser/webdata/web_data_service_factory.h",
"!chrome/browser/webdata/web_data_service_test_util.h",
"!chrome/test/base",
], ],
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/browser/autocheckout/whitelist_manager.h" #include "components/autofill/content/browser/autocheckout/whitelist_manager.h"
#include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/autofill_switches.h"
...@@ -93,14 +92,6 @@ class WhitelistManagerTest : public testing::Test { ...@@ -93,14 +92,6 @@ class WhitelistManagerTest : public testing::Test {
WhitelistManagerTest() WhitelistManagerTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
virtual void SetUp() {
profile_.CreateRequestContext();
}
virtual void TearDown() {
profile_.ResetRequestContext();
}
protected: protected:
void CreateWhitelistManager() { void CreateWhitelistManager() {
if (!whitelist_manager_.get()) { if (!whitelist_manager_.get()) {
...@@ -141,7 +132,6 @@ class WhitelistManagerTest : public testing::Test { ...@@ -141,7 +132,6 @@ class WhitelistManagerTest : public testing::Test {
} }
protected: protected:
TestingProfile profile_;
scoped_ptr<TestWhitelistManager> whitelist_manager_; scoped_ptr<TestWhitelistManager> whitelist_manager_;
private: private:
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/browser/wallet/encryption_escrow_client.h" #include "components/autofill/content/browser/wallet/encryption_escrow_client.h"
#include "components/autofill/content/browser/wallet/encryption_escrow_client_observer.h" #include "components/autofill/content/browser/wallet/encryption_escrow_client_observer.h"
#include "components/autofill/content/browser/wallet/instrument.h" #include "components/autofill/content/browser/wallet/instrument.h"
#include "components/autofill/content/browser/wallet/wallet_test_util.h" #include "components/autofill/content/browser/wallet/wallet_test_util.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_status_code.h" #include "net/http/http_status_code.h"
...@@ -65,20 +65,15 @@ class TestEncryptionEscrowClient : public EncryptionEscrowClient { ...@@ -65,20 +65,15 @@ class TestEncryptionEscrowClient : public EncryptionEscrowClient {
class EncryptionEscrowClientTest : public testing::Test { class EncryptionEscrowClientTest : public testing::Test {
public: public:
EncryptionEscrowClientTest() EncryptionEscrowClientTest()
: instrument_(GetTestInstrument()), : instrument_(GetTestInstrument()) {}
io_thread_(content::BrowserThread::IO) {}
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
io_thread_.StartIOThread();
profile_.CreateRequestContext();
encryption_escrow_client_.reset(new TestEncryptionEscrowClient( encryption_escrow_client_.reset(new TestEncryptionEscrowClient(
profile_.GetRequestContext(), &observer_)); browser_context_.GetRequestContext(), &observer_));
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
encryption_escrow_client_.reset(); encryption_escrow_client_.reset();
profile_.ResetRequestContext();
io_thread_.Stop();
} }
std::vector<uint8> MakeOneTimePad() { std::vector<uint8> MakeOneTimePad() {
...@@ -110,9 +105,7 @@ class EncryptionEscrowClientTest : public testing::Test { ...@@ -110,9 +105,7 @@ class EncryptionEscrowClientTest : public testing::Test {
private: private:
// The profile's request context must be released on the IO thread. content::TestBrowserContext browser_context_;
content::TestBrowserThread io_thread_;
TestingProfile profile_;
net::TestURLFetcherFactory factory_; net::TestURLFetcherFactory factory_;
}; };
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/browser/wallet/full_wallet.h" #include "components/autofill/content/browser/wallet/full_wallet.h"
#include "components/autofill/content/browser/wallet/instrument.h" #include "components/autofill/content/browser/wallet/instrument.h"
#include "components/autofill/content/browser/wallet/wallet_client.h" #include "components/autofill/content/browser/wallet/wallet_client.h"
...@@ -18,6 +17,7 @@ ...@@ -18,6 +17,7 @@
#include "components/autofill/content/browser/wallet/wallet_test_util.h" #include "components/autofill/content/browser/wallet/wallet_test_util.h"
#include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/common/autocheckout_status.h" #include "components/autofill/core/common/autocheckout_status.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -729,19 +729,15 @@ class MockWalletClientDelegate : public WalletClientDelegate { ...@@ -729,19 +729,15 @@ class MockWalletClientDelegate : public WalletClientDelegate {
class WalletClientTest : public testing::Test { class WalletClientTest : public testing::Test {
public: public:
WalletClientTest() : io_thread_(content::BrowserThread::IO) {} WalletClientTest() {}
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
io_thread_.StartIOThread();
profile_.CreateRequestContext();
wallet_client_.reset( wallet_client_.reset(
new WalletClient(profile_.GetRequestContext(), &delegate_)); new WalletClient(browser_context_.GetRequestContext(), &delegate_));
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
wallet_client_.reset(); wallet_client_.reset();
profile_.ResetRequestContext();
io_thread_.Stop();
} }
std::string GetData(net::TestURLFetcher* fetcher) { std::string GetData(net::TestURLFetcher* fetcher) {
...@@ -781,12 +777,10 @@ class WalletClientTest : public testing::Test { ...@@ -781,12 +777,10 @@ class WalletClientTest : public testing::Test {
protected: protected:
scoped_ptr<WalletClient> wallet_client_; scoped_ptr<WalletClient> wallet_client_;
content::TestBrowserContext browser_context_;
MockWalletClientDelegate delegate_; MockWalletClientDelegate delegate_;
private: private:
// The profile's request context must be released on the IO thread.
content::TestBrowserThread io_thread_;
TestingProfile profile_;
net::TestURLFetcherFactory factory_; net::TestURLFetcherFactory factory_;
}; };
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/browser/wallet/wallet_service_url.h" #include "components/autofill/content/browser/wallet/wallet_service_url.h"
#include "components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h" #include "components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/gaia_urls.h"
...@@ -76,21 +76,17 @@ class WalletSigninHelperForTesting : public WalletSigninHelper { ...@@ -76,21 +76,17 @@ class WalletSigninHelperForTesting : public WalletSigninHelper {
class WalletSigninHelperTest : public testing::Test { class WalletSigninHelperTest : public testing::Test {
public: public:
WalletSigninHelperTest() : io_thread_(content::BrowserThread::IO) {} WalletSigninHelperTest() {}
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
io_thread_.StartIOThread();
profile_.CreateRequestContext();
signin_helper_.reset(new WalletSigninHelperForTesting( signin_helper_.reset(new WalletSigninHelperForTesting(
&mock_delegate_, &mock_delegate_,
profile_.GetRequestContext())); browser_context_.GetRequestContext()));
EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state()); EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state());
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
signin_helper_.reset(); signin_helper_.reset();
profile_.ResetRequestContext();
io_thread_.Stop();
} }
protected: protected:
...@@ -188,10 +184,8 @@ class WalletSigninHelperTest : public testing::Test { ...@@ -188,10 +184,8 @@ class WalletSigninHelperTest : public testing::Test {
MockWalletSigninHelperDelegate mock_delegate_; MockWalletSigninHelperDelegate mock_delegate_;
private: private:
// The profile's request context must be released on the IO thread.
content::TestBrowserThread io_thread_;
net::TestURLFetcherFactory factory_; net::TestURLFetcherFactory factory_;
TestingProfile profile_; content::TestBrowserContext browser_context_;
}; };
TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) {
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include "base/guid.h" #include "base/guid.h"
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "components/autofill/core/browser/autofill_profile.h" #include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/common/autofill_pref_names.h" #include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/form_field_data.h"
#include "components/user_prefs/user_prefs.h" #include "components/user_prefs/user_prefs.h"
#include "components/webdata/encryptor/encryptor.h" #include "components/webdata/encryptor/encryptor.h"
#include "content/public/browser/browser_context.h"
namespace autofill { namespace autofill {
namespace test { namespace test {
...@@ -142,7 +142,7 @@ void SetCreditCardInfo(CreditCard* credit_card, ...@@ -142,7 +142,7 @@ void SetCreditCardInfo(CreditCard* credit_card,
check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year);
} }
void DisableSystemServices(Profile* profile) { void DisableSystemServices(content::BrowserContext* browser_context) {
// Use a mock Keychain rather than the OS one to store credit card data. // Use a mock Keychain rather than the OS one to store credit card data.
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
Encryptor::UseMockKeychain(true); Encryptor::UseMockKeychain(true);
...@@ -150,8 +150,8 @@ void DisableSystemServices(Profile* profile) { ...@@ -150,8 +150,8 @@ void DisableSystemServices(Profile* profile) {
// Disable auxiliary profiles for unit testing. These reach out to system // Disable auxiliary profiles for unit testing. These reach out to system
// services on the Mac. // services on the Mac.
if (profile) { if (browser_context) {
user_prefs::UserPrefs::Get(profile)->SetBoolean( user_prefs::UserPrefs::Get(browser_context)->SetBoolean(
prefs::kAutofillAuxiliaryProfilesEnabled, false); prefs::kAutofillAuxiliaryProfilesEnabled, false);
} }
} }
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_
class Profile; namespace content {
class BrowserContext;
}
namespace autofill { namespace autofill {
...@@ -68,7 +70,7 @@ void SetCreditCardInfo(CreditCard* credit_card, ...@@ -68,7 +70,7 @@ void SetCreditCardInfo(CreditCard* credit_card,
// TODO(isherman): We should do this automatically for all tests, not manually // TODO(isherman): We should do this automatically for all tests, not manually
// on a per-test basis: http://crbug.com/57221 // on a per-test basis: http://crbug.com/57221
// Disables or mocks out code that would otherwise reach out to system services. // Disables or mocks out code that would otherwise reach out to system services.
void DisableSystemServices(Profile* profile); void DisableSystemServices(content::BrowserContext* browser_context);
} // namespace test } // namespace test
} // namespace autofill } // namespace autofill
......
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