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

Unified Diff: components/autofill/content/browser/payments/payments_client_unittest.cc

Issue 2829853008: Stores server card as a full server card when upload to server succeeds. (Closed)
Patch Set: Renames AddServerCreditCard to AddFullServerCreditCard. Adds DCHECK to verify that we are in a tran… Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/browser/payments/payments_client_unittest.cc
diff --git a/components/autofill/content/browser/payments/payments_client_unittest.cc b/components/autofill/content/browser/payments/payments_client_unittest.cc
index c825367b63b7718ddb35c5dcca88f4017400d521..835210713366f1baf15eace44532981765f1b62e 100644
--- a/components/autofill/content/browser/payments/payments_client_unittest.cc
+++ b/components/autofill/content/browser/payments/payments_client_unittest.cc
@@ -34,6 +34,7 @@ class PaymentsClientTest : public testing::Test, public PaymentsClientDelegate {
switches::kWalletServiceUseSandbox, "0");
result_ = AutofillClient::NONE;
+ server_id_.clear();
real_pan_.clear();
legal_message_.reset();
@@ -66,8 +67,10 @@ class PaymentsClientTest : public testing::Test, public PaymentsClientDelegate {
legal_message_ = std::move(legal_message);
}
- void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) override {
+ void OnDidUploadCard(AutofillClient::PaymentsRpcResult result,
+ const std::string& server_id) override {
result_ = result;
+ server_id_ = server_id;
}
protected:
@@ -130,6 +133,7 @@ class PaymentsClientTest : public testing::Test, public PaymentsClientDelegate {
}
AutofillClient::PaymentsRpcResult result_;
+ std::string server_id_;
std::string real_pan_;
std::unique_ptr<base::DictionaryValue> legal_message_;
@@ -227,11 +231,20 @@ TEST_F(PaymentsClientTest, GetDetailsRemovesNonLocationData) {
EXPECT_TRUE(GetUploadData().find("0090") == std::string::npos);
}
-TEST_F(PaymentsClientTest, UploadSuccess) {
+TEST_F(PaymentsClientTest, UploadSuccessWithoutServerId) {
StartUploading();
IssueOAuthToken();
ReturnResponse(net::HTTP_OK, "{}");
EXPECT_EQ(AutofillClient::SUCCESS, result_);
+ EXPECT_TRUE(server_id_.empty());
+}
+
+TEST_F(PaymentsClientTest, UploadSuccessWithServerId) {
+ StartUploading();
+ IssueOAuthToken();
+ ReturnResponse(net::HTTP_OK, "{ \"credit_card_id\": \"InstrumentData:1\" }");
+ EXPECT_EQ(AutofillClient::SUCCESS, result_);
+ EXPECT_EQ("InstrumentData:1", server_id_);
}
TEST_F(PaymentsClientTest, UploadIncludesNonLocationData) {
« no previous file with comments | « chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc ('k') | components/autofill/core/browser/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698