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

Unified Diff: chrome/browser/autofill/form_field_unittest.cc

Issue 3127030: AutoFill address profile not seen in dropdown for name and address field on dell.com (Closed)
Patch Set: Addressing nit. Created 10 years, 4 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 | « no previous file | chrome/browser/autofill/form_structure.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/form_field_unittest.cc
diff --git a/chrome/browser/autofill/form_field_unittest.cc b/chrome/browser/autofill/form_field_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..616525afdc1bd20d7417c27a8b4d4f9c14d2a3a7
--- /dev/null
+++ b/chrome/browser/autofill/form_field_unittest.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2010 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/form_field.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+TEST(FormFieldTest, Match) {
+ AutoFillField field;
+
+ // Empty strings match.
+ EXPECT_TRUE(FormField::Match(&field, string16(), true));
+
+ // Empty pattern matches non-empty string.
+ field.set_label(ASCIIToUTF16("a"));
+ EXPECT_TRUE(FormField::Match(&field, string16(), true));
+
+ // Non-empty pattern doesn't match empty string.
+ field.set_label(string16());
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("a"), true));
+
+ // Beginning of line.
+ field.set_label(ASCIIToUTF16("head_tail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head"), true));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail"), true));
+
+ // End of line.
+ field.set_label(ASCIIToUTF16("head_tail"));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head$"), true));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("tail$"), true));
+
+ // Exact.
+ field.set_label(ASCIIToUTF16("head_tail"));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^head$"), true));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail$"), true));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head_tail$"), true));
+
+ // Escaped dots.
+ field.set_label(ASCIIToUTF16("m.i."));
+ // Note: This pattern is misleading as the "." characters are wild cards.
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), true));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), true));
+ field.set_label(ASCIIToUTF16("mXiX"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), true));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), true));
+
+ // Repetition.
+ field.set_label(ASCIIToUTF16("headtail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true));
+ field.set_label(ASCIIToUTF16("headXtail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true));
+ field.set_label(ASCIIToUTF16("headXXXtail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true));
+ field.set_label(ASCIIToUTF16("headtail"));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true));
+ field.set_label(ASCIIToUTF16("headXtail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true));
+ field.set_label(ASCIIToUTF16("headXXXtail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true));
+
+ // Alternation.
+ field.set_label(ASCIIToUTF16("head_tail"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head|other"), true));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("tail|other"), true));
+ EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("bad|good"), true));
+
+ // Case sensitivity.
+ field.set_label(ASCIIToUTF16("xxxHeAd_tAiLxxx"));
+ EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head_tail"), true));
+}
+
+} // namespace
« no previous file with comments | « no previous file | chrome/browser/autofill/form_structure.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698