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