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

Side by Side Diff: components/autofill/core/browser/credit_card_unittest.cc

Issue 870203002: Add status to server credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add TODO Created 5 years, 11 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/guid.h" 6 #include "base/guid.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/autofill/core/browser/autofill_test_utils.h" 8 #include "components/autofill/core/browser/autofill_test_utils.h"
9 #include "components/autofill/core/browser/autofill_type.h" 9 #include "components/autofill/core/browser/autofill_type.h"
10 #include "components/autofill/core/browser/credit_card.h" 10 #include "components/autofill/core/browser/credit_card.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 TEST(CreditCardTest, Copy) { 139 TEST(CreditCardTest, Copy) {
140 CreditCard a(base::GenerateGUID(), "https://www.example.com"); 140 CreditCard a(base::GenerateGUID(), "https://www.example.com");
141 test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010"); 141 test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010");
142 142
143 // Clone should be logically equal to the original. 143 // Clone should be logically equal to the original.
144 CreditCard b(a); 144 CreditCard b(a);
145 EXPECT_TRUE(a == b); 145 EXPECT_TRUE(a == b);
146 } 146 }
147 147
148 TEST(CreditCardTest, Compare) { 148 TEST(CreditCardTest, IsLocalDuplicateOfServerCard) {
149 struct { 149 struct {
150 CreditCard::RecordType first_card_record_type; 150 CreditCard::RecordType first_card_record_type;
151 const char* first_card_name; 151 const char* first_card_name;
152 const char* first_card_number; 152 const char* first_card_number;
153 const char* first_card_exp_mo; 153 const char* first_card_exp_mo;
154 const char* first_card_exp_yr; 154 const char* first_card_exp_yr;
155 155
156 CreditCard::RecordType second_card_record_type; 156 CreditCard::RecordType second_card_record_type;
157 const char* second_card_name; 157 const char* second_card_name;
158 const char* second_card_number; 158 const char* second_card_number;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 if (test_cases[i].second_card_record_type == CreditCard::MASKED_SERVER_CARD) 211 if (test_cases[i].second_card_record_type == CreditCard::MASKED_SERVER_CARD)
212 b.SetTypeForMaskedCard(test_cases[i].second_card_type); 212 b.SetTypeForMaskedCard(test_cases[i].second_card_type);
213 213
214 EXPECT_EQ(test_cases[i].is_local_duplicate, 214 EXPECT_EQ(test_cases[i].is_local_duplicate,
215 a.IsLocalDuplicateOfServerCard(b)) << " when comparing cards " 215 a.IsLocalDuplicateOfServerCard(b)) << " when comparing cards "
216 << a.Label() << " and " << b.Label(); 216 << a.Label() << " and " << b.Label();
217 } 217 }
218 } 218 }
219 219
220 TEST(CreditCardTest, IsLocalDuplicateOfServerCard) { 220 TEST(CreditCardTest, Compare) {
221 CreditCard a(base::GenerateGUID(), std::string()); 221 CreditCard a(base::GenerateGUID(), std::string());
222 CreditCard b(base::GenerateGUID(), std::string()); 222 CreditCard b(base::GenerateGUID(), std::string());
223 223
224 // Empty cards are the same. 224 // Empty cards are the same.
225 EXPECT_EQ(0, a.Compare(b)); 225 EXPECT_EQ(0, a.Compare(b));
226 226
227 // GUIDs don't count. 227 // GUIDs don't count.
228 a.set_guid(base::GenerateGUID()); 228 a.set_guid(base::GenerateGUID());
229 b.set_guid(base::GenerateGUID()); 229 b.set_guid(base::GenerateGUID());
230 EXPECT_EQ(0, a.Compare(b)); 230 EXPECT_EQ(0, a.Compare(b));
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 base::string16 card_number = base::ASCIIToUTF16("test"); 627 base::string16 card_number = base::ASCIIToUTF16("test");
628 int month = 1; 628 int month = 1;
629 int year = 3000; 629 int year = 3000;
630 CreditCard card(card_number, month, year); 630 CreditCard card(card_number, month, year);
631 EXPECT_EQ(card_number, card.number()); 631 EXPECT_EQ(card_number, card.number());
632 EXPECT_EQ(month, card.expiration_month()); 632 EXPECT_EQ(month, card.expiration_month());
633 EXPECT_EQ(year, card.expiration_year()); 633 EXPECT_EQ(year, card.expiration_year());
634 } 634 }
635 635
636 } // namespace autofill 636 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | components/autofill/core/browser/webdata/autofill_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698