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 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 ASSERT_TRUE(!!email_model); | 895 ASSERT_TRUE(!!email_model); |
896 EXPECT_EQ(4, email_model->GetItemCount()); | 896 EXPECT_EQ(4, email_model->GetItemCount()); |
897 | 897 |
898 // The first one is the default. | 898 // The first one is the default. |
899 SuggestionsMenuModel* email_suggestions = static_cast<SuggestionsMenuModel*>( | 899 SuggestionsMenuModel* email_suggestions = static_cast<SuggestionsMenuModel*>( |
900 controller()->MenuModelForSection(SECTION_EMAIL)); | 900 controller()->MenuModelForSection(SECTION_EMAIL)); |
901 EXPECT_EQ(0, email_suggestions->checked_item()); | 901 EXPECT_EQ(0, email_suggestions->checked_item()); |
902 | 902 |
903 email_model->ActivatedAt(0); | 903 email_model->ActivatedAt(0); |
904 EXPECT_EQ(kEmail1, | 904 EXPECT_EQ(kEmail1, |
905 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 905 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 906 vertically_compact_text); |
906 email_model->ActivatedAt(1); | 907 email_model->ActivatedAt(1); |
907 EXPECT_EQ(kEmail2, | 908 EXPECT_EQ(kEmail2, |
908 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 909 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 910 vertically_compact_text); |
909 | 911 |
910 controller()->EditClickedForSection(SECTION_EMAIL); | 912 controller()->EditClickedForSection(SECTION_EMAIL); |
911 const DetailInputs& inputs = | 913 const DetailInputs& inputs = |
912 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 914 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
913 EXPECT_EQ(kEmail2, inputs[0].initial_value); | 915 EXPECT_EQ(kEmail2, inputs[0].initial_value); |
914 | 916 |
915 // The choice of variant is persisted across runs of the dialog. | 917 // The choice of variant is persisted across runs of the dialog. |
916 email_model->ActivatedAt(0); | 918 email_model->ActivatedAt(0); |
917 email_model->ActivatedAt(1); | 919 email_model->ActivatedAt(1); |
918 FillCreditCardInputs(); | 920 FillCreditCardInputs(); |
919 controller()->OnAccept(); | 921 controller()->OnAccept(); |
920 | 922 |
921 Reset(); | 923 Reset(); |
922 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 924 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
923 email_suggestions = static_cast<SuggestionsMenuModel*>( | 925 email_suggestions = static_cast<SuggestionsMenuModel*>( |
924 controller()->MenuModelForSection(SECTION_EMAIL)); | 926 controller()->MenuModelForSection(SECTION_EMAIL)); |
925 EXPECT_EQ(1, email_suggestions->checked_item()); | 927 EXPECT_EQ(1, email_suggestions->checked_item()); |
926 } | 928 } |
927 | 929 |
928 TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { | 930 TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { |
929 AutofillProfile profile(test::GetVerifiedProfile()); | 931 AutofillProfile profile(test::GetVerifiedProfile()); |
930 const string16 kValidEmail = ASCIIToUTF16(kFakeEmail); | 932 const string16 kValidEmail = ASCIIToUTF16(kFakeEmail); |
931 profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); | 933 profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); |
932 controller()->GetTestingManager()->AddTestingProfile(&profile); | 934 controller()->GetTestingManager()->AddTestingProfile(&profile); |
933 | 935 |
934 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(0); | 936 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(0); |
935 EXPECT_EQ(kValidEmail, | 937 EXPECT_EQ(kValidEmail, |
936 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 938 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 939 vertically_compact_text); |
937 } | 940 } |
938 | 941 |
939 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { | 942 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { |
940 AutofillProfile profile(test::GetVerifiedProfile()); | 943 AutofillProfile profile(test::GetVerifiedProfile()); |
941 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); | 944 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); |
942 controller()->GetTestingManager()->AddTestingProfile(&profile); | 945 controller()->GetTestingManager()->AddTestingProfile(&profile); |
943 EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), | 946 EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), |
944 controller()->MenuModelForSection(SECTION_EMAIL)); | 947 controller()->MenuModelForSection(SECTION_EMAIL)); |
945 } | 948 } |
946 | 949 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 ui::MenuModel* email_model = | 1472 ui::MenuModel* email_model = |
1470 controller()->MenuModelForSection(SECTION_EMAIL); | 1473 controller()->MenuModelForSection(SECTION_EMAIL); |
1471 EXPECT_EQ(3, email_model->GetItemCount()); | 1474 EXPECT_EQ(3, email_model->GetItemCount()); |
1472 | 1475 |
1473 // When unedited, the initial_value should be empty. | 1476 // When unedited, the initial_value should be empty. |
1474 email_model->ActivatedAt(0); | 1477 email_model->ActivatedAt(0); |
1475 const DetailInputs& inputs0 = | 1478 const DetailInputs& inputs0 = |
1476 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1479 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
1477 EXPECT_EQ(string16(), inputs0[0].initial_value); | 1480 EXPECT_EQ(string16(), inputs0[0].initial_value); |
1478 EXPECT_EQ(kEmail, | 1481 EXPECT_EQ(kEmail, |
1479 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 1482 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 1483 vertically_compact_text); |
1480 | 1484 |
1481 // When edited, the initial_value should contain the value. | 1485 // When edited, the initial_value should contain the value. |
1482 controller()->EditClickedForSection(SECTION_EMAIL); | 1486 controller()->EditClickedForSection(SECTION_EMAIL); |
1483 const DetailInputs& inputs1 = | 1487 const DetailInputs& inputs1 = |
1484 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1488 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
1485 EXPECT_EQ(kEmail, inputs1[0].initial_value); | 1489 EXPECT_EQ(kEmail, inputs1[0].initial_value); |
1486 EXPECT_EQ(string16(), | 1490 EXPECT_FALSE(controller()->SuggestionStateForSection(SECTION_EMAIL).visible); |
1487 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | |
1488 | 1491 |
1489 // When edit is cancelled, the initial_value should be empty. | 1492 // When edit is cancelled, the initial_value should be empty. |
1490 controller()->EditCancelledForSection(SECTION_EMAIL); | 1493 controller()->EditCancelledForSection(SECTION_EMAIL); |
1491 const DetailInputs& inputs2 = | 1494 const DetailInputs& inputs2 = |
1492 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1495 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
1493 EXPECT_EQ(kEmail, | 1496 EXPECT_EQ(kEmail, |
1494 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 1497 controller()->SuggestionStateForSection(SECTION_EMAIL). |
| 1498 vertically_compact_text); |
1495 EXPECT_EQ(string16(), inputs2[0].initial_value); | 1499 EXPECT_EQ(string16(), inputs2[0].initial_value); |
1496 } | 1500 } |
1497 | 1501 |
1498 // Tests that editing an autofill profile and then submitting works. | 1502 // Tests that editing an autofill profile and then submitting works. |
1499 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { | 1503 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { |
1500 SwitchToAutofill(); | 1504 SwitchToAutofill(); |
1501 | 1505 |
1502 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); | 1506 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); |
1503 | 1507 |
1504 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1508 AutofillProfile full_profile(test::GetVerifiedProfile()); |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 2513 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
2510 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); | 2514 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); |
2511 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2515 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
2512 controller()->OnAutocheckoutError(); | 2516 controller()->OnAutocheckoutError(); |
2513 controller()->ViewClosed(); | 2517 controller()->ViewClosed(); |
2514 | 2518 |
2515 EXPECT_EQ(0, mock_new_card_bubble_controller()->bubbles_shown()); | 2519 EXPECT_EQ(0, mock_new_card_bubble_controller()->bubbles_shown()); |
2516 } | 2520 } |
2517 | 2521 |
2518 } // namespace autofill | 2522 } // namespace autofill |
OLD | NEW |