summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/phone_number_i18n_unittest.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 21:35:39 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 21:35:39 +0000
commit746750b6d511d7febcbc8d1930f0bb7971dbbab5 (patch)
tree5a586fc70b75fce1fa245da37f84b40ed41a571f /chrome/browser/autofill/phone_number_i18n_unittest.cc
parent2a21ba248898528a7cf31fbba982cf4835dac6d1 (diff)
downloadchromium_src-746750b6d511d7febcbc8d1930f0bb7971dbbab5.zip
chromium_src-746750b6d511d7febcbc8d1930f0bb7971dbbab5.tar.gz
chromium_src-746750b6d511d7febcbc8d1930f0bb7971dbbab5.tar.bz2
Autofill DOMUI Prefs should work with i18n phone numbers
Adds validation to the phone and fax lists in WebUI based prefs for Autofill. Also adds the start of phone_number_i18n.cc/h module. BUG=80101 TEST=PhoneNumberI18NTest.PhoneNumbersMatch Review URL: http://codereview.chromium.org/6930037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/phone_number_i18n_unittest.cc')
-rw-r--r--chrome/browser/autofill/phone_number_i18n_unittest.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/autofill/phone_number_i18n_unittest.cc b/chrome/browser/autofill/phone_number_i18n_unittest.cc
new file mode 100644
index 0000000..d74d124
--- /dev/null
+++ b/chrome/browser/autofill/phone_number_i18n_unittest.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2011 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/utf_string_conversions.h"
+#include "chrome/browser/autofill/phone_number_i18n.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace autofill_i18n;
+
+TEST(PhoneNumberI18NTest, PhoneNumbersMatch) {
+ // Same numbers, defined country code.
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
+ ASCIIToUTF16("4158889999"),
+ "US"));
+ // Same numbers, undefined country code.
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
+ ASCIIToUTF16("4158889999"),
+ ""));
+
+ // Numbers differ by country code only.
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
+ ASCIIToUTF16("4158889999"),
+ "US"));
+
+ // Same numbers, different formats.
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
+ ASCIIToUTF16("415-888-9999"),
+ "US"));
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
+ ASCIIToUTF16("(415)888-9999"),
+ "US"));
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
+ ASCIIToUTF16("415 888 9999"),
+ "US"));
+ EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
+ ASCIIToUTF16("415 TUV WXYZ"),
+ "US"));
+
+ // Partial matches don't count.
+ EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
+ ASCIIToUTF16("8889999"),
+ "US"));
+}