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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_table_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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/webdata/autofill_table.h" 5 #include "components/autofill/core/browser/webdata/autofill_table.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 EXPECT_GE(s_target_updated.ColumnInt64(5), pre_modification_time.ToTimeT()); 1022 EXPECT_GE(s_target_updated.ColumnInt64(5), pre_modification_time.ToTimeT());
1023 EXPECT_LE(s_target_updated.ColumnInt64(5), post_modification_time.ToTimeT()); 1023 EXPECT_LE(s_target_updated.ColumnInt64(5), post_modification_time.ToTimeT());
1024 EXPECT_FALSE(s_target_updated.Step()); 1024 EXPECT_FALSE(s_target_updated.Step());
1025 1025
1026 // Remove the 'Target' credit card. 1026 // Remove the 'Target' credit card.
1027 EXPECT_TRUE(table_->RemoveCreditCard(target_creditcard.guid())); 1027 EXPECT_TRUE(table_->RemoveCreditCard(target_creditcard.guid()));
1028 db_creditcard = table_->GetCreditCard(target_creditcard.guid()); 1028 db_creditcard = table_->GetCreditCard(target_creditcard.guid());
1029 EXPECT_FALSE(db_creditcard); 1029 EXPECT_FALSE(db_creditcard);
1030 } 1030 }
1031 1031
1032 TEST_F(AutofillTableTest, AddFullServerCreditCard) {
1033 CreditCard credit_card;
1034 credit_card.set_record_type(CreditCard::FULL_SERVER_CARD);
1035 credit_card.set_server_id("server_id");
1036 credit_card.set_origin("https://www.example.com/");
1037 credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Jack Torrance"));
1038 credit_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1234567890123456"));
1039 credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04"));
1040 credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2013"));
1041
1042 EXPECT_TRUE(table_->AddFullServerCreditCard(credit_card));
1043
1044 std::vector<std::unique_ptr<CreditCard>> outputs;
1045 ASSERT_TRUE(table_->GetServerCreditCards(&outputs));
1046 ASSERT_EQ(1U, outputs.size());
1047 EXPECT_EQ(0, credit_card.Compare(*outputs[0]));
1048 }
1049
1032 TEST_F(AutofillTableTest, UpdateAutofillProfile) { 1050 TEST_F(AutofillTableTest, UpdateAutofillProfile) {
1033 // Add a profile to the db. 1051 // Add a profile to the db.
1034 AutofillProfile profile; 1052 AutofillProfile profile;
1035 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); 1053 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
1036 profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Q.")); 1054 profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Q."));
1037 profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); 1055 profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith"));
1038 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@example.com")); 1056 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@example.com"));
1039 profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google")); 1057 profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google"));
1040 profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Apple Way")); 1058 profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Apple Way"));
1041 profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("unit 5")); 1059 profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("unit 5"));
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 sql::Statement s(db_->GetSQLConnection()->GetUniqueStatement( 2170 sql::Statement s(db_->GetSQLConnection()->GetUniqueStatement(
2153 "INSERT OR REPLACE INTO autofill_model_type_state " 2171 "INSERT OR REPLACE INTO autofill_model_type_state "
2154 "(rowid, value) VALUES(1, ?)")); 2172 "(rowid, value) VALUES(1, ?)"));
2155 s.BindString(0, "unparseable"); 2173 s.BindString(0, "unparseable");
2156 EXPECT_TRUE(s.Run()); 2174 EXPECT_TRUE(s.Run());
2157 2175
2158 EXPECT_FALSE(table_->GetAllSyncMetadata(syncer::AUTOFILL, &metadata_batch)); 2176 EXPECT_FALSE(table_->GetAllSyncMetadata(syncer::AUTOFILL, &metadata_batch));
2159 } 2177 }
2160 2178
2161 } // namespace autofill 2179 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698