| 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 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 | 1659 |
| 1660 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1660 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1661 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1661 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
| 1662 | 1662 |
| 1663 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); | 1663 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); |
| 1664 | 1664 |
| 1665 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1665 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1666 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1666 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
| 1667 } | 1667 } |
| 1668 | 1668 |
| 1669 // TODO(dbeam): disallow changing accounts instead and remove this test. | |
| 1670 TEST_F(AutofillDialogControllerTest, ChangeAccountDuringSubmit) { | |
| 1671 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
| 1672 GetFullWallet(_)).Times(1); | |
| 1673 | |
| 1674 SubmitWithWalletItems(CompleteAndValidWalletItems()); | |
| 1675 | |
| 1676 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
| 1677 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
| 1678 | |
| 1679 SwitchToWallet(); | |
| 1680 SwitchToAutofill(); | |
| 1681 | |
| 1682 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
| 1683 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
| 1684 } | |
| 1685 | |
| 1686 TEST_F(AutofillDialogControllerTest, ErrorDuringVerifyCvv) { | 1669 TEST_F(AutofillDialogControllerTest, ErrorDuringVerifyCvv) { |
| 1687 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1670 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1688 GetFullWallet(_)).Times(1); | 1671 GetFullWallet(_)).Times(1); |
| 1689 | 1672 |
| 1690 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 1673 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 1691 controller()->OnDidGetFullWallet(CreateFullWallet("verify_cvv")); | 1674 controller()->OnDidGetFullWallet(CreateFullWallet("verify_cvv")); |
| 1692 | 1675 |
| 1693 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1676 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1694 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1677 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
| 1695 | 1678 |
| 1696 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); | 1679 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); |
| 1697 | 1680 |
| 1698 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1681 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1699 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1682 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
| 1700 } | 1683 } |
| 1701 | 1684 |
| 1702 // TODO(dbeam): disallow changing accounts instead and remove this test. | |
| 1703 TEST_F(AutofillDialogControllerTest, ChangeAccountDuringVerifyCvv) { | |
| 1704 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
| 1705 GetFullWallet(_)).Times(1); | |
| 1706 | |
| 1707 SubmitWithWalletItems(CompleteAndValidWalletItems()); | |
| 1708 controller()->OnDidGetFullWallet(CreateFullWallet("verify_cvv")); | |
| 1709 | |
| 1710 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
| 1711 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
| 1712 | |
| 1713 SwitchToWallet(); | |
| 1714 SwitchToAutofill(); | |
| 1715 | |
| 1716 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
| 1717 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
| 1718 } | |
| 1719 | |
| 1720 // Simulates receiving an INVALID_FORM_FIELD required action while processing a | 1685 // Simulates receiving an INVALID_FORM_FIELD required action while processing a |
| 1721 // |WalletClientDelegate::OnDid{Save,Update}*()| call. This can happen if Online | 1686 // |WalletClientDelegate::OnDid{Save,Update}*()| call. This can happen if Online |
| 1722 // Wallet's server validation differs from Chrome's local validation. | 1687 // Wallet's server validation differs from Chrome's local validation. |
| 1723 TEST_F(AutofillDialogControllerTest, WalletServerSideValidation) { | 1688 TEST_F(AutofillDialogControllerTest, WalletServerSideValidation) { |
| 1724 scoped_ptr<wallet::WalletItems> wallet_items = | 1689 scoped_ptr<wallet::WalletItems> wallet_items = |
| 1725 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); | 1690 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); |
| 1726 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1691 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1727 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1692 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1728 controller()->OnAccept(); | 1693 controller()->OnAccept(); |
| 1729 | 1694 |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 controller()->OnAccept(); | 2511 controller()->OnAccept(); |
| 2547 | 2512 |
| 2548 const CreditCard& imported_card = test_pdm->imported_credit_card(); | 2513 const CreditCard& imported_card = test_pdm->imported_credit_card(); |
| 2549 EXPECT_EQ(test_profile.GetRawInfo(NAME_FULL), | 2514 EXPECT_EQ(test_profile.GetRawInfo(NAME_FULL), |
| 2550 imported_card.GetRawInfo(CREDIT_CARD_NAME)); | 2515 imported_card.GetRawInfo(CREDIT_CARD_NAME)); |
| 2551 | 2516 |
| 2552 controller()->ViewClosed(); | 2517 controller()->ViewClosed(); |
| 2553 } | 2518 } |
| 2554 | 2519 |
| 2555 } // namespace autofill | 2520 } // namespace autofill |
| OLD | NEW |