Commit 87353147 authored by blundell@google.com's avatar blundell@google.com

Componentize several Autofill unit tests.

The PersonalDataManager unittests are the only ones requiring non-trivial
refactoring.

BUG=303083
R=isherman@chromium.org
TBR=jochen

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255541 0039d316-1c4b-4281-b951-d872f2087c98
parent be9d55eb
...@@ -123,7 +123,7 @@ class AutofillTest : public InProcessBrowserTest { ...@@ -123,7 +123,7 @@ class AutofillTest : public InProcessBrowserTest {
virtual void SetUpOnMainThread() OVERRIDE { virtual void SetUpOnMainThread() OVERRIDE {
// Don't want Keychain coming up on Mac. // Don't want Keychain coming up on Mac.
test::DisableSystemServices(browser()->profile()); test::DisableSystemServices(browser()->profile()->GetPrefs());
} }
virtual void CleanUpOnMainThread() OVERRIDE { virtual void CleanUpOnMainThread() OVERRIDE {
......
...@@ -209,7 +209,7 @@ class AutofillInteractiveTest : public InProcessBrowserTest { ...@@ -209,7 +209,7 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
TranslateService::SetUseInfobar(true); TranslateService::SetUseInfobar(true);
// Don't want Keychain coming up on Mac. // Don't want Keychain coming up on Mac.
test::DisableSystemServices(browser()->profile()); test::DisableSystemServices(browser()->profile()->GetPrefs());
// Inject the test delegate into the AutofillManager. // Inject the test delegate into the AutofillManager.
content::WebContents* web_contents = GetWebContents(); content::WebContents* web_contents = GetWebContents();
......
...@@ -451,7 +451,7 @@ class RemoveAutofillTester : public autofill::PersonalDataManagerObserver { ...@@ -451,7 +451,7 @@ class RemoveAutofillTester : public autofill::PersonalDataManagerObserver {
explicit RemoveAutofillTester(TestingProfile* profile) explicit RemoveAutofillTester(TestingProfile* profile)
: personal_data_manager_( : personal_data_manager_(
autofill::PersonalDataManagerFactory::GetForProfile(profile)) { autofill::PersonalDataManagerFactory::GetForProfile(profile)) {
autofill::test::DisableSystemServices(profile); autofill::test::DisableSystemServices(profile->GetPrefs());
personal_data_manager_->AddObserver(this); personal_data_manager_->AddObserver(this);
} }
......
...@@ -62,7 +62,7 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest { ...@@ -62,7 +62,7 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
virtual void SetUpOnMainThread() OVERRIDE { virtual void SetUpOnMainThread() OVERRIDE {
// Disable Autofill requesting access to AddressBook data. This will cause // Disable Autofill requesting access to AddressBook data. This will cause
// the tests to hang on Mac. // the tests to hang on Mac.
autofill::test::DisableSystemServices(browser()->profile()); autofill::test::DisableSystemServices(browser()->profile()->GetPrefs());
// Set observer for popup. // Set observer for popup.
ChromePasswordManagerClient* client = ChromePasswordManagerClient* client =
......
...@@ -439,7 +439,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, ...@@ -439,7 +439,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
net::TestURLFetcherFactory factory; net::TestURLFetcherFactory factory;
// Disable Autofill requesting access to AddressBook data. This causes // Disable Autofill requesting access to AddressBook data. This causes
// the test to hang on Mac. // the test to hang on Mac.
autofill::test::DisableSystemServices(browser()->profile()); autofill::test::DisableSystemServices(browser()->profile()->GetPrefs());
// Visit a signup form. // Visit a signup form.
NavigateToFile("/password/signup_form.html"); NavigateToFile("/password/signup_form.html");
......
...@@ -315,7 +315,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { ...@@ -315,7 +315,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
} }
virtual void SetUpOnMainThread() OVERRIDE { virtual void SetUpOnMainThread() OVERRIDE {
autofill::test::DisableSystemServices(browser()->profile()); autofill::test::DisableSystemServices(browser()->profile()->GetPrefs());
InitializeController(); InitializeController();
} }
......
...@@ -72,7 +72,7 @@ class AutofillDialogCocoaBrowserTest : public InProcessBrowserTest { ...@@ -72,7 +72,7 @@ class AutofillDialogCocoaBrowserTest : public InProcessBrowserTest {
virtual void SetUpOnMainThread() OVERRIDE { virtual void SetUpOnMainThread() OVERRIDE {
// Ensure Mac OS X does not pop up a modal dialog for the Address Book. // Ensure Mac OS X does not pop up a modal dialog for the Address Book.
autofill::test::DisableSystemServices(browser()->profile()); autofill::test::DisableSystemServices(browser()->profile()->GetPrefs());
// Stick to local autofill mode. // Stick to local autofill mode.
browser()->profile()->GetPrefs()->SetBoolean( browser()->profile()->GetPrefs()->SetBoolean(
......
...@@ -265,7 +265,7 @@ static void SetupSettingsAutofillPageTest(Profile* profile, ...@@ -265,7 +265,7 @@ static void SetupSettingsAutofillPageTest(Profile* profile,
const char* zipcode, const char* zipcode,
const char* country, const char* country,
const char* phone) { const char* phone) {
autofill::test::DisableSystemServices(profile); autofill::test::DisableSystemServices(profile->GetPrefs());
AutofillProfile autofill_profile; AutofillProfile autofill_profile;
autofill::test::SetProfileInfo(&autofill_profile, autofill::test::SetProfileInfo(&autofill_profile,
first_name, first_name,
......
...@@ -1950,11 +1950,7 @@ ...@@ -1950,11 +1950,7 @@
'../components/autofill/content/browser/wallet/wallet_items_unittest.cc', '../components/autofill/content/browser/wallet/wallet_items_unittest.cc',
'../components/autofill/content/browser/wallet/wallet_service_url_unittest.cc', '../components/autofill/content/browser/wallet/wallet_service_url_unittest.cc',
'../components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc', '../components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc',
'../components/autofill/core/browser/autofill_external_delegate_unittest.cc',
'../components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc',
'../components/autofill/core/browser/autofill_metrics_unittest.cc', '../components/autofill/core/browser/autofill_metrics_unittest.cc',
'../components/autofill/core/browser/password_autofill_manager_unittest.cc',
'../components/autofill/core/browser/personal_data_manager_unittest.cc',
# TODO(yael): Move to //components/components_tests.gypi once # TODO(yael): Move to //components/components_tests.gypi once
# nacl_defines is moved out of chrome.gyp into a common place. # nacl_defines is moved out of chrome.gyp into a common place.
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/popup_item_ids.h" #include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/browser/test_autofill_driver.h" #include "components/autofill/core/browser/test_autofill_driver.h"
......
...@@ -261,7 +261,7 @@ void AutofillMetricsTest::SetUp() { ...@@ -261,7 +261,7 @@ void AutofillMetricsTest::SetUp() {
ChromeRenderViewHostTestHarness::SetUp(); ChromeRenderViewHostTestHarness::SetUp();
// Ensure Mac OS X does not pop up a modal dialog for the Address Book. // Ensure Mac OS X does not pop up a modal dialog for the Address Book.
autofill::test::DisableSystemServices(profile()); autofill::test::DisableSystemServices(profile()->GetPrefs());
PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile(), NULL); PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile(), NULL);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "components/encryptor/os_crypt.h" #include "components/encryptor/os_crypt.h"
#include "components/user_prefs/pref_registry_syncable.h" #include "components/user_prefs/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.h" #include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
using base::ASCIIToUTF16; using base::ASCIIToUTF16;
...@@ -204,7 +203,7 @@ void SetCreditCardInfo(CreditCard* credit_card, ...@@ -204,7 +203,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(content::BrowserContext* browser_context) { void DisableSystemServices(PrefService* prefs) {
// 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)
OSCrypt::UseMockKeychain(true); OSCrypt::UseMockKeychain(true);
...@@ -212,10 +211,8 @@ void DisableSystemServices(content::BrowserContext* browser_context) { ...@@ -212,10 +211,8 @@ void DisableSystemServices(content::BrowserContext* browser_context) {
// 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 (browser_context) { if (prefs)
user_prefs::UserPrefs::Get(browser_context)->SetBoolean( prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false);
prefs::kAutofillAuxiliaryProfilesEnabled, false);
}
} }
} // namespace test } // namespace test
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
class PrefService; class PrefService;
namespace content {
class BrowserContext;
}
namespace autofill { namespace autofill {
class AutofillProfile; class AutofillProfile;
...@@ -93,7 +89,7 @@ void SetCreditCardInfo(CreditCard* credit_card, ...@@ -93,7 +89,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(content::BrowserContext* browser_context); void DisableSystemServices(PrefService* prefs);
} // namespace test } // namespace test
} // namespace autofill } // namespace autofill
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
'autofill/core/browser/autofill_data_model_unittest.cc', 'autofill/core/browser/autofill_data_model_unittest.cc',
'autofill/core/browser/autofill_download_unittest.cc', 'autofill/core/browser/autofill_download_unittest.cc',
'autofill/core/browser/autofill_download_url_unittest.cc', 'autofill/core/browser/autofill_download_url_unittest.cc',
'autofill/core/browser/autofill_external_delegate_unittest.cc',
'autofill/core/browser/autofill_field_unittest.cc', 'autofill/core/browser/autofill_field_unittest.cc',
'autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc',
'autofill/core/browser/autofill_manager_unittest.cc', 'autofill/core/browser/autofill_manager_unittest.cc',
'autofill/core/browser/autofill_merge_unittest.cc', 'autofill/core/browser/autofill_merge_unittest.cc',
'autofill/core/browser/autofill_profile_unittest.cc', 'autofill/core/browser/autofill_profile_unittest.cc',
...@@ -39,7 +41,9 @@ ...@@ -39,7 +41,9 @@
'autofill/core/browser/form_field_unittest.cc', 'autofill/core/browser/form_field_unittest.cc',
'autofill/core/browser/form_structure_unittest.cc', 'autofill/core/browser/form_structure_unittest.cc',
'autofill/core/browser/name_field_unittest.cc', 'autofill/core/browser/name_field_unittest.cc',
'autofill/core/browser/password_autofill_manager_unittest.cc',
'autofill/core/browser/password_generator_unittest.cc', 'autofill/core/browser/password_generator_unittest.cc',
'autofill/core/browser/personal_data_manager_unittest.cc',
'autofill/core/browser/phone_field_unittest.cc', 'autofill/core/browser/phone_field_unittest.cc',
'autofill/core/browser/phone_number_unittest.cc', 'autofill/core/browser/phone_number_unittest.cc',
'autofill/core/browser/phone_number_i18n_unittest.cc', 'autofill/core/browser/phone_number_i18n_unittest.cc',
......
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