| 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 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 required_actions, | 1763 required_actions, |
| 1764 form_errors); | 1764 form_errors); |
| 1765 | 1765 |
| 1766 EXPECT_EQ(1U, NotificationsOfType( | 1766 EXPECT_EQ(1U, NotificationsOfType( |
| 1767 DialogNotification::REQUIRED_ACTION).size()); | 1767 DialogNotification::REQUIRED_ACTION).size()); |
| 1768 } | 1768 } |
| 1769 | 1769 |
| 1770 // Test Wallet banners are show in the right situations. These banners promote | 1770 // Test Wallet banners are show in the right situations. These banners promote |
| 1771 // saving details into Wallet (i.e. "[x] Save details to Wallet"). | 1771 // saving details into Wallet (i.e. "[x] Save details to Wallet"). |
| 1772 TEST_F(AutofillDialogControllerTest, WalletBanners) { | 1772 TEST_F(AutofillDialogControllerTest, WalletBanners) { |
| 1773 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 1774 command_line->AppendSwitch(switches::kWalletServiceUseProd); | |
| 1775 | |
| 1776 // Simulate non-signed-in case. | 1773 // Simulate non-signed-in case. |
| 1777 SetUpControllerWithFormData(DefaultFormData()); | 1774 SetUpControllerWithFormData(DefaultFormData()); |
| 1778 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 1775 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
| 1779 controller()->OnPassiveSigninFailure(error); | 1776 controller()->OnPassiveSigninFailure(error); |
| 1780 EXPECT_EQ(0U, NotificationsOfType( | 1777 EXPECT_EQ(0U, NotificationsOfType( |
| 1781 DialogNotification::WALLET_USAGE_CONFIRMATION).size()); | 1778 DialogNotification::WALLET_USAGE_CONFIRMATION).size()); |
| 1782 | 1779 |
| 1783 // Sign in a user with a completed account. | 1780 // Sign in a user with a completed account. |
| 1784 SetUpControllerWithFormData(DefaultFormData()); | 1781 SetUpControllerWithFormData(DefaultFormData()); |
| 1785 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1782 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 controller()->ForceFinishSubmit(); | 2130 controller()->ForceFinishSubmit(); |
| 2134 EXPECT_TRUE(form_structure()); | 2131 EXPECT_TRUE(form_structure()); |
| 2135 } | 2132 } |
| 2136 | 2133 |
| 2137 TEST_F(AutofillDialogControllerTest, NotProdNotification) { | 2134 TEST_F(AutofillDialogControllerTest, NotProdNotification) { |
| 2138 // To make IsPayingWithWallet() true. | 2135 // To make IsPayingWithWallet() true. |
| 2139 controller()->OnDidGetWalletItems( | 2136 controller()->OnDidGetWalletItems( |
| 2140 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); | 2137 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); |
| 2141 | 2138 |
| 2142 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 2139 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 2143 ASSERT_FALSE(command_line->HasSwitch(switches::kWalletServiceUseProd)); | 2140 ASSERT_EQ( |
| 2144 EXPECT_FALSE( | 2141 "", |
| 2145 NotificationsOfType(DialogNotification::DEVELOPER_WARNING).empty()); | 2142 command_line->GetSwitchValueASCII(switches::kWalletServiceUseSandbox)); |
| 2146 | 2143 |
| 2147 command_line->AppendSwitch(switches::kWalletServiceUseProd); | 2144 #if defined(OS_MACOSX) |
| 2148 EXPECT_TRUE( | 2145 // Default on Mac is to use sandbox (which shows a warning). |
| 2149 NotificationsOfType(DialogNotification::DEVELOPER_WARNING).empty()); | 2146 EXPECT_EQ(1U, |
| 2147 NotificationsOfType(DialogNotification::DEVELOPER_WARNING).size()); |
| 2148 #else |
| 2149 // Default everywhere else is to use prod (no warning). |
| 2150 EXPECT_EQ(0U, |
| 2151 NotificationsOfType(DialogNotification::DEVELOPER_WARNING).size()); |
| 2152 #endif |
| 2153 |
| 2154 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); |
| 2155 EXPECT_EQ(1U, |
| 2156 NotificationsOfType(DialogNotification::DEVELOPER_WARNING).size()); |
| 2150 } | 2157 } |
| 2151 | 2158 |
| 2152 // Ensure Wallet instruments marked expired by the server are shown as invalid. | 2159 // Ensure Wallet instruments marked expired by the server are shown as invalid. |
| 2153 TEST_F(AutofillDialogControllerTest, WalletExpiredCard) { | 2160 TEST_F(AutofillDialogControllerTest, WalletExpiredCard) { |
| 2154 scoped_ptr<wallet::WalletItems> wallet_items = | 2161 scoped_ptr<wallet::WalletItems> wallet_items = |
| 2155 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); | 2162 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); |
| 2156 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired()); | 2163 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired()); |
| 2157 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 2164 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 2158 | 2165 |
| 2159 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC_BILLING)); | 2166 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC_BILLING)); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 controller()->OnAccept(); | 2553 controller()->OnAccept(); |
| 2547 | 2554 |
| 2548 const CreditCard& imported_card = test_pdm->imported_credit_card(); | 2555 const CreditCard& imported_card = test_pdm->imported_credit_card(); |
| 2549 EXPECT_EQ(test_profile.GetRawInfo(NAME_FULL), | 2556 EXPECT_EQ(test_profile.GetRawInfo(NAME_FULL), |
| 2550 imported_card.GetRawInfo(CREDIT_CARD_NAME)); | 2557 imported_card.GetRawInfo(CREDIT_CARD_NAME)); |
| 2551 | 2558 |
| 2552 controller()->ViewClosed(); | 2559 controller()->ViewClosed(); |
| 2553 } | 2560 } |
| 2554 | 2561 |
| 2555 } // namespace autofill | 2562 } // namespace autofill |
| OLD | NEW |