| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/autofill/autofill_common_test.h" | 7 #include "chrome/browser/autofill/autofill_common_test.h" |
| 8 #include "chrome/browser/autofill/credit_card.h" | 8 #include "chrome/browser/autofill/credit_card.h" |
| 9 #include "chrome/test/base/testing_browser_process_test.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 | 12 |
| 14 // From https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card
_numbers.htm | 13 // From https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card
_numbers.htm |
| 15 const char* const kValidNumbers[] = { | 14 const char* const kValidNumbers[] = { |
| 16 "378282246310005", | 15 "378282246310005", |
| 17 "3714 4963 5398 431", | 16 "3714 4963 5398 431", |
| 18 "3787-3449-3671-000", | 17 "3787-3449-3671-000", |
| 19 "5610591081018250", | 18 "5610591081018250", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 33 }; | 32 }; |
| 34 const char* const kInvalidNumbers[] = { | 33 const char* const kInvalidNumbers[] = { |
| 35 "4111 1111 112", /* too short */ | 34 "4111 1111 112", /* too short */ |
| 36 "41111111111111111115", /* too long */ | 35 "41111111111111111115", /* too long */ |
| 37 "4111-1111-1111-1110", /* wrong Luhn checksum */ | 36 "4111-1111-1111-1110", /* wrong Luhn checksum */ |
| 38 "3056 9309 0259 04aa", /* non-digit characters */ | 37 "3056 9309 0259 04aa", /* non-digit characters */ |
| 39 }; | 38 }; |
| 40 | 39 |
| 41 } // namespace | 40 } // namespace |
| 42 | 41 |
| 43 typedef TestingBrowserProcessTest CreditCardTest; | 42 typedef testing::Test CreditCardTest; |
| 44 | 43 |
| 45 // Tests credit card summary string generation. This test simulates a variety | 44 // Tests credit card summary string generation. This test simulates a variety |
| 46 // of different possible summary strings. Variations occur based on the | 45 // of different possible summary strings. Variations occur based on the |
| 47 // existence of credit card number, month, and year fields. | 46 // existence of credit card number, month, and year fields. |
| 48 TEST_F(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { | 47 TEST_F(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { |
| 49 // Case 0: empty credit card. | 48 // Case 0: empty credit card. |
| 50 CreditCard credit_card0; | 49 CreditCard credit_card0; |
| 51 string16 summary0 = credit_card0.Label(); | 50 string16 summary0 = credit_card0.Label(); |
| 52 EXPECT_EQ(string16(), summary0); | 51 EXPECT_EQ(string16(), summary0); |
| 53 string16 obfuscated0 = credit_card0.ObfuscatedNumber(); | 52 string16 obfuscated0 = credit_card0.ObfuscatedNumber(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 173 |
| 175 card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("7")); | 174 card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("7")); |
| 176 EXPECT_EQ(ASCIIToUTF16("07"), card.GetInfo(CREDIT_CARD_EXP_MONTH)); | 175 EXPECT_EQ(ASCIIToUTF16("07"), card.GetInfo(CREDIT_CARD_EXP_MONTH)); |
| 177 | 176 |
| 178 card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("January")); | 177 card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("January")); |
| 179 EXPECT_EQ(ASCIIToUTF16("01"), card.GetInfo(CREDIT_CARD_EXP_MONTH)); | 178 EXPECT_EQ(ASCIIToUTF16("01"), card.GetInfo(CREDIT_CARD_EXP_MONTH)); |
| 180 | 179 |
| 181 card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("Apr")); | 180 card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("Apr")); |
| 182 EXPECT_EQ(ASCIIToUTF16("04"), card.GetInfo(CREDIT_CARD_EXP_MONTH)); | 181 EXPECT_EQ(ASCIIToUTF16("04"), card.GetInfo(CREDIT_CARD_EXP_MONTH)); |
| 183 } | 182 } |
| OLD | NEW |