| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 ASSERT_TRUE(!!email_model); | 884 ASSERT_TRUE(!!email_model); |
| 885 EXPECT_EQ(4, email_model->GetItemCount()); | 885 EXPECT_EQ(4, email_model->GetItemCount()); |
| 886 | 886 |
| 887 // The first one is the default. | 887 // The first one is the default. |
| 888 SuggestionsMenuModel* email_suggestions = static_cast<SuggestionsMenuModel*>( | 888 SuggestionsMenuModel* email_suggestions = static_cast<SuggestionsMenuModel*>( |
| 889 controller()->MenuModelForSection(SECTION_EMAIL)); | 889 controller()->MenuModelForSection(SECTION_EMAIL)); |
| 890 EXPECT_EQ(0, email_suggestions->checked_item()); | 890 EXPECT_EQ(0, email_suggestions->checked_item()); |
| 891 | 891 |
| 892 email_model->ActivatedAt(0); | 892 email_model->ActivatedAt(0); |
| 893 EXPECT_EQ(kEmail1, | 893 EXPECT_EQ(kEmail1, |
| 894 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 894 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 895 vertically_compact_text); |
| 895 email_model->ActivatedAt(1); | 896 email_model->ActivatedAt(1); |
| 896 EXPECT_EQ(kEmail2, | 897 EXPECT_EQ(kEmail2, |
| 897 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 898 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 899 vertically_compact_text); |
| 898 | 900 |
| 899 controller()->EditClickedForSection(SECTION_EMAIL); | 901 controller()->EditClickedForSection(SECTION_EMAIL); |
| 900 const DetailInputs& inputs = | 902 const DetailInputs& inputs = |
| 901 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 903 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| 902 EXPECT_EQ(kEmail2, inputs[0].initial_value); | 904 EXPECT_EQ(kEmail2, inputs[0].initial_value); |
| 903 | 905 |
| 904 // The choice of variant is persisted across runs of the dialog. | 906 // The choice of variant is persisted across runs of the dialog. |
| 905 email_model->ActivatedAt(0); | 907 email_model->ActivatedAt(0); |
| 906 email_model->ActivatedAt(1); | 908 email_model->ActivatedAt(1); |
| 907 FillCreditCardInputs(); | 909 FillCreditCardInputs(); |
| 908 controller()->OnAccept(); | 910 controller()->OnAccept(); |
| 909 | 911 |
| 910 Reset(); | 912 Reset(); |
| 911 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 913 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 912 email_suggestions = static_cast<SuggestionsMenuModel*>( | 914 email_suggestions = static_cast<SuggestionsMenuModel*>( |
| 913 controller()->MenuModelForSection(SECTION_EMAIL)); | 915 controller()->MenuModelForSection(SECTION_EMAIL)); |
| 914 EXPECT_EQ(1, email_suggestions->checked_item()); | 916 EXPECT_EQ(1, email_suggestions->checked_item()); |
| 915 } | 917 } |
| 916 | 918 |
| 917 TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { | 919 TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { |
| 918 AutofillProfile profile(test::GetVerifiedProfile()); | 920 AutofillProfile profile(test::GetVerifiedProfile()); |
| 919 const string16 kValidEmail = ASCIIToUTF16(kFakeEmail); | 921 const string16 kValidEmail = ASCIIToUTF16(kFakeEmail); |
| 920 profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); | 922 profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); |
| 921 controller()->GetTestingManager()->AddTestingProfile(&profile); | 923 controller()->GetTestingManager()->AddTestingProfile(&profile); |
| 922 | 924 |
| 923 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(0); | 925 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(0); |
| 924 EXPECT_EQ(kValidEmail, | 926 EXPECT_EQ(kValidEmail, |
| 925 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 927 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 928 vertically_compact_text); |
| 926 } | 929 } |
| 927 | 930 |
| 928 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { | 931 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { |
| 929 AutofillProfile profile(test::GetVerifiedProfile()); | 932 AutofillProfile profile(test::GetVerifiedProfile()); |
| 930 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); | 933 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); |
| 931 controller()->GetTestingManager()->AddTestingProfile(&profile); | 934 controller()->GetTestingManager()->AddTestingProfile(&profile); |
| 932 EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), | 935 EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), |
| 933 controller()->MenuModelForSection(SECTION_EMAIL)); | 936 controller()->MenuModelForSection(SECTION_EMAIL)); |
| 934 } | 937 } |
| 935 | 938 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 ui::MenuModel* email_model = | 1443 ui::MenuModel* email_model = |
| 1441 controller()->MenuModelForSection(SECTION_EMAIL); | 1444 controller()->MenuModelForSection(SECTION_EMAIL); |
| 1442 EXPECT_EQ(3, email_model->GetItemCount()); | 1445 EXPECT_EQ(3, email_model->GetItemCount()); |
| 1443 | 1446 |
| 1444 // When unedited, the initial_value should be empty. | 1447 // When unedited, the initial_value should be empty. |
| 1445 email_model->ActivatedAt(0); | 1448 email_model->ActivatedAt(0); |
| 1446 const DetailInputs& inputs0 = | 1449 const DetailInputs& inputs0 = |
| 1447 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1450 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| 1448 EXPECT_EQ(string16(), inputs0[0].initial_value); | 1451 EXPECT_EQ(string16(), inputs0[0].initial_value); |
| 1449 EXPECT_EQ(kEmail, | 1452 EXPECT_EQ(kEmail, |
| 1450 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 1453 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 1454 vertically_compact_text); |
| 1451 | 1455 |
| 1452 // When edited, the initial_value should contain the value. | 1456 // When edited, the initial_value should contain the value. |
| 1453 controller()->EditClickedForSection(SECTION_EMAIL); | 1457 controller()->EditClickedForSection(SECTION_EMAIL); |
| 1454 const DetailInputs& inputs1 = | 1458 const DetailInputs& inputs1 = |
| 1455 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1459 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| 1456 EXPECT_EQ(kEmail, inputs1[0].initial_value); | 1460 EXPECT_EQ(kEmail, inputs1[0].initial_value); |
| 1457 EXPECT_EQ(string16(), | 1461 EXPECT_FALSE(controller()->SuggestionStateForSection(SECTION_EMAIL).visible); |
| 1458 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | |
| 1459 | 1462 |
| 1460 // When edit is cancelled, the initial_value should be empty. | 1463 // When edit is cancelled, the initial_value should be empty. |
| 1461 controller()->EditCancelledForSection(SECTION_EMAIL); | 1464 controller()->EditCancelledForSection(SECTION_EMAIL); |
| 1462 const DetailInputs& inputs2 = | 1465 const DetailInputs& inputs2 = |
| 1463 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1466 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| 1464 EXPECT_EQ(kEmail, | 1467 EXPECT_EQ(kEmail, |
| 1465 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 1468 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 1469 vertically_compact_text); |
| 1466 EXPECT_EQ(string16(), inputs2[0].initial_value); | 1470 EXPECT_EQ(string16(), inputs2[0].initial_value); |
| 1467 } | 1471 } |
| 1468 | 1472 |
| 1469 // Tests that editing an autofill profile and then submitting works. | 1473 // Tests that editing an autofill profile and then submitting works. |
| 1470 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { | 1474 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { |
| 1471 SwitchToAutofill(); | 1475 SwitchToAutofill(); |
| 1472 | 1476 |
| 1473 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1477 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1474 | 1478 |
| 1475 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1479 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); | 2471 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); |
| 2468 | 2472 |
| 2469 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 2473 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 2470 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); | 2474 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); |
| 2471 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2475 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
| 2472 controller()->OnAutocheckoutError(); | 2476 controller()->OnAutocheckoutError(); |
| 2473 controller()->ViewClosed(); | 2477 controller()->ViewClosed(); |
| 2474 } | 2478 } |
| 2475 | 2479 |
| 2476 } // namespace autofill | 2480 } // namespace autofill |
| OLD | NEW |