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

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

Issue 1515293003: Fix invalid cast in AutofillDialogControllerTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove casts Created 5 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | 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/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
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 controller()->view());
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocompleteEvent) { 879 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocompleteEvent) {
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(controller->view());
890 static_cast<TestAutofillDialogController*>(controller)->view());
891 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); 890 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
892 view->SubmitForTesting(); 891 view->SubmitForTesting();
893 ExpectDomMessage("success"); 892 ExpectDomMessage("success");
894 } 893 }
895 894
896 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 895 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
897 AutocompleteErrorEventReasonInvalid) { 896 AutocompleteErrorEventReasonInvalid) {
898 AutofillDialogControllerImpl* controller = 897 AutofillDialogControllerImpl* controller =
899 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); 898 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>");
900 ASSERT_TRUE(controller); 899 ASSERT_TRUE(controller);
901 900
902 const CreditCard& credit_card = test::GetVerifiedCreditCard(); 901 const CreditCard& credit_card = test::GetVerifiedCreditCard();
903 ASSERT_TRUE( 902 ASSERT_TRUE(
904 credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) == 903 credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) ==
905 base::string16::npos); 904 base::string16::npos);
906 AddCreditcardToProfile(controller->profile(), credit_card); 905 AddCreditcardToProfile(controller->profile(), credit_card);
907 AddAutofillProfileToProfile(controller->profile(), 906 AddAutofillProfileToProfile(controller->profile(),
908 test::GetVerifiedProfile()); 907 test::GetVerifiedProfile());
909 908
910 scoped_ptr<AutofillDialogViewTester> view = 909 scoped_ptr<AutofillDialogViewTester> view =
911 AutofillDialogViewTester::For( 910 AutofillDialogViewTester::For(controller->view());
912 static_cast<TestAutofillDialogController*>(controller)->view());
913 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); 911 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
914 view->SubmitForTesting(); 912 view->SubmitForTesting();
915 ExpectDomMessage("error: invalid"); 913 ExpectDomMessage("error: invalid");
916 914
917 int invalid_count = -1; 915 int invalid_count = -1;
918 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 916 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
919 GetRenderViewHost(), "send(invalidEvents.length);", &invalid_count)); 917 GetRenderViewHost(), "send(invalidEvents.length);", &invalid_count));
920 EXPECT_EQ(1, invalid_count); 918 EXPECT_EQ(1, invalid_count);
921 919
922 std::string invalid_type; 920 std::string invalid_type;
923 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 921 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
924 GetRenderViewHost(), 922 GetRenderViewHost(),
925 "send(invalidEvents[0].target.autocomplete);", 923 "send(invalidEvents[0].target.autocomplete);",
926 &invalid_type)); 924 &invalid_type));
927 EXPECT_EQ("cc-name", invalid_type); 925 EXPECT_EQ("cc-name", invalid_type);
928 } 926 }
929 927
930 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 928 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
931 AutocompleteErrorEventReasonCancel) { 929 AutocompleteErrorEventReasonCancel) {
932 AutofillDialogControllerImpl* controller = 930 AutofillDialogControllerImpl* controller =
933 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); 931 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>");
934 ASSERT_TRUE(controller); 932 ASSERT_TRUE(controller);
935 AutofillDialogViewTester::For( 933 AutofillDialogViewTester::For(controller->view())->
936 static_cast<TestAutofillDialogController*>(controller)->view())->
937 CancelForTesting(); 934 CancelForTesting();
938 ExpectDomMessage("error: cancel"); 935 ExpectDomMessage("error: cancel");
939 } 936 }
940 937
941 // http://crbug.com/318526 938 // http://crbug.com/318526
942 #if defined(OS_MACOSX) 939 #if defined(OS_MACOSX)
943 #define MAYBE_ErrorWithFrameNavigation DISABLED_ErrorWithFrameNavigation 940 #define MAYBE_ErrorWithFrameNavigation DISABLED_ErrorWithFrameNavigation
944 #else 941 #else
945 #define MAYBE_ErrorWithFrameNavigation ErrorWithFrameNavigation 942 #define MAYBE_ErrorWithFrameNavigation ErrorWithFrameNavigation
946 #endif 943 #endif
947 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 944 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
948 MAYBE_ErrorWithFrameNavigation) { 945 MAYBE_ErrorWithFrameNavigation) {
949 AutofillDialogControllerImpl* controller = 946 AutofillDialogControllerImpl* controller =
950 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); 947 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>");
951 ASSERT_TRUE(controller); 948 ASSERT_TRUE(controller);
952 949
953 std::string unused; 950 std::string unused;
954 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), 951 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(),
955 "loadIframe();", 952 "loadIframe();",
956 &unused)); 953 &unused));
957 ExpectDomMessage("iframe loaded"); 954 ExpectDomMessage("iframe loaded");
958 955
959 AutofillDialogViewTester::For( 956 AutofillDialogViewTester::For(controller->view())->
960 static_cast<TestAutofillDialogController*>(controller)->view())->
961 CancelForTesting(); 957 CancelForTesting();
962 ExpectDomMessage("error: cancel"); 958 ExpectDomMessage("error: cancel");
963 } 959 }
964 960
965 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { 961 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) {
966 controller()->set_use_validation(true); 962 controller()->set_use_validation(true);
967 963
968 CreditCard credit_card(test::GetVerifiedCreditCard()); 964 CreditCard credit_card(test::GetVerifiedCreditCard());
969 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); 965 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
970 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); 966 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
971 967
972 ASSERT_NO_FATAL_FAILURE(GetViewTester()->SubmitForTesting()); 968 ASSERT_NO_FATAL_FAILURE(GetViewTester()->SubmitForTesting());
973 } 969 }
974 970
975 // Verify that filling a form works correctly, including filling the CVC when 971 // Verify that filling a form works correctly, including filling the CVC when
976 // that is requested separately. 972 // that is requested separately.
977 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 973 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
978 FillFormIncludesCVC) { 974 FillFormIncludesCVC) {
979 AutofillDialogControllerImpl* controller = 975 AutofillDialogControllerImpl* controller =
980 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); 976 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>");
981 ASSERT_TRUE(controller); 977 ASSERT_TRUE(controller);
982 978
983 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); 979 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard());
984 AddAutofillProfileToProfile(controller->profile(), 980 AddAutofillProfileToProfile(controller->profile(),
985 test::GetVerifiedProfile()); 981 test::GetVerifiedProfile());
986 982
987 scoped_ptr<AutofillDialogViewTester> view = 983 scoped_ptr<AutofillDialogViewTester> view =
988 AutofillDialogViewTester::For( 984 AutofillDialogViewTester::For(controller->view());
989 static_cast<TestAutofillDialogController*>(controller)->view());
990 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); 985 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
991 view->SubmitForTesting(); 986 view->SubmitForTesting();
992 ExpectDomMessage("success"); 987 ExpectDomMessage("success");
993 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); 988 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc"));
994 } 989 }
995 990
996 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { 991 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) {
997 // Ensure the input under test is a combobox. 992 // Ensure the input under test is a combobox.
998 ASSERT_TRUE( 993 ASSERT_TRUE(
999 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); 994 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH));
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), 1325 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(),
1331 "navigateFrame();", 1326 "navigateFrame();",
1332 &unused)); 1327 &unused));
1333 ExpectDomMessage("iframe loaded"); 1328 ExpectDomMessage("iframe loaded");
1334 ChromeAutofillClient* client = 1329 ChromeAutofillClient* client =
1335 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); 1330 ChromeAutofillClient::FromWebContents(GetActiveWebContents());
1336 EXPECT_FALSE(client->GetDialogControllerForTesting()); 1331 EXPECT_FALSE(client->GetDialogControllerForTesting());
1337 } 1332 }
1338 1333
1339 } // namespace autofill 1334 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698