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 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/guid.h" | 11 #include "base/guid.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
13 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
17 #include "base/tuple.h" | 19 #include "base/tuple.h" |
(...skipping 23 matching lines...) Expand all Loading... |
41 #include "components/autofill/core/browser/autofill_test_utils.h" | 43 #include "components/autofill/core/browser/autofill_test_utils.h" |
42 #include "components/autofill/core/browser/test_personal_data_manager.h" | 44 #include "components/autofill/core/browser/test_personal_data_manager.h" |
43 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 45 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
44 #include "components/autofill/core/common/autofill_switches.h" | 46 #include "components/autofill/core/common/autofill_switches.h" |
45 #include "components/autofill/core/common/form_data.h" | 47 #include "components/autofill/core/common/form_data.h" |
46 #include "components/user_prefs/user_prefs.h" | 48 #include "components/user_prefs/user_prefs.h" |
47 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
48 #include "content/public/test/mock_render_process_host.h" | 50 #include "content/public/test/mock_render_process_host.h" |
49 #include "google_apis/gaia/google_service_auth_error.h" | 51 #include "google_apis/gaia/google_service_auth_error.h" |
50 #include "grit/webkit_resources.h" | 52 #include "grit/webkit_resources.h" |
| 53 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_data.h" |
| 54 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_validator.h" |
51 #include "testing/gmock/include/gmock/gmock.h" | 55 #include "testing/gmock/include/gmock/gmock.h" |
52 #include "testing/gtest/include/gtest/gtest.h" | 56 #include "testing/gtest/include/gtest/gtest.h" |
53 #include "ui/base/resource/resource_bundle.h" | 57 #include "ui/base/resource/resource_bundle.h" |
54 | 58 |
55 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
56 #include "ui/base/win/scoped_ole_initializer.h" | 60 #include "ui/base/win/scoped_ole_initializer.h" |
57 #endif | 61 #endif |
58 | 62 |
59 using base::ASCIIToUTF16; | 63 using base::ASCIIToUTF16; |
60 using base::UTF8ToUTF16; | 64 using base::UTF8ToUTF16; |
61 | 65 |
62 namespace autofill { | 66 namespace autofill { |
63 | 67 |
64 namespace { | 68 namespace { |
65 | 69 |
| 70 using ::i18n::addressinput::AddressData; |
| 71 using ::i18n::addressinput::AddressProblemFilter; |
| 72 using ::i18n::addressinput::AddressProblems; |
| 73 using ::i18n::addressinput::AddressValidator; |
| 74 using testing::AtLeast; |
| 75 using testing::Return; |
66 using testing::_; | 76 using testing::_; |
67 | 77 |
68 const char kFakeEmail[] = "user@chromium.org"; | 78 const char kFakeEmail[] = "user@chromium.org"; |
69 const char kFakeFingerprintEncoded[] = "CgVaAwiACA=="; | 79 const char kFakeFingerprintEncoded[] = "CgVaAwiACA=="; |
70 const char kEditedBillingAddress[] = "123 edited billing address"; | 80 const char kEditedBillingAddress[] = "123 edited billing address"; |
71 const char* kFieldsFromPage[] = | 81 const char* kFieldsFromPage[] = |
72 { "email", | 82 { "email", |
73 "cc-name", | 83 "cc-name", |
74 "cc-number", | 84 "cc-number", |
75 "cc-exp-month", | 85 "cc-exp-month", |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 private: | 236 private: |
227 std::map<DialogSection, FieldValueMap> outputs_; | 237 std::map<DialogSection, FieldValueMap> outputs_; |
228 std::map<DialogSection, size_t> section_updates_; | 238 std::map<DialogSection, size_t> section_updates_; |
229 | 239 |
230 int updates_started_; | 240 int updates_started_; |
231 bool save_details_locally_checked_; | 241 bool save_details_locally_checked_; |
232 | 242 |
233 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogView); | 243 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogView); |
234 }; | 244 }; |
235 | 245 |
| 246 class MockAddressValidator : public AddressValidator { |
| 247 public: |
| 248 MOCK_METHOD1(LoadRules, void(const std::string& country_code)); |
| 249 MOCK_CONST_METHOD3(ValidateAddress, |
| 250 ::i18n::addressinput::AddressValidator::Status( |
| 251 const AddressData& address, |
| 252 const AddressProblemFilter& filter, |
| 253 AddressProblems* problems)); |
| 254 using ::i18n::addressinput::AddressValidator::RULES_NOT_READY; |
| 255 }; |
| 256 |
236 class TestAutofillDialogController | 257 class TestAutofillDialogController |
237 : public AutofillDialogControllerImpl, | 258 : public AutofillDialogControllerImpl, |
238 public base::SupportsWeakPtr<TestAutofillDialogController> { | 259 public base::SupportsWeakPtr<TestAutofillDialogController> { |
239 public: | 260 public: |
240 TestAutofillDialogController( | 261 TestAutofillDialogController( |
241 content::WebContents* contents, | 262 content::WebContents* contents, |
242 const FormData& form_structure, | 263 const FormData& form_structure, |
243 const GURL& source_url, | 264 const GURL& source_url, |
244 const AutofillMetrics& metric_logger, | 265 const AutofillMetrics& metric_logger, |
245 const base::Callback<void(const FormStructure*)>& callback, | 266 const base::Callback<void(const FormStructure*)>& callback, |
| 267 MockAddressValidator* mock_validator, |
246 MockNewCreditCardBubbleController* mock_new_card_bubble_controller) | 268 MockNewCreditCardBubbleController* mock_new_card_bubble_controller) |
247 : AutofillDialogControllerImpl(contents, | 269 : AutofillDialogControllerImpl(contents, |
248 form_structure, | 270 form_structure, |
249 source_url, | 271 source_url, |
250 callback), | 272 callback), |
251 metric_logger_(metric_logger), | 273 metric_logger_(metric_logger), |
252 mock_wallet_client_( | 274 mock_wallet_client_( |
253 Profile::FromBrowserContext(contents->GetBrowserContext())-> | 275 Profile::FromBrowserContext(contents->GetBrowserContext())-> |
254 GetRequestContext(), this, source_url), | 276 GetRequestContext(), this, source_url), |
| 277 mock_validator_(mock_validator), |
255 mock_new_card_bubble_controller_(mock_new_card_bubble_controller), | 278 mock_new_card_bubble_controller_(mock_new_card_bubble_controller), |
256 submit_button_delay_count_(0) {} | 279 submit_button_delay_count_(0) {} |
257 | 280 |
258 virtual ~TestAutofillDialogController() {} | 281 virtual ~TestAutofillDialogController() {} |
259 | 282 |
260 virtual AutofillDialogView* CreateView() OVERRIDE { | 283 virtual AutofillDialogView* CreateView() OVERRIDE { |
261 return new testing::NiceMock<TestAutofillDialogView>(); | 284 return new testing::NiceMock<TestAutofillDialogView>(); |
262 } | 285 } |
263 | 286 |
| 287 using AutofillDialogControllerImpl::GetInfoFromInputs; |
| 288 |
264 void Init(content::BrowserContext* browser_context) { | 289 void Init(content::BrowserContext* browser_context) { |
265 test_manager_.Init( | 290 test_manager_.Init( |
266 WebDataServiceFactory::GetAutofillWebDataForProfile( | 291 WebDataServiceFactory::GetAutofillWebDataForProfile( |
267 Profile::FromBrowserContext(browser_context), | 292 Profile::FromBrowserContext(browser_context), |
268 Profile::EXPLICIT_ACCESS), | 293 Profile::EXPLICIT_ACCESS), |
269 user_prefs::UserPrefs::Get(browser_context), | 294 user_prefs::UserPrefs::Get(browser_context), |
270 browser_context->IsOffTheRecord()); | 295 browser_context->IsOffTheRecord()); |
271 } | 296 } |
272 | 297 |
273 TestAutofillDialogView* GetView() { | 298 TestAutofillDialogView* GetView() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 protected: | 346 protected: |
322 virtual PersonalDataManager* GetManager() const OVERRIDE { | 347 virtual PersonalDataManager* GetManager() const OVERRIDE { |
323 return const_cast<TestAutofillDialogController*>(this)-> | 348 return const_cast<TestAutofillDialogController*>(this)-> |
324 GetTestingManager(); | 349 GetTestingManager(); |
325 } | 350 } |
326 | 351 |
327 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { | 352 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { |
328 return &mock_wallet_client_; | 353 return &mock_wallet_client_; |
329 } | 354 } |
330 | 355 |
| 356 virtual AddressValidator* GetValidator() { |
| 357 return mock_validator_; |
| 358 } |
| 359 |
331 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { | 360 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { |
332 open_tab_url_ = url; | 361 open_tab_url_ = url; |
333 } | 362 } |
334 | 363 |
335 virtual void ShowNewCreditCardBubble( | 364 virtual void ShowNewCreditCardBubble( |
336 scoped_ptr<CreditCard> new_card, | 365 scoped_ptr<CreditCard> new_card, |
337 scoped_ptr<AutofillProfile> billing_profile) OVERRIDE { | 366 scoped_ptr<AutofillProfile> billing_profile) OVERRIDE { |
338 mock_new_card_bubble_controller_->Show(new_card.Pass(), | 367 mock_new_card_bubble_controller_->Show(new_card.Pass(), |
339 billing_profile.Pass()); | 368 billing_profile.Pass()); |
340 } | 369 } |
341 | 370 |
342 // AutofillDialogControllerImpl calls this method before showing the dialog | 371 // AutofillDialogControllerImpl calls this method before showing the dialog |
343 // window. | 372 // window. |
344 virtual void SubmitButtonDelayBegin() OVERRIDE { | 373 virtual void SubmitButtonDelayBegin() OVERRIDE { |
345 // Do not delay enabling the submit button in testing. | 374 // Do not delay enabling the submit button in testing. |
346 submit_button_delay_count_++; | 375 submit_button_delay_count_++; |
347 } | 376 } |
348 | 377 |
349 private: | 378 private: |
350 // To specify our own metric logger. | 379 // To specify our own metric logger. |
351 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 380 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
352 return metric_logger_; | 381 return metric_logger_; |
353 } | 382 } |
354 | 383 |
355 const AutofillMetrics& metric_logger_; | 384 const AutofillMetrics& metric_logger_; |
356 TestPersonalDataManager test_manager_; | 385 TestPersonalDataManager test_manager_; |
357 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 386 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
| 387 MockAddressValidator* mock_validator_; |
358 GURL open_tab_url_; | 388 GURL open_tab_url_; |
359 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; | 389 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; |
360 | 390 |
361 // The number of times that the submit button was delayed. | 391 // The number of times that the submit button was delayed. |
362 int submit_button_delay_count_; | 392 int submit_button_delay_count_; |
363 | 393 |
364 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); | 394 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); |
365 }; | 395 }; |
366 | 396 |
367 class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { | 397 class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 449 |
420 base::Callback<void(const FormStructure*)> callback = | 450 base::Callback<void(const FormStructure*)> callback = |
421 base::Bind(&AutofillDialogControllerTest::FinishedCallback, | 451 base::Bind(&AutofillDialogControllerTest::FinishedCallback, |
422 base::Unretained(this)); | 452 base::Unretained(this)); |
423 controller_ = (new testing::NiceMock<TestAutofillDialogController>( | 453 controller_ = (new testing::NiceMock<TestAutofillDialogController>( |
424 web_contents(), | 454 web_contents(), |
425 form_data, | 455 form_data, |
426 GURL(), | 456 GURL(), |
427 metric_logger_, | 457 metric_logger_, |
428 callback, | 458 callback, |
| 459 mock_validator_.get(), |
429 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); | 460 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); |
430 controller_->Init(profile()); | 461 controller_->Init(profile()); |
431 } | 462 } |
432 | 463 |
433 // Creates a new controller for |form_data| and sets up some initial wallet | 464 // Creates a new controller for |form_data| and sets up some initial wallet |
434 // data for it. | 465 // data for it. |
435 void SetUpControllerWithFormData(const FormData& form_data) { | 466 void SetUpControllerWithFormData(const FormData& form_data) { |
436 ResetControllerWithFormData(form_data); | 467 ResetControllerWithFormData(form_data); |
437 controller()->Show(); | 468 controller()->Show(); |
438 if (!profile()->GetPrefs()->GetBoolean( | 469 if (!profile()->GetPrefs()->GetBoolean( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 EXPECT_FALSE(billing_name.empty()); | 629 EXPECT_FALSE(billing_name.empty()); |
599 EXPECT_FALSE(shipping_name.empty()); | 630 EXPECT_FALSE(shipping_name.empty()); |
600 EXPECT_EQ(cc_name, billing_name); | 631 EXPECT_EQ(cc_name, billing_name); |
601 EXPECT_EQ(cc_name, shipping_name); | 632 EXPECT_EQ(cc_name, shipping_name); |
602 } | 633 } |
603 | 634 |
604 TestAutofillDialogController* controller() { return controller_.get(); } | 635 TestAutofillDialogController* controller() { return controller_.get(); } |
605 | 636 |
606 const FormStructure* form_structure() { return form_structure_; } | 637 const FormStructure* form_structure() { return form_structure_; } |
607 | 638 |
| 639 MockAddressValidator* GetMockValidator() const { |
| 640 return mock_validator_.get(); |
| 641 } |
| 642 void SetMockValidator(scoped_ptr<MockAddressValidator> validator) { |
| 643 mock_validator_ = validator.Pass(); |
| 644 } |
| 645 |
608 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller() { | 646 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller() { |
609 return test_generated_bubble_controller_; | 647 return test_generated_bubble_controller_; |
610 } | 648 } |
611 | 649 |
612 const MockNewCreditCardBubbleController* mock_new_card_bubble_controller() { | 650 const MockNewCreditCardBubbleController* mock_new_card_bubble_controller() { |
613 return mock_new_card_bubble_controller_.get(); | 651 return mock_new_card_bubble_controller_.get(); |
614 } | 652 } |
615 | 653 |
616 private: | 654 private: |
617 void FinishedCallback(const FormStructure* form_structure) { | 655 void FinishedCallback(const FormStructure* form_structure) { |
618 form_structure_ = form_structure; | 656 form_structure_ = form_structure; |
619 } | 657 } |
620 | 658 |
621 #if defined(OS_WIN) | 659 #if defined(OS_WIN) |
622 // http://crbug.com/227221 | 660 // http://crbug.com/227221 |
623 ui::ScopedOleInitializer ole_initializer_; | 661 ui::ScopedOleInitializer ole_initializer_; |
624 #endif | 662 #endif |
625 | 663 |
626 // The controller owns itself. | 664 // The controller owns itself. |
627 base::WeakPtr<TestAutofillDialogController> controller_; | 665 base::WeakPtr<TestAutofillDialogController> controller_; |
628 | 666 |
629 // Must outlive the controller. | 667 // Must outlive the controller. |
630 AutofillMetrics metric_logger_; | 668 AutofillMetrics metric_logger_; |
631 | 669 |
632 // Returned when the dialog closes successfully. | 670 // Returned when the dialog closes successfully. |
633 const FormStructure* form_structure_; | 671 const FormStructure* form_structure_; |
634 | 672 |
| 673 // A mock validator object to prevent network requests and track when |
| 674 // validation rules are loaded or validation attempts occur. |
| 675 scoped_ptr<MockAddressValidator> mock_validator_; |
| 676 |
635 // Used to monitor if the Autofill credit card bubble is shown. Owned by | 677 // Used to monitor if the Autofill credit card bubble is shown. Owned by |
636 // |web_contents()|. | 678 // |web_contents()|. |
637 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller_; | 679 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller_; |
638 | 680 |
639 // Used to record when new card bubbles would show. Created in |Reset()|. | 681 // Used to record when new card bubbles would show. Created in |Reset()|. |
640 scoped_ptr<MockNewCreditCardBubbleController> | 682 scoped_ptr<MockNewCreditCardBubbleController> |
641 mock_new_card_bubble_controller_; | 683 mock_new_card_bubble_controller_; |
642 | 684 |
643 scoped_ptr<ScopedTestingLocalState> scoped_local_state_; | 685 scoped_ptr<ScopedTestingLocalState> scoped_local_state_; |
644 }; | 686 }; |
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 }; | 2968 }; |
2927 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 2969 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
2928 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { | 2970 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { |
2929 SCOPED_TRACE(base::IntToString(i)); | 2971 SCOPED_TRACE(base::IntToString(i)); |
2930 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); | 2972 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); |
2931 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); | 2973 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); |
2932 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); | 2974 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); |
2933 } | 2975 } |
2934 } | 2976 } |
2935 | 2977 |
2936 TEST_F(AutofillDialogControllerTest, CountryChangeUpdatesSection) { | 2978 class AutofillDialogControllerI18nTest : public AutofillDialogControllerTest { |
2937 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 2979 public: |
2938 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n); | 2980 // AutofillDialogControllerTest implementation. |
| 2981 virtual void SetUp() OVERRIDE { |
| 2982 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 2983 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n); |
| 2984 AutofillDialogControllerTest::SetUp(); |
| 2985 } |
| 2986 }; |
2939 | 2987 |
2940 Reset(); | 2988 TEST_F(AutofillDialogControllerI18nTest, CountryChangeUpdatesSection) { |
2941 | |
2942 TestAutofillDialogView* view = controller()->GetView(); | 2989 TestAutofillDialogView* view = controller()->GetView(); |
2943 view->ClearSectionUpdates(); | 2990 view->ClearSectionUpdates(); |
2944 | 2991 |
2945 controller()->UserEditedOrActivatedInput(SECTION_SHIPPING, | 2992 controller()->UserEditedOrActivatedInput(SECTION_SHIPPING, |
2946 ADDRESS_HOME_COUNTRY, | 2993 ADDRESS_HOME_COUNTRY, |
2947 gfx::NativeView(), | 2994 gfx::NativeView(), |
2948 gfx::Rect(), | 2995 gfx::Rect(), |
2949 ASCIIToUTF16("China"), | 2996 ASCIIToUTF16("China"), |
2950 true); | 2997 true); |
2951 std::map<DialogSection, size_t> updates = view->section_updates(); | 2998 std::map<DialogSection, size_t> updates = view->section_updates(); |
(...skipping 19 matching lines...) Expand all Loading... |
2971 ADDRESS_BILLING_COUNTRY, | 3018 ADDRESS_BILLING_COUNTRY, |
2972 gfx::NativeView(), | 3019 gfx::NativeView(), |
2973 gfx::Rect(), | 3020 gfx::Rect(), |
2974 ASCIIToUTF16("Italy"), | 3021 ASCIIToUTF16("Italy"), |
2975 true); | 3022 true); |
2976 updates = view->section_updates(); | 3023 updates = view->section_updates(); |
2977 EXPECT_EQ(1U, updates[SECTION_BILLING]); | 3024 EXPECT_EQ(1U, updates[SECTION_BILLING]); |
2978 EXPECT_EQ(1U, updates.size()); | 3025 EXPECT_EQ(1U, updates.size()); |
2979 } | 3026 } |
2980 | 3027 |
| 3028 TEST_F(AutofillDialogControllerI18nTest, CorrectCountryFromInputs) { |
| 3029 FieldValueMap inputs; |
| 3030 inputs[ADDRESS_BILLING_COUNTRY] = base::ASCIIToUTF16("China"); |
| 3031 inputs[ADDRESS_HOME_COUNTRY] = base::ASCIIToUTF16("France"); |
| 3032 |
| 3033 base::Callback<base::string16(DialogSection, const AutofillType&)> get_info = |
| 3034 base::Bind(&TestAutofillDialogController::GetInfoFromInputs, |
| 3035 base::ConstRef(inputs)); |
| 3036 |
| 3037 // Ensure that callbacks bound to the billing section only return |
| 3038 // billing-specific info from |inputs| (e.g. the billing country). |
| 3039 EXPECT_EQ(base::ASCIIToUTF16("China"), |
| 3040 get_info.Run(SECTION_BILLING, AutofillType(ADDRESS_HOME_COUNTRY))); |
| 3041 EXPECT_EQ(base::ASCIIToUTF16("CN"), |
| 3042 get_info.Run(SECTION_BILLING, AutofillType(HTML_TYPE_COUNTRY_CODE, |
| 3043 HTML_MODE_SHIPPING))); |
| 3044 |
| 3045 // And conversely that shipping sections only return the shipping country. |
| 3046 EXPECT_EQ( |
| 3047 base::ASCIIToUTF16("France"), |
| 3048 get_info.Run(SECTION_SHIPPING, AutofillType(ADDRESS_BILLING_COUNTRY))); |
| 3049 EXPECT_EQ(base::ASCIIToUTF16("FR"), |
| 3050 get_info.Run(SECTION_SHIPPING, AutofillType(HTML_TYPE_COUNTRY_CODE, |
| 3051 HTML_MODE_BILLING))); |
| 3052 } |
| 3053 |
| 3054 TEST_F(AutofillDialogControllerI18nTest, LoadValidationRules) { |
| 3055 SetMockValidator(make_scoped_ptr(new MockAddressValidator)); |
| 3056 EXPECT_CALL(*GetMockValidator(), ValidateAddress(_, _, _)). |
| 3057 WillRepeatedly(Return(MockAddressValidator::RULES_NOT_READY)); |
| 3058 |
| 3059 EXPECT_CALL(*GetMockValidator(), LoadRules("US")).Times(AtLeast(1)); |
| 3060 Reset(); |
| 3061 |
| 3062 EXPECT_CALL(*GetMockValidator(), LoadRules("FR")); |
| 3063 controller()->UserEditedOrActivatedInput(SECTION_CC_BILLING, |
| 3064 ADDRESS_BILLING_COUNTRY, |
| 3065 gfx::NativeView(), |
| 3066 gfx::Rect(), |
| 3067 ASCIIToUTF16("France"), |
| 3068 true); |
| 3069 } |
| 3070 |
2981 } // namespace autofill | 3071 } // namespace autofill |
OLD | NEW |