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 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/autofill/personal_data_manager_factory.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/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h"
......
......@@ -18,29 +18,19 @@ include_rules = [
specific_include_rules = {
'.*_[a-z]*test\.cc': [
"+content/public/test",
],
# TODO(joi, kaiwang): 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/encryptor.h",
"!chrome/browser/password_manager/password_manager.h",
"!chrome/browser/password_manager/password_manager_delegate_impl.h",
"!chrome/browser/profiles/profile.h",
"!chrome/browser/sync/profile_sync_service.h",
"!chrome/browser/sync/profile_sync_service_factory.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",
# TODO(joi): Removing these dependencies needs to wait until some
# other things (AutofillWebData::FromBrowserContext and a few other
# things) move out of being built in //chrome. If we break the
# dependency on ChromeRenderViewHostTestHarness now (by switching to
# content::RenderViewHostTestHarness) but leave the test running in
# the 'unit_tests' target, it will fail at runtime trying to cast a
# plain BrowserContext to a Profile. If on the other hand we move it
# to the 'components_unittests' target, it will at this point fail
# to build due to a few link-time dependencies.
'autocheckout_manager_unittest.cc': [
"!chrome/test/base/chrome_render_view_host_test_harness.h",
"!chrome/test/base/testing_profile.h",
],
}
......@@ -5,7 +5,6 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.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/core/browser/autofill_metrics.h"
#include "components/autofill/core/common/autofill_switches.h"
......@@ -93,14 +92,6 @@ class WhitelistManagerTest : public testing::Test {
WhitelistManagerTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
virtual void SetUp() {
profile_.CreateRequestContext();
}
virtual void TearDown() {
profile_.ResetRequestContext();
}
protected:
void CreateWhitelistManager() {
if (!whitelist_manager_.get()) {
......@@ -141,7 +132,6 @@ class WhitelistManagerTest : public testing::Test {
}
protected:
TestingProfile profile_;
scoped_ptr<TestWhitelistManager> whitelist_manager_;
private:
......
......@@ -3,11 +3,11 @@
// found in the LICENSE file.
#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_observer.h"
#include "components/autofill/content/browser/wallet/instrument.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 "net/base/net_errors.h"
#include "net/http/http_status_code.h"
......@@ -65,20 +65,15 @@ class TestEncryptionEscrowClient : public EncryptionEscrowClient {
class EncryptionEscrowClientTest : public testing::Test {
public:
EncryptionEscrowClientTest()
: instrument_(GetTestInstrument()),
io_thread_(content::BrowserThread::IO) {}
: instrument_(GetTestInstrument()) {}
virtual void SetUp() OVERRIDE {
io_thread_.StartIOThread();
profile_.CreateRequestContext();
encryption_escrow_client_.reset(new TestEncryptionEscrowClient(
profile_.GetRequestContext(), &observer_));
browser_context_.GetRequestContext(), &observer_));
}
virtual void TearDown() OVERRIDE {
encryption_escrow_client_.reset();
profile_.ResetRequestContext();
io_thread_.Stop();
}
std::vector<uint8> MakeOneTimePad() {
......@@ -110,9 +105,7 @@ class EncryptionEscrowClientTest : public testing::Test {
private:
// The profile's request context must be released on the IO thread.
content::TestBrowserThread io_thread_;
TestingProfile profile_;
content::TestBrowserContext browser_context_;
net::TestURLFetcherFactory factory_;
};
......
......@@ -9,7 +9,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.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/instrument.h"
#include "components/autofill/content/browser/wallet/wallet_client.h"
......@@ -18,6 +17,7 @@
#include "components/autofill/content/browser/wallet/wallet_test_util.h"
#include "components/autofill/core/browser/autofill_metrics.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 "googleurl/src/gurl.h"
#include "net/base/net_errors.h"
......@@ -729,19 +729,15 @@ class MockWalletClientDelegate : public WalletClientDelegate {
class WalletClientTest : public testing::Test {
public:
WalletClientTest() : io_thread_(content::BrowserThread::IO) {}
WalletClientTest() {}
virtual void SetUp() OVERRIDE {
io_thread_.StartIOThread();
profile_.CreateRequestContext();
wallet_client_.reset(
new WalletClient(profile_.GetRequestContext(), &delegate_));
new WalletClient(browser_context_.GetRequestContext(), &delegate_));
}
virtual void TearDown() OVERRIDE {
wallet_client_.reset();
profile_.ResetRequestContext();
io_thread_.Stop();
}
std::string GetData(net::TestURLFetcher* fetcher) {
......@@ -781,12 +777,10 @@ class WalletClientTest : public testing::Test {
protected:
scoped_ptr<WalletClient> wallet_client_;
content::TestBrowserContext browser_context_;
MockWalletClientDelegate delegate_;
private:
// The profile's request context must be released on the IO thread.
content::TestBrowserThread io_thread_;
TestingProfile profile_;
net::TestURLFetcherFactory factory_;
};
......
......@@ -7,9 +7,9 @@
#include "base/bind.h"
#include "base/bind_helpers.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_signin_helper_delegate.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
......@@ -76,21 +76,17 @@ class WalletSigninHelperForTesting : public WalletSigninHelper {
class WalletSigninHelperTest : public testing::Test {
public:
WalletSigninHelperTest() : io_thread_(content::BrowserThread::IO) {}
WalletSigninHelperTest() {}
virtual void SetUp() OVERRIDE {
io_thread_.StartIOThread();
profile_.CreateRequestContext();
signin_helper_.reset(new WalletSigninHelperForTesting(
&mock_delegate_,
profile_.GetRequestContext()));
browser_context_.GetRequestContext()));
EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state());
}
virtual void TearDown() OVERRIDE {
signin_helper_.reset();
profile_.ResetRequestContext();
io_thread_.Stop();
}
protected:
......@@ -188,10 +184,8 @@ class WalletSigninHelperTest : public testing::Test {
MockWalletSigninHelperDelegate mock_delegate_;
private:
// The profile's request context must be released on the IO thread.
content::TestBrowserThread io_thread_;
net::TestURLFetcherFactory factory_;
TestingProfile profile_;
content::TestBrowserContext browser_context_;
};
TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) {
......
......@@ -7,13 +7,13 @@
#include "base/guid.h"
#include "base/prefs/pref_service.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/credit_card.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/user_prefs/user_prefs.h"
#include "components/webdata/encryptor/encryptor.h"
#include "content/public/browser/browser_context.h"
namespace autofill {
namespace test {
......@@ -142,7 +142,7 @@ void SetCreditCardInfo(CreditCard* credit_card,
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.
#if defined(OS_MACOSX)
Encryptor::UseMockKeychain(true);
......@@ -150,8 +150,8 @@ void DisableSystemServices(Profile* profile) {
// Disable auxiliary profiles for unit testing. These reach out to system
// services on the Mac.
if (profile) {
user_prefs::UserPrefs::Get(profile)->SetBoolean(
if (browser_context) {
user_prefs::UserPrefs::Get(browser_context)->SetBoolean(
prefs::kAutofillAuxiliaryProfilesEnabled, false);
}
}
......
......@@ -5,7 +5,9 @@
#ifndef 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 {
......@@ -68,7 +70,7 @@ void SetCreditCardInfo(CreditCard* credit_card,
// TODO(isherman): We should do this automatically for all tests, not manually
// on a per-test basis: http://crbug.com/57221
// 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 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