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

Unified Diff: components/autofill/browser/validation_unittest.cc

Issue 17392006: In components/autofill, move browser/ to core/browser/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to fix conflicts Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/browser/validation.cc ('k') | components/autofill/browser/webdata/autofill_change.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/browser/validation_unittest.cc
diff --git a/components/autofill/browser/validation_unittest.cc b/components/autofill/browser/validation_unittest.cc
deleted file mode 100644
index eda933e79b76c89a252b2d093f06812eb7929221..0000000000000000000000000000000000000000
--- a/components/autofill/browser/validation_unittest.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/strings/utf_string_conversions.h"
-#include "base/time.h"
-#include "components/autofill/browser/validation.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace autofill {
-namespace {
-
-struct ExpirationDate {
- const char* year;
- const char* month;
-};
-
-// From https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm
-const char* const kValidNumbers[] = {
- "378282246310005",
- "3714 4963 5398 431",
- "3787-3449-3671-000",
- "5610591081018250",
- "3056 9309 0259 04",
- "3852-0000-0232-37",
- "6011111111111117",
- "6011 0009 9013 9424",
- "3530-1113-3330-0000",
- "3566002020360505",
- "5555 5555 5555 4444",
- "5105-1051-0510-5100",
- "4111111111111111",
- "4012 8888 8888 1881",
- "4222-2222-2222-2",
- "5019717010103742",
- "6331101999990016",
-};
-const char* const kInvalidNumbers[] = {
- "4111 1111 112", /* too short */
- "41111111111111111115", /* too long */
- "4111-1111-1111-1110", /* wrong Luhn checksum */
- "3056 9309 0259 04aa", /* non-digit characters */
-};
-const char kCurrentDate[]="1 May 2013";
-const ExpirationDate kValidCreditCardExpirationDate[] = {
- { "2013", "5" }, // Valid month in current year.
- { "2014", "1" }, // Any month in next year.
- { "2014", " 1" }, // Whitespace in month.
- { " 2014", "1" }, // Whitespace in year.
-};
-const ExpirationDate kInvalidCreditCardExpirationDate[] = {
- { "2013", "04" }, // Previous month in current year.
- { "2012", "12" }, // Any month in previous year.
-};
-const char* const kValidCreditCardSecurityCode[] = {
- "323", // 3-digit CSC.
- "3234", // 4-digit CSC.
-};
-const char* const kInvalidCreditCardSecurityCode[] = {
- "32", // CSC too short.
- "12345", // CSC too long.
- "asd", // non-numeric CSC.
-};
-const char* const kValidEmailAddress[] = {
- "user@example",
- "user@example.com",
- "user@subdomain.example.com",
- "user+postfix@example.com",
-};
-const char* const kInvalidEmailAddress[] = {
- "user",
- "foo.com",
- "user@",
- "user@=example.com"
-};
-const char kAmericanExpressCard[] = "341111111111111";
-const char kVisaCard[] = "4111111111111111";
-const char kAmericanExpressCVC[] = "1234";
-const char kVisaCVC[] = "123";
-} // namespace
-
-TEST(AutofillValidation, IsValidCreditCardNumber) {
- for (size_t i = 0; i < arraysize(kValidNumbers); ++i) {
- SCOPED_TRACE(kValidNumbers[i]);
- EXPECT_TRUE(
- autofill::IsValidCreditCardNumber(ASCIIToUTF16(kValidNumbers[i])));
- }
- for (size_t i = 0; i < arraysize(kInvalidNumbers); ++i) {
- SCOPED_TRACE(kInvalidNumbers[i]);
- EXPECT_FALSE(
- autofill::IsValidCreditCardNumber(ASCIIToUTF16(kInvalidNumbers[i])));
- }
-}
-
-TEST(AutofillValidation, IsValidCreditCardExpirationDate)
-{
- base::Time now;
- ASSERT_TRUE(base::Time::FromString(kCurrentDate, &now));
-
- for (size_t i = 0; i < arraysize(kValidCreditCardExpirationDate); ++i) {
- const ExpirationDate data = kValidCreditCardExpirationDate[i];
- SCOPED_TRACE(data.year);
- SCOPED_TRACE(data.month);
- EXPECT_TRUE(
- autofill::IsValidCreditCardExpirationDate(ASCIIToUTF16(data.year),
- ASCIIToUTF16(data.month),
- now));
- }
- for (size_t i = 0; i < arraysize(kInvalidCreditCardExpirationDate); ++i) {
- const ExpirationDate data = kInvalidCreditCardExpirationDate[i];
- SCOPED_TRACE(data.year);
- SCOPED_TRACE(data.month);
- EXPECT_TRUE(
- !autofill::IsValidCreditCardExpirationDate(ASCIIToUTF16(data.year),
- ASCIIToUTF16(data.month),
- now));
- }
-}
-
-TEST(AutofillValidation, IsValidCreditCardSecurityCode) {
- for (size_t i = 0; i < arraysize(kValidCreditCardSecurityCode); ++i) {
- SCOPED_TRACE(kValidCreditCardSecurityCode[i]);
- EXPECT_TRUE(
- autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kValidCreditCardSecurityCode[i])));
- }
- for (size_t i = 0; i < arraysize(kInvalidCreditCardSecurityCode); ++i) {
- SCOPED_TRACE(kInvalidCreditCardSecurityCode[i]);
- EXPECT_FALSE(
- autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kInvalidCreditCardSecurityCode[i])));
- }
-}
-
-TEST(AutofillValidation, IsValidEmailAddress) {
- for (size_t i = 0; i < arraysize(kValidEmailAddress); ++i) {
- SCOPED_TRACE(kValidEmailAddress[i]);
- EXPECT_TRUE(
- autofill::IsValidEmailAddress(ASCIIToUTF16(kValidEmailAddress[i])));
- }
- for (size_t i = 0; i < arraysize(kInvalidEmailAddress); ++i) {
- SCOPED_TRACE(kInvalidEmailAddress[i]);
- EXPECT_FALSE(
- autofill::IsValidEmailAddress(ASCIIToUTF16(kInvalidEmailAddress[i])));
- }
-}
-
-TEST(AutofillValidation, IsValidCreditCardSecurityCodeWithNumber) {
- EXPECT_TRUE(autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kAmericanExpressCard)));
- EXPECT_TRUE(autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kVisaCard)));
- EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kAmericanExpressCard)));
- EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kVisaCard)));
- EXPECT_TRUE(autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kInvalidNumbers[0])));
- EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode(
- ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kInvalidNumbers[0])));
-}
-
-} // namespace autofill
« no previous file with comments | « components/autofill/browser/validation.cc ('k') | components/autofill/browser/webdata/autofill_change.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698