Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1695)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc

Issue 12893007: Implementing VERIFY_CVV required action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index afad2757fb06fbf3f9c56e1b7ae71621b9a41c88..b80ca5e24f030b3539658456e23f23322572a7ed 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/browser/autofill_common_test.h"
#include "components/autofill/browser/autofill_metrics.h"
+#include "components/autofill/browser/wallet/full_wallet.h"
#include "components/autofill/browser/wallet/instrument.h"
#include "components/autofill/browser/wallet/wallet_address.h"
#include "components/autofill/browser/wallet/wallet_client.h"
@@ -93,6 +94,11 @@ class TestWalletClient : public wallet::WalletClient {
const std::string& google_transaction_id,
const GURL& source_url));
+ MOCK_METHOD3(AuthenticateInstrument,
+ void(const std::string& instrument_id,
+ const std::string& card_verification_number,
+ const std::string& obfuscated_gaia_id));
+
MOCK_METHOD1(GetFullWallet,
void(const wallet::WalletClient::FullWalletRequest& request));
@@ -219,6 +225,17 @@ class AutofillDialogControllerTest : public testing::Test {
}
protected:
+ size_t CountNotificationsOfType(DialogNotification::Type type) {
+ size_t count = 0;
+ const std::vector<DialogNotification>& notifications =
+ controller()->CurrentNotifications();
+ for (size_t i = 0; i < notifications.size(); ++i) {
+ if (notifications[i].type() == type)
+ ++count;
+ }
+ return count;
+ }
+
TestAutofillDialogController* controller() { return controller_; }
TestingProfile* profile() { return &profile_; }
@@ -342,7 +359,7 @@ TEST_F(AutofillDialogControllerTest, AcceptLegalDocuments) {
wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
wallet_items->AddAddress(wallet::GetTestShippingAddress());
controller()->OnDidGetWalletItems(wallet_items.Pass());
- controller()->OnSubmit();
+ controller()->OnAccept();
}
TEST_F(AutofillDialogControllerTest, SaveAddress) {
@@ -355,7 +372,7 @@ TEST_F(AutofillDialogControllerTest, SaveAddress) {
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
controller()->OnDidGetWalletItems(wallet_items.Pass());
- controller()->OnSubmit();
+ controller()->OnAccept();
}
TEST_F(AutofillDialogControllerTest, SaveInstrument) {
@@ -368,7 +385,7 @@ TEST_F(AutofillDialogControllerTest, SaveInstrument) {
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddAddress(wallet::GetTestShippingAddress());
controller()->OnDidGetWalletItems(wallet_items.Pass());
- controller()->OnSubmit();
+ controller()->OnAccept();
}
TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) {
@@ -379,11 +396,13 @@ TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) {
SaveInstrumentAndAddress(_, _, _, _)).Times(1);
controller()->OnDidGetWalletItems(wallet::GetTestWalletItems());
- controller()->OnSubmit();
+ controller()->OnAccept();
}
-TEST_F(AutofillDialogControllerTest, Cancel) {
+TEST_F(AutofillDialogControllerTest, CancelNoSave) {
controller()->set_is_paying_with_wallet(true);
+ EXPECT_CALL(*controller()->GetTestingWalletClient(),
+ SaveInstrumentAndAddress(_, _, _, _)).Times(0);
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
@@ -391,4 +410,40 @@ TEST_F(AutofillDialogControllerTest, Cancel) {
controller()->OnCancel();
}
+TEST_F(AutofillDialogControllerTest, VerifyCvv) {
+ controller()->set_is_paying_with_wallet(true);
+
+ EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2);
+ EXPECT_CALL(*controller()->GetTestingWalletClient(),
+ GetFullWallet(_)).Times(1);
+ EXPECT_CALL(*controller()->GetTestingWalletClient(),
+ AuthenticateInstrument(_, _, _)).Times(1);
+
+ scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
+ wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
+ wallet_items->AddAddress(wallet::GetTestShippingAddress());
+ controller()->OnDidGetWalletItems(wallet_items.Pass());
+ controller()->OnAccept();
+
+ base::DictionaryValue dict;
+ scoped_ptr<base::ListValue> list(new base::ListValue());
+ list->AppendString("verify_cvv");
+ dict.Set("required_action", list.release());
+ controller()->OnDidGetFullWallet(wallet::FullWallet::CreateFullWallet(dict));
+
+ EXPECT_TRUE(controller()->IsSubmitPausedOn(wallet::VERIFY_CVV));
+ EXPECT_EQ(1U, CountNotificationsOfType(DialogNotification::REQUIRED_ACTION));
+
+ EXPECT_FALSE(controller()->SectionIsActive(SECTION_EMAIL));
+ EXPECT_FALSE(controller()->SectionIsActive(SECTION_SHIPPING));
+
+ EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING));
+ EXPECT_TRUE(
+ !controller()->SuggestionTextForSection(SECTION_CC_BILLING).empty());
+ EXPECT_EQ(
+ 0, controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount());
+
+ controller()->OnAccept();
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698