Chromium Code Reviews| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 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.
| |
| 183 void(const wallet::Address& address, const GURL& source_url)); | 182 void(wallet::Instrument* instrument, |
| 184 | 183 wallet::Address* address, |
| 185 MOCK_METHOD3(SaveInstrument, | |
| 186 void(const wallet::Instrument& instrument, | |
| 187 const std::string& obfuscated_gaia_id, | |
| 188 const GURL& source_url)); | 184 const GURL& source_url)); |
| 189 | 185 |
| 190 MOCK_METHOD4(SaveInstrumentAndAddress, | 186 virtual void SaveToWallet(scoped_ptr<wallet::Instrument> instrument, |
| 191 void(const wallet::Instrument& instrument, | 187 scoped_ptr<wallet::Address> address, |
| 192 const wallet::Address& address, | 188 const GURL& source_url) OVERRIDE { |
| 193 const std::string& obfuscated_gaia_id, | 189 SaveToWalletTester(instrument.get(), address.get(), source_url); |
| 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 } | |
| 204 | |
| 205 const wallet::Address* updated_billing_address() { | |
| 206 return updated_billing_address_.get(); | |
| 207 } | 190 } |
| 208 | 191 |
| 209 private: | 192 private: |
| 210 scoped_ptr<wallet::Address> updated_billing_address_; | |
| 211 | |
| 212 DISALLOW_COPY_AND_ASSIGN(TestWalletClient); | 193 DISALLOW_COPY_AND_ASSIGN(TestWalletClient); |
| 213 }; | 194 }; |
| 214 | 195 |
| 215 // Bring over command-ids from AccountChooserModel. | 196 // Bring over command-ids from AccountChooserModel. |
| 216 class TestAccountChooserModel : public AccountChooserModel { | 197 class TestAccountChooserModel : public AccountChooserModel { |
| 217 public: | 198 public: |
| 218 TestAccountChooserModel(AccountChooserModelDelegate* delegate, | 199 TestAccountChooserModel(AccountChooserModelDelegate* delegate, |
| 219 PrefService* prefs, | 200 PrefService* prefs, |
| 220 const AutofillMetrics& metric_logger) | 201 const AutofillMetrics& metric_logger) |
| 221 : AccountChooserModel(delegate, prefs, metric_logger, | 202 : AccountChooserModel(delegate, prefs, metric_logger, |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1100 EXPECT_EQ(4, | 1081 EXPECT_EQ(4, |
| 1101 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); | 1082 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); |
| 1102 // "add" | 1083 // "add" |
| 1103 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> | 1084 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> |
| 1104 IsItemCheckedAt(2)); | 1085 IsItemCheckedAt(2)); |
| 1105 } | 1086 } |
| 1106 | 1087 |
| 1107 TEST_F(AutofillDialogControllerTest, SaveAddress) { | 1088 TEST_F(AutofillDialogControllerTest, SaveAddress) { |
| 1108 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1089 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1109 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1090 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1110 SaveAddress(_, _)).Times(1); | 1091 SaveToWalletTester(testing::IsNull(), |
| 1092 testing::NotNull(), | |
| 1093 _)).Times(1); | |
| 1111 | 1094 |
| 1112 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1095 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1113 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1096 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1114 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1097 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1115 // If there is no shipping address in wallet, it will default to | 1098 // 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 | 1099 // "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". | 1100 // by the following tests. The last item in the menu is "add-new-item". |
| 1118 ui::MenuModel* shipping_model = | 1101 ui::MenuModel* shipping_model = |
| 1119 controller()->MenuModelForSection(SECTION_SHIPPING); | 1102 controller()->MenuModelForSection(SECTION_SHIPPING); |
| 1120 shipping_model->ActivatedAt(shipping_model->GetItemCount() - 1); | 1103 shipping_model->ActivatedAt(shipping_model->GetItemCount() - 1); |
| 1121 AcceptAndLoadFakeFingerprint(); | 1104 AcceptAndLoadFakeFingerprint(); |
| 1122 } | 1105 } |
| 1123 | 1106 |
| 1124 TEST_F(AutofillDialogControllerTest, SaveInstrument) { | 1107 TEST_F(AutofillDialogControllerTest, SaveInstrument) { |
| 1125 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1108 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1126 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1109 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1127 SaveInstrument(_, _, _)).Times(1); | 1110 SaveToWalletTester(testing::NotNull(), |
| 1111 testing::IsNull(), | |
| 1112 _)).Times(1); | |
| 1128 | 1113 |
| 1129 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1114 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1130 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1115 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1131 SubmitWithWalletItems(wallet_items.Pass()); | 1116 SubmitWithWalletItems(wallet_items.Pass()); |
| 1132 } | 1117 } |
| 1133 | 1118 |
| 1134 TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) { | 1119 TEST_F(AutofillDialogControllerTest, SaveInstrumentWithInvalidInstruments) { |
| 1135 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1120 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1136 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1121 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1137 SaveInstrument(_, _, _)).Times(1); | 1122 SaveToWalletTester(testing::NotNull(), |
| 1123 testing::IsNull(), | |
| 1124 _)).Times(1); | |
| 1138 | 1125 |
| 1139 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1126 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1140 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1127 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1141 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid()); | 1128 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid()); |
| 1142 SubmitWithWalletItems(wallet_items.Pass()); | 1129 SubmitWithWalletItems(wallet_items.Pass()); |
| 1143 } | 1130 } |
| 1144 | 1131 |
| 1145 TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) { | 1132 TEST_F(AutofillDialogControllerTest, SaveInstrumentAndAddress) { |
| 1146 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1133 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1147 SaveInstrumentAndAddress(_, _, _, _)).Times(1); | 1134 SaveToWalletTester(testing::NotNull(), |
| 1135 testing::NotNull(), | |
| 1136 _)).Times(1); | |
| 1148 | 1137 |
| 1149 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); | 1138 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); |
| 1150 AcceptAndLoadFakeFingerprint(); | 1139 AcceptAndLoadFakeFingerprint(); |
| 1151 } | 1140 } |
| 1152 | 1141 |
| 1142 MATCHER(IsUpdatingExistingData, "updating existing Wallet data") { | |
| 1143 return !arg->object_id().empty(); | |
| 1144 } | |
| 1145 | |
| 1153 // Tests that editing an address (in wallet mode0 and submitting the dialog | 1146 // Tests that editing an address (in wallet mode0 and submitting the dialog |
| 1154 // should update the existing address on the server via WalletClient. | 1147 // should update the existing address on the server via WalletClient. |
| 1155 TEST_F(AutofillDialogControllerTest, UpdateAddress) { | 1148 TEST_F(AutofillDialogControllerTest, UpdateAddress) { |
| 1156 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1149 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1157 UpdateAddress(_, _)).Times(1); | 1150 SaveToWalletTester(testing::IsNull(), |
| 1151 IsUpdatingExistingData(), | |
| 1152 _)).Times(1); | |
| 1158 | 1153 |
| 1159 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1154 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1160 | 1155 |
| 1161 controller()->EditClickedForSection(SECTION_SHIPPING); | 1156 controller()->EditClickedForSection(SECTION_SHIPPING); |
| 1162 AcceptAndLoadFakeFingerprint(); | 1157 AcceptAndLoadFakeFingerprint(); |
| 1163 } | 1158 } |
| 1164 | 1159 |
| 1165 // Tests that editing an instrument (CC + address) in wallet mode updates an | 1160 // Tests that editing an instrument (CC + address) in wallet mode updates an |
| 1166 // existing instrument on the server via WalletClient. | 1161 // existing instrument on the server via WalletClient. |
| 1167 TEST_F(AutofillDialogControllerTest, UpdateInstrument) { | 1162 TEST_F(AutofillDialogControllerTest, UpdateInstrument) { |
| 1163 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
| 1164 SaveToWalletTester(IsUpdatingExistingData(), | |
| 1165 testing::IsNull(), | |
| 1166 _)).Times(1); | |
| 1167 | |
| 1168 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1168 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1169 | 1169 |
| 1170 controller()->EditClickedForSection(SECTION_CC_BILLING); | 1170 controller()->EditClickedForSection(SECTION_CC_BILLING); |
| 1171 AcceptAndLoadFakeFingerprint(); | 1171 AcceptAndLoadFakeFingerprint(); |
| 1172 | |
| 1173 EXPECT_TRUE( | |
| 1174 controller()->GetTestingWalletClient()->updated_billing_address()); | |
| 1175 } | 1172 } |
| 1176 | 1173 |
| 1177 // Test that a user is able to edit their instrument and add a new address in | 1174 // Test that a user is able to edit their instrument and add a new address in |
| 1178 // the same submission. | 1175 // the same submission. |
| 1179 TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) { | 1176 TEST_F(AutofillDialogControllerTest, UpdateInstrumentSaveAddress) { |
| 1180 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1177 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1181 SaveAddress(_, _)).Times(1); | 1178 SaveToWalletTester(IsUpdatingExistingData(), |
| 1179 testing::NotNull(), | |
| 1180 _)).Times(1); | |
| 1182 | 1181 |
| 1183 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1182 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1184 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1183 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1185 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1184 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1186 | 1185 |
| 1187 controller()->EditClickedForSection(SECTION_CC_BILLING); | 1186 controller()->EditClickedForSection(SECTION_CC_BILLING); |
| 1188 AcceptAndLoadFakeFingerprint(); | 1187 AcceptAndLoadFakeFingerprint(); |
| 1189 | |
| 1190 EXPECT_TRUE( | |
| 1191 controller()->GetTestingWalletClient()->updated_billing_address()); | |
| 1192 } | |
| 1193 | |
| 1194 // Test that saving a new instrument and editing an address works. | |
| 1195 TEST_F(AutofillDialogControllerTest, SaveInstrumentUpdateAddress) { | |
| 1196 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
| 1197 SaveInstrument(_, _, _)).Times(1); | |
| 1198 EXPECT_CALL(*controller()->GetTestingWalletClient(), | |
| 1199 UpdateAddress(_, _)).Times(1); | |
| 1200 | |
| 1201 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | |
| 1202 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | |
| 1203 | |
| 1204 controller()->OnDidGetWalletItems(wallet_items.Pass()); | |
| 1205 | |
| 1206 controller()->EditClickedForSection(SECTION_SHIPPING); | |
| 1207 AcceptAndLoadFakeFingerprint(); | |
| 1208 } | 1188 } |
| 1209 | 1189 |
| 1210 MATCHER(UsesLocalBillingAddress, "uses the local billing address") { | 1190 MATCHER(UsesLocalBillingAddress, "uses the local billing address") { |
| 1211 return arg.address_line_1() == ASCIIToUTF16(kEditedBillingAddress); | 1191 return arg->address_line_1() == ASCIIToUTF16(kEditedBillingAddress); |
| 1212 } | 1192 } |
| 1213 | 1193 |
| 1214 // Tests that when using billing address for shipping, and there is no exact | 1194 // Tests that when using billing address for shipping, and there is no exact |
| 1215 // matched shipping address, then a shipping address should be added. | 1195 // matched shipping address, then a shipping address should be added. |
| 1216 TEST_F(AutofillDialogControllerTest, BillingForShipping) { | 1196 TEST_F(AutofillDialogControllerTest, BillingForShipping) { |
| 1217 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1197 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1218 SaveAddress(_, _)).Times(1); | 1198 SaveToWalletTester(testing::IsNull(), |
| 1199 testing::NotNull(), | |
| 1200 _)).Times(1); | |
| 1219 | 1201 |
| 1220 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1202 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1221 // Select "Same as billing" in the address menu. | 1203 // Select "Same as billing" in the address menu. |
| 1222 UseBillingForShipping(); | 1204 UseBillingForShipping(); |
| 1223 | 1205 |
| 1224 AcceptAndLoadFakeFingerprint(); | 1206 AcceptAndLoadFakeFingerprint(); |
| 1225 } | 1207 } |
| 1226 | 1208 |
| 1227 // Tests that when using billing address for shipping, and there is an exact | 1209 // 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. | 1210 // matched shipping address, then a shipping address should not be added. |
| 1229 TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) { | 1211 TEST_F(AutofillDialogControllerTest, BillingForShippingHasMatch) { |
| 1230 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1212 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1231 SaveAddress(_, _)).Times(0); | 1213 SaveToWalletTester(_, _, _)).Times(0); |
| 1232 | 1214 |
| 1233 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1215 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1234 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument = | 1216 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument = |
| 1235 wallet::GetTestMaskedInstrument(); | 1217 wallet::GetTestMaskedInstrument(); |
| 1236 // Copy billing address as shipping address, and assign an id to it. | 1218 // Copy billing address as shipping address, and assign an id to it. |
| 1237 scoped_ptr<wallet::Address> shipping_address( | 1219 scoped_ptr<wallet::Address> shipping_address( |
| 1238 new wallet::Address(instrument->address())); | 1220 new wallet::Address(instrument->address())); |
| 1239 shipping_address->set_object_id("shipping_address_id"); | 1221 shipping_address->set_object_id("shipping_address_id"); |
| 1240 wallet_items->AddAddress(shipping_address.Pass()); | 1222 wallet_items->AddAddress(shipping_address.Pass()); |
| 1241 wallet_items->AddInstrument(instrument.Pass()); | 1223 wallet_items->AddInstrument(instrument.Pass()); |
| 1242 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1224 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1243 | 1225 |
| 1244 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1226 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1245 // Select "Same as billing" in the address menu. | 1227 // Select "Same as billing" in the address menu. |
| 1246 UseBillingForShipping(); | 1228 UseBillingForShipping(); |
| 1247 | 1229 |
| 1248 AcceptAndLoadFakeFingerprint(); | 1230 AcceptAndLoadFakeFingerprint(); |
| 1249 } | 1231 } |
| 1250 | 1232 |
| 1233 // HUH?? | |
| 1251 // Tests that adding new instrument and also using billing address for shipping, | 1234 // Tests that adding new instrument and also using billing address for shipping, |
| 1252 // then a shipping address should not be added. | 1235 // then a shipping address should not be added. |
| 1253 TEST_F(AutofillDialogControllerTest, BillingForShippingNewInstrument) { | 1236 TEST_F(AutofillDialogControllerTest, BillingForShippingNewInstrument) { |
| 1254 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1237 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1255 SaveInstrumentAndAddress(_, _, _, _)).Times(1); | 1238 SaveToWalletTester(_, _, _)).Times(1); |
| 1256 | 1239 |
| 1257 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1240 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1258 wallet_items->AddAddress(wallet::GetTestShippingAddress()); | 1241 wallet_items->AddAddress(wallet::GetTestShippingAddress()); |
| 1259 | 1242 |
| 1260 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1243 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1261 // Select "Same as billing" in the address menu. | 1244 // Select "Same as billing" in the address menu. |
| 1262 UseBillingForShipping(); | 1245 UseBillingForShipping(); |
| 1263 | 1246 |
| 1264 AcceptAndLoadFakeFingerprint(); | 1247 AcceptAndLoadFakeFingerprint(); |
| 1265 } | 1248 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1278 const DetailInputs& inputs = | 1261 const DetailInputs& inputs = |
| 1279 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); | 1262 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); |
| 1280 for (size_t i = 0; i < inputs.size(); ++i) { | 1263 for (size_t i = 0; i < inputs.size(); ++i) { |
| 1281 const DetailInput& input = inputs[i]; | 1264 const DetailInput& input = inputs[i]; |
| 1282 outputs[&input] = input.type == ADDRESS_BILLING_LINE1 ? | 1265 outputs[&input] = input.type == ADDRESS_BILLING_LINE1 ? |
| 1283 ASCIIToUTF16(kEditedBillingAddress) : input.initial_value; | 1266 ASCIIToUTF16(kEditedBillingAddress) : input.initial_value; |
| 1284 } | 1267 } |
| 1285 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); | 1268 controller()->GetView()->SetUserInput(SECTION_CC_BILLING, outputs); |
| 1286 | 1269 |
| 1287 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1270 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1288 SaveAddress(UsesLocalBillingAddress(), _)).Times(1); | 1271 SaveToWalletTester(testing::NotNull(), |
| 1272 UsesLocalBillingAddress(), | |
| 1273 _)).Times(1); | |
| 1289 AcceptAndLoadFakeFingerprint(); | 1274 AcceptAndLoadFakeFingerprint(); |
| 1290 | |
| 1291 EXPECT_TRUE( | |
| 1292 controller()->GetTestingWalletClient()->updated_billing_address()); | |
| 1293 } | 1275 } |
| 1294 | 1276 |
| 1295 TEST_F(AutofillDialogControllerTest, CancelNoSave) { | 1277 TEST_F(AutofillDialogControllerTest, CancelNoSave) { |
| 1296 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1278 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1297 SaveInstrumentAndAddress(_, _, _, _)).Times(0); | 1279 SaveToWalletTester(_, _, _)).Times(0); |
| 1298 | 1280 |
| 1299 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1281 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1300 | 1282 |
| 1301 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); | 1283 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); |
| 1302 controller()->OnCancel(); | 1284 controller()->OnCancel(); |
| 1303 } | 1285 } |
| 1304 | 1286 |
| 1305 // Checks that clicking the Manage menu item opens a new tab with a different | 1287 // Checks that clicking the Manage menu item opens a new tab with a different |
| 1306 // URL for Wallet and Autofill. | 1288 // URL for Wallet and Autofill. |
| 1307 TEST_F(AutofillDialogControllerTest, ManageItem) { | 1289 TEST_F(AutofillDialogControllerTest, ManageItem) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1490 std::vector<base::string16> email_values; | 1472 std::vector<base::string16> email_values; |
| 1491 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values); | 1473 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values); |
| 1492 ASSERT_EQ(2U, email_values.size()); | 1474 ASSERT_EQ(2U, email_values.size()); |
| 1493 EXPECT_EQ(new_email, email_values[1]); | 1475 EXPECT_EQ(new_email, email_values[1]); |
| 1494 } | 1476 } |
| 1495 | 1477 |
| 1496 TEST_F(AutofillDialogControllerTest, VerifyCvv) { | 1478 TEST_F(AutofillDialogControllerTest, VerifyCvv) { |
| 1497 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1479 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1498 GetFullWallet(_)).Times(1); | 1480 GetFullWallet(_)).Times(1); |
| 1499 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1481 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
| 1500 AuthenticateInstrument(_, _, _)).Times(1); | 1482 AuthenticateInstrument(_, _)).Times(1); |
| 1501 | 1483 |
| 1502 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 1484 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 1503 | 1485 |
| 1504 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty()); | 1486 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty()); |
| 1505 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING)); | 1487 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING)); |
| 1506 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING)); | 1488 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING)); |
| 1507 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1489 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1508 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); | 1490 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_CANCEL)); |
| 1509 | 1491 |
| 1510 SuggestionState suggestion_state = | 1492 SuggestionState suggestion_state = |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1606 | 1588 |
| 1607 std::vector<wallet::RequiredAction> required_actions; | 1589 std::vector<wallet::RequiredAction> required_actions; |
| 1608 required_actions.push_back(wallet::INVALID_FORM_FIELD); | 1590 required_actions.push_back(wallet::INVALID_FORM_FIELD); |
| 1609 | 1591 |
| 1610 std::vector<wallet::FormFieldError> form_errors; | 1592 std::vector<wallet::FormFieldError> form_errors; |
| 1611 form_errors.push_back( | 1593 form_errors.push_back( |
| 1612 wallet::FormFieldError(wallet::FormFieldError::INVALID_POSTAL_CODE, | 1594 wallet::FormFieldError(wallet::FormFieldError::INVALID_POSTAL_CODE, |
| 1613 wallet::FormFieldError::SHIPPING_ADDRESS)); | 1595 wallet::FormFieldError::SHIPPING_ADDRESS)); |
| 1614 | 1596 |
| 1615 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); | 1597 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); |
| 1616 controller()->OnDidSaveAddress(std::string(), required_actions, form_errors); | 1598 controller()->OnDidSaveToWallet(std::string(), |
| 1599 std::string(), | |
| 1600 required_actions, | |
| 1601 form_errors); | |
| 1617 } | 1602 } |
| 1618 | 1603 |
| 1619 // Simulates receiving unrecoverable Wallet server validation errors. | 1604 // Simulates receiving unrecoverable Wallet server validation errors. |
| 1620 TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) { | 1605 TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) { |
| 1621 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 1606 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 1622 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1607 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1623 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1608 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1624 controller()->OnAccept(); | 1609 controller()->OnAccept(); |
| 1625 | 1610 |
| 1626 std::vector<wallet::RequiredAction> required_actions; | 1611 std::vector<wallet::RequiredAction> required_actions; |
| 1627 required_actions.push_back(wallet::INVALID_FORM_FIELD); | 1612 required_actions.push_back(wallet::INVALID_FORM_FIELD); |
| 1628 | 1613 |
| 1629 std::vector<wallet::FormFieldError> form_errors; | 1614 std::vector<wallet::FormFieldError> form_errors; |
| 1630 form_errors.push_back( | 1615 form_errors.push_back( |
| 1631 wallet::FormFieldError(wallet::FormFieldError::UNKNOWN_ERROR, | 1616 wallet::FormFieldError(wallet::FormFieldError::UNKNOWN_ERROR, |
| 1632 wallet::FormFieldError::UNKNOWN_LOCATION)); | 1617 wallet::FormFieldError::UNKNOWN_LOCATION)); |
| 1633 | 1618 |
| 1634 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); | 1619 EXPECT_CALL(*controller()->GetView(), UpdateForErrors()).Times(1); |
| 1635 controller()->OnDidSaveAddress(std::string(), required_actions, form_errors); | 1620 controller()->OnDidSaveToWallet(std::string(), |
| 1621 std::string(), | |
| 1622 required_actions, | |
| 1623 form_errors); | |
| 1636 | 1624 |
| 1637 EXPECT_EQ(1U, NotificationsOfType( | 1625 EXPECT_EQ(1U, NotificationsOfType( |
| 1638 DialogNotification::REQUIRED_ACTION).size()); | 1626 DialogNotification::REQUIRED_ACTION).size()); |
| 1639 } | 1627 } |
| 1640 | 1628 |
| 1641 // Test Wallet banners are show in the right situations. These banners explain | 1629 // 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 | 1630 // 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"). | 1631 // saving details into Wallet (i.e. "[x] Save details to Wallet"). |
| 1644 TEST_F(AutofillDialogControllerTest, WalletBanners) { | 1632 TEST_F(AutofillDialogControllerTest, WalletBanners) { |
| 1645 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1633 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2172 controller()->CurrentAutocheckoutSteps()[1].type()); | 2160 controller()->CurrentAutocheckoutSteps()[1].type()); |
| 2173 EXPECT_EQ(AUTOCHECKOUT_STEP_STARTED, | 2161 EXPECT_EQ(AUTOCHECKOUT_STEP_STARTED, |
| 2174 controller()->CurrentAutocheckoutSteps()[1].status()); | 2162 controller()->CurrentAutocheckoutSteps()[1].status()); |
| 2175 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING, | 2163 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING, |
| 2176 controller()->CurrentAutocheckoutSteps()[2].type()); | 2164 controller()->CurrentAutocheckoutSteps()[2].type()); |
| 2177 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED, | 2165 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED, |
| 2178 controller()->CurrentAutocheckoutSteps()[2].status()); | 2166 controller()->CurrentAutocheckoutSteps()[2].status()); |
| 2179 } | 2167 } |
| 2180 | 2168 |
| 2181 } // namespace autofill | 2169 } // namespace autofill |
| OLD | NEW |