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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 | 1612 |
1613 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1613 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
1614 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1614 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
1615 | 1615 |
1616 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); | 1616 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); |
1617 | 1617 |
1618 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1618 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
1619 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1619 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
1620 } | 1620 } |
1621 | 1621 |
1622 // TODO(dbeam): disallow changing accounts instead and remove this test. | |
1623 TEST_F(AutofillDialogControllerTest, ChangeAccountDuringSubmit) { | |
1624 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
1625 GetFullWallet(_)).Times(1); | |
1626 | |
1627 SubmitWithWalletItems(CompleteAndValidWalletItems()); | |
1628 | |
1629 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
1630 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
1631 | |
1632 SwitchToWallet(); | |
1633 SwitchToAutofill(); | |
1634 | |
1635 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
1636 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
1637 } | |
1638 | |
1639 TEST_F(AutofillDialogControllerTest, ErrorDuringVerifyCvv) { | 1622 TEST_F(AutofillDialogControllerTest, ErrorDuringVerifyCvv) { |
1640 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1623 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
1641 GetFullWallet(_)).Times(1); | 1624 GetFullWallet(_)).Times(1); |
1642 | 1625 |
1643 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 1626 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
1644 controller()->OnDidGetFullWallet(CreateFullWallet("verify_cvv")); | 1627 controller()->OnDidGetFullWallet(CreateFullWallet("verify_cvv")); |
1645 | 1628 |
1646 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1629 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
1647 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1630 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
1648 | 1631 |
1649 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); | 1632 controller()->OnWalletError(wallet::WalletClient::UNKNOWN_ERROR); |
1650 | 1633 |
1651 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1634 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
1652 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1635 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
1653 } | 1636 } |
1654 | 1637 |
1655 // TODO(dbeam): disallow changing accounts instead and remove this test. | |
1656 TEST_F(AutofillDialogControllerTest, ChangeAccountDuringVerifyCvv) { | |
1657 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
1658 GetFullWallet(_)).Times(1); | |
1659 | |
1660 SubmitWithWalletItems(CompleteAndValidWalletItems()); | |
1661 controller()->OnDidGetFullWallet(CreateFullWallet("verify_cvv")); | |
1662 | |
1663 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
1664 ASSERT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
1665 | |
1666 SwitchToWallet(); | |
1667 SwitchToAutofill(); | |
1668 | |
1669 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
1670 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | |
1671 } | |
1672 | |
1673 // Simulates receiving an INVALID_FORM_FIELD required action while processing a | 1638 // Simulates receiving an INVALID_FORM_FIELD required action while processing a |
1674 // |WalletClientDelegate::OnDid{Save,Update}*()| call. This can happen if Online | 1639 // |WalletClientDelegate::OnDid{Save,Update}*()| call. This can happen if Online |
1675 // Wallet's server validation differs from Chrome's local validation. | 1640 // Wallet's server validation differs from Chrome's local validation. |
1676 TEST_F(AutofillDialogControllerTest, WalletServerSideValidation) { | 1641 TEST_F(AutofillDialogControllerTest, WalletServerSideValidation) { |
1677 scoped_ptr<wallet::WalletItems> wallet_items = | 1642 scoped_ptr<wallet::WalletItems> wallet_items = |
1678 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); | 1643 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); |
1679 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1644 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
1680 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1645 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
1681 controller()->OnAccept(); | 1646 controller()->OnAccept(); |
1682 | 1647 |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 controller()->OnAccept(); | 2469 controller()->OnAccept(); |
2505 | 2470 |
2506 const CreditCard& imported_card = test_pdm->imported_credit_card(); | 2471 const CreditCard& imported_card = test_pdm->imported_credit_card(); |
2507 EXPECT_EQ(test_profile.GetRawInfo(NAME_FULL), | 2472 EXPECT_EQ(test_profile.GetRawInfo(NAME_FULL), |
2508 imported_card.GetRawInfo(CREDIT_CARD_NAME)); | 2473 imported_card.GetRawInfo(CREDIT_CARD_NAME)); |
2509 | 2474 |
2510 controller()->ViewClosed(); | 2475 controller()->ViewClosed(); |
2511 } | 2476 } |
2512 | 2477 |
2513 } // namespace autofill | 2478 } // namespace autofill |
OLD | NEW |