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

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

Issue 17970003: New encryption/escrow endpoints for Wallet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deleting old escrow unit tests Created 7 years, 6 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 181ad531cf613af4f8d5d4cab39f601440e22cd5..5f9709f7676ba12de2b98d9a56453b3ef70689ef 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -169,46 +169,27 @@ class TestWalletClient : public wallet::WalletClient {
const std::string& google_transaction_id,
const GURL& source_url));
- MOCK_METHOD3(AuthenticateInstrument,
+ MOCK_METHOD2(AuthenticateInstrument,
void(const std::string& instrument_id,
- const std::string& card_verification_number,
- const std::string& obfuscated_gaia_id));
+ const std::string& card_verification_number));
MOCK_METHOD1(GetFullWallet,
void(const wallet::WalletClient::FullWalletRequest& request));
MOCK_METHOD1(GetWalletItems, void(const GURL& source_url));
- MOCK_METHOD2(SaveAddress,
- void(const wallet::Address& address, const GURL& source_url));
-
- MOCK_METHOD3(SaveInstrument,
- void(const wallet::Instrument& instrument,
- const std::string& obfuscated_gaia_id,
- const GURL& source_url));
-
- MOCK_METHOD4(SaveInstrumentAndAddress,
- void(const wallet::Instrument& instrument,
- const wallet::Address& address,
- const std::string& obfuscated_gaia_id,
+ MOCK_METHOD3(SaveToWalletTester,
Raman Kakilate 2013/07/01 19:37:56 Add a comment on why this is needed, will be usefu
ahutter 2013/07/01 21:37:45 Done.
+ void(wallet::Instrument* instrument,
+ wallet::Address* address,
const GURL& source_url));
- MOCK_METHOD2(UpdateAddress,
- void(const wallet::Address& address, const GURL& source_url));
-
- virtual void UpdateInstrument(
- const wallet::WalletClient::UpdateInstrumentRequest& update_request,
- scoped_ptr<wallet::Address> billing_address) {
- updated_billing_address_ = billing_address.Pass();
- }
-
- const wallet::Address* updated_billing_address() {
- return updated_billing_address_.get();
+ virtual void SaveToWallet(scoped_ptr<wallet::Instrument> instrument,
+ scoped_ptr<wallet::Address> address,
+ const GURL& source_url) OVERRIDE {
+ SaveToWalletTester(instrument.get(), address.get(), source_url);
}
private:
- scoped_ptr<wallet::Address> updated_billing_address_;
-
DISALLOW_COPY_AND_ASSIGN(TestWalletClient);
};
@@ -1107,7 +1088,9 @@ TEST_F(AutofillDialogControllerTest, SelectInstrument) {
TEST_F(AutofillDialogControllerTest, SaveAddress) {
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveAddress(_, _)).Times(1);
+ SaveToWalletTester(testing::IsNull(),
+ testing::NotNull(),
+ _)).Times(1);
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
@@ -1124,7 +1107,9 @@ TEST_F(AutofillDialogControllerTest, SaveAddress) {
TEST_F(AutofillDialogControllerTest, SaveInstrument) {
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveInstrument(_, _, _)).Times(1);
+ SaveToWalletTester(testing::NotNull(),
+ testing::IsNull(),
+ _)).Times(1);
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddAddress(wallet::GetTestShippingAddress());
@@ -1134,7 +1119,9 @@ TEST_F(AutofillDialogControllerTest, SaveInstrument) {
TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) {
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveInstrument(_, _, _)).Times(1);
+ SaveToWalletTester(testing::NotNull(),
+ testing::IsNull(),
+ _)).Times(1);
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddAddress(wallet::GetTestShippingAddress());
@@ -1144,17 +1131,25 @@ TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) {
TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveInstrumentAndAddress(_, _, _, _)).Times(1);
+ SaveToWalletTester(testing::NotNull(),
+ testing::NotNull(),
+ _)).Times(1);
controller()->OnDidGetWalletItems(wallet::GetTestWalletItems());
AcceptAndLoadFakeFingerprint();
}
+MATCHER(IsUpdatingExistingData, "updating existing Wallet data") {
+ return !arg->object_id().empty();
+}
+
// Tests that editing an address (in wallet mode0 and submitting the dialog
// should update the existing address on the server via WalletClient.
TEST_F(AutofillDialogControllerTest, UpdateAddress) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- UpdateAddress(_, _)).Times(1);
+ SaveToWalletTester(testing::IsNull(),
+ IsUpdatingExistingData(),
+ _)).Times(1);
controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
@@ -1165,20 +1160,24 @@ TEST_F(AutofillDialogControllerTest, UpdateAddress) {
// Tests that editing an instrument (CC + address) in wallet mode updates an
// existing instrument on the server via WalletClient.
TEST_F(AutofillDialogControllerTest, UpdateInstrument) {
+ EXPECT_CALL(*controller()->GetTestingWalletClient(),
+ SaveToWalletTester(IsUpdatingExistingData(),
+ testing::IsNull(),
+ _)).Times(1);
+
controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
controller()->EditClickedForSection(SECTION_CC_BILLING);
AcceptAndLoadFakeFingerprint();
-
- EXPECT_TRUE(
- controller()->GetTestingWalletClient()->updated_billing_address());
}
// Test that a user is able to edit their instrument and add a new address in
// the same submission.
TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveAddress(_, _)).Times(1);
+ SaveToWalletTester(IsUpdatingExistingData(),
+ testing::NotNull(),
+ _)).Times(1);
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
@@ -1186,36 +1185,19 @@ TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) {
controller()->EditClickedForSection(SECTION_CC_BILLING);
AcceptAndLoadFakeFingerprint();
-
- EXPECT_TRUE(
- controller()->GetTestingWalletClient()->updated_billing_address());
-}
-
-// Test that saving a new instrument and editing an address works.
-TEST_F(AutofillDialogControllerTest, SaveInstrumentUpdateAddress) {
- EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveInstrument(_, _, _)).Times(1);
- EXPECT_CALL(*controller()->GetTestingWalletClient(),
- UpdateAddress(_, _)).Times(1);
-
- scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
- wallet_items->AddAddress(wallet::GetTestShippingAddress());
-
- controller()->OnDidGetWalletItems(wallet_items.Pass());
-
- controller()->EditClickedForSection(SECTION_SHIPPING);
- AcceptAndLoadFakeFingerprint();
}
MATCHER(UsesLocalBillingAddress, "uses the local billing address") {
- return arg.address_line_1() == ASCIIToUTF16(kEditedBillingAddress);
+ return arg->address_line_1() == ASCIIToUTF16(kEditedBillingAddress);
}
// Tests that when using billing address for shipping, and there is no exact
// matched shipping address, then a shipping address should be added.
TEST_F(AutofillDialogControllerTest, BillingForShipping) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveAddress(_, _)).Times(1);
+ SaveToWalletTester(testing::IsNull(),
+ testing::NotNull(),
+ _)).Times(1);
controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
// Select "Same as billing" in the address menu.
@@ -1228,7 +1210,7 @@ TEST_F(AutofillDialogControllerTest, BillingForShipping) {
// matched shipping address, then a shipping address should not be added.
TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveAddress(_, _)).Times(0);
+ SaveToWalletTester(_, _, _)).Times(0);
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument =
@@ -1248,11 +1230,12 @@ TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) {
AcceptAndLoadFakeFingerprint();
}
+// HUH??
// Tests that adding new instrument and also using billing address for shipping,
// then a shipping address should not be added.
TEST_F(AutofillDialogControllerTest, BillingForShippingNewInstrument) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveInstrumentAndAddress(_, _, _, _)).Times(1);
+ SaveToWalletTester(_, _, _)).Times(1);
scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
wallet_items->AddAddress(wallet::GetTestShippingAddress());
@@ -1285,16 +1268,15 @@ TEST_F(AutofillDialogControllerTest, SaveInstrumentSameAsBilling) {
controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs);
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveAddress(UsesLocalBillingAddress(), _)).Times(1);
+ SaveToWalletTester(testing::NotNull(),
+ UsesLocalBillingAddress(),
+ _)).Times(1);
AcceptAndLoadFakeFingerprint();
-
- EXPECT_TRUE(
- controller()->GetTestingWalletClient()->updated_billing_address());
}
TEST_F(AutofillDialogControllerTest, CancelNoSave) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- SaveInstrumentAndAddress(_, _, _, _)).Times(0);
+ SaveToWalletTester(_, _, _)).Times(0);
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
@@ -1497,7 +1479,7 @@ TEST_F(AutofillDialogControllerTest, VerifyCvv) {
EXPECT_CALL(*controller()->GetTestingWalletClient(),
GetFullWallet(_)).Times(1);
EXPECT_CALL(*controller()->GetTestingWalletClient(),
- AuthenticateInstrument(_, _, _)).Times(1);
+ AuthenticateInstrument(_, _)).Times(1);
SubmitWithWalletItems(CompleteAndValidWalletItems());
@@ -1613,7 +1595,10 @@ TEST_F(AutofillDialogControllerTest, WalletServerSideValidation) {
wallet::FormFieldError::SHIPPING_ADDRESS));
EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1);
- controller()->OnDidSaveAddress(std::string(), required_actions, form_errors);
+ controller()->OnDidSaveToWallet(std::string(),
+ std::string(),
+ required_actions,
+ form_errors);
}
// Simulates receiving unrecoverable Wallet server validation errors.
@@ -1632,7 +1617,10 @@ TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) {
wallet::FormFieldError::UNKNOWN_LOCATION));
EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1);
- controller()->OnDidSaveAddress(std::string(), required_actions, form_errors);
+ controller()->OnDidSaveToWallet(std::string(),
+ std::string(),
+ required_actions,
+ form_errors);
EXPECT_EQ(1U, NotificationsOfType(
DialogNotification::REQUIRED_ACTION).size());

Powered by Google App Engine
This is Rietveld 408576698