Chromium Code Reviews| 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 }; | 516 }; |
| 517 | 517 |
| 518 // Submit the form data. | 518 // Submit the form data. |
| 519 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { | 519 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { |
| 520 base::HistogramTester histogram; | 520 base::HistogramTester histogram; |
| 521 AddCreditcardToProfile(controller()->profile(), | 521 AddCreditcardToProfile(controller()->profile(), |
| 522 test::GetVerifiedCreditCard()); | 522 test::GetVerifiedCreditCard()); |
| 523 AddAutofillProfileToProfile(controller()->profile(), | 523 AddAutofillProfileToProfile(controller()->profile(), |
| 524 test::GetVerifiedProfile()); | 524 test::GetVerifiedProfile()); |
| 525 scoped_ptr<AutofillDialogViewTester> view = AutofillDialogViewTester::For( | 525 scoped_ptr<AutofillDialogViewTester> view = AutofillDialogViewTester::For( |
| 526 static_cast<TestAutofillDialogController*>(controller())->view()); | 526 static_cast<AutofillDialogControllerImpl*>(controller())->view()); |
|
Evan Stade
2015/12/11 23:17:40
you can just remove this cast
krasin
2015/12/11 23:23:50
Done.
| |
| 527 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 527 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 528 GetViewTester()->SubmitForTesting(); | 528 GetViewTester()->SubmitForTesting(); |
| 529 RunMessageLoop(); | 529 RunMessageLoop(); |
| 530 | 530 |
| 531 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Submit", 1); | 531 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Submit", 1); |
| 532 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Cancel", 0); | 532 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Cancel", 0); |
| 533 } | 533 } |
| 534 | 534 |
| 535 // Cancel out of the dialog. | 535 // Cancel out of the dialog. |
| 536 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { | 536 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 AutofillDialogControllerImpl* controller = | 880 AutofillDialogControllerImpl* controller = |
| 881 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); | 881 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
| 882 ASSERT_TRUE(controller); | 882 ASSERT_TRUE(controller); |
| 883 | 883 |
| 884 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); | 884 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); |
| 885 AddAutofillProfileToProfile(controller->profile(), | 885 AddAutofillProfileToProfile(controller->profile(), |
| 886 test::GetVerifiedProfile()); | 886 test::GetVerifiedProfile()); |
| 887 | 887 |
| 888 scoped_ptr<AutofillDialogViewTester> view = | 888 scoped_ptr<AutofillDialogViewTester> view = |
| 889 AutofillDialogViewTester::For( | 889 AutofillDialogViewTester::For( |
| 890 static_cast<TestAutofillDialogController*>(controller)->view()); | 890 static_cast<AutofillDialogControllerImpl*>(controller)->view()); |
|
Evan Stade
2015/12/11 23:17:40
you don't need this cast
krasin
2015/12/11 23:23:50
Done.
| |
| 891 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 891 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 892 view->SubmitForTesting(); | 892 view->SubmitForTesting(); |
| 893 ExpectDomMessage("success"); | 893 ExpectDomMessage("success"); |
| 894 } | 894 } |
| 895 | 895 |
| 896 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 896 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 897 AutocompleteErrorEventReasonInvalid) { | 897 AutocompleteErrorEventReasonInvalid) { |
| 898 AutofillDialogControllerImpl* controller = | 898 AutofillDialogControllerImpl* controller = |
| 899 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); | 899 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); |
| 900 ASSERT_TRUE(controller); | 900 ASSERT_TRUE(controller); |
| 901 | 901 |
| 902 const CreditCard& credit_card = test::GetVerifiedCreditCard(); | 902 const CreditCard& credit_card = test::GetVerifiedCreditCard(); |
| 903 ASSERT_TRUE( | 903 ASSERT_TRUE( |
| 904 credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) == | 904 credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) == |
| 905 base::string16::npos); | 905 base::string16::npos); |
| 906 AddCreditcardToProfile(controller->profile(), credit_card); | 906 AddCreditcardToProfile(controller->profile(), credit_card); |
| 907 AddAutofillProfileToProfile(controller->profile(), | 907 AddAutofillProfileToProfile(controller->profile(), |
| 908 test::GetVerifiedProfile()); | 908 test::GetVerifiedProfile()); |
| 909 | 909 |
| 910 scoped_ptr<AutofillDialogViewTester> view = | 910 scoped_ptr<AutofillDialogViewTester> view = |
| 911 AutofillDialogViewTester::For( | 911 AutofillDialogViewTester::For( |
| 912 static_cast<TestAutofillDialogController*>(controller)->view()); | 912 static_cast<AutofillDialogControllerImpl*>(controller)->view()); |
|
Evan Stade
2015/12/11 23:17:40
ditto
krasin
2015/12/11 23:23:50
Done.
| |
| 913 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 913 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 914 view->SubmitForTesting(); | 914 view->SubmitForTesting(); |
| 915 ExpectDomMessage("error: invalid"); | 915 ExpectDomMessage("error: invalid"); |
| 916 | 916 |
| 917 int invalid_count = -1; | 917 int invalid_count = -1; |
| 918 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 918 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 919 GetRenderViewHost(), "send(invalidEvents.length);", &invalid_count)); | 919 GetRenderViewHost(), "send(invalidEvents.length);", &invalid_count)); |
| 920 EXPECT_EQ(1, invalid_count); | 920 EXPECT_EQ(1, invalid_count); |
| 921 | 921 |
| 922 std::string invalid_type; | 922 std::string invalid_type; |
| 923 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 923 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 924 GetRenderViewHost(), | 924 GetRenderViewHost(), |
| 925 "send(invalidEvents[0].target.autocomplete);", | 925 "send(invalidEvents[0].target.autocomplete);", |
| 926 &invalid_type)); | 926 &invalid_type)); |
| 927 EXPECT_EQ("cc-name", invalid_type); | 927 EXPECT_EQ("cc-name", invalid_type); |
| 928 } | 928 } |
| 929 | 929 |
| 930 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 930 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 931 AutocompleteErrorEventReasonCancel) { | 931 AutocompleteErrorEventReasonCancel) { |
| 932 AutofillDialogControllerImpl* controller = | 932 AutofillDialogControllerImpl* controller = |
| 933 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); | 933 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
| 934 ASSERT_TRUE(controller); | 934 ASSERT_TRUE(controller); |
| 935 AutofillDialogViewTester::For( | 935 AutofillDialogViewTester::For( |
| 936 static_cast<TestAutofillDialogController*>(controller)->view())-> | 936 static_cast<AutofillDialogControllerImpl*>(controller)->view())-> |
| 937 CancelForTesting(); | 937 CancelForTesting(); |
| 938 ExpectDomMessage("error: cancel"); | 938 ExpectDomMessage("error: cancel"); |
| 939 } | 939 } |
| 940 | 940 |
| 941 // http://crbug.com/318526 | 941 // http://crbug.com/318526 |
| 942 #if defined(OS_MACOSX) | 942 #if defined(OS_MACOSX) |
| 943 #define MAYBE_ErrorWithFrameNavigation DISABLED_ErrorWithFrameNavigation | 943 #define MAYBE_ErrorWithFrameNavigation DISABLED_ErrorWithFrameNavigation |
| 944 #else | 944 #else |
| 945 #define MAYBE_ErrorWithFrameNavigation ErrorWithFrameNavigation | 945 #define MAYBE_ErrorWithFrameNavigation ErrorWithFrameNavigation |
| 946 #endif | 946 #endif |
| 947 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 947 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 948 MAYBE_ErrorWithFrameNavigation) { | 948 MAYBE_ErrorWithFrameNavigation) { |
| 949 AutofillDialogControllerImpl* controller = | 949 AutofillDialogControllerImpl* controller = |
| 950 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); | 950 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
| 951 ASSERT_TRUE(controller); | 951 ASSERT_TRUE(controller); |
| 952 | 952 |
| 953 std::string unused; | 953 std::string unused; |
| 954 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), | 954 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), |
| 955 "loadIframe();", | 955 "loadIframe();", |
| 956 &unused)); | 956 &unused)); |
| 957 ExpectDomMessage("iframe loaded"); | 957 ExpectDomMessage("iframe loaded"); |
| 958 | 958 |
| 959 AutofillDialogViewTester::For( | 959 AutofillDialogViewTester::For( |
| 960 static_cast<TestAutofillDialogController*>(controller)->view())-> | 960 static_cast<AutofillDialogControllerImpl*>(controller)->view())-> |
| 961 CancelForTesting(); | 961 CancelForTesting(); |
| 962 ExpectDomMessage("error: cancel"); | 962 ExpectDomMessage("error: cancel"); |
| 963 } | 963 } |
| 964 | 964 |
| 965 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { | 965 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { |
| 966 controller()->set_use_validation(true); | 966 controller()->set_use_validation(true); |
| 967 | 967 |
| 968 CreditCard credit_card(test::GetVerifiedCreditCard()); | 968 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 969 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 969 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 970 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 970 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
| 971 | 971 |
| 972 ASSERT_NO_FATAL_FAILURE(GetViewTester()->SubmitForTesting()); | 972 ASSERT_NO_FATAL_FAILURE(GetViewTester()->SubmitForTesting()); |
| 973 } | 973 } |
| 974 | 974 |
| 975 // Verify that filling a form works correctly, including filling the CVC when | 975 // Verify that filling a form works correctly, including filling the CVC when |
| 976 // that is requested separately. | 976 // that is requested separately. |
| 977 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 977 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 978 FillFormIncludesCVC) { | 978 FillFormIncludesCVC) { |
| 979 AutofillDialogControllerImpl* controller = | 979 AutofillDialogControllerImpl* controller = |
| 980 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); | 980 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); |
| 981 ASSERT_TRUE(controller); | 981 ASSERT_TRUE(controller); |
| 982 | 982 |
| 983 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); | 983 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); |
| 984 AddAutofillProfileToProfile(controller->profile(), | 984 AddAutofillProfileToProfile(controller->profile(), |
| 985 test::GetVerifiedProfile()); | 985 test::GetVerifiedProfile()); |
| 986 | 986 |
| 987 scoped_ptr<AutofillDialogViewTester> view = | 987 scoped_ptr<AutofillDialogViewTester> view = |
| 988 AutofillDialogViewTester::For( | 988 AutofillDialogViewTester::For( |
| 989 static_cast<TestAutofillDialogController*>(controller)->view()); | 989 static_cast<AutofillDialogControllerImpl*>(controller)->view()); |
| 990 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 990 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| 991 view->SubmitForTesting(); | 991 view->SubmitForTesting(); |
| 992 ExpectDomMessage("success"); | 992 ExpectDomMessage("success"); |
| 993 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); | 993 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); |
| 994 } | 994 } |
| 995 | 995 |
| 996 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { | 996 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { |
| 997 // Ensure the input under test is a combobox. | 997 // Ensure the input under test is a combobox. |
| 998 ASSERT_TRUE( | 998 ASSERT_TRUE( |
| 999 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); | 999 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1330 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), | 1330 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), |
| 1331 "navigateFrame();", | 1331 "navigateFrame();", |
| 1332 &unused)); | 1332 &unused)); |
| 1333 ExpectDomMessage("iframe loaded"); | 1333 ExpectDomMessage("iframe loaded"); |
| 1334 ChromeAutofillClient* client = | 1334 ChromeAutofillClient* client = |
| 1335 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); | 1335 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); |
| 1336 EXPECT_FALSE(client->GetDialogControllerForTesting()); | 1336 EXPECT_FALSE(client->GetDialogControllerForTesting()); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 } // namespace autofill | 1339 } // namespace autofill |
| OLD | NEW |