| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <map> | 5 #include <map> |
| 6 #include <utility> |
| 6 | 7 |
| 8 #define I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_ // Use base/basictypes.h instead. |
| 9 |
| 10 #include "base/basictypes.h" |
| 7 #include "base/bind.h" | 11 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 13 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 11 #include "base/guid.h" | 15 #include "base/guid.h" |
| 12 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 14 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
| 15 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 16 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 47 #include "components/autofill/core/common/autofill_switches.h" | 51 #include "components/autofill/core/common/autofill_switches.h" |
| 48 #include "components/autofill/core/common/form_data.h" | 52 #include "components/autofill/core/common/form_data.h" |
| 49 #include "components/user_prefs/user_prefs.h" | 53 #include "components/user_prefs/user_prefs.h" |
| 50 #include "content/public/browser/web_contents.h" | 54 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/test/mock_render_process_host.h" | 55 #include "content/public/test/mock_render_process_host.h" |
| 52 #include "google_apis/gaia/google_service_auth_error.h" | 56 #include "google_apis/gaia/google_service_auth_error.h" |
| 53 #include "grit/component_scaled_resources.h" | 57 #include "grit/component_scaled_resources.h" |
| 54 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
| 55 #include "testing/gmock/include/gmock/gmock.h" | 59 #include "testing/gmock/include/gmock/gmock.h" |
| 56 #include "testing/gtest/include/gtest/gtest.h" | 60 #include "testing/gtest/include/gtest/gtest.h" |
| 57 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_data.h" | 61 #include "third_party/libaddressinput/chromium/preload_address_validator.h" |
| 58 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_validator.h" | 62 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi
eld.h" |
| 63 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr
oblem.h" |
| 64 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_va
lidator.h" |
| 59 #include "ui/base/resource/resource_bundle.h" | 65 #include "ui/base/resource/resource_bundle.h" |
| 60 | 66 |
| 61 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
| 62 #include "ui/base/win/scoped_ole_initializer.h" | 68 #include "ui/base/win/scoped_ole_initializer.h" |
| 63 #endif | 69 #endif |
| 64 | 70 |
| 65 using base::ASCIIToUTF16; | 71 using base::ASCIIToUTF16; |
| 66 using base::UTF8ToUTF16; | 72 using base::UTF8ToUTF16; |
| 67 | 73 |
| 68 namespace autofill { | 74 namespace autofill { |
| 69 | 75 |
| 70 namespace { | 76 namespace { |
| 71 | 77 |
| 72 using ::i18n::addressinput::AddressData; | 78 using ::i18n::addressinput::FieldProblemMap; |
| 73 using ::i18n::addressinput::AddressProblemFilter; | |
| 74 using ::i18n::addressinput::AddressProblem; | |
| 75 using ::i18n::addressinput::AddressProblems; | |
| 76 using ::i18n::addressinput::AddressValidator; | |
| 77 using testing::AtLeast; | 79 using testing::AtLeast; |
| 78 using testing::DoAll; | 80 using testing::DoAll; |
| 79 using testing::Return; | 81 using testing::Return; |
| 80 using testing::SetArgPointee; | 82 using testing::SetArgPointee; |
| 81 using testing::_; | 83 using testing::_; |
| 82 | 84 |
| 83 const char kSourceUrl[] = "http://localbike.shop"; | 85 const char kSourceUrl[] = "http://localbike.shop"; |
| 84 const char kFakeEmail[] = "user@chromium.org"; | 86 const char kFakeEmail[] = "user@chromium.org"; |
| 85 const char kFakeFingerprintEncoded[] = "CgVaAwiACA=="; | 87 const char kFakeFingerprintEncoded[] = "CgVaAwiACA=="; |
| 86 const char kEditedBillingAddress[] = "123 edited billing address"; | 88 const char kEditedBillingAddress[] = "123 edited billing address"; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 using AutofillDialogControllerImpl::NOT_CHECKED; | 338 using AutofillDialogControllerImpl::NOT_CHECKED; |
| 337 using AutofillDialogControllerImpl::popup_input_type; | 339 using AutofillDialogControllerImpl::popup_input_type; |
| 338 using AutofillDialogControllerImpl::SignedInState; | 340 using AutofillDialogControllerImpl::SignedInState; |
| 339 | 341 |
| 340 protected: | 342 protected: |
| 341 virtual PersonalDataManager* GetManager() const OVERRIDE { | 343 virtual PersonalDataManager* GetManager() const OVERRIDE { |
| 342 return const_cast<TestAutofillDialogController*>(this)-> | 344 return const_cast<TestAutofillDialogController*>(this)-> |
| 343 GetTestingManager(); | 345 GetTestingManager(); |
| 344 } | 346 } |
| 345 | 347 |
| 346 virtual AddressValidator* GetValidator() OVERRIDE { | 348 virtual PreloadAddressValidator* GetValidator() OVERRIDE { |
| 347 return &mock_validator_; | 349 return &mock_validator_; |
| 348 } | 350 } |
| 349 | 351 |
| 350 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { | 352 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { |
| 351 return &mock_wallet_client_; | 353 return &mock_wallet_client_; |
| 352 } | 354 } |
| 353 | 355 |
| 354 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { | 356 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { |
| 355 open_tab_url_ = url; | 357 open_tab_url_ = url; |
| 356 } | 358 } |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1003 |
| 1002 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 1004 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
| 1003 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1005 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 1004 EXPECT_EQ(4, shipping_model->GetItemCount()); | 1006 EXPECT_EQ(4, shipping_model->GetItemCount()); |
| 1005 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 1007 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1006 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING)); | 1008 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING)); |
| 1007 | 1009 |
| 1008 // Now make up a problem and make sure the profile isn't in the list. | 1010 // Now make up a problem and make sure the profile isn't in the list. |
| 1009 Reset(); | 1011 Reset(); |
| 1010 SwitchToAutofill(); | 1012 SwitchToAutofill(); |
| 1011 AddressProblems problems; | 1013 FieldProblemMap problems; |
| 1012 problems.push_back( | 1014 problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE, |
| 1013 AddressProblem(::i18n::addressinput::POSTAL_CODE, | 1015 ::i18n::addressinput::MISMATCHING_VALUE)); |
| 1014 AddressProblem::MISMATCHING_VALUE, | |
| 1015 IDS_LEARN_MORE)); | |
| 1016 EXPECT_CALL(*controller()->GetMockValidator(), | 1016 EXPECT_CALL(*controller()->GetMockValidator(), |
| 1017 ValidateAddress(CountryCodeMatcher("US"), _, _)). | 1017 Validate(CountryCodeMatcher("US"), _, _)). |
| 1018 WillRepeatedly(DoAll(SetArgPointee<2>(problems), | 1018 WillRepeatedly(DoAll(SetArgPointee<2>(problems), |
| 1019 Return(AddressValidator::SUCCESS))); | 1019 Return(PreloadAddressValidator::SUCCESS))); |
| 1020 | 1020 |
| 1021 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1021 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 1022 shipping_model = GetMenuModelForSection(SECTION_SHIPPING); | 1022 shipping_model = GetMenuModelForSection(SECTION_SHIPPING); |
| 1023 EXPECT_EQ(4, shipping_model->GetItemCount()); | 1023 EXPECT_EQ(4, shipping_model->GetItemCount()); |
| 1024 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 1024 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1025 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); | 1025 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 // Makes sure suggestion profiles are re-validated when validation rules load. | 1028 // Makes sure suggestion profiles are re-validated when validation rules load. |
| 1029 TEST_F(AutofillDialogControllerTest, AutofillProfilesRevalidateAfterRulesLoad) { | 1029 TEST_F(AutofillDialogControllerTest, AutofillProfilesRevalidateAfterRulesLoad) { |
| 1030 SwitchToAutofill(); | 1030 SwitchToAutofill(); |
| 1031 SuggestionsMenuModel* shipping_model = | 1031 SuggestionsMenuModel* shipping_model = |
| 1032 GetMenuModelForSection(SECTION_SHIPPING); | 1032 GetMenuModelForSection(SECTION_SHIPPING); |
| 1033 EXPECT_EQ(3, shipping_model->GetItemCount()); | 1033 EXPECT_EQ(3, shipping_model->GetItemCount()); |
| 1034 // "Same as billing" is selected. | 1034 // "Same as billing" is selected. |
| 1035 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 1035 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1036 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); | 1036 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); |
| 1037 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 1037 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
| 1038 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1038 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 1039 EXPECT_EQ(4, shipping_model->GetItemCount()); | 1039 EXPECT_EQ(4, shipping_model->GetItemCount()); |
| 1040 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 1040 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1041 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING)); | 1041 EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING)); |
| 1042 | 1042 |
| 1043 AddressProblems problems; | 1043 FieldProblemMap problems; |
| 1044 problems.push_back( | 1044 problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE, |
| 1045 AddressProblem(::i18n::addressinput::POSTAL_CODE, | 1045 ::i18n::addressinput::MISMATCHING_VALUE)); |
| 1046 AddressProblem::MISMATCHING_VALUE, | |
| 1047 IDS_LEARN_MORE)); | |
| 1048 EXPECT_CALL(*controller()->GetMockValidator(), | 1046 EXPECT_CALL(*controller()->GetMockValidator(), |
| 1049 ValidateAddress(CountryCodeMatcher("US"), _, _)). | 1047 Validate(CountryCodeMatcher("US"), _, _)). |
| 1050 WillRepeatedly(DoAll(SetArgPointee<2>(problems), | 1048 WillRepeatedly(DoAll(SetArgPointee<2>(problems), |
| 1051 Return(AddressValidator::SUCCESS))); | 1049 Return(PreloadAddressValidator::SUCCESS))); |
| 1052 | 1050 |
| 1053 controller()->OnAddressValidationRulesLoaded("US", true); | 1051 controller()->AddressValidationRulesLoaded(true, "US", 0); |
| 1054 EXPECT_EQ(4, shipping_model->GetItemCount()); | 1052 EXPECT_EQ(4, shipping_model->GetItemCount()); |
| 1055 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 1053 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1056 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); | 1054 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); |
| 1057 } | 1055 } |
| 1058 | 1056 |
| 1059 // Makes sure that the choice of which Autofill profile to use for each section | 1057 // Makes sure that the choice of which Autofill profile to use for each section |
| 1060 // is sticky. | 1058 // is sticky. |
| 1061 TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) { | 1059 TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) { |
| 1062 SwitchToAutofill(); | 1060 SwitchToAutofill(); |
| 1063 AutofillProfile profile(test::GetVerifiedProfile()); | 1061 AutofillProfile profile(test::GetVerifiedProfile()); |
| (...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3201 gfx::Rect(), | 3199 gfx::Rect(), |
| 3202 ASCIIToUTF16("Italy"), | 3200 ASCIIToUTF16("Italy"), |
| 3203 true); | 3201 true); |
| 3204 updates = view->section_updates(); | 3202 updates = view->section_updates(); |
| 3205 EXPECT_EQ(1U, updates[SECTION_BILLING]); | 3203 EXPECT_EQ(1U, updates[SECTION_BILLING]); |
| 3206 EXPECT_EQ(1U, updates.size()); | 3204 EXPECT_EQ(1U, updates.size()); |
| 3207 } | 3205 } |
| 3208 | 3206 |
| 3209 TEST_F(AutofillDialogControllerTest, CorrectCountryFromInputs) { | 3207 TEST_F(AutofillDialogControllerTest, CorrectCountryFromInputs) { |
| 3210 EXPECT_CALL(*controller()->GetMockValidator(), | 3208 EXPECT_CALL(*controller()->GetMockValidator(), |
| 3211 ValidateAddress(CountryCodeMatcher("DE"), _, _)); | 3209 Validate(CountryCodeMatcher("DE"), _, _)); |
| 3212 | 3210 |
| 3213 FieldValueMap billing_inputs; | 3211 FieldValueMap billing_inputs; |
| 3214 billing_inputs[ADDRESS_BILLING_COUNTRY] = ASCIIToUTF16("Germany"); | 3212 billing_inputs[ADDRESS_BILLING_COUNTRY] = ASCIIToUTF16("Germany"); |
| 3215 controller()->InputsAreValid(SECTION_BILLING, billing_inputs); | 3213 controller()->InputsAreValid(SECTION_BILLING, billing_inputs); |
| 3216 | 3214 |
| 3217 EXPECT_CALL(*controller()->GetMockValidator(), | 3215 EXPECT_CALL(*controller()->GetMockValidator(), |
| 3218 ValidateAddress(CountryCodeMatcher("FR"), _, _)); | 3216 Validate(CountryCodeMatcher("FR"), _, _)); |
| 3219 | 3217 |
| 3220 FieldValueMap shipping_inputs; | 3218 FieldValueMap shipping_inputs; |
| 3221 shipping_inputs[ADDRESS_HOME_COUNTRY] = ASCIIToUTF16("France"); | 3219 shipping_inputs[ADDRESS_HOME_COUNTRY] = ASCIIToUTF16("France"); |
| 3222 controller()->InputsAreValid(SECTION_SHIPPING, shipping_inputs); | 3220 controller()->InputsAreValid(SECTION_SHIPPING, shipping_inputs); |
| 3223 } | 3221 } |
| 3224 | 3222 |
| 3225 TEST_F(AutofillDialogControllerTest, ValidationRulesLoadedOnCountryChange) { | 3223 TEST_F(AutofillDialogControllerTest, ValidationRulesLoadedOnCountryChange) { |
| 3226 ResetControllerWithFormData(DefaultFormData()); | 3224 ResetControllerWithFormData(DefaultFormData()); |
| 3227 EXPECT_CALL(*controller()->GetMockValidator(), | 3225 EXPECT_CALL(*controller()->GetMockValidator(), |
| 3228 LoadRules("US")).Times(AtLeast(1)); | 3226 MockLoadRules("US")).Times(AtLeast(1)); |
| 3229 controller()->Show(); | 3227 controller()->Show(); |
| 3230 | 3228 |
| 3231 EXPECT_CALL(*controller()->GetMockValidator(), LoadRules("FR")); | 3229 EXPECT_CALL(*controller()->GetMockValidator(), MockLoadRules("FR")); |
| 3232 controller()->UserEditedOrActivatedInput(SECTION_BILLING, | 3230 controller()->UserEditedOrActivatedInput(SECTION_BILLING, |
| 3233 ADDRESS_BILLING_COUNTRY, | 3231 ADDRESS_BILLING_COUNTRY, |
| 3234 gfx::NativeView(), | 3232 gfx::NativeView(), |
| 3235 gfx::Rect(), | 3233 gfx::Rect(), |
| 3236 ASCIIToUTF16("France"), | 3234 ASCIIToUTF16("France"), |
| 3237 true); | 3235 true); |
| 3238 } | 3236 } |
| 3239 | 3237 |
| 3240 TEST_F(AutofillDialogControllerTest, UsValidationRulesLoadedForJpOnlyProfile) { | 3238 TEST_F(AutofillDialogControllerTest, UsValidationRulesLoadedForJpOnlyProfile) { |
| 3241 ResetControllerWithFormData(DefaultFormData()); | 3239 ResetControllerWithFormData(DefaultFormData()); |
| 3242 AutofillProfile jp_profile(base::GenerateGUID(), kSettingsOrigin); | 3240 AutofillProfile jp_profile(base::GenerateGUID(), kSettingsOrigin); |
| 3243 jp_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP")); | 3241 jp_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP")); |
| 3244 controller()->GetTestingManager()->AddTestingProfile(&jp_profile); | 3242 controller()->GetTestingManager()->AddTestingProfile(&jp_profile); |
| 3245 EXPECT_CALL(*controller()->GetMockValidator(), LoadRules("US")); | 3243 EXPECT_CALL(*controller()->GetMockValidator(), MockLoadRules("US")); |
| 3246 EXPECT_CALL(*controller()->GetMockValidator(), | 3244 EXPECT_CALL(*controller()->GetMockValidator(), |
| 3247 LoadRules("JP")).Times(AtLeast(1)); | 3245 MockLoadRules("JP")).Times(AtLeast(1)); |
| 3248 controller()->Show(); | 3246 controller()->Show(); |
| 3249 } | 3247 } |
| 3250 | 3248 |
| 3251 TEST_F(AutofillDialogControllerTest, InvalidWhenRulesNotReady) { | 3249 TEST_F(AutofillDialogControllerTest, InvalidWhenRulesNotReady) { |
| 3252 // Select "Add new shipping address...". | 3250 // Select "Add new shipping address...". |
| 3253 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 3251 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 3254 | 3252 |
| 3255 // If the rules haven't loaded yet, validation errors should show on submit. | 3253 // If the rules haven't loaded yet, validation errors should show on submit. |
| 3256 EXPECT_CALL(*controller()->GetMockValidator(), | 3254 EXPECT_CALL(*controller()->GetMockValidator(), |
| 3257 ValidateAddress(CountryCodeMatcher("US"), _, _)). | 3255 Validate(CountryCodeMatcher("US"), _, _)). |
| 3258 WillRepeatedly(Return(AddressValidator::RULES_NOT_READY)); | 3256 WillRepeatedly(Return(PreloadAddressValidator::RULES_NOT_READY)); |
| 3259 | 3257 |
| 3260 FieldValueMap inputs; | 3258 FieldValueMap inputs; |
| 3261 inputs[ADDRESS_HOME_ZIP] = ASCIIToUTF16("1234"); | 3259 inputs[ADDRESS_HOME_ZIP] = ASCIIToUTF16("1234"); |
| 3262 inputs[ADDRESS_HOME_COUNTRY] = ASCIIToUTF16("United States"); | 3260 inputs[ADDRESS_HOME_COUNTRY] = ASCIIToUTF16("United States"); |
| 3263 | 3261 |
| 3264 ValidityMessages messages = | 3262 ValidityMessages messages = |
| 3265 controller()->InputsAreValid(SECTION_SHIPPING, inputs); | 3263 controller()->InputsAreValid(SECTION_SHIPPING, inputs); |
| 3266 EXPECT_FALSE(messages.GetMessageOrDefault(ADDRESS_HOME_ZIP).text.empty()); | 3264 EXPECT_FALSE(messages.GetMessageOrDefault(ADDRESS_HOME_ZIP).text.empty()); |
| 3267 EXPECT_FALSE(messages.HasSureError(ADDRESS_HOME_ZIP)); | 3265 EXPECT_FALSE(messages.HasSureError(ADDRESS_HOME_ZIP)); |
| 3268 // Country should never show an error message as it's always valid. | 3266 // Country should never show an error message as it's always valid. |
| 3269 EXPECT_TRUE(messages.GetMessageOrDefault(ADDRESS_HOME_COUNTRY).text.empty()); | 3267 EXPECT_TRUE(messages.GetMessageOrDefault(ADDRESS_HOME_COUNTRY).text.empty()); |
| 3270 } | 3268 } |
| 3271 | 3269 |
| 3272 TEST_F(AutofillDialogControllerTest, ValidButUnverifiedWhenRulesFail) { | 3270 TEST_F(AutofillDialogControllerTest, ValidButUnverifiedWhenRulesFail) { |
| 3273 SwitchToAutofill(); | 3271 SwitchToAutofill(); |
| 3274 | 3272 |
| 3275 // Add suggestions so the credit card and billing sections aren't showing | 3273 // Add suggestions so the credit card and billing sections aren't showing |
| 3276 // their manual inputs (to isolate to just shipping). | 3274 // their manual inputs (to isolate to just shipping). |
| 3277 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 3275 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
| 3278 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 3276 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 3279 CreditCard verified_card(test::GetVerifiedCreditCard()); | 3277 CreditCard verified_card(test::GetVerifiedCreditCard()); |
| 3280 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); | 3278 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); |
| 3281 | 3279 |
| 3282 // Select "Add new shipping address...". | 3280 // Select "Add new shipping address...". |
| 3283 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); | 3281 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); |
| 3284 | 3282 |
| 3285 // If the rules are unavailable, validation errors should not show. | 3283 // If the rules are unavailable, validation errors should not show. |
| 3286 EXPECT_CALL(*controller()->GetMockValidator(), | 3284 EXPECT_CALL(*controller()->GetMockValidator(), |
| 3287 ValidateAddress(CountryCodeMatcher("US"), _, _)). | 3285 Validate(CountryCodeMatcher("US"), _, _)) |
| 3288 WillRepeatedly(Return(AddressValidator::RULES_UNAVAILABLE)); | 3286 .WillRepeatedly(Return(PreloadAddressValidator::RULES_UNAVAILABLE)); |
| 3289 | 3287 |
| 3290 FieldValueMap outputs; | 3288 FieldValueMap outputs; |
| 3291 AutofillProfile full_profile(test::GetFullProfile()); | 3289 AutofillProfile full_profile(test::GetFullProfile()); |
| 3292 const DetailInputs& inputs = | 3290 const DetailInputs& inputs = |
| 3293 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 3291 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 3294 for (size_t i = 0; i < inputs.size(); ++i) { | 3292 for (size_t i = 0; i < inputs.size(); ++i) { |
| 3295 const ServerFieldType type = inputs[i].type; | 3293 const ServerFieldType type = inputs[i].type; |
| 3296 outputs[type] = full_profile.GetInfo(AutofillType(type), "en-US"); | 3294 outputs[type] = full_profile.GetInfo(AutofillType(type), "en-US"); |
| 3297 } | 3295 } |
| 3298 controller()->GetView()->SetUserInput(SECTION_SHIPPING, outputs); | 3296 controller()->GetView()->SetUserInput(SECTION_SHIPPING, outputs); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3528 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(2); | 3526 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(2); |
| 3529 | 3527 |
| 3530 FieldValueMap outputs; | 3528 FieldValueMap outputs; |
| 3531 outputs[NAME_FULL] = ASCIIToUTF16("madonna"); | 3529 outputs[NAME_FULL] = ASCIIToUTF16("madonna"); |
| 3532 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); | 3530 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); |
| 3533 | 3531 |
| 3534 ASSERT_NO_FATAL_FAILURE(SwitchToAutofill()); | 3532 ASSERT_NO_FATAL_FAILURE(SwitchToAutofill()); |
| 3535 } | 3533 } |
| 3536 | 3534 |
| 3537 } // namespace autofill | 3535 } // namespace autofill |
| OLD | NEW |