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" |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); | 762 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); |
763 } | 763 } |
764 | 764 |
765 base::HistogramTester histogram; | 765 base::HistogramTester histogram; |
766 view->SubmitForTesting(); | 766 view->SubmitForTesting(); |
767 histogram.ExpectUniqueSample( | 767 histogram.ExpectUniqueSample( |
768 "RequestAutocomplete.DismissalState", | 768 "RequestAutocomplete.DismissalState", |
769 AutofillMetrics::DIALOG_ACCEPTED_SAVE_TO_AUTOFILL, 1); | 769 AutofillMetrics::DIALOG_ACCEPTED_SAVE_TO_AUTOFILL, 1); |
770 } | 770 } |
771 | 771 |
772 // This test makes sure that picking a profile variant in the Autofill | |
773 // popup works as expected. | |
774 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | |
775 FillInputFromAutofillVariant) { | |
776 AutofillProfile full_profile(test::GetFullProfile()); | |
777 | |
778 // Set up some variant data. | |
779 std::vector<base::string16> names; | |
780 names.push_back(ASCIIToUTF16("John Doe")); | |
781 names.push_back(ASCIIToUTF16("Jane Doe")); | |
782 full_profile.SetRawMultiInfo(NAME_FULL, names); | |
783 std::vector<base::string16> emails; | |
784 emails.push_back(ASCIIToUTF16("user@example.com")); | |
785 emails.push_back(ASCIIToUTF16("admin@example.com")); | |
786 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); | |
787 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | |
788 | |
789 const DetailInputs& inputs = | |
790 controller()->RequestedFieldsForSection(SECTION_BILLING); | |
791 const ServerFieldType triggering_type = inputs[0].type; | |
792 EXPECT_EQ(NAME_BILLING_FULL, triggering_type); | |
793 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | |
794 view->ActivateInput(triggering_type); | |
795 | |
796 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | |
797 | |
798 // Choose the variant suggestion. | |
799 controller()->DidAcceptSuggestion(base::string16(), 1); | |
800 | |
801 // All inputs should be filled. | |
802 AutofillProfileWrapper wrapper( | |
803 &full_profile, AutofillType(NAME_BILLING_FULL), 1); | |
804 for (size_t i = 0; i < inputs.size(); ++i) { | |
805 EXPECT_EQ(wrapper.GetInfoForDisplay(AutofillType(inputs[i].type)), | |
806 view->GetTextContentsOfInput(inputs[i].type)); | |
807 } | |
808 | |
809 // Make sure the wrapper applies the variant index to the right group. | |
810 EXPECT_EQ(names[1], wrapper.GetInfo(AutofillType(NAME_BILLING_FULL))); | |
811 // Make sure the wrapper doesn't apply the variant index to the wrong group. | |
812 EXPECT_EQ(emails[0], wrapper.GetInfo(AutofillType(EMAIL_ADDRESS))); | |
813 } | |
814 | |
815 // Tests that changing the value of a CC expiration date combobox works as | 772 // Tests that changing the value of a CC expiration date combobox works as |
816 // expected when Autofill is used to fill text inputs. | 773 // expected when Autofill is used to fill text inputs. |
817 // | 774 // |
818 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. | 775 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. |
819 #if defined(OS_WIN) | 776 #if defined(OS_WIN) |
820 #define MAYBE_FillComboboxFromAutofill DISABLED_FillComboboxFromAutofill | 777 #define MAYBE_FillComboboxFromAutofill DISABLED_FillComboboxFromAutofill |
821 #else | 778 #else |
822 #define MAYBE_FillComboboxFromAutofill FillComboboxFromAutofill | 779 #define MAYBE_FillComboboxFromAutofill FillComboboxFromAutofill |
823 #endif | 780 #endif |
824 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 781 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), | 1811 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), |
1855 "navigateFrame();", | 1812 "navigateFrame();", |
1856 &unused)); | 1813 &unused)); |
1857 ExpectDomMessage("iframe loaded"); | 1814 ExpectDomMessage("iframe loaded"); |
1858 ChromeAutofillClient* client = | 1815 ChromeAutofillClient* client = |
1859 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); | 1816 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); |
1860 EXPECT_FALSE(client->GetDialogControllerForTesting()); | 1817 EXPECT_FALSE(client->GetDialogControllerForTesting()); |
1861 } | 1818 } |
1862 | 1819 |
1863 } // namespace autofill | 1820 } // namespace autofill |
OLD | NEW |