| 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 EXPECT_EQ(4, | 1119 EXPECT_EQ(4, |
| 1120 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); | 1120 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); |
| 1121 // "add" | 1121 // "add" |
| 1122 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> | 1122 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> |
| 1123 IsItemCheckedAt(2)); | 1123 IsItemCheckedAt(2)); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 TEST_F(AutofillDialogControllerTest, SaveAddress) { | 1126 TEST_F(AutofillDialogControllerTest, SaveAddress) { |
| 1127 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1127 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1128 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1128 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1129 SaveAddress(_, _)).Times(1); | 1129 SaveToWalletMock(testing::IsNull(), |
| 1130 testing::NotNull(), |
| 1131 _)).Times(1); |
| 1130 | 1132 |
| 1131 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1133 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1132 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1134 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1133 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1135 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1134 // If there is no shipping address in wallet, it will default to | 1136 // If there is no shipping address in wallet, it will default to |
| 1135 // "same-as-billing" instead of "add-new-item". "same-as-billing" is covered | 1137 // "same-as-billing" instead of "add-new-item". "same-as-billing" is covered |
| 1136 // by the following tests. The last item in the menu is "add-new-item". | 1138 // by the following tests. The last item in the menu is "add-new-item". |
| 1137 ui::MenuModel* shipping_model = | 1139 ui::MenuModel* shipping_model = |
| 1138 controller()->MenuModelForSection(SECTION_SHIPPING); | 1140 controller()->MenuModelForSection(SECTION_SHIPPING); |
| 1139 shipping_model->ActivatedAt(shipping_model->GetItemCount() - 1); | 1141 shipping_model->ActivatedAt(shipping_model->GetItemCount() - 1); |
| 1140 AcceptAndLoadFakeFingerprint(); | 1142 AcceptAndLoadFakeFingerprint(); |
| 1141 } | 1143 } |
| 1142 | 1144 |
| 1143 TEST_F(AutofillDialogControllerTest, SaveInstrument) { | 1145 TEST_F(AutofillDialogControllerTest, SaveInstrument) { |
| 1144 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1146 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1145 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1147 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1146 SaveInstrument(_, _, _)).Times(1); | 1148 SaveToWalletMock(testing::NotNull(), |
| 1149 testing::IsNull(), |
| 1150 _)).Times(1); |
| 1147 | 1151 |
| 1148 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1152 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1149 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1153 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1150 SubmitWithWalletItems(wallet_items.Pass()); | 1154 SubmitWithWalletItems(wallet_items.Pass()); |
| 1151 } | 1155 } |
| 1152 | 1156 |
| 1153 TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) { | 1157 TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) { |
| 1154 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1158 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1155 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1159 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1156 SaveInstrument(_, _, _)).Times(1); | 1160 SaveToWalletMock(testing::NotNull(), |
| 1161 testing::IsNull(), |
| 1162 _)).Times(1); |
| 1157 | 1163 |
| 1158 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1164 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1159 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1165 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1160 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid()); | 1166 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid()); |
| 1161 SubmitWithWalletItems(wallet_items.Pass()); | 1167 SubmitWithWalletItems(wallet_items.Pass()); |
| 1162 } | 1168 } |
| 1163 | 1169 |
| 1164 TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) { | 1170 TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) { |
| 1165 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1171 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1166 SaveInstrumentAndAddress(_, _, _, _)).Times(1); | 1172 SaveToWalletMock(testing::NotNull(), |
| 1173 testing::NotNull(), |
| 1174 _)).Times(1); |
| 1167 | 1175 |
| 1168 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); | 1176 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); |
| 1169 AcceptAndLoadFakeFingerprint(); | 1177 AcceptAndLoadFakeFingerprint(); |
| 1170 } | 1178 } |
| 1171 | 1179 |
| 1180 MATCHER(IsUpdatingExistingData, "updating existing Wallet data") { |
| 1181 return !arg->object_id().empty(); |
| 1182 } |
| 1183 |
| 1172 // Tests that editing an address (in wallet mode0 and submitting the dialog | 1184 // Tests that editing an address (in wallet mode0 and submitting the dialog |
| 1173 // should update the existing address on the server via WalletClient. | 1185 // should update the existing address on the server via WalletClient. |
| 1174 TEST_F(AutofillDialogControllerTest, UpdateAddress) { | 1186 TEST_F(AutofillDialogControllerTest, UpdateAddress) { |
| 1175 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1187 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1176 UpdateAddress(_, _)).Times(1); | 1188 SaveToWalletMock(testing::IsNull(), |
| 1189 IsUpdatingExistingData(), |
| 1190 _)).Times(1); |
| 1177 | 1191 |
| 1178 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1192 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1179 | 1193 |
| 1180 controller()->EditClickedForSection(SECTION_SHIPPING); | 1194 controller()->EditClickedForSection(SECTION_SHIPPING); |
| 1181 AcceptAndLoadFakeFingerprint(); | 1195 AcceptAndLoadFakeFingerprint(); |
| 1182 } | 1196 } |
| 1183 | 1197 |
| 1184 // Tests that editing an instrument (CC + address) in wallet mode updates an | 1198 // Tests that editing an instrument (CC + address) in wallet mode updates an |
| 1185 // existing instrument on the server via WalletClient. | 1199 // existing instrument on the server via WalletClient. |
| 1186 TEST_F(AutofillDialogControllerTest, UpdateInstrument) { | 1200 TEST_F(AutofillDialogControllerTest, UpdateInstrument) { |
| 1201 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1202 SaveToWalletMock(IsUpdatingExistingData(), |
| 1203 testing::IsNull(), |
| 1204 _)).Times(1); |
| 1205 |
| 1187 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1206 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1188 | 1207 |
| 1189 controller()->EditClickedForSection(SECTION_CC_BILLING); | 1208 controller()->EditClickedForSection(SECTION_CC_BILLING); |
| 1190 AcceptAndLoadFakeFingerprint(); | 1209 AcceptAndLoadFakeFingerprint(); |
| 1191 | |
| 1192 EXPECT_TRUE( | |
| 1193 controller()->GetTestingWalletClient()->updated_billing_address()); | |
| 1194 } | 1210 } |
| 1195 | 1211 |
| 1196 // Test that a user is able to edit their instrument and add a new address in | 1212 // Test that a user is able to edit their instrument and add a new address in |
| 1197 // the same submission. | 1213 // the same submission. |
| 1198 TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) { | 1214 TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) { |
| 1199 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1215 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1200 SaveAddress(_, _)).Times(1); | 1216 SaveToWalletMock(IsUpdatingExistingData(), |
| 1217 testing::NotNull(), |
| 1218 _)).Times(1); |
| 1201 | 1219 |
| 1202 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1220 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1203 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1221 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1204 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1222 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1205 | 1223 |
| 1206 controller()->EditClickedForSection(SECTION_CC_BILLING); | 1224 controller()->EditClickedForSection(SECTION_CC_BILLING); |
| 1207 AcceptAndLoadFakeFingerprint(); | 1225 AcceptAndLoadFakeFingerprint(); |
| 1208 | |
| 1209 EXPECT_TRUE( | |
| 1210 controller()->GetTestingWalletClient()->updated_billing_address()); | |
| 1211 } | 1226 } |
| 1212 | 1227 |
| 1213 // Test that saving a new instrument and editing an address works. | 1228 // Test that saving a new instrument and editing an address works. |
| 1214 TEST_F(AutofillDialogControllerTest, SaveInstrumentUpdateAddress) { | 1229 TEST_F(AutofillDialogControllerTest, SaveInstrumentUpdateAddress) { |
| 1215 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1230 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1216 SaveInstrument(_, _, _)).Times(1); | 1231 SaveToWalletMock(testing::NotNull(), |
| 1217 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1232 IsUpdatingExistingData(), |
| 1218 UpdateAddress(_, _)).Times(1); | 1233 _)).Times(1); |
| 1219 | 1234 |
| 1220 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1235 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1221 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1236 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1222 | 1237 |
| 1223 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1238 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1224 | 1239 |
| 1225 controller()->EditClickedForSection(SECTION_SHIPPING); | 1240 controller()->EditClickedForSection(SECTION_SHIPPING); |
| 1226 AcceptAndLoadFakeFingerprint(); | 1241 AcceptAndLoadFakeFingerprint(); |
| 1227 } | 1242 } |
| 1228 | 1243 |
| 1229 MATCHER(UsesLocalBillingAddress, "uses the local billing address") { | 1244 MATCHER(UsesLocalBillingAddress, "uses the local billing address") { |
| 1230 return arg.address_line_1() == ASCIIToUTF16(kEditedBillingAddress); | 1245 return arg->address_line_1() == ASCIIToUTF16(kEditedBillingAddress); |
| 1231 } | 1246 } |
| 1232 | 1247 |
| 1233 // Tests that when using billing address for shipping, and there is no exact | 1248 // Tests that when using billing address for shipping, and there is no exact |
| 1234 // matched shipping address, then a shipping address should be added. | 1249 // matched shipping address, then a shipping address should be added. |
| 1235 TEST_F(AutofillDialogControllerTest, BillingForShipping) { | 1250 TEST_F(AutofillDialogControllerTest, BillingForShipping) { |
| 1236 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1251 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1237 SaveAddress(_, _)).Times(1); | 1252 SaveToWalletMock(testing::IsNull(), |
| 1253 testing::NotNull(), |
| 1254 _)).Times(1); |
| 1238 | 1255 |
| 1239 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1256 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1240 // Select "Same as billing" in the address menu. | 1257 // Select "Same as billing" in the address menu. |
| 1241 UseBillingForShipping(); | 1258 UseBillingForShipping(); |
| 1242 | 1259 |
| 1243 AcceptAndLoadFakeFingerprint(); | 1260 AcceptAndLoadFakeFingerprint(); |
| 1244 } | 1261 } |
| 1245 | 1262 |
| 1246 // Tests that when using billing address for shipping, and there is an exact | 1263 // Tests that when using billing address for shipping, and there is an exact |
| 1247 // matched shipping address, then a shipping address should not be added. | 1264 // matched shipping address, then a shipping address should not be added. |
| 1248 TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) { | 1265 TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) { |
| 1249 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1266 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1250 SaveAddress(_, _)).Times(0); | 1267 SaveToWalletMock(_, _, _)).Times(0); |
| 1251 | 1268 |
| 1252 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1269 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1253 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument = | 1270 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument = |
| 1254 wallet::GetTestMaskedInstrument(); | 1271 wallet::GetTestMaskedInstrument(); |
| 1255 // Copy billing address as shipping address, and assign an id to it. | 1272 // Copy billing address as shipping address, and assign an id to it. |
| 1256 scoped_ptr<wallet::Address> shipping_address( | 1273 scoped_ptr<wallet::Address> shipping_address( |
| 1257 new wallet::Address(instrument->address())); | 1274 new wallet::Address(instrument->address())); |
| 1258 shipping_address->set_object_id("shipping_address_id"); | 1275 shipping_address->set_object_id("shipping_address_id"); |
| 1259 wallet_items->AddAddress(shipping_address.Pass()); | 1276 wallet_items->AddAddress(shipping_address.Pass()); |
| 1260 wallet_items->AddInstrument(instrument.Pass()); | 1277 wallet_items->AddInstrument(instrument.Pass()); |
| 1261 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1278 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1262 | 1279 |
| 1263 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1280 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1264 // Select "Same as billing" in the address menu. | 1281 // Select "Same as billing" in the address menu. |
| 1265 UseBillingForShipping(); | 1282 UseBillingForShipping(); |
| 1266 | 1283 |
| 1267 AcceptAndLoadFakeFingerprint(); | 1284 AcceptAndLoadFakeFingerprint(); |
| 1268 } | 1285 } |
| 1269 | 1286 |
| 1270 // Tests that adding new instrument and also using billing address for shipping, | |
| 1271 // then a shipping address should not be added. | |
| 1272 TEST_F(AutofillDialogControllerTest, BillingForShippingNewInstrument) { | |
| 1273 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
| 1274 SaveInstrumentAndAddress(_, _, _, _)).Times(1); | |
| 1275 | |
| 1276 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | |
| 1277 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | |
| 1278 | |
| 1279 controller()->OnDidGetWalletItems(wallet_items.Pass()); | |
| 1280 // Select "Same as billing" in the address menu. | |
| 1281 UseBillingForShipping(); | |
| 1282 | |
| 1283 AcceptAndLoadFakeFingerprint(); | |
| 1284 } | |
| 1285 | |
| 1286 // Test that the local view contents is used when saving a new instrument and | 1287 // Test that the local view contents is used when saving a new instrument and |
| 1287 // the user has selected "Same as billing". | 1288 // the user has selected "Same as billing". |
| 1288 TEST_F(AutofillDialogControllerTest, SaveInstrumentSameAsBilling) { | 1289 TEST_F(AutofillDialogControllerTest, SaveInstrumentSameAsBilling) { |
| 1289 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1290 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1290 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1291 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1291 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1292 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1292 | 1293 |
| 1293 controller()->EditClickedForSection(SECTION_CC_BILLING); | 1294 controller()->EditClickedForSection(SECTION_CC_BILLING); |
| 1294 controller()->OnAccept(); | 1295 controller()->OnAccept(); |
| 1295 | 1296 |
| 1296 DetailOutputMap outputs; | 1297 DetailOutputMap outputs; |
| 1297 const DetailInputs& inputs = | 1298 const DetailInputs& inputs = |
| 1298 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); | 1299 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); |
| 1299 for (size_t i = 0; i < inputs.size(); ++i) { | 1300 for (size_t i = 0; i < inputs.size(); ++i) { |
| 1300 const DetailInput& input = inputs[i]; | 1301 const DetailInput& input = inputs[i]; |
| 1301 outputs[&input] = input.type == ADDRESS_BILLING_LINE1 ? | 1302 outputs[&input] = input.type == ADDRESS_BILLING_LINE1 ? |
| 1302 ASCIIToUTF16(kEditedBillingAddress) : input.initial_value; | 1303 ASCIIToUTF16(kEditedBillingAddress) : input.initial_value; |
| 1303 } | 1304 } |
| 1304 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); | 1305 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); |
| 1305 | 1306 |
| 1306 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1307 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1307 SaveAddress(UsesLocalBillingAddress(), _)).Times(1); | 1308 SaveToWalletMock(testing::NotNull(), |
| 1309 UsesLocalBillingAddress(), |
| 1310 _)).Times(1); |
| 1308 AcceptAndLoadFakeFingerprint(); | 1311 AcceptAndLoadFakeFingerprint(); |
| 1309 | |
| 1310 EXPECT_TRUE( | |
| 1311 controller()->GetTestingWalletClient()->updated_billing_address()); | |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 TEST_F(AutofillDialogControllerTest, CancelNoSave) { | 1314 TEST_F(AutofillDialogControllerTest, CancelNoSave) { |
| 1315 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1315 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1316 SaveInstrumentAndAddress(_, _, _, _)).Times(0); | 1316 SaveToWalletMock(_, _, _)).Times(0); |
| 1317 | 1317 |
| 1318 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1318 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1319 | 1319 |
| 1320 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); | 1320 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); |
| 1321 controller()->OnCancel(); | 1321 controller()->OnCancel(); |
| 1322 } | 1322 } |
| 1323 | 1323 |
| 1324 // Checks that clicking the Manage menu item opens a new tab with a different | 1324 // Checks that clicking the Manage menu item opens a new tab with a different |
| 1325 // URL for Wallet and Autofill. | 1325 // URL for Wallet and Autofill. |
| 1326 TEST_F(AutofillDialogControllerTest, ManageItem) { | 1326 TEST_F(AutofillDialogControllerTest, ManageItem) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 std::vector<base::string16> email_values; | 1498 std::vector<base::string16> email_values; |
| 1499 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values); | 1499 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values); |
| 1500 ASSERT_EQ(2U, email_values.size()); | 1500 ASSERT_EQ(2U, email_values.size()); |
| 1501 EXPECT_EQ(new_email, email_values[1]); | 1501 EXPECT_EQ(new_email, email_values[1]); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 TEST_F(AutofillDialogControllerTest, VerifyCvv) { | 1504 TEST_F(AutofillDialogControllerTest, VerifyCvv) { |
| 1505 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1505 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1506 GetFullWallet(_)).Times(1); | 1506 GetFullWallet(_)).Times(1); |
| 1507 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1507 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1508 AuthenticateInstrument(_, _, _)).Times(1); | 1508 AuthenticateInstrument(_, _)).Times(1); |
| 1509 | 1509 |
| 1510 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 1510 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 1511 | 1511 |
| 1512 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty()); | 1512 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty()); |
| 1513 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING)); | 1513 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING)); |
| 1514 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING)); | 1514 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING)); |
| 1515 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1515 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1516 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1516 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
| 1517 | 1517 |
| 1518 SuggestionState suggestion_state = | 1518 SuggestionState suggestion_state = |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1614 |
| 1615 std::vector<wallet::RequiredAction> required_actions; | 1615 std::vector<wallet::RequiredAction> required_actions; |
| 1616 required_actions.push_back(wallet::INVALID_FORM_FIELD); | 1616 required_actions.push_back(wallet::INVALID_FORM_FIELD); |
| 1617 | 1617 |
| 1618 std::vector<wallet::FormFieldError> form_errors; | 1618 std::vector<wallet::FormFieldError> form_errors; |
| 1619 form_errors.push_back( | 1619 form_errors.push_back( |
| 1620 wallet::FormFieldError(wallet::FormFieldError::INVALID_POSTAL_CODE, | 1620 wallet::FormFieldError(wallet::FormFieldError::INVALID_POSTAL_CODE, |
| 1621 wallet::FormFieldError::SHIPPING_ADDRESS)); | 1621 wallet::FormFieldError::SHIPPING_ADDRESS)); |
| 1622 | 1622 |
| 1623 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); | 1623 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); |
| 1624 controller()->OnDidSaveAddress(std::string(), required_actions, form_errors); | 1624 controller()->OnDidSaveToWallet(std::string(), |
| 1625 std::string(), |
| 1626 required_actions, |
| 1627 form_errors); |
| 1625 } | 1628 } |
| 1626 | 1629 |
| 1627 // Simulates receiving unrecoverable Wallet server validation errors. | 1630 // Simulates receiving unrecoverable Wallet server validation errors. |
| 1628 TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) { | 1631 TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) { |
| 1629 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1632 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1630 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1633 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1631 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1634 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1632 controller()->OnAccept(); | 1635 controller()->OnAccept(); |
| 1633 | 1636 |
| 1634 std::vector<wallet::RequiredAction> required_actions; | 1637 std::vector<wallet::RequiredAction> required_actions; |
| 1635 required_actions.push_back(wallet::INVALID_FORM_FIELD); | 1638 required_actions.push_back(wallet::INVALID_FORM_FIELD); |
| 1636 | 1639 |
| 1637 std::vector<wallet::FormFieldError> form_errors; | 1640 std::vector<wallet::FormFieldError> form_errors; |
| 1638 form_errors.push_back( | 1641 form_errors.push_back( |
| 1639 wallet::FormFieldError(wallet::FormFieldError::UNKNOWN_ERROR, | 1642 wallet::FormFieldError(wallet::FormFieldError::UNKNOWN_ERROR, |
| 1640 wallet::FormFieldError::UNKNOWN_LOCATION)); | 1643 wallet::FormFieldError::UNKNOWN_LOCATION)); |
| 1641 | 1644 |
| 1642 controller()->OnDidSaveAddress(std::string(), required_actions, form_errors); | 1645 controller()->OnDidSaveToWallet(std::string(), |
| 1646 std::string(), |
| 1647 required_actions, |
| 1648 form_errors); |
| 1643 | 1649 |
| 1644 EXPECT_EQ(1U, NotificationsOfType( | 1650 EXPECT_EQ(1U, NotificationsOfType( |
| 1645 DialogNotification::REQUIRED_ACTION).size()); | 1651 DialogNotification::REQUIRED_ACTION).size()); |
| 1646 } | 1652 } |
| 1647 | 1653 |
| 1648 // Test Wallet banners are show in the right situations. These banners explain | 1654 // Test Wallet banners are show in the right situations. These banners explain |
| 1649 // where Chrome got the user's data (i.e. "Got details from Wallet") or promote | 1655 // where Chrome got the user's data (i.e. "Got details from Wallet") or promote |
| 1650 // saving details into Wallet (i.e. "[x] Save details to Wallet"). | 1656 // saving details into Wallet (i.e. "[x] Save details to Wallet"). |
| 1651 TEST_F(AutofillDialogControllerTest, WalletBanners) { | 1657 TEST_F(AutofillDialogControllerTest, WalletBanners) { |
| 1652 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1658 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2274 EXPECT_CALL(*test_bubble_controller(), | 2280 EXPECT_CALL(*test_bubble_controller(), |
| 2275 ShowAsGeneratedCardBubble(_, _)).Times(1); | 2281 ShowAsGeneratedCardBubble(_, _)).Times(1); |
| 2276 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); | 2282 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); |
| 2277 | 2283 |
| 2278 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 2284 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 2279 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2285 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
| 2280 controller()->ViewClosed(); | 2286 controller()->ViewClosed(); |
| 2281 } | 2287 } |
| 2282 | 2288 |
| 2283 } // namespace autofill | 2289 } // namespace autofill |
| OLD | NEW |