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

Side by Side Diff: chrome/browser/autofill/credit_card_unittest.cc

Issue 2818033: AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. (Closed)
Patch Set: Comment. Created 10 years, 5 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/autofill/autofill_common_unittest.h" 6 #include "chrome/browser/autofill/autofill_common_unittest.h"
7 #include "chrome/browser/autofill/credit_card.h" 7 #include "chrome/browser/autofill/credit_card.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
11 11
12 // Tests credit card summary string generation. This test simulates a variety 12 // Tests credit card summary string generation. This test simulates a variety
13 // of different possible summary strings. Variations occur based on the 13 // of different possible summary strings. Variations occur based on the
14 // existence of credit card number, month, and year fields. 14 // existence of credit card number, month, and year fields.
15 TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { 15 TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) {
16 // Case 0: empty credit card. 16 // Case 0: empty credit card.
17 CreditCard credit_card0(string16(), 0); 17 CreditCard credit_card0(string16(), 0);
18 string16 summary0 = credit_card0.PreviewSummary(); 18 string16 summary0 = credit_card0.PreviewSummary();
19 EXPECT_EQ(summary0, string16()); 19 EXPECT_EQ(summary0, string16());
20 string16 obfuscated0 = credit_card0.ObfuscatedNumber(); 20 string16 obfuscated0 = credit_card0.ObfuscatedNumber();
21 EXPECT_EQ(obfuscated0, string16()); 21 EXPECT_EQ(obfuscated0, string16());
22 22
23 // Case 00: Empty credit card with empty strings. 23 // Case 00: Empty credit card with empty strings.
24 CreditCard credit_card00(string16(), 0); 24 CreditCard credit_card00(string16(), 0);
25 autofill_unittest::SetCreditCardInfo( 25 autofill_unittest::SetCreditCardInfo(&credit_card00, "Corporate",
26 &credit_card00, 26 "John Dillinger", "Visa", "", "", "", "Chicago");
27 "Corporate",
28 "John Dillinger",
29 "Visa",
30 "",
31 "",
32 "",
33 "123",
34 "Chicago",
35 "Indianapolis");
36 string16 summary00 = credit_card00.PreviewSummary(); 27 string16 summary00 = credit_card00.PreviewSummary();
37 EXPECT_EQ(summary00, string16()); 28 EXPECT_EQ(summary00, string16());
38 string16 obfuscated00 = credit_card00.ObfuscatedNumber(); 29 string16 obfuscated00 = credit_card00.ObfuscatedNumber();
39 EXPECT_EQ(obfuscated00, string16()); 30 EXPECT_EQ(obfuscated00, string16());
40 31
41 // Case 1: No credit card number. 32 // Case 1: No credit card number.
42 CreditCard credit_card1(string16(), 0); 33 CreditCard credit_card1(string16(), 0);
43 autofill_unittest::SetCreditCardInfo( 34 autofill_unittest::SetCreditCardInfo(&credit_card1, "Corporate",
44 &credit_card1, 35 "John Dillinger", "Visa", "", "01", "2010", "Chicago");
45 "Corporate",
46 "John Dillinger",
47 "Visa",
48 "",
49 "01",
50 "2010",
51 "123",
52 "Chicago",
53 "Indianapolis");
54 string16 summary1 = credit_card1.PreviewSummary(); 36 string16 summary1 = credit_card1.PreviewSummary();
55 EXPECT_EQ(summary1, string16()); 37 EXPECT_EQ(summary1, string16());
56 string16 obfuscated1 = credit_card1.ObfuscatedNumber(); 38 string16 obfuscated1 = credit_card1.ObfuscatedNumber();
57 EXPECT_EQ(obfuscated1, string16()); 39 EXPECT_EQ(obfuscated1, string16());
58 40
59 // Case 2: No month. 41 // Case 2: No month.
60 CreditCard credit_card2(string16(), 0); 42 CreditCard credit_card2(string16(), 0);
61 autofill_unittest::SetCreditCardInfo( 43 autofill_unittest::SetCreditCardInfo(&credit_card2, "Corporate",
62 &credit_card2, 44 "John Dillinger", "Visa", "123456789012", "", "2010", "Chicago");
63 "Corporate",
64 "John Dillinger",
65 "Visa",
66 "123456789012",
67 "",
68 "2010",
69 "123",
70 "Chicago",
71 "Indianapolis");
72 string16 summary2 = credit_card2.PreviewSummary(); 45 string16 summary2 = credit_card2.PreviewSummary();
73 EXPECT_EQ(summary2, string16(ASCIIToUTF16("************9012"))); 46 EXPECT_EQ(summary2, string16(ASCIIToUTF16("************9012")));
74 string16 obfuscated2 = credit_card2.ObfuscatedNumber(); 47 string16 obfuscated2 = credit_card2.ObfuscatedNumber();
75 EXPECT_EQ(obfuscated2, string16(ASCIIToUTF16("************9012"))); 48 EXPECT_EQ(obfuscated2, string16(ASCIIToUTF16("************9012")));
76 49
77 // Case 3: No year. 50 // Case 3: No year.
78 CreditCard credit_card3(string16(), 0); 51 CreditCard credit_card3(string16(), 0);
79 autofill_unittest::SetCreditCardInfo( 52 autofill_unittest::SetCreditCardInfo(&credit_card3, "Corporate",
80 &credit_card3, 53 "John Dillinger", "Visa", "123456789012", "01", "", "Chicago");
81 "Corporate",
82 "John Dillinger",
83 "Visa",
84 "123456789012",
85 "01",
86 "",
87 "123",
88 "Chicago",
89 "Indianapolis");
90 string16 summary3 = credit_card3.PreviewSummary(); 54 string16 summary3 = credit_card3.PreviewSummary();
91 EXPECT_EQ(summary3, string16(ASCIIToUTF16("************9012"))); 55 EXPECT_EQ(summary3, string16(ASCIIToUTF16("************9012")));
92 string16 obfuscated3 = credit_card3.ObfuscatedNumber(); 56 string16 obfuscated3 = credit_card3.ObfuscatedNumber();
93 EXPECT_EQ(obfuscated3, string16(ASCIIToUTF16("************9012"))); 57 EXPECT_EQ(obfuscated3, string16(ASCIIToUTF16("************9012")));
94 58
95 // Case 4: Have everything. 59 // Case 4: Have everything.
96 CreditCard credit_card4(string16(), 0); 60 CreditCard credit_card4(string16(), 0);
97 autofill_unittest::SetCreditCardInfo( 61 autofill_unittest::SetCreditCardInfo(&credit_card4, "Corporate",
98 &credit_card4, 62 "John Dillinger", "Visa", "123456789012", "01", "2010", "Chicago");
99 "Corporate",
100 "John Dillinger",
101 "Visa",
102 "123456789012",
103 "01",
104 "2010",
105 "123",
106 "Chicago",
107 "Indianapolis");
108 string16 summary4 = credit_card4.PreviewSummary(); 63 string16 summary4 = credit_card4.PreviewSummary();
109 EXPECT_EQ(summary4, string16(ASCIIToUTF16("************9012, Exp: 01/2010"))); 64 EXPECT_EQ(summary4, string16(ASCIIToUTF16("************9012, Exp: 01/2010")));
110 string16 obfuscated4 = credit_card4.ObfuscatedNumber(); 65 string16 obfuscated4 = credit_card4.ObfuscatedNumber();
111 EXPECT_EQ(obfuscated4, string16(ASCIIToUTF16("************9012"))); 66 EXPECT_EQ(obfuscated4, string16(ASCIIToUTF16("************9012")));
112 } 67 }
113 68
114 } // namespace 69 } // namespace
115 70
OLDNEW
« no previous file with comments | « chrome/browser/autofill/credit_card_field_unittest.cc ('k') | chrome/browser/autofill/field_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698