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

Side by Side 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: Dane's review Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 TestWalletClient(net::URLRequestContextGetter* context, 162 TestWalletClient(net::URLRequestContextGetter* context,
163 wallet::WalletClientDelegate* delegate) 163 wallet::WalletClientDelegate* delegate)
164 : wallet::WalletClient(context, delegate) {} 164 : wallet::WalletClient(context, delegate) {}
165 virtual ~TestWalletClient() {} 165 virtual ~TestWalletClient() {}
166 166
167 MOCK_METHOD3(AcceptLegalDocuments, 167 MOCK_METHOD3(AcceptLegalDocuments,
168 void(const std::vector<wallet::WalletItems::LegalDocument*>& documents, 168 void(const std::vector<wallet::WalletItems::LegalDocument*>& documents,
169 const std::string& google_transaction_id, 169 const std::string& google_transaction_id,
170 const GURL& source_url)); 170 const GURL& source_url));
171 171
172 MOCK_METHOD3(AuthenticateInstrument, 172 MOCK_METHOD2(AuthenticateInstrument,
173 void(const std::string& instrument_id, 173 void(const std::string& instrument_id,
174 const std::string& card_verification_number, 174 const std::string& card_verification_number));
175 const std::string& obfuscated_gaia_id));
176 175
177 MOCK_METHOD1(GetFullWallet, 176 MOCK_METHOD1(GetFullWallet,
178 void(const wallet::WalletClient::FullWalletRequest& request)); 177 void(const wallet::WalletClient::FullWalletRequest& request));
179 178
180 MOCK_METHOD1(GetWalletItems, void(const GURL& source_url)); 179 MOCK_METHOD1(GetWalletItems, void(const GURL& source_url));
181 180
182 MOCK_METHOD2(SaveAddress, 181 // Methods with scoped_ptrs can't be mocked but by using the implementation
183 void(const wallet::Address& address, const GURL& source_url)); 182 // below the same effect can be achieved.
184 183 virtual void SaveToWallet(scoped_ptr<wallet::Instrument> instrument,
185 MOCK_METHOD3(SaveInstrument, 184 scoped_ptr<wallet::Address> address,
186 void(const wallet::Instrument& instrument, 185 const GURL& source_url) OVERRIDE {
187 const std::string& obfuscated_gaia_id, 186 SaveToWalletTester(instrument.get(), address.get(), source_url);
Dan Beam 2013/07/02 01:25:52 nit: SaveToWalletMock, IMO
ahutter 2013/07/02 15:44:23 Done.
188 const GURL& source_url));
189
190 MOCK_METHOD4(SaveInstrumentAndAddress,
191 void(const wallet::Instrument& instrument,
192 const wallet::Address& address,
193 const std::string& obfuscated_gaia_id,
194 const GURL& source_url));
195
196 MOCK_METHOD2(UpdateAddress,
197 void(const wallet::Address& address, const GURL& source_url));
198
199 virtual void UpdateInstrument(
200 const wallet::WalletClient::UpdateInstrumentRequest& update_request,
201 scoped_ptr<wallet::Address> billing_address) {
202 updated_billing_address_ = billing_address.Pass();
203 } 187 }
204 188
205 const wallet::Address* updated_billing_address() { 189 MOCK_METHOD3(SaveToWalletTester, void(wallet::Instrument* instrument,
206 return updated_billing_address_.get(); 190 wallet::Address* address,
207 } 191 const GURL& source_url));
208 192
209 private: 193 private:
210 scoped_ptr<wallet::Address> updated_billing_address_;
211
212 DISALLOW_COPY_AND_ASSIGN(TestWalletClient); 194 DISALLOW_COPY_AND_ASSIGN(TestWalletClient);
213 }; 195 };
214 196
215 // Bring over command-ids from AccountChooserModel. 197 // Bring over command-ids from AccountChooserModel.
216 class TestAccountChooserModel : public AccountChooserModel { 198 class TestAccountChooserModel : public AccountChooserModel {
217 public: 199 public:
218 TestAccountChooserModel(AccountChooserModelDelegate* delegate, 200 TestAccountChooserModel(AccountChooserModelDelegate* delegate,
219 PrefService* prefs, 201 PrefService* prefs,
220 const AutofillMetrics& metric_logger) 202 const AutofillMetrics& metric_logger)
221 : AccountChooserModel(delegate, prefs, metric_logger, 203 : AccountChooserModel(delegate, prefs, metric_logger,
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 EXPECT_EQ(4, 1082 EXPECT_EQ(4,
1101 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); 1083 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount());
1102 // "add" 1084 // "add"
1103 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> 1085 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)->
1104 IsItemCheckedAt(2)); 1086 IsItemCheckedAt(2));
1105 } 1087 }
1106 1088
1107 TEST_F(AutofillDialogControllerTest, SaveAddress) { 1089 TEST_F(AutofillDialogControllerTest, SaveAddress) {
1108 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 1090 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
1109 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1091 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1110 SaveAddress(_, _)).Times(1); 1092 SaveToWalletTester(testing::IsNull(),
1093 testing::NotNull(),
1094 _)).Times(1);
1111 1095
1112 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1096 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1113 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 1097 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
1114 controller()->OnDidGetWalletItems(wallet_items.Pass()); 1098 controller()->OnDidGetWalletItems(wallet_items.Pass());
1115 // If there is no shipping address in wallet, it will default to 1099 // If there is no shipping address in wallet, it will default to
1116 // "same-as-billing" instead of "add-new-item". "same-as-billing" is covered 1100 // "same-as-billing" instead of "add-new-item". "same-as-billing" is covered
1117 // by the following tests. The last item in the menu is "add-new-item". 1101 // by the following tests. The last item in the menu is "add-new-item".
1118 ui::MenuModel* shipping_model = 1102 ui::MenuModel* shipping_model =
1119 controller()->MenuModelForSection(SECTION_SHIPPING); 1103 controller()->MenuModelForSection(SECTION_SHIPPING);
1120 shipping_model->ActivatedAt(shipping_model->GetItemCount() - 1); 1104 shipping_model->ActivatedAt(shipping_model->GetItemCount() - 1);
1121 AcceptAndLoadFakeFingerprint(); 1105 AcceptAndLoadFakeFingerprint();
1122 } 1106 }
1123 1107
1124 TEST_F(AutofillDialogControllerTest, SaveInstrument) { 1108 TEST_F(AutofillDialogControllerTest, SaveInstrument) {
1125 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 1109 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
1126 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1110 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1127 SaveInstrument(_, _, _)).Times(1); 1111 SaveToWalletTester(testing::NotNull(),
1112 testing::IsNull(),
1113 _)).Times(1);
1128 1114
1129 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1115 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1130 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 1116 wallet_items->AddAddress(wallet::GetTestShippingAddress());
1131 SubmitWithWalletItems(wallet_items.Pass()); 1117 SubmitWithWalletItems(wallet_items.Pass());
1132 } 1118 }
1133 1119
1134 TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) { 1120 TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) {
1135 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 1121 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
1136 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1122 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1137 SaveInstrument(_, _, _)).Times(1); 1123 SaveToWalletTester(testing::NotNull(),
1124 testing::IsNull(),
1125 _)).Times(1);
1138 1126
1139 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1127 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1140 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 1128 wallet_items->AddAddress(wallet::GetTestShippingAddress());
1141 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid()); 1129 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid());
1142 SubmitWithWalletItems(wallet_items.Pass()); 1130 SubmitWithWalletItems(wallet_items.Pass());
1143 } 1131 }
1144 1132
1145 TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) { 1133 TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) {
1146 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1134 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1147 SaveInstrumentAndAddress(_, _, _, _)).Times(1); 1135 SaveToWalletTester(testing::NotNull(),
1136 testing::NotNull(),
1137 _)).Times(1);
1148 1138
1149 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); 1139 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems());
1150 AcceptAndLoadFakeFingerprint(); 1140 AcceptAndLoadFakeFingerprint();
1151 } 1141 }
1152 1142
1143 MATCHER(IsUpdatingExistingData, "updating existing Wallet data") {
1144 return !arg->object_id().empty();
1145 }
1146
1153 // Tests that editing an address (in wallet mode0 and submitting the dialog 1147 // Tests that editing an address (in wallet mode0 and submitting the dialog
1154 // should update the existing address on the server via WalletClient. 1148 // should update the existing address on the server via WalletClient.
1155 TEST_F(AutofillDialogControllerTest, UpdateAddress) { 1149 TEST_F(AutofillDialogControllerTest, UpdateAddress) {
1156 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1150 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1157 UpdateAddress(_, _)).Times(1); 1151 SaveToWalletTester(testing::IsNull(),
1152 IsUpdatingExistingData(),
1153 _)).Times(1);
1158 1154
1159 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); 1155 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
1160 1156
1161 controller()->EditClickedForSection(SECTION_SHIPPING); 1157 controller()->EditClickedForSection(SECTION_SHIPPING);
1162 AcceptAndLoadFakeFingerprint(); 1158 AcceptAndLoadFakeFingerprint();
1163 } 1159 }
1164 1160
1165 // Tests that editing an instrument (CC + address) in wallet mode updates an 1161 // Tests that editing an instrument (CC + address) in wallet mode updates an
1166 // existing instrument on the server via WalletClient. 1162 // existing instrument on the server via WalletClient.
1167 TEST_F(AutofillDialogControllerTest, UpdateInstrument) { 1163 TEST_F(AutofillDialogControllerTest, UpdateInstrument) {
1164 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1165 SaveToWalletTester(IsUpdatingExistingData(),
1166 testing::IsNull(),
1167 _)).Times(1);
1168
1168 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); 1169 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
1169 1170
1170 controller()->EditClickedForSection(SECTION_CC_BILLING); 1171 controller()->EditClickedForSection(SECTION_CC_BILLING);
1171 AcceptAndLoadFakeFingerprint(); 1172 AcceptAndLoadFakeFingerprint();
1172
1173 EXPECT_TRUE(
1174 controller()->GetTestingWalletClient()->updated_billing_address());
1175 } 1173 }
1176 1174
1177 // Test that a user is able to edit their instrument and add a new address in 1175 // Test that a user is able to edit their instrument and add a new address in
1178 // the same submission. 1176 // the same submission.
1179 TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) { 1177 TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) {
1180 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1178 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1181 SaveAddress(_, _)).Times(1); 1179 SaveToWalletTester(IsUpdatingExistingData(),
1180 testing::NotNull(),
1181 _)).Times(1);
1182 1182
1183 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1183 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1184 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 1184 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
1185 controller()->OnDidGetWalletItems(wallet_items.Pass()); 1185 controller()->OnDidGetWalletItems(wallet_items.Pass());
1186 1186
1187 controller()->EditClickedForSection(SECTION_CC_BILLING); 1187 controller()->EditClickedForSection(SECTION_CC_BILLING);
1188 AcceptAndLoadFakeFingerprint(); 1188 AcceptAndLoadFakeFingerprint();
1189
1190 EXPECT_TRUE(
1191 controller()->GetTestingWalletClient()->updated_billing_address());
1192 } 1189 }
1193 1190
1194 // Test that saving a new instrument and editing an address works. 1191 // Test that saving a new instrument and editing an address works.
1195 TEST_F(AutofillDialogControllerTest, SaveInstrumentUpdateAddress) { 1192 TEST_F(AutofillDialogControllerTest, SaveInstrumentUpdateAddress) {
1196 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1193 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1197 SaveInstrument(_, _, _)).Times(1); 1194 SaveToWalletTester(testing::NotNull(),
1198 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1195 IsUpdatingExistingData(),
1199 UpdateAddress(_, _)).Times(1); 1196 _)).Times(1);
1200 1197
1201 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1198 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1202 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 1199 wallet_items->AddAddress(wallet::GetTestShippingAddress());
1203 1200
1204 controller()->OnDidGetWalletItems(wallet_items.Pass()); 1201 controller()->OnDidGetWalletItems(wallet_items.Pass());
1205 1202
1206 controller()->EditClickedForSection(SECTION_SHIPPING); 1203 controller()->EditClickedForSection(SECTION_SHIPPING);
1207 AcceptAndLoadFakeFingerprint(); 1204 AcceptAndLoadFakeFingerprint();
1208 } 1205 }
1209 1206
1210 MATCHER(UsesLocalBillingAddress, "uses the local billing address") { 1207 MATCHER(UsesLocalBillingAddress, "uses the local billing address") {
1211 return arg.address_line_1() == ASCIIToUTF16(kEditedBillingAddress); 1208 return arg->address_line_1() == ASCIIToUTF16(kEditedBillingAddress);
1212 } 1209 }
1213 1210
1214 // Tests that when using billing address for shipping, and there is no exact 1211 // Tests that when using billing address for shipping, and there is no exact
1215 // matched shipping address, then a shipping address should be added. 1212 // matched shipping address, then a shipping address should be added.
1216 TEST_F(AutofillDialogControllerTest, BillingForShipping) { 1213 TEST_F(AutofillDialogControllerTest, BillingForShipping) {
1217 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1214 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1218 SaveAddress(_, _)).Times(1); 1215 SaveToWalletTester(testing::IsNull(),
1216 testing::NotNull(),
1217 _)).Times(1);
1219 1218
1220 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); 1219 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
1221 // Select "Same as billing" in the address menu. 1220 // Select "Same as billing" in the address menu.
1222 UseBillingForShipping(); 1221 UseBillingForShipping();
1223 1222
1224 AcceptAndLoadFakeFingerprint(); 1223 AcceptAndLoadFakeFingerprint();
1225 } 1224 }
1226 1225
1227 // Tests that when using billing address for shipping, and there is an exact 1226 // Tests that when using billing address for shipping, and there is an exact
1228 // matched shipping address, then a shipping address should not be added. 1227 // matched shipping address, then a shipping address should not be added.
1229 TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) { 1228 TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) {
1230 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1229 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1231 SaveAddress(_, _)).Times(0); 1230 SaveToWalletTester(_, _, _)).Times(0);
1232 1231
1233 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1232 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1234 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument = 1233 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument =
1235 wallet::GetTestMaskedInstrument(); 1234 wallet::GetTestMaskedInstrument();
1236 // Copy billing address as shipping address, and assign an id to it. 1235 // Copy billing address as shipping address, and assign an id to it.
1237 scoped_ptr<wallet::Address> shipping_address( 1236 scoped_ptr<wallet::Address> shipping_address(
1238 new wallet::Address(instrument->address())); 1237 new wallet::Address(instrument->address()));
1239 shipping_address->set_object_id("shipping_address_id"); 1238 shipping_address->set_object_id("shipping_address_id");
1240 wallet_items->AddAddress(shipping_address.Pass()); 1239 wallet_items->AddAddress(shipping_address.Pass());
1241 wallet_items->AddInstrument(instrument.Pass()); 1240 wallet_items->AddInstrument(instrument.Pass());
1242 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 1241 wallet_items->AddAddress(wallet::GetTestShippingAddress());
1243 1242
1244 controller()->OnDidGetWalletItems(wallet_items.Pass()); 1243 controller()->OnDidGetWalletItems(wallet_items.Pass());
1245 // Select "Same as billing" in the address menu. 1244 // Select "Same as billing" in the address menu.
1246 UseBillingForShipping(); 1245 UseBillingForShipping();
1247 1246
1248 AcceptAndLoadFakeFingerprint(); 1247 AcceptAndLoadFakeFingerprint();
1249 } 1248 }
1250 1249
1250 // HUH??
Dan Beam 2013/07/02 01:25:52 // WHA??
Raman Kakilate 2013/07/02 01:41:24 ??
1251 // Tests that adding new instrument and also using billing address for shipping, 1251 // Tests that adding new instrument and also using billing address for shipping,
1252 // then a shipping address should not be added. 1252 // then a shipping address should not be added.
Dan Beam 2013/07/02 01:25:52 "Tests that adding new instrument and while using
ahutter 2013/07/02 15:44:23 But then the test should have been failing...
1253 TEST_F(AutofillDialogControllerTest, BillingForShippingNewInstrument) { 1253 TEST_F(AutofillDialogControllerTest, BillingForShippingNewInstrument) {
1254 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1254 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1255 SaveInstrumentAndAddress(_, _, _, _)).Times(1); 1255 SaveToWalletTester(_, _, _)).Times(1);
1256 1256
1257 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1257 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1258 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 1258 wallet_items->AddAddress(wallet::GetTestShippingAddress());
1259 1259
1260 controller()->OnDidGetWalletItems(wallet_items.Pass()); 1260 controller()->OnDidGetWalletItems(wallet_items.Pass());
1261 // Select "Same as billing" in the address menu. 1261 // Select "Same as billing" in the address menu.
1262 UseBillingForShipping(); 1262 UseBillingForShipping();
1263 1263
1264 AcceptAndLoadFakeFingerprint(); 1264 AcceptAndLoadFakeFingerprint();
1265 } 1265 }
(...skipping 12 matching lines...) Expand all
1278 const DetailInputs& inputs = 1278 const DetailInputs& inputs =
1279 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); 1279 controller()->RequestedFieldsForSection(SECTION_CC_BILLING);
1280 for (size_t i = 0; i < inputs.size(); ++i) { 1280 for (size_t i = 0; i < inputs.size(); ++i) {
1281 const DetailInput& input = inputs[i]; 1281 const DetailInput& input = inputs[i];
1282 outputs[&input] = input.type == ADDRESS_BILLING_LINE1 ? 1282 outputs[&input] = input.type == ADDRESS_BILLING_LINE1 ?
1283 ASCIIToUTF16(kEditedBillingAddress) : input.initial_value; 1283 ASCIIToUTF16(kEditedBillingAddress) : input.initial_value;
1284 } 1284 }
1285 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); 1285 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs);
1286 1286
1287 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1287 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1288 SaveAddress(UsesLocalBillingAddress(), _)).Times(1); 1288 SaveToWalletTester(testing::NotNull(),
1289 UsesLocalBillingAddress(),
1290 _)).Times(1);
1289 AcceptAndLoadFakeFingerprint(); 1291 AcceptAndLoadFakeFingerprint();
1290
1291 EXPECT_TRUE(
1292 controller()->GetTestingWalletClient()->updated_billing_address());
1293 } 1292 }
1294 1293
1295 TEST_F(AutofillDialogControllerTest, CancelNoSave) { 1294 TEST_F(AutofillDialogControllerTest, CancelNoSave) {
1296 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1295 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1297 SaveInstrumentAndAddress(_, _, _, _)).Times(0); 1296 SaveToWalletTester(_, _, _)).Times(0);
1298 1297
1299 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 1298 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
1300 1299
1301 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); 1300 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems());
1302 controller()->OnCancel(); 1301 controller()->OnCancel();
1303 } 1302 }
1304 1303
1305 // Checks that clicking the Manage menu item opens a new tab with a different 1304 // Checks that clicking the Manage menu item opens a new tab with a different
1306 // URL for Wallet and Autofill. 1305 // URL for Wallet and Autofill.
1307 TEST_F(AutofillDialogControllerTest, ManageItem) { 1306 TEST_F(AutofillDialogControllerTest, ManageItem) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 std::vector<base::string16> email_values; 1489 std::vector<base::string16> email_values;
1491 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values); 1490 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values);
1492 ASSERT_EQ(2U, email_values.size()); 1491 ASSERT_EQ(2U, email_values.size());
1493 EXPECT_EQ(new_email, email_values[1]); 1492 EXPECT_EQ(new_email, email_values[1]);
1494 } 1493 }
1495 1494
1496 TEST_F(AutofillDialogControllerTest, VerifyCvv) { 1495 TEST_F(AutofillDialogControllerTest, VerifyCvv) {
1497 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1496 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1498 GetFullWallet(_)).Times(1); 1497 GetFullWallet(_)).Times(1);
1499 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1498 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1500 AuthenticateInstrument(_, _, _)).Times(1); 1499 AuthenticateInstrument(_, _)).Times(1);
1501 1500
1502 SubmitWithWalletItems(CompleteAndValidWalletItems()); 1501 SubmitWithWalletItems(CompleteAndValidWalletItems());
1503 1502
1504 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty()); 1503 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty());
1505 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING)); 1504 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING));
1506 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING)); 1505 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING));
1507 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); 1506 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
1508 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); 1507 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL));
1509 1508
1510 SuggestionState suggestion_state = 1509 SuggestionState suggestion_state =
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 1605
1607 std::vector<wallet::RequiredAction> required_actions; 1606 std::vector<wallet::RequiredAction> required_actions;
1608 required_actions.push_back(wallet::INVALID_FORM_FIELD); 1607 required_actions.push_back(wallet::INVALID_FORM_FIELD);
1609 1608
1610 std::vector<wallet::FormFieldError> form_errors; 1609 std::vector<wallet::FormFieldError> form_errors;
1611 form_errors.push_back( 1610 form_errors.push_back(
1612 wallet::FormFieldError(wallet::FormFieldError::INVALID_POSTAL_CODE, 1611 wallet::FormFieldError(wallet::FormFieldError::INVALID_POSTAL_CODE,
1613 wallet::FormFieldError::SHIPPING_ADDRESS)); 1612 wallet::FormFieldError::SHIPPING_ADDRESS));
1614 1613
1615 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); 1614 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1);
1616 controller()->OnDidSaveAddress(std::string(), required_actions, form_errors); 1615 controller()->OnDidSaveToWallet(std::string(),
1616 std::string(),
1617 required_actions,
1618 form_errors);
1617 } 1619 }
1618 1620
1619 // Simulates receiving unrecoverable Wallet server validation errors. 1621 // Simulates receiving unrecoverable Wallet server validation errors.
1620 TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) { 1622 TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) {
1621 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 1623 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1622 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 1624 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
1623 controller()->OnDidGetWalletItems(wallet_items.Pass()); 1625 controller()->OnDidGetWalletItems(wallet_items.Pass());
1624 controller()->OnAccept(); 1626 controller()->OnAccept();
1625 1627
1626 std::vector<wallet::RequiredAction> required_actions; 1628 std::vector<wallet::RequiredAction> required_actions;
1627 required_actions.push_back(wallet::INVALID_FORM_FIELD); 1629 required_actions.push_back(wallet::INVALID_FORM_FIELD);
1628 1630
1629 std::vector<wallet::FormFieldError> form_errors; 1631 std::vector<wallet::FormFieldError> form_errors;
1630 form_errors.push_back( 1632 form_errors.push_back(
1631 wallet::FormFieldError(wallet::FormFieldError::UNKNOWN_ERROR, 1633 wallet::FormFieldError(wallet::FormFieldError::UNKNOWN_ERROR,
1632 wallet::FormFieldError::UNKNOWN_LOCATION)); 1634 wallet::FormFieldError::UNKNOWN_LOCATION));
1633 1635
1634 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); 1636 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1);
1635 controller()->OnDidSaveAddress(std::string(), required_actions, form_errors); 1637 controller()->OnDidSaveToWallet(std::string(),
1638 std::string(),
1639 required_actions,
1640 form_errors);
1636 1641
1637 EXPECT_EQ(1U, NotificationsOfType( 1642 EXPECT_EQ(1U, NotificationsOfType(
1638 DialogNotification::REQUIRED_ACTION).size()); 1643 DialogNotification::REQUIRED_ACTION).size());
1639 } 1644 }
1640 1645
1641 // Test Wallet banners are show in the right situations. These banners explain 1646 // Test Wallet banners are show in the right situations. These banners explain
1642 // where Chrome got the user's data (i.e. "Got details from Wallet") or promote 1647 // where Chrome got the user's data (i.e. "Got details from Wallet") or promote
1643 // saving details into Wallet (i.e. "[x] Save details to Wallet"). 1648 // saving details into Wallet (i.e. "[x] Save details to Wallet").
1644 TEST_F(AutofillDialogControllerTest, WalletBanners) { 1649 TEST_F(AutofillDialogControllerTest, WalletBanners) {
1645 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1650 CommandLine* command_line = CommandLine::ForCurrentProcess();
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 controller()->CurrentAutocheckoutSteps()[1].type()); 2179 controller()->CurrentAutocheckoutSteps()[1].type());
2175 EXPECT_EQ(AUTOCHECKOUT_STEP_STARTED, 2180 EXPECT_EQ(AUTOCHECKOUT_STEP_STARTED,
2176 controller()->CurrentAutocheckoutSteps()[1].status()); 2181 controller()->CurrentAutocheckoutSteps()[1].status());
2177 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING, 2182 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING,
2178 controller()->CurrentAutocheckoutSteps()[2].type()); 2183 controller()->CurrentAutocheckoutSteps()[2].type());
2179 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED, 2184 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED,
2180 controller()->CurrentAutocheckoutSteps()[2].status()); 2185 controller()->CurrentAutocheckoutSteps()[2].status());
2181 } 2186 }
2182 2187
2183 } // namespace autofill 2188 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698