Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/test/scoped_feature_list.h" | |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "components/autofill/core/browser/autofill_experiments.h" | 14 #include "components/autofill/core/browser/autofill_experiments.h" |
| 14 #include "components/autofill/core/browser/autofill_test_utils.h" | 15 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 15 #include "components/autofill/core/browser/autofill_type.h" | 16 #include "components/autofill/core/browser/autofill_type.h" |
| 16 #include "components/autofill/core/browser/credit_card.h" | 17 #include "components/autofill/core/browser/credit_card.h" |
| 17 #include "components/autofill/core/browser/validation.h" | 18 #include "components/autofill/core/browser/validation.h" |
| 18 #include "components/autofill/core/common/autofill_constants.h" | 19 #include "components/autofill/core/common/autofill_constants.h" |
| 19 #include "components/autofill/core/common/form_field_data.h" | 20 #include "components/autofill/core/common/form_field_data.h" |
| 20 #include "components/variations/variations_params_manager.h" | 21 #include "components/variations/variations_params_manager.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 test::SetCreditCardInfo( | 136 test::SetCreditCardInfo( |
| 136 &credit_card5, | 137 &credit_card5, |
| 137 "John Dillinger", | 138 "John Dillinger", |
| 138 "0123456789 0123456789 0123456789 5105 1051 0510 5100", "01", "2010"); | 139 "0123456789 0123456789 0123456789 5105 1051 0510 5100", "01", "2010"); |
| 139 base::string16 summary5 = credit_card5.Label(); | 140 base::string16 summary5 = credit_card5.Label(); |
| 140 EXPECT_EQ(UTF8ToUTF16("Card" + kUTF8MidlineEllipsis + "5100, 01/2010"), | 141 EXPECT_EQ(UTF8ToUTF16("Card" + kUTF8MidlineEllipsis + "5100, 01/2010"), |
| 141 summary5); | 142 summary5); |
| 142 base::string16 obfuscated5 = credit_card5.TypeAndLastFourDigits(); | 143 base::string16 obfuscated5 = credit_card5.TypeAndLastFourDigits(); |
| 143 EXPECT_EQ(UTF8ToUTF16("Card" + kUTF8MidlineEllipsis + "5100"), | 144 EXPECT_EQ(UTF8ToUTF16("Card" + kUTF8MidlineEllipsis + "5100"), |
| 144 obfuscated5); | 145 obfuscated5); |
| 146 | |
| 147 // Case 6: Have everything and show bank name. | |
| 148 CreditCard credit_card6(base::GenerateGUID(), "https://www.example.com/"); | |
| 149 test::SetCreditCardInfo( | |
| 150 &credit_card6, "John Dillinger", "5105 1051 0510 5100", "01", "2010"); | |
| 151 credit_card6.SetBankName(UTF8ToUTF16("Chase")); | |
| 152 base::test::ScopedFeatureList scoped_feature_list_; | |
| 153 scoped_feature_list_.InitAndEnableFeature(kAutofillCreditCardBankNameDisplay); | |
| 154 base::string16 summary6 = credit_card6.Label(); | |
| 155 EXPECT_EQ(UTF8ToUTF16("MasterCard" + kUTF8MidlineEllipsis + "5100, 01/2010"), | |
| 156 summary6); | |
|
Jared Saul
2017/02/22 02:49:45
What's the difference between the summary/Label in
| |
| 157 base::string16 obfuscated6 = credit_card6.TypeAndLastFourDigits(); | |
| 158 EXPECT_EQ(UTF8ToUTF16("Chase" + kUTF8MidlineEllipsis + "5100"), | |
| 159 obfuscated6); | |
| 145 } | 160 } |
| 146 | 161 |
| 147 TEST(CreditCardTest, AssignmentOperator) { | 162 TEST(CreditCardTest, AssignmentOperator) { |
| 148 CreditCard a(base::GenerateGUID(), "some origin"); | 163 CreditCard a(base::GenerateGUID(), "some origin"); |
| 149 test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010"); | 164 test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010"); |
| 150 | 165 |
| 151 // Result of assignment should be logically equal to the original profile. | 166 // Result of assignment should be logically equal to the original profile. |
| 152 CreditCard b(base::GenerateGUID(), "some other origin"); | 167 CreditCard b(base::GenerateGUID(), "some other origin"); |
| 153 b = a; | 168 b = a; |
| 154 EXPECT_TRUE(a == b); | 169 EXPECT_TRUE(a == b); |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 credit_card0.GetLastUsedDateForDisplay(test_case.app_locale)); | 966 credit_card0.GetLastUsedDateForDisplay(test_case.app_locale)); |
| 952 EXPECT_EQ(test_case.last_used_date, | 967 EXPECT_EQ(test_case.last_used_date, |
| 953 credit_card1.GetLastUsedDateForDisplay(test_case.app_locale)); | 968 credit_card1.GetLastUsedDateForDisplay(test_case.app_locale)); |
| 954 EXPECT_EQ(test_case.last_used_year_ago, | 969 EXPECT_EQ(test_case.last_used_year_ago, |
| 955 credit_card2.GetLastUsedDateForDisplay(test_case.app_locale)); | 970 credit_card2.GetLastUsedDateForDisplay(test_case.app_locale)); |
| 956 variation_params_.ClearAllVariationParams(); | 971 variation_params_.ClearAllVariationParams(); |
| 957 } | 972 } |
| 958 } | 973 } |
| 959 | 974 |
| 960 } // namespace autofill | 975 } // namespace autofill |
| OLD | NEW |