| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 16 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
| 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 18 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
| 19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 20 #include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h" |
| 20 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 21 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 21 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 22 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 22 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" | 23 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" |
| 23 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" | |
| 24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" | 25 #include "chrome/browser/ui/browser_tabstrip.h" |
| 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/test/base/in_process_browser_test.h" | 30 #include "chrome/test/base/in_process_browser_test.h" |
| 31 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
| 32 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" | 32 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
| 33 #include "components/autofill/content/browser/wallet/gaia_account.h" | 33 #include "components/autofill/content/browser/wallet/gaia_account.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 metric_logger_, | 334 metric_logger_, |
| 335 message_loop_runner_); | 335 message_loop_runner_); |
| 336 controller_->Show(); | 336 controller_->Show(); |
| 337 CycleRunLoops(); // Ensures dialog is fully visible. | 337 CycleRunLoops(); // Ensures dialog is fully visible. |
| 338 } | 338 } |
| 339 | 339 |
| 340 content::WebContents* GetActiveWebContents() { | 340 content::WebContents* GetActiveWebContents() { |
| 341 return browser()->tab_strip_model()->GetActiveWebContents(); | 341 return browser()->tab_strip_model()->GetActiveWebContents(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 scoped_ptr<AutofillDialogViewTester> GetViewTester() { |
| 345 return AutofillDialogViewTester::For(controller()->view()).Pass(); |
| 346 } |
| 347 |
| 344 const MockAutofillMetrics& metric_logger() { return metric_logger_; } | 348 const MockAutofillMetrics& metric_logger() { return metric_logger_; } |
| 345 TestAutofillDialogController* controller() { return controller_; } | 349 TestAutofillDialogController* controller() { return controller_; } |
| 346 | 350 |
| 347 void RunMessageLoop() { | 351 void RunMessageLoop() { |
| 348 message_loop_runner_->Run(); | 352 message_loop_runner_->Run(); |
| 349 } | 353 } |
| 350 | 354 |
| 351 // Loads an HTML page in |GetActiveWebContents()| with markup as follows: | 355 // Loads an HTML page in |GetActiveWebContents()| with markup as follows: |
| 352 // <form>|form_inner_html|</form>. After loading, emulates a click event on | 356 // <form>|form_inner_html|</form>. After loading, emulates a click event on |
| 353 // the page as requestAutocomplete() must be in response to a user gesture. | 357 // the page as requestAutocomplete() must be in response to a user gesture. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 494 |
| 491 // Weak; owned by the active web contents. | 495 // Weak; owned by the active web contents. |
| 492 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller_; | 496 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller_; |
| 493 | 497 |
| 494 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); | 498 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); |
| 495 }; | 499 }; |
| 496 | 500 |
| 497 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 501 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| 498 // Submit the form data. | 502 // Submit the form data. |
| 499 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { | 503 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { |
| 500 controller()->GetTestableView()->SubmitForTesting(); | 504 GetViewTester()->SubmitForTesting(); |
| 501 | 505 |
| 502 RunMessageLoop(); | 506 RunMessageLoop(); |
| 503 | 507 |
| 504 EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, | 508 EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, |
| 505 metric_logger().dialog_dismissal_action()); | 509 metric_logger().dialog_dismissal_action()); |
| 506 } | 510 } |
| 507 | 511 |
| 508 // Cancel out of the dialog. | 512 // Cancel out of the dialog. |
| 509 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { | 513 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { |
| 510 controller()->GetTestableView()->CancelForTesting(); | 514 GetViewTester()->CancelForTesting(); |
| 511 | 515 |
| 512 RunMessageLoop(); | 516 RunMessageLoop(); |
| 513 | 517 |
| 514 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 518 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
| 515 metric_logger().dialog_dismissal_action()); | 519 metric_logger().dialog_dismissal_action()); |
| 516 } | 520 } |
| 517 | 521 |
| 518 // Take some other action that dismisses the dialog. | 522 // Take some other action that dismisses the dialog. |
| 519 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) { | 523 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) { |
| 520 controller()->Hide(); | 524 controller()->Hide(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 541 } | 545 } |
| 542 | 546 |
| 543 // Ensure that the expected metric is logged when the dialog is closed during | 547 // Ensure that the expected metric is logged when the dialog is closed during |
| 544 // signin. | 548 // signin. |
| 545 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) { | 549 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) { |
| 546 controller()->SignInLinkClicked(); | 550 controller()->SignInLinkClicked(); |
| 547 | 551 |
| 548 EXPECT_CALL(metric_logger(), | 552 EXPECT_CALL(metric_logger(), |
| 549 LogDialogDismissalState( | 553 LogDialogDismissalState( |
| 550 AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN)); | 554 AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN)); |
| 551 controller()->GetTestableView()->CancelForTesting(); | 555 GetViewTester()->CancelForTesting(); |
| 552 | 556 |
| 553 RunMessageLoop(); | 557 RunMessageLoop(); |
| 554 | 558 |
| 555 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 559 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
| 556 metric_logger().dialog_dismissal_action()); | 560 metric_logger().dialog_dismissal_action()); |
| 557 } | 561 } |
| 558 | 562 |
| 559 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { | 563 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { |
| 560 AutofillProfile full_profile(test::GetFullProfile()); | 564 AutofillProfile full_profile(test::GetFullProfile()); |
| 561 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 565 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 562 | 566 |
| 563 // Select "Add new shipping address...". | 567 // Select "Add new shipping address...". |
| 564 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); | 568 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); |
| 565 model->ActivatedAt(model->GetItemCount() - 2); | 569 model->ActivatedAt(model->GetItemCount() - 2); |
| 566 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 570 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 567 | 571 |
| 568 const DetailInputs& inputs = | 572 const DetailInputs& inputs = |
| 569 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 573 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 570 const ServerFieldType triggering_type = inputs[0].type; | 574 const ServerFieldType triggering_type = inputs[0].type; |
| 571 base::string16 value = full_profile.GetRawInfo(triggering_type); | 575 base::string16 value = full_profile.GetRawInfo(triggering_type); |
| 572 TestableAutofillDialogView* view = controller()->GetTestableView(); | 576 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 573 view->SetTextContentsOfInput(triggering_type, | 577 view->SetTextContentsOfInput(triggering_type, |
| 574 value.substr(0, value.size() / 2)); | 578 value.substr(0, value.size() / 2)); |
| 575 view->ActivateInput(triggering_type); | 579 view->ActivateInput(triggering_type); |
| 576 | 580 |
| 577 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 581 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
| 578 controller()->DidAcceptSuggestion(base::string16(), 0); | 582 controller()->DidAcceptSuggestion(base::string16(), 0); |
| 579 | 583 |
| 580 // All inputs should be filled. | 584 // All inputs should be filled. |
| 581 AutofillProfileWrapper wrapper(&full_profile); | 585 AutofillProfileWrapper wrapper(&full_profile); |
| 582 for (size_t i = 0; i < inputs.size(); ++i) { | 586 for (size_t i = 0; i < inputs.size(); ++i) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 630 |
| 627 // Select "Add new shipping address...". | 631 // Select "Add new shipping address...". |
| 628 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); | 632 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); |
| 629 model->ActivatedAt(model->GetItemCount() - 2); | 633 model->ActivatedAt(model->GetItemCount() - 2); |
| 630 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 634 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 631 | 635 |
| 632 const DetailInputs& inputs = | 636 const DetailInputs& inputs = |
| 633 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 637 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 634 const ServerFieldType triggering_type = inputs[0].type; | 638 const ServerFieldType triggering_type = inputs[0].type; |
| 635 base::string16 value = full_profile.GetRawInfo(triggering_type); | 639 base::string16 value = full_profile.GetRawInfo(triggering_type); |
| 636 TestableAutofillDialogView* view = controller()->GetTestableView(); | 640 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 637 view->SetTextContentsOfInput(triggering_type, | 641 view->SetTextContentsOfInput(triggering_type, |
| 638 value.substr(0, value.size() / 2)); | 642 value.substr(0, value.size() / 2)); |
| 639 view->ActivateInput(triggering_type); | 643 view->ActivateInput(triggering_type); |
| 640 | 644 |
| 641 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 645 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
| 642 controller()->DidAcceptSuggestion(base::string16(), 0); | 646 controller()->DidAcceptSuggestion(base::string16(), 0); |
| 643 | 647 |
| 644 // All inputs should be filled. | 648 // All inputs should be filled. |
| 645 AutofillProfileWrapper wrapper(&full_profile); | 649 AutofillProfileWrapper wrapper(&full_profile); |
| 646 for (size_t i = 0; i < inputs.size(); ++i) { | 650 for (size_t i = 0; i < inputs.size(); ++i) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 std::vector<base::string16> emails; | 703 std::vector<base::string16> emails; |
| 700 emails.push_back(ASCIIToUTF16("user@example.com")); | 704 emails.push_back(ASCIIToUTF16("user@example.com")); |
| 701 emails.push_back(ASCIIToUTF16("admin@example.com")); | 705 emails.push_back(ASCIIToUTF16("admin@example.com")); |
| 702 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); | 706 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); |
| 703 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 707 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 704 | 708 |
| 705 const DetailInputs& inputs = | 709 const DetailInputs& inputs = |
| 706 controller()->RequestedFieldsForSection(SECTION_BILLING); | 710 controller()->RequestedFieldsForSection(SECTION_BILLING); |
| 707 const ServerFieldType triggering_type = inputs[0].type; | 711 const ServerFieldType triggering_type = inputs[0].type; |
| 708 EXPECT_EQ(NAME_BILLING_FULL, triggering_type); | 712 EXPECT_EQ(NAME_BILLING_FULL, triggering_type); |
| 709 TestableAutofillDialogView* view = controller()->GetTestableView(); | 713 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 710 view->ActivateInput(triggering_type); | 714 view->ActivateInput(triggering_type); |
| 711 | 715 |
| 712 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 716 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
| 713 | 717 |
| 714 // Choose the variant suggestion. | 718 // Choose the variant suggestion. |
| 715 controller()->DidAcceptSuggestion(base::string16(), 1); | 719 controller()->DidAcceptSuggestion(base::string16(), 1); |
| 716 | 720 |
| 717 // All inputs should be filled. | 721 // All inputs should be filled. |
| 718 AutofillProfileWrapper wrapper( | 722 AutofillProfileWrapper wrapper( |
| 719 &full_profile, AutofillType(NAME_BILLING_FULL), 1); | 723 &full_profile, AutofillType(NAME_BILLING_FULL), 1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 745 CreditCard card2; | 749 CreditCard card2; |
| 746 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); | 750 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); |
| 747 controller()->GetTestingManager()->AddTestingCreditCard(&card2); | 751 controller()->GetTestingManager()->AddTestingCreditCard(&card2); |
| 748 AutofillProfile full_profile(test::GetFullProfile()); | 752 AutofillProfile full_profile(test::GetFullProfile()); |
| 749 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 753 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 750 | 754 |
| 751 const DetailInputs& inputs = | 755 const DetailInputs& inputs = |
| 752 controller()->RequestedFieldsForSection(SECTION_CC); | 756 controller()->RequestedFieldsForSection(SECTION_CC); |
| 753 const ServerFieldType triggering_type = inputs[0].type; | 757 const ServerFieldType triggering_type = inputs[0].type; |
| 754 base::string16 value = card1.GetRawInfo(triggering_type); | 758 base::string16 value = card1.GetRawInfo(triggering_type); |
| 755 TestableAutofillDialogView* view = controller()->GetTestableView(); | 759 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 756 view->SetTextContentsOfInput(triggering_type, | 760 view->SetTextContentsOfInput(triggering_type, |
| 757 value.substr(0, value.size() / 2)); | 761 value.substr(0, value.size() / 2)); |
| 758 view->ActivateInput(triggering_type); | 762 view->ActivateInput(triggering_type); |
| 759 | 763 |
| 760 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 764 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
| 761 controller()->DidAcceptSuggestion(base::string16(), 0); | 765 controller()->DidAcceptSuggestion(base::string16(), 0); |
| 762 | 766 |
| 763 // All inputs should be filled. | 767 // All inputs should be filled. |
| 764 AutofillCreditCardWrapper wrapper1(&card1); | 768 AutofillCreditCardWrapper wrapper1(&card1); |
| 765 for (size_t i = 0; i < inputs.size(); ++i) { | 769 for (size_t i = 0; i < inputs.size(); ++i) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 } | 824 } |
| 821 } | 825 } |
| 822 | 826 |
| 823 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) { | 827 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) { |
| 824 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); | 828 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); |
| 825 | 829 |
| 826 CreditCard card(test::GetCreditCard()); | 830 CreditCard card(test::GetCreditCard()); |
| 827 ASSERT_FALSE(card.IsVerified()); | 831 ASSERT_FALSE(card.IsVerified()); |
| 828 controller()->GetTestingManager()->AddTestingCreditCard(&card); | 832 controller()->GetTestingManager()->AddTestingCreditCard(&card); |
| 829 | 833 |
| 830 TestableAutofillDialogView* view = controller()->GetTestableView(); | 834 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 831 view->SetTextContentsOfInput( | 835 view->SetTextContentsOfInput( |
| 832 CREDIT_CARD_NUMBER, | 836 CREDIT_CARD_NUMBER, |
| 833 card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1)); | 837 card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1)); |
| 834 | 838 |
| 835 view->ActivateInput(CREDIT_CARD_NUMBER); | 839 view->ActivateInput(CREDIT_CARD_NUMBER); |
| 836 EXPECT_FALSE(controller()->ShouldShowErrorBubble()); | 840 EXPECT_FALSE(controller()->ShouldShowErrorBubble()); |
| 837 | 841 |
| 838 controller()->FocusMoved(); | 842 controller()->FocusMoved(); |
| 839 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); | 843 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); |
| 840 } | 844 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 863 ASSERT_TRUE(model->IsItemCheckedAt(0)); | 867 ASSERT_TRUE(model->IsItemCheckedAt(0)); |
| 864 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 868 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
| 865 | 869 |
| 866 model->ActivatedAt(1); | 870 model->ActivatedAt(1); |
| 867 ASSERT_TRUE(model->IsItemCheckedAt(1)); | 871 ASSERT_TRUE(model->IsItemCheckedAt(1)); |
| 868 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); | 872 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); |
| 869 } | 873 } |
| 870 | 874 |
| 871 // Notifications with long message text should not make the dialog bigger. | 875 // Notifications with long message text should not make the dialog bigger. |
| 872 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { | 876 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { |
| 873 const gfx::Size no_notification_size = | 877 const gfx::Size no_notification_size = GetViewTester()->GetSize(); |
| 874 controller()->GetTestableView()->GetSize(); | |
| 875 ASSERT_GT(no_notification_size.width(), 0); | 878 ASSERT_GT(no_notification_size.width(), 0); |
| 876 | 879 |
| 877 std::vector<DialogNotification> notifications; | 880 std::vector<DialogNotification> notifications; |
| 878 notifications.push_back( | 881 notifications.push_back( |
| 879 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16( | 882 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16( |
| 880 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " | 883 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " |
| 881 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " | 884 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " |
| 882 "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " | 885 "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " |
| 883 "aliquip ex ea commodo consequat. Duis aute irure dolor in " | 886 "aliquip ex ea commodo consequat. Duis aute irure dolor in " |
| 884 "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla " | 887 "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla " |
| 885 "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in " | 888 "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in " |
| 886 "culpa qui officia deserunt mollit anim id est laborum."))); | 889 "culpa qui officia deserunt mollit anim id est laborum."))); |
| 887 controller()->set_notifications(notifications); | 890 controller()->set_notifications(notifications); |
| 888 controller()->view()->UpdateNotificationArea(); | 891 controller()->view()->UpdateNotificationArea(); |
| 889 | 892 |
| 890 EXPECT_EQ(no_notification_size.width(), | 893 EXPECT_EQ(no_notification_size.width(), |
| 891 controller()->GetTestableView()->GetSize().width()); | 894 GetViewTester()->GetSize().width()); |
| 892 } | 895 } |
| 893 | 896 |
| 894 // http://crbug.com/318526 | 897 // http://crbug.com/318526 |
| 895 #if defined(OS_MACOSX) | 898 #if defined(OS_MACOSX) |
| 896 #define MAYBE_AutocompleteEvent DISABLED_AutocompleteEvent | 899 #define MAYBE_AutocompleteEvent DISABLED_AutocompleteEvent |
| 897 #else | 900 #else |
| 898 #define MAYBE_AutocompleteEvent AutocompleteEvent | 901 #define MAYBE_AutocompleteEvent AutocompleteEvent |
| 899 #endif | 902 #endif |
| 900 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_AutocompleteEvent) { | 903 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_AutocompleteEvent) { |
| 901 AutofillDialogControllerImpl* controller = | 904 AutofillDialogControllerImpl* controller = |
| 902 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); | 905 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
| 903 ASSERT_TRUE(controller); | 906 ASSERT_TRUE(controller); |
| 904 | 907 |
| 905 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); | 908 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); |
| 906 AddAutofillProfileToProfile(controller->profile(), | 909 AddAutofillProfileToProfile(controller->profile(), |
| 907 test::GetVerifiedProfile()); | 910 test::GetVerifiedProfile()); |
| 908 | 911 |
| 909 TestableAutofillDialogView* view = controller->GetTestableView(); | 912 scoped_ptr<AutofillDialogViewTester> view = |
| 913 AutofillDialogViewTester::For( |
| 914 static_cast<TestAutofillDialogController*>(controller)->view()); |
| 910 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 915 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 911 view->SubmitForTesting(); | 916 view->SubmitForTesting(); |
| 912 ExpectDomMessage("success"); | 917 ExpectDomMessage("success"); |
| 913 } | 918 } |
| 914 | 919 |
| 915 // http://crbug.com/318526 | 920 // http://crbug.com/318526 |
| 916 #if defined(OS_MACOSX) | 921 #if defined(OS_MACOSX) |
| 917 #define MAYBE_AutocompleteErrorEventReasonInvalid \ | 922 #define MAYBE_AutocompleteErrorEventReasonInvalid \ |
| 918 DISABLED_AutocompleteErrorEventReasonInvalid | 923 DISABLED_AutocompleteErrorEventReasonInvalid |
| 919 #else | 924 #else |
| 920 #define MAYBE_AutocompleteErrorEventReasonInvalid \ | 925 #define MAYBE_AutocompleteErrorEventReasonInvalid \ |
| 921 AutocompleteErrorEventReasonInvalid | 926 AutocompleteErrorEventReasonInvalid |
| 922 #endif | 927 #endif |
| 923 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 928 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 924 MAYBE_AutocompleteErrorEventReasonInvalid) { | 929 MAYBE_AutocompleteErrorEventReasonInvalid) { |
| 925 AutofillDialogControllerImpl* controller = | 930 AutofillDialogControllerImpl* controller = |
| 926 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); | 931 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); |
| 927 ASSERT_TRUE(controller); | 932 ASSERT_TRUE(controller); |
| 928 | 933 |
| 929 const CreditCard& credit_card = test::GetVerifiedCreditCard(); | 934 const CreditCard& credit_card = test::GetVerifiedCreditCard(); |
| 930 ASSERT_TRUE( | 935 ASSERT_TRUE( |
| 931 credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) == | 936 credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) == |
| 932 base::string16::npos); | 937 base::string16::npos); |
| 933 AddCreditcardToProfile(controller->profile(), credit_card); | 938 AddCreditcardToProfile(controller->profile(), credit_card); |
| 934 AddAutofillProfileToProfile(controller->profile(), | 939 AddAutofillProfileToProfile(controller->profile(), |
| 935 test::GetVerifiedProfile()); | 940 test::GetVerifiedProfile()); |
| 936 | 941 |
| 937 TestableAutofillDialogView* view = controller->GetTestableView(); | 942 scoped_ptr<AutofillDialogViewTester> view = |
| 943 AutofillDialogViewTester::For( |
| 944 static_cast<TestAutofillDialogController*>(controller)->view()); |
| 938 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 945 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 939 view->SubmitForTesting(); | 946 view->SubmitForTesting(); |
| 940 ExpectDomMessage("error: invalid"); | 947 ExpectDomMessage("error: invalid"); |
| 941 } | 948 } |
| 942 | 949 |
| 943 // http://crbug.com/318526 | 950 // http://crbug.com/318526 |
| 944 #if defined(OS_MACOSX) | 951 #if defined(OS_MACOSX) |
| 945 #define MAYBE_AutocompleteErrorEventReasonCancel \ | 952 #define MAYBE_AutocompleteErrorEventReasonCancel \ |
| 946 DISABLED_AutocompleteErrorEventReasonCancel | 953 DISABLED_AutocompleteErrorEventReasonCancel |
| 947 #else | 954 #else |
| 948 #define MAYBE_AutocompleteErrorEventReasonCancel \ | 955 #define MAYBE_AutocompleteErrorEventReasonCancel \ |
| 949 AutocompleteErrorEventReasonCancel | 956 AutocompleteErrorEventReasonCancel |
| 950 #endif | 957 #endif |
| 951 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 958 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 952 MAYBE_AutocompleteErrorEventReasonCancel) { | 959 MAYBE_AutocompleteErrorEventReasonCancel) { |
| 953 AutofillDialogControllerImpl* controller = | 960 AutofillDialogControllerImpl* controller = |
| 954 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); | 961 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
| 955 ASSERT_TRUE(controller); | 962 ASSERT_TRUE(controller); |
| 956 controller->GetTestableView()->CancelForTesting(); | 963 AutofillDialogViewTester::For( |
| 964 static_cast<TestAutofillDialogController*>(controller)->view())-> |
| 965 CancelForTesting(); |
| 957 ExpectDomMessage("error: cancel"); | 966 ExpectDomMessage("error: cancel"); |
| 958 } | 967 } |
| 959 | 968 |
| 960 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { | 969 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { |
| 961 controller()->set_use_validation(true); | 970 controller()->set_use_validation(true); |
| 962 | 971 |
| 963 CreditCard credit_card(test::GetVerifiedCreditCard()); | 972 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 964 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 973 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 965 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 974 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
| 966 | 975 |
| 967 ASSERT_NO_FATAL_FAILURE( | 976 ASSERT_NO_FATAL_FAILURE(GetViewTester()->SubmitForTesting()); |
| 968 controller()->GetTestableView()->SubmitForTesting()); | |
| 969 } | 977 } |
| 970 | 978 |
| 971 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. | 979 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. |
| 972 #if defined(OS_WIN) | 980 #if defined(OS_WIN) |
| 973 #define MAYBE_PreservedSections DISABLED_PreservedSections | 981 #define MAYBE_PreservedSections DISABLED_PreservedSections |
| 974 #else | 982 #else |
| 975 #define MAYBE_PreservedSections PreservedSections | 983 #define MAYBE_PreservedSections PreservedSections |
| 976 #endif | 984 #endif |
| 977 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { | 985 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { |
| 978 controller()->set_use_validation(true); | 986 controller()->set_use_validation(true); |
| 979 | 987 |
| 980 TestableAutofillDialogView* view = controller()->GetTestableView(); | 988 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 981 view->SetTextContentsOfInput(CREDIT_CARD_NUMBER, | 989 view->SetTextContentsOfInput(CREDIT_CARD_NUMBER, |
| 982 ASCIIToUTF16("4111111111111111")); | 990 ASCIIToUTF16("4111111111111111")); |
| 983 | 991 |
| 984 // Create some invalid, manually inputted shipping data. | 992 // Create some invalid, manually inputted shipping data. |
| 985 view->SetTextContentsOfInput(ADDRESS_HOME_ZIP, ASCIIToUTF16("shipping zip")); | 993 view->SetTextContentsOfInput(ADDRESS_HOME_ZIP, ASCIIToUTF16("shipping zip")); |
| 986 | 994 |
| 987 // Switch to Wallet by simulating a successful server response. | 995 // Switch to Wallet by simulating a successful server response. |
| 988 controller()->OnDidFetchWalletCookieValue(std::string()); | 996 controller()->OnDidFetchWalletCookieValue(std::string()); |
| 989 controller()->OnDidGetWalletItems( | 997 controller()->OnDidGetWalletItems( |
| 990 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); | 998 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1014 | 1022 |
| 1015 scoped_ptr<wallet::WalletItems> wallet_items = | 1023 scoped_ptr<wallet::WalletItems> wallet_items = |
| 1016 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); | 1024 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); |
| 1017 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1025 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1018 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1026 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1019 | 1027 |
| 1020 base::string16 last_four = | 1028 base::string16 last_four = |
| 1021 wallet_items->instruments()[0]->TypeAndLastFourDigits(); | 1029 wallet_items->instruments()[0]->TypeAndLastFourDigits(); |
| 1022 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1030 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1023 | 1031 |
| 1024 TestableAutofillDialogView* test_view = controller()->GetTestableView(); | 1032 scoped_ptr<AutofillDialogViewTester> test_view = GetViewTester(); |
| 1025 EXPECT_FALSE(test_view->IsShowingOverlay()); | 1033 EXPECT_FALSE(test_view->IsShowingOverlay()); |
| 1026 EXPECT_CALL(*controller(), LoadRiskFingerprintData()); | 1034 EXPECT_CALL(*controller(), LoadRiskFingerprintData()); |
| 1027 controller()->OnAccept(); | 1035 controller()->OnAccept(); |
| 1028 EXPECT_TRUE(test_view->IsShowingOverlay()); | 1036 EXPECT_TRUE(test_view->IsShowingOverlay()); |
| 1029 | 1037 |
| 1030 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetFullWallet(_)); | 1038 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetFullWallet(_)); |
| 1031 scoped_ptr<risk::Fingerprint> fingerprint(new risk::Fingerprint()); | 1039 scoped_ptr<risk::Fingerprint> fingerprint(new risk::Fingerprint()); |
| 1032 fingerprint->mutable_machine_characteristics()->mutable_screen_size()-> | 1040 fingerprint->mutable_machine_characteristics()->mutable_screen_size()-> |
| 1033 set_width(1024); | 1041 set_width(1024); |
| 1034 controller()->OnDidLoadRiskFingerprintData(fingerprint.Pass()); | 1042 controller()->OnDidLoadRiskFingerprintData(fingerprint.Pass()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); | 1086 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); |
| 1079 | 1087 |
| 1080 NavEntryCommittedObserver sign_in_page_observer( | 1088 NavEntryCommittedObserver sign_in_page_observer( |
| 1081 controller()->SignInUrl(), | 1089 controller()->SignInUrl(), |
| 1082 content::NotificationService::AllSources()); | 1090 content::NotificationService::AllSources()); |
| 1083 | 1091 |
| 1084 // Simulate a user clicking "Sign In" (which loads dialog's web contents). | 1092 // Simulate a user clicking "Sign In" (which loads dialog's web contents). |
| 1085 controller()->SignInLinkClicked(); | 1093 controller()->SignInLinkClicked(); |
| 1086 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); | 1094 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); |
| 1087 | 1095 |
| 1088 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1096 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1089 content::WebContents* sign_in_contents = view->GetSignInWebContents(); | 1097 content::WebContents* sign_in_contents = view->GetSignInWebContents(); |
| 1090 ASSERT_TRUE(sign_in_contents); | 1098 ASSERT_TRUE(sign_in_contents); |
| 1091 | 1099 |
| 1092 sign_in_page_observer.Wait(); | 1100 sign_in_page_observer.Wait(); |
| 1093 | 1101 |
| 1094 NavEntryCommittedObserver continue_page_observer( | 1102 NavEntryCommittedObserver continue_page_observer( |
| 1095 wallet::GetSignInContinueUrl(), | 1103 wallet::GetSignInContinueUrl(), |
| 1096 content::NotificationService::AllSources()); | 1104 content::NotificationService::AllSources()); |
| 1097 | 1105 |
| 1098 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); | 1106 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 | 1151 |
| 1144 NavEntryCommittedObserver sign_in_page_observer( | 1152 NavEntryCommittedObserver sign_in_page_observer( |
| 1145 controller()->SignInUrl(), | 1153 controller()->SignInUrl(), |
| 1146 content::NotificationService::AllSources()); | 1154 content::NotificationService::AllSources()); |
| 1147 | 1155 |
| 1148 // Simulate a user clicking "add account". | 1156 // Simulate a user clicking "add account". |
| 1149 account_chooser_model->ActivatedAt( | 1157 account_chooser_model->ActivatedAt( |
| 1150 account_chooser_model->GetItemCount() - 2); | 1158 account_chooser_model->GetItemCount() - 2); |
| 1151 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); | 1159 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); |
| 1152 | 1160 |
| 1153 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1161 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1154 content::WebContents* sign_in_contents = view->GetSignInWebContents(); | 1162 content::WebContents* sign_in_contents = view->GetSignInWebContents(); |
| 1155 ASSERT_TRUE(sign_in_contents); | 1163 ASSERT_TRUE(sign_in_contents); |
| 1156 | 1164 |
| 1157 sign_in_page_observer.Wait(); | 1165 sign_in_page_observer.Wait(); |
| 1158 | 1166 |
| 1159 NavEntryCommittedObserver continue_page_observer( | 1167 NavEntryCommittedObserver continue_page_observer( |
| 1160 wallet::GetSignInContinueUrl(), | 1168 wallet::GetSignInContinueUrl(), |
| 1161 content::NotificationService::AllSources()); | 1169 content::NotificationService::AllSources()); |
| 1162 | 1170 |
| 1163 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); | 1171 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 1212 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 1205 MAYBE_FillFormIncludesCVC) { | 1213 MAYBE_FillFormIncludesCVC) { |
| 1206 AutofillDialogControllerImpl* controller = | 1214 AutofillDialogControllerImpl* controller = |
| 1207 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); | 1215 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); |
| 1208 ASSERT_TRUE(controller); | 1216 ASSERT_TRUE(controller); |
| 1209 | 1217 |
| 1210 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); | 1218 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); |
| 1211 AddAutofillProfileToProfile(controller->profile(), | 1219 AddAutofillProfileToProfile(controller->profile(), |
| 1212 test::GetVerifiedProfile()); | 1220 test::GetVerifiedProfile()); |
| 1213 | 1221 |
| 1214 TestableAutofillDialogView* view = controller->GetTestableView(); | 1222 scoped_ptr<AutofillDialogViewTester> view = |
| 1223 AutofillDialogViewTester::For( |
| 1224 static_cast<TestAutofillDialogController*>(controller)->view()); |
| 1215 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 1225 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 1216 view->SubmitForTesting(); | 1226 view->SubmitForTesting(); |
| 1217 ExpectDomMessage("success"); | 1227 ExpectDomMessage("success"); |
| 1218 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); | 1228 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); |
| 1219 } | 1229 } |
| 1220 | 1230 |
| 1221 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { | 1231 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { |
| 1222 // Ensure the input under test is a combobox. | 1232 // Ensure the input under test is a combobox. |
| 1223 ASSERT_TRUE( | 1233 ASSERT_TRUE( |
| 1224 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); | 1234 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); |
| 1225 | 1235 |
| 1226 // Set up an expired card. | 1236 // Set up an expired card. |
| 1227 CreditCard card; | 1237 CreditCard card; |
| 1228 test::SetCreditCardInfo(&card, "Roy Demeo", "4111111111111111", "8", "2013"); | 1238 test::SetCreditCardInfo(&card, "Roy Demeo", "4111111111111111", "8", "2013"); |
| 1229 card.set_origin("Chrome settings"); | 1239 card.set_origin("Chrome settings"); |
| 1230 ASSERT_TRUE(card.IsVerified()); | 1240 ASSERT_TRUE(card.IsVerified()); |
| 1231 | 1241 |
| 1232 // Add the card and check that there's a menu for that section. | 1242 // Add the card and check that there's a menu for that section. |
| 1233 controller()->GetTestingManager()->AddTestingCreditCard(&card); | 1243 controller()->GetTestingManager()->AddTestingCreditCard(&card); |
| 1234 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_CC)); | 1244 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_CC)); |
| 1235 | 1245 |
| 1236 // Select the invalid, suggested card from the menu. | 1246 // Select the invalid, suggested card from the menu. |
| 1237 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0); | 1247 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0); |
| 1238 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); | 1248 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); |
| 1239 | 1249 |
| 1240 // Get the contents of the combobox of the credit card's expiration month. | 1250 // Get the contents of the combobox of the credit card's expiration month. |
| 1241 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1251 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1242 base::string16 cc_exp_month_text = | 1252 base::string16 cc_exp_month_text = |
| 1243 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH); | 1253 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH); |
| 1244 | 1254 |
| 1245 // Select "New X..." from the suggestion menu to clear the section's inputs. | 1255 // Select "New X..." from the suggestion menu to clear the section's inputs. |
| 1246 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1); | 1256 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1); |
| 1247 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 1257 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
| 1248 | 1258 |
| 1249 // Ensure that the credit card expiration month has changed. | 1259 // Ensure that the credit card expiration month has changed. |
| 1250 EXPECT_NE(cc_exp_month_text, | 1260 EXPECT_NE(cc_exp_month_text, |
| 1251 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH)); | 1261 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 controller()->OnDidFetchWalletCookieValue(std::string()); | 1311 controller()->OnDidFetchWalletCookieValue(std::string()); |
| 1302 controller()->OnDidGetWalletItems( | 1312 controller()->OnDidGetWalletItems( |
| 1303 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); | 1313 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); |
| 1304 | 1314 |
| 1305 NavEntryCommittedObserver sign_in_page_observer( | 1315 NavEntryCommittedObserver sign_in_page_observer( |
| 1306 controller()->SignInUrl(), | 1316 controller()->SignInUrl(), |
| 1307 content::NotificationService::AllSources()); | 1317 content::NotificationService::AllSources()); |
| 1308 | 1318 |
| 1309 controller()->SignInLinkClicked(); | 1319 controller()->SignInLinkClicked(); |
| 1310 | 1320 |
| 1311 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1321 content::WebContents* sign_in_contents = |
| 1312 content::WebContents* sign_in_contents = view->GetSignInWebContents(); | 1322 GetViewTester()->GetSignInWebContents(); |
| 1313 ASSERT_TRUE(sign_in_contents); | 1323 ASSERT_TRUE(sign_in_contents); |
| 1314 | 1324 |
| 1315 sign_in_page_observer.Wait(); | 1325 sign_in_page_observer.Wait(); |
| 1316 | 1326 |
| 1317 content::OpenURLParams params(GURL("http://google.com"), | 1327 content::OpenURLParams params(GURL("http://google.com"), |
| 1318 content::Referrer(), | 1328 content::Referrer(), |
| 1319 CURRENT_TAB, | 1329 CURRENT_TAB, |
| 1320 content::PAGE_TRANSITION_LINK, | 1330 content::PAGE_TRANSITION_LINK, |
| 1321 true); | 1331 true); |
| 1322 params.user_gesture = true; | 1332 params.user_gesture = true; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, | 1468 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, |
| 1459 CountryChangeRebuildsSection) { | 1469 CountryChangeRebuildsSection) { |
| 1460 EXPECT_FALSE( | 1470 EXPECT_FALSE( |
| 1461 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); | 1471 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); |
| 1462 EXPECT_FALSE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); | 1472 EXPECT_FALSE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); |
| 1463 | 1473 |
| 1464 // Select "Add new shipping address...". | 1474 // Select "Add new shipping address...". |
| 1465 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1475 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 1466 | 1476 |
| 1467 // Add some valid user input that should be preserved when country changes. | 1477 // Add some valid user input that should be preserved when country changes. |
| 1468 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1478 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1469 view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw")); | 1479 view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw")); |
| 1470 | 1480 |
| 1471 // Change both sections' countries. | 1481 // Change both sections' countries. |
| 1472 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); | 1482 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); |
| 1473 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1483 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
| 1474 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); | 1484 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); |
| 1475 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1485 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
| 1476 | 1486 |
| 1477 // Verify the name is still there. | 1487 // Verify the name is still there. |
| 1478 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); | 1488 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1497 items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1507 items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1498 items->AddAddress(wallet::GetTestShippingAddress()); | 1508 items->AddAddress(wallet::GetTestShippingAddress()); |
| 1499 controller()->OnDidGetWalletItems(items.Pass()); | 1509 controller()->OnDidGetWalletItems(items.Pass()); |
| 1500 | 1510 |
| 1501 EXPECT_TRUE(controller()->IsPayingWithWallet()); | 1511 EXPECT_TRUE(controller()->IsPayingWithWallet()); |
| 1502 | 1512 |
| 1503 // Select "Add new billing/shipping address...". | 1513 // Select "Add new billing/shipping address...". |
| 1504 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1); | 1514 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1); |
| 1505 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); | 1515 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); |
| 1506 | 1516 |
| 1507 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1517 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1508 ASSERT_EQ(ASCIIToUTF16("United States"), | 1518 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1509 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1519 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
| 1510 ASSERT_EQ(ASCIIToUTF16("United States"), | 1520 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1511 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1521 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1512 | 1522 |
| 1513 // Switch both billing and shipping countries. | 1523 // Switch both billing and shipping countries. |
| 1514 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); | 1524 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); |
| 1515 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1525 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
| 1516 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); | 1526 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); |
| 1517 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1527 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1545 } | 1555 } |
| 1546 | 1556 |
| 1547 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) { | 1557 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) { |
| 1548 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 1558 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
| 1549 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1559 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 1550 | 1560 |
| 1551 // Select "Add new billing/shipping address...". | 1561 // Select "Add new billing/shipping address...". |
| 1552 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); | 1562 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); |
| 1553 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); | 1563 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); |
| 1554 | 1564 |
| 1555 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1565 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1556 ASSERT_EQ(ASCIIToUTF16("United States"), | 1566 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1557 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1567 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
| 1558 ASSERT_EQ(ASCIIToUTF16("United States"), | 1568 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1559 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1569 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1560 | 1570 |
| 1561 // Switch both billing and shipping countries. | 1571 // Switch both billing and shipping countries. |
| 1562 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); | 1572 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); |
| 1563 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1573 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
| 1564 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); | 1574 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); |
| 1565 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1575 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1576 | 1586 |
| 1577 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, | 1587 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, |
| 1578 FillingFormRebuildsInputs) { | 1588 FillingFormRebuildsInputs) { |
| 1579 AutofillProfile full_profile(test::GetFullProfile()); | 1589 AutofillProfile full_profile(test::GetFullProfile()); |
| 1580 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CN")); | 1590 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CN")); |
| 1581 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1591 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1582 | 1592 |
| 1583 // Select "Add new shipping address...". | 1593 // Select "Add new shipping address...". |
| 1584 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1594 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 1585 | 1595 |
| 1586 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1596 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1587 ASSERT_EQ(ASCIIToUTF16("United States"), | 1597 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1588 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1598 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
| 1589 ASSERT_EQ(ASCIIToUTF16("United States"), | 1599 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1590 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1600 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1591 | 1601 |
| 1592 base::string16 name = full_profile.GetRawInfo(NAME_FULL); | 1602 base::string16 name = full_profile.GetRawInfo(NAME_FULL); |
| 1593 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); | 1603 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); |
| 1594 view->ActivateInput(NAME_FULL); | 1604 view->ActivateInput(NAME_FULL); |
| 1595 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); | 1605 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); |
| 1596 controller()->DidAcceptSuggestion(base::string16(), 0); | 1606 controller()->DidAcceptSuggestion(base::string16(), 0); |
| 1597 | 1607 |
| 1598 EXPECT_EQ(ASCIIToUTF16("China"), | 1608 EXPECT_EQ(ASCIIToUTF16("China"), |
| 1599 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1609 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
| 1600 EXPECT_EQ(ASCIIToUTF16("China"), | 1610 EXPECT_EQ(ASCIIToUTF16("China"), |
| 1601 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1611 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1602 } | 1612 } |
| 1603 | 1613 |
| 1604 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, | 1614 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, |
| 1605 FillingFormPreservesChangedCountry) { | 1615 FillingFormPreservesChangedCountry) { |
| 1606 AutofillProfile full_profile(test::GetFullProfile()); | 1616 AutofillProfile full_profile(test::GetFullProfile()); |
| 1607 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CN")); | 1617 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CN")); |
| 1608 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1618 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1609 | 1619 |
| 1610 // Select "Add new shipping address...". | 1620 // Select "Add new shipping address...". |
| 1611 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1621 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 1612 | 1622 |
| 1613 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1623 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1614 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France")); | 1624 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France")); |
| 1615 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1625 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
| 1616 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus")); | 1626 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus")); |
| 1617 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1627 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
| 1618 | 1628 |
| 1619 base::string16 name = full_profile.GetRawInfo(NAME_FULL); | 1629 base::string16 name = full_profile.GetRawInfo(NAME_FULL); |
| 1620 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); | 1630 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); |
| 1621 view->ActivateInput(NAME_FULL); | 1631 view->ActivateInput(NAME_FULL); |
| 1622 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); | 1632 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); |
| 1623 controller()->DidAcceptSuggestion(base::string16(), 0); | 1633 controller()->DidAcceptSuggestion(base::string16(), 0); |
| 1624 | 1634 |
| 1625 EXPECT_EQ(ASCIIToUTF16("France"), | 1635 EXPECT_EQ(ASCIIToUTF16("France"), |
| 1626 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1636 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
| 1627 EXPECT_EQ(ASCIIToUTF16("Belarus"), | 1637 EXPECT_EQ(ASCIIToUTF16("Belarus"), |
| 1628 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1638 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1629 } | 1639 } |
| 1630 | 1640 |
| 1631 } // namespace autofill | 1641 } // namespace autofill |
| OLD | NEW |