| Index: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| index 769ffaa763d6b2adc00a0c7c929d2be897f53587..4dd6833c453d5d92fb0b83d21e861627d55b8fef 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| @@ -3,7 +3,11 @@
|
| // found in the LICENSE file.
|
|
|
| #include <map>
|
| +#include <utility>
|
|
|
| +#define I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_ // Use base/basictypes.h instead.
|
| +
|
| +#include "base/basictypes.h"
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| #include "base/callback.h"
|
| @@ -54,8 +58,10 @@
|
| #include "grit/generated_resources.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
|
| -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h"
|
| +#include "third_party/libaddressinput/chromium/preload_address_validator.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_problem.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_validator.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
|
|
| #if defined(OS_WIN)
|
| @@ -69,11 +75,7 @@ namespace autofill {
|
|
|
| namespace {
|
|
|
| -using ::i18n::addressinput::AddressData;
|
| -using ::i18n::addressinput::AddressProblemFilter;
|
| -using ::i18n::addressinput::AddressProblem;
|
| -using ::i18n::addressinput::AddressProblems;
|
| -using ::i18n::addressinput::AddressValidator;
|
| +using ::i18n::addressinput::FieldProblemMap;
|
| using testing::AtLeast;
|
| using testing::DoAll;
|
| using testing::Return;
|
| @@ -343,7 +345,7 @@ class TestAutofillDialogController
|
| GetTestingManager();
|
| }
|
|
|
| - virtual AddressValidator* GetValidator() OVERRIDE {
|
| + virtual PreloadAddressValidator* GetValidator() OVERRIDE {
|
| return &mock_validator_;
|
| }
|
|
|
| @@ -1008,15 +1010,13 @@ TEST_F(AutofillDialogControllerTest, AutofillProfilesPopInvalidIntoEdit) {
|
| // Now make up a problem and make sure the profile isn't in the list.
|
| Reset();
|
| SwitchToAutofill();
|
| - AddressProblems problems;
|
| - problems.push_back(
|
| - AddressProblem(::i18n::addressinput::POSTAL_CODE,
|
| - AddressProblem::MISMATCHING_VALUE,
|
| - IDS_LEARN_MORE));
|
| + FieldProblemMap problems;
|
| + problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE,
|
| + ::i18n::addressinput::MISMATCHING_VALUE));
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - ValidateAddress(CountryCodeMatcher("US"), _, _)).
|
| + Validate(CountryCodeMatcher("US"), _, _)).
|
| WillRepeatedly(DoAll(SetArgPointee<2>(problems),
|
| - Return(AddressValidator::SUCCESS)));
|
| + Return(PreloadAddressValidator::SUCCESS)));
|
|
|
| controller()->GetTestingManager()->AddTestingProfile(&verified_profile);
|
| shipping_model = GetMenuModelForSection(SECTION_SHIPPING);
|
| @@ -1040,17 +1040,15 @@ TEST_F(AutofillDialogControllerTest, AutofillProfilesRevalidateAfterRulesLoad) {
|
| EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
|
| EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING));
|
|
|
| - AddressProblems problems;
|
| - problems.push_back(
|
| - AddressProblem(::i18n::addressinput::POSTAL_CODE,
|
| - AddressProblem::MISMATCHING_VALUE,
|
| - IDS_LEARN_MORE));
|
| + FieldProblemMap problems;
|
| + problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE,
|
| + ::i18n::addressinput::MISMATCHING_VALUE));
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - ValidateAddress(CountryCodeMatcher("US"), _, _)).
|
| + Validate(CountryCodeMatcher("US"), _, _)).
|
| WillRepeatedly(DoAll(SetArgPointee<2>(problems),
|
| - Return(AddressValidator::SUCCESS)));
|
| + Return(PreloadAddressValidator::SUCCESS)));
|
|
|
| - controller()->OnAddressValidationRulesLoaded("US", true);
|
| + controller()->AddressValidationRulesLoaded(true, "US", 0);
|
| EXPECT_EQ(4, shipping_model->GetItemCount());
|
| EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
|
| EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING));
|
| @@ -3208,14 +3206,14 @@ TEST_F(AutofillDialogControllerTest, CountryChangeUpdatesSection) {
|
|
|
| TEST_F(AutofillDialogControllerTest, CorrectCountryFromInputs) {
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - ValidateAddress(CountryCodeMatcher("DE"), _, _));
|
| + Validate(CountryCodeMatcher("DE"), _, _));
|
|
|
| FieldValueMap billing_inputs;
|
| billing_inputs[ADDRESS_BILLING_COUNTRY] = ASCIIToUTF16("Germany");
|
| controller()->InputsAreValid(SECTION_BILLING, billing_inputs);
|
|
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - ValidateAddress(CountryCodeMatcher("FR"), _, _));
|
| + Validate(CountryCodeMatcher("FR"), _, _));
|
|
|
| FieldValueMap shipping_inputs;
|
| shipping_inputs[ADDRESS_HOME_COUNTRY] = ASCIIToUTF16("France");
|
| @@ -3225,10 +3223,10 @@ TEST_F(AutofillDialogControllerTest, CorrectCountryFromInputs) {
|
| TEST_F(AutofillDialogControllerTest, ValidationRulesLoadedOnCountryChange) {
|
| ResetControllerWithFormData(DefaultFormData());
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - LoadRules("US")).Times(AtLeast(1));
|
| + MockLoadRules("US")).Times(AtLeast(1));
|
| controller()->Show();
|
|
|
| - EXPECT_CALL(*controller()->GetMockValidator(), LoadRules("FR"));
|
| + EXPECT_CALL(*controller()->GetMockValidator(), MockLoadRules("FR"));
|
| controller()->UserEditedOrActivatedInput(SECTION_BILLING,
|
| ADDRESS_BILLING_COUNTRY,
|
| gfx::NativeView(),
|
| @@ -3242,9 +3240,9 @@ TEST_F(AutofillDialogControllerTest, UsValidationRulesLoadedForJpOnlyProfile) {
|
| AutofillProfile jp_profile(base::GenerateGUID(), kSettingsOrigin);
|
| jp_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP"));
|
| controller()->GetTestingManager()->AddTestingProfile(&jp_profile);
|
| - EXPECT_CALL(*controller()->GetMockValidator(), LoadRules("US"));
|
| + EXPECT_CALL(*controller()->GetMockValidator(), MockLoadRules("US"));
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - LoadRules("JP")).Times(AtLeast(1));
|
| + MockLoadRules("JP")).Times(AtLeast(1));
|
| controller()->Show();
|
| }
|
|
|
| @@ -3254,8 +3252,8 @@ TEST_F(AutofillDialogControllerTest, InvalidWhenRulesNotReady) {
|
|
|
| // If the rules haven't loaded yet, validation errors should show on submit.
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - ValidateAddress(CountryCodeMatcher("US"), _, _)).
|
| - WillRepeatedly(Return(AddressValidator::RULES_NOT_READY));
|
| + Validate(CountryCodeMatcher("US"), _, _)).
|
| + WillRepeatedly(Return(PreloadAddressValidator::RULES_NOT_READY));
|
|
|
| FieldValueMap inputs;
|
| inputs[ADDRESS_HOME_ZIP] = ASCIIToUTF16("1234");
|
| @@ -3284,8 +3282,8 @@ TEST_F(AutofillDialogControllerTest, ValidButUnverifiedWhenRulesFail) {
|
|
|
| // If the rules are unavailable, validation errors should not show.
|
| EXPECT_CALL(*controller()->GetMockValidator(),
|
| - ValidateAddress(CountryCodeMatcher("US"), _, _)).
|
| - WillRepeatedly(Return(AddressValidator::RULES_UNAVAILABLE));
|
| + Validate(CountryCodeMatcher("US"), _, _))
|
| + .WillRepeatedly(Return(PreloadAddressValidator::RULES_UNAVAILABLE));
|
|
|
| FieldValueMap outputs;
|
| AutofillProfile full_profile(test::GetFullProfile());
|
|
|