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

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

Issue 16096007: add a regression test for requestAutocomplete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unrelated WIP changes Created 7 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/guid.h" 5 #include "base/guid.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 for (size_t i = 0; i < arraysize(kFieldsFromPage); ++i) { 301 for (size_t i = 0; i < arraysize(kFieldsFromPage); ++i) {
302 FormFieldData field; 302 FormFieldData field;
303 field.autocomplete_attribute = kFieldsFromPage[i]; 303 field.autocomplete_attribute = kFieldsFromPage[i];
304 form_data.fields.push_back(field); 304 form_data.fields.push_back(field);
305 } 305 }
306 306
307 profile()->CreateRequestContext(); 307 profile()->CreateRequestContext();
308 test_web_contents_.reset( 308 test_web_contents_.reset(
309 content::WebContentsTester::CreateTestWebContents(profile(), NULL)); 309 content::WebContentsTester::CreateTestWebContents(profile(), NULL));
310 310
311 SetUpControllerWithFormData(form_data);
312 }
313
314 virtual void TearDown() OVERRIDE {
315 if (controller_)
316 controller_->ViewClosed();
317 }
318
319 protected:
320 void SetUpControllerWithFormData(const FormData& form_data) {
321 if (controller_)
322 controller_->ViewClosed();
323
311 base::Callback<void(const FormStructure*, const std::string&)> callback = 324 base::Callback<void(const FormStructure*, const std::string&)> callback =
312 base::Bind(&AutofillDialogControllerTest::FinishedCallback, 325 base::Bind(&AutofillDialogControllerTest::FinishedCallback,
313 base::Unretained(this)); 326 base::Unretained(this));
314 controller_ = (new testing::NiceMock<TestAutofillDialogController>( 327 controller_ = (new testing::NiceMock<TestAutofillDialogController>(
315 test_web_contents_.get(), 328 test_web_contents_.get(),
316 form_data, 329 form_data,
317 GURL(), 330 GURL(),
318 metric_logger_, 331 metric_logger_,
319 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, 332 DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
320 callback))->AsWeakPtr(); 333 callback))->AsWeakPtr();
321 controller_->Init(profile()); 334 controller_->Init(profile());
322 controller_->Show(); 335 controller_->Show();
323 controller_->OnUserNameFetchSuccess(kFakeEmail); 336 controller_->OnUserNameFetchSuccess(kFakeEmail);
324 } 337 }
325 338
326 virtual void TearDown() OVERRIDE {
327 if (controller_)
328 controller_->ViewClosed();
329 }
330
331 protected:
332 void FillCreditCardInputs() { 339 void FillCreditCardInputs() {
333 DetailOutputMap cc_outputs; 340 DetailOutputMap cc_outputs;
334 const DetailInputs& cc_inputs = 341 const DetailInputs& cc_inputs =
335 controller()->RequestedFieldsForSection(SECTION_CC); 342 controller()->RequestedFieldsForSection(SECTION_CC);
336 for (size_t i = 0; i < cc_inputs.size(); ++i) { 343 for (size_t i = 0; i < cc_inputs.size(); ++i) {
337 cc_outputs[&cc_inputs[i]] = ASCIIToUTF16("11"); 344 cc_outputs[&cc_inputs[i]] = ASCIIToUTF16("11");
338 } 345 }
339 controller()->GetView()->SetUserInput(SECTION_CC, cc_outputs); 346 controller()->GetView()->SetUserInput(SECTION_CC, cc_outputs);
340 } 347 }
341 348
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 UseBillingForShipping(); 720 UseBillingForShipping();
714 721
715 controller()->OnAccept(); 722 controller()->OnAccept();
716 ASSERT_EQ(4U, form_structure()->field_count()); 723 ASSERT_EQ(4U, form_structure()->field_count());
717 EXPECT_EQ("CA", UTF16ToUTF8(form_structure()->field(2)->value)); 724 EXPECT_EQ("CA", UTF16ToUTF8(form_structure()->field(2)->value));
718 EXPECT_EQ("CA", UTF16ToUTF8(form_structure()->field(3)->value)); 725 EXPECT_EQ("CA", UTF16ToUTF8(form_structure()->field(3)->value));
719 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure()->field(2)->type()); 726 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure()->field(2)->type());
720 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure()->field(3)->type()); 727 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure()->field(3)->type());
721 } 728 }
722 729
730 // Tests that shipping and billing telephone fields are supported, and filled
731 // in by their respective profiles. http://crbug.com/244515
732 TEST_F(AutofillDialogControllerTest, DISABLED_BillingVsShippingPhoneNumber) {
733 FormFieldData shipping_tel;
734 shipping_tel.autocomplete_attribute = "shipping tel";
735 FormFieldData billing_tel;
736 billing_tel.autocomplete_attribute = "billing tel";
737
738 FormData form_data;
739 form_data.fields.push_back(shipping_tel);
740 form_data.fields.push_back(billing_tel);
741 SetUpControllerWithFormData(form_data);
742
743 AutofillProfile full_profile(test::GetVerifiedProfile());
744 AutofillProfile full_profile2(test::GetVerifiedProfile2());
Dan Beam 2013/05/28 19:17:49 can you use {shipping,billing}_profile so it's mor
Evan Stade 2013/05/28 19:30:09 Done.
745 CreditCard credit_card(test::GetVerifiedCreditCard());
746 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
747 controller()->GetTestingManager()->AddTestingProfile(&full_profile2);
748 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
749 ui::MenuModel* billing_model =
750 controller()->MenuModelForSection(SECTION_BILLING);
751 billing_model->ActivatedAt(1);
752
753 controller()->OnAccept();
754 ASSERT_EQ(2U, form_structure()->field_count());
755 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, form_structure()->field(0)->type());
756 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, form_structure()->field(1)->type());
757 EXPECT_EQ(full_profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER),
758 form_structure()->field(0)->value);
759 EXPECT_EQ(full_profile2.GetRawInfo(PHONE_HOME_WHOLE_NUMBER),
760 form_structure()->field(1)->value);
761 EXPECT_NE(form_structure()->field(1)->value,
762 form_structure()->field(0)->value);
763 }
764
723 TEST_F(AutofillDialogControllerTest, AcceptLegalDocuments) { 765 TEST_F(AutofillDialogControllerTest, AcceptLegalDocuments) {
724 EXPECT_CALL(*controller()->GetTestingWalletClient(), 766 EXPECT_CALL(*controller()->GetTestingWalletClient(),
725 AcceptLegalDocuments(_, _, _)).Times(1); 767 AcceptLegalDocuments(_, _, _)).Times(1);
726 EXPECT_CALL(*controller()->GetTestingWalletClient(), 768 EXPECT_CALL(*controller()->GetTestingWalletClient(),
727 GetFullWallet(_)).Times(1); 769 GetFullWallet(_)).Times(1);
728 EXPECT_CALL(*controller(), LoadRiskFingerprintData()).Times(1); 770 EXPECT_CALL(*controller(), LoadRiskFingerprintData()).Times(1);
729 771
730 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 772 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
731 wallet_items->AddLegalDocument(wallet::GetTestLegalDocument()); 773 wallet_items->AddLegalDocument(wallet::GetTestLegalDocument());
732 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 774 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 controller()->OnDidGetWalletItems( 1721 controller()->OnDidGetWalletItems(
1680 wallet::WalletItems::CreateWalletItems(dict).Pass()); 1722 wallet::WalletItems::CreateWalletItems(dict).Pass());
1681 1723
1682 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); 1724 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING));
1683 // "Same as billing" and "Add address...". 1725 // "Same as billing" and "Add address...".
1684 EXPECT_EQ( 1726 EXPECT_EQ(
1685 2, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); 1727 2, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount());
1686 } 1728 }
1687 1729
1688 } // namespace autofill 1730 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698