Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 // Returns the number of times that the submit button was delayed. 298 // Returns the number of times that the submit button was delayed.
299 int get_submit_button_delay_count() const { 299 int get_submit_button_delay_count() const {
300 return submit_button_delay_count_; 300 return submit_button_delay_count_;
301 } 301 }
302 302
303 MOCK_METHOD0(LoadRiskFingerprintData, void()); 303 MOCK_METHOD0(LoadRiskFingerprintData, void());
304 using AutofillDialogControllerImpl::AccountChooserModelForTesting; 304 using AutofillDialogControllerImpl::AccountChooserModelForTesting;
305 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; 305 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData;
306 using AutofillDialogControllerImpl::IsEditingExistingData; 306 using AutofillDialogControllerImpl::IsEditingExistingData;
307 using AutofillDialogControllerImpl::IsManuallyEditingSection;
307 using AutofillDialogControllerImpl::IsSubmitPausedOn; 308 using AutofillDialogControllerImpl::IsSubmitPausedOn;
308 using AutofillDialogControllerImpl::NOT_CHECKED; 309 using AutofillDialogControllerImpl::NOT_CHECKED;
309 using AutofillDialogControllerImpl::SignedInState; 310 using AutofillDialogControllerImpl::SignedInState;
310 311
311 protected: 312 protected:
312 virtual PersonalDataManager* GetManager() const OVERRIDE { 313 virtual PersonalDataManager* GetManager() const OVERRIDE {
313 return const_cast<TestAutofillDialogController*>(this)-> 314 return const_cast<TestAutofillDialogController*>(this)->
314 GetTestingManager(); 315 GetTestingManager();
315 } 316 }
316 317
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return true; 547 return true;
547 } 548 }
548 return false; 549 return false;
549 } 550 }
550 551
551 SuggestionsMenuModel* GetMenuModelForSection(DialogSection section) { 552 SuggestionsMenuModel* GetMenuModelForSection(DialogSection section) {
552 ui::MenuModel* model = controller()->MenuModelForSection(section); 553 ui::MenuModel* model = controller()->MenuModelForSection(section);
553 return static_cast<SuggestionsMenuModel*>(model); 554 return static_cast<SuggestionsMenuModel*>(model);
554 } 555 }
555 556
557 void SubmitAndVerifyShippingAndBillingResults() {
558 // Test after setting use billing for shipping.
559 UseBillingForShipping();
560
561 controller()->OnAccept();
562
563 ASSERT_EQ(20U, form_structure()->field_count());
564 EXPECT_EQ(ADDRESS_HOME_COUNTRY,
565 form_structure()->field(11)->Type().GetStorableType());
566 EXPECT_EQ(ADDRESS_BILLING, form_structure()->field(11)->Type().group());
567 EXPECT_EQ(ADDRESS_HOME_COUNTRY,
568 form_structure()->field(18)->Type().GetStorableType());
569 EXPECT_EQ(ADDRESS_HOME, form_structure()->field(18)->Type().group());
570 base::string16 billing_country = form_structure()->field(11)->value;
571 EXPECT_EQ(2U, billing_country.size());
572 base::string16 shipping_country = form_structure()->field(18)->value;
573 EXPECT_EQ(2U, shipping_country.size());
574 EXPECT_FALSE(billing_country.empty());
575 EXPECT_FALSE(shipping_country.empty());
576 EXPECT_EQ(billing_country, shipping_country);
577
578 EXPECT_EQ(CREDIT_CARD_NAME,
579 form_structure()->field(1)->Type().GetStorableType());
580 base::string16 cc_name = form_structure()->field(1)->value;
581 EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType());
582 EXPECT_EQ(NAME_BILLING, form_structure()->field(6)->Type().group());
583 base::string16 billing_name = form_structure()->field(6)->value;
584 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().GetStorableType());
585 EXPECT_EQ(NAME, form_structure()->field(13)->Type().group());
586 base::string16 shipping_name = form_structure()->field(13)->value;
587
588 EXPECT_FALSE(cc_name.empty());
589 EXPECT_FALSE(billing_name.empty());
590 EXPECT_FALSE(shipping_name.empty());
591 EXPECT_EQ(cc_name, billing_name);
592 EXPECT_EQ(cc_name, shipping_name);
593 }
594
556 TestAutofillDialogController* controller() { return controller_.get(); } 595 TestAutofillDialogController* controller() { return controller_.get(); }
557 596
558 const FormStructure* form_structure() { return form_structure_; } 597 const FormStructure* form_structure() { return form_structure_; }
559 598
560 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller() { 599 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller() {
561 return test_generated_bubble_controller_; 600 return test_generated_bubble_controller_;
562 } 601 }
563 602
564 const MockNewCreditCardBubbleController* mock_new_card_bubble_controller() { 603 const MockNewCreditCardBubbleController* mock_new_card_bubble_controller() {
565 return mock_new_card_bubble_controller_.get(); 604 return mock_new_card_bubble_controller_.get();
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 EXPECT_FALSE(billing_name.empty()); 1127 EXPECT_FALSE(billing_name.empty());
1089 EXPECT_FALSE(shipping_name.empty()); 1128 EXPECT_FALSE(shipping_name.empty());
1090 // Billing name should always be the same as cardholder name. 1129 // Billing name should always be the same as cardholder name.
1091 EXPECT_EQ(cc_name, billing_name); 1130 EXPECT_EQ(cc_name, billing_name);
1092 EXPECT_NE(cc_name, shipping_name); 1131 EXPECT_NE(cc_name, shipping_name);
1093 } 1132 }
1094 1133
1095 // Test selecting UseBillingForShipping. 1134 // Test selecting UseBillingForShipping.
1096 TEST_F(AutofillDialogControllerTest, UseBillingAsShipping) { 1135 TEST_F(AutofillDialogControllerTest, UseBillingAsShipping) {
1097 SwitchToAutofill(); 1136 SwitchToAutofill();
1137
1098 AutofillProfile full_profile(test::GetVerifiedProfile()); 1138 AutofillProfile full_profile(test::GetVerifiedProfile());
1139 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
1140
1099 AutofillProfile full_profile2(test::GetVerifiedProfile2()); 1141 AutofillProfile full_profile2(test::GetVerifiedProfile2());
1142 controller()->GetTestingManager()->AddTestingProfile(&full_profile2);
1143
1100 CreditCard credit_card(test::GetVerifiedCreditCard()); 1144 CreditCard credit_card(test::GetVerifiedCreditCard());
1101 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
1102 controller()->GetTestingManager()->AddTestingProfile(&full_profile2);
1103 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); 1145 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
1104 1146
1105 // Test after setting use billing for shipping. 1147 ASSERT_FALSE(controller()->IsManuallyEditingSection(SECTION_CC));
1106 UseBillingForShipping(); 1148 ASSERT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING));
1107 1149
1108 controller()->OnAccept(); 1150 SubmitAndVerifyShippingAndBillingResults();
1109 ASSERT_EQ(20U, form_structure()->field_count()); 1151 }
1110 EXPECT_EQ(ADDRESS_HOME_STATE,
1111 form_structure()->field(9)->Type().GetStorableType());
1112 EXPECT_EQ(ADDRESS_BILLING, form_structure()->field(9)->Type().group());
1113 EXPECT_EQ(ADDRESS_HOME_STATE,
1114 form_structure()->field(16)->Type().GetStorableType());
1115 EXPECT_EQ(ADDRESS_HOME, form_structure()->field(16)->Type().group());
1116 base::string16 billing_state = form_structure()->field(9)->value;
1117 base::string16 shipping_state = form_structure()->field(16)->value;
1118 EXPECT_FALSE(billing_state.empty());
1119 EXPECT_FALSE(shipping_state.empty());
1120 EXPECT_EQ(billing_state, shipping_state);
1121 1152
1122 EXPECT_EQ(CREDIT_CARD_NAME, 1153 TEST_F(AutofillDialogControllerTest, UseBillingAsShippingManualInput) {
1123 form_structure()->field(1)->Type().GetStorableType()); 1154 SwitchToAutofill();
1124 base::string16 cc_name = form_structure()->field(1)->value;
1125 EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType());
1126 EXPECT_EQ(NAME_BILLING, form_structure()->field(6)->Type().group());
1127 base::string16 billing_name = form_structure()->field(6)->value;
1128 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().GetStorableType());
1129 EXPECT_EQ(NAME, form_structure()->field(13)->Type().group());
1130 base::string16 shipping_name = form_structure()->field(13)->value;
1131 1155
1132 EXPECT_FALSE(cc_name.empty()); 1156 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_CC));
1133 EXPECT_FALSE(billing_name.empty()); 1157 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING));
1134 EXPECT_FALSE(shipping_name.empty()); 1158
1135 EXPECT_EQ(cc_name, billing_name); 1159 CreditCard credit_card(test::GetVerifiedCreditCard());
1136 EXPECT_EQ(cc_name, shipping_name); 1160 FillInputs(SECTION_CC, credit_card);
1161
1162 AutofillProfile full_profile(test::GetVerifiedProfile());
1163 FillInputs(SECTION_BILLING, full_profile);
1164
1165 SubmitAndVerifyShippingAndBillingResults();
1137 } 1166 }
1138 1167
1139 // Tests that shipping and billing telephone fields are supported, and filled 1168 // Tests that shipping and billing telephone fields are supported, and filled
1140 // in by their respective profiles. http://crbug.com/244515 1169 // in by their respective profiles. http://crbug.com/244515
1141 TEST_F(AutofillDialogControllerTest, BillingVsShippingPhoneNumber) { 1170 TEST_F(AutofillDialogControllerTest, BillingVsShippingPhoneNumber) {
1142 FormFieldData shipping_tel; 1171 FormFieldData shipping_tel;
1143 shipping_tel.autocomplete_attribute = "shipping tel"; 1172 shipping_tel.autocomplete_attribute = "shipping tel";
1144 FormFieldData billing_tel; 1173 FormFieldData billing_tel;
1145 billing_tel.autocomplete_attribute = "billing tel"; 1174 billing_tel.autocomplete_attribute = "billing tel";
1146 1175
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 2792 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
2764 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { 2793 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) {
2765 SCOPED_TRACE(base::IntToString(i)); 2794 SCOPED_TRACE(base::IntToString(i));
2766 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); 2795 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]);
2767 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); 2796 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width());
2768 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); 2797 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height());
2769 } 2798 }
2770 } 2799 }
2771 2800
2772 } // namespace autofill 2801 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | chrome/browser/ui/autofill/autofill_dialog_i18n_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698