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 "components/autofill/core/browser/form_field.h" | 5 #include "components/autofill/core/browser/form_field.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 field.label = ASCIIToUTF16("head_tail"); | 81 field.label = ASCIIToUTF16("head_tail"); |
82 EXPECT_TRUE(FormField::Match(&field, "head|other", FormField::MATCH_LABEL)); | 82 EXPECT_TRUE(FormField::Match(&field, "head|other", FormField::MATCH_LABEL)); |
83 EXPECT_TRUE(FormField::Match(&field, "tail|other", FormField::MATCH_LABEL)); | 83 EXPECT_TRUE(FormField::Match(&field, "tail|other", FormField::MATCH_LABEL)); |
84 EXPECT_FALSE(FormField::Match(&field, "bad|good", FormField::MATCH_LABEL)); | 84 EXPECT_FALSE(FormField::Match(&field, "bad|good", FormField::MATCH_LABEL)); |
85 | 85 |
86 // Case sensitivity. | 86 // Case sensitivity. |
87 field.label = ASCIIToUTF16("xxxHeAd_tAiLxxx"); | 87 field.label = ASCIIToUTF16("xxxHeAd_tAiLxxx"); |
88 EXPECT_TRUE(FormField::Match(&field, "head_tail", FormField::MATCH_LABEL)); | 88 EXPECT_TRUE(FormField::Match(&field, "head_tail", FormField::MATCH_LABEL)); |
89 | 89 |
90 // Word boundaries. | 90 // Word boundaries. |
91 const std::string kWordBoundary = "(\\A|\\z|\\PL)"; | 91 const std::string kWordBoundary = "(?:\\A|\\z|\\PL)"; |
92 field.label = ASCIIToUTF16("contains word:"); | 92 field.label = ASCIIToUTF16("contains word:"); |
93 EXPECT_TRUE(FormField::Match(&field, kWordBoundary + "word" + kWordBoundary, | 93 EXPECT_TRUE(FormField::Match(&field, kWordBoundary + "word" + kWordBoundary, |
94 FormField::MATCH_LABEL)); | 94 FormField::MATCH_LABEL)); |
95 EXPECT_FALSE(FormField::Match(&field, kWordBoundary + "con" + kWordBoundary, | 95 EXPECT_FALSE(FormField::Match(&field, kWordBoundary + "con" + kWordBoundary, |
96 FormField::MATCH_LABEL)); | 96 FormField::MATCH_LABEL)); |
97 // Make sure the circumflex in 'crepe' is not treated as a word boundary. | 97 // Make sure the circumflex in 'crepe' is not treated as a word boundary. |
98 field.label = base::UTF8ToUTF16("cr" "\xC3\xAA" "pe"); | 98 field.label = base::UTF8ToUTF16("cr" "\xC3\xAA" "pe"); |
99 EXPECT_FALSE(FormField::Match(&field, kWordBoundary + "cr" + kWordBoundary, | 99 EXPECT_FALSE(FormField::Match(&field, kWordBoundary + "cr" + kWordBoundary, |
100 FormField::MATCH_LABEL)); | 100 FormField::MATCH_LABEL)); |
101 } | 101 } |
(...skipping 30 matching lines...) Expand all Loading... |
132 FormField::ParseFormFields(fields.get(), true, &field_type_map); | 132 FormField::ParseFormFields(fields.get(), true, &field_type_map); |
133 ASSERT_EQ(3U, field_type_map.size()); | 133 ASSERT_EQ(3U, field_type_map.size()); |
134 | 134 |
135 EXPECT_EQ(ADDRESS_HOME_LINE1, | 135 EXPECT_EQ(ADDRESS_HOME_LINE1, |
136 field_type_map.find(ASCIIToUTF16("Address line1"))->second); | 136 field_type_map.find(ASCIIToUTF16("Address line1"))->second); |
137 EXPECT_EQ(ADDRESS_HOME_LINE2, | 137 EXPECT_EQ(ADDRESS_HOME_LINE2, |
138 field_type_map.find(ASCIIToUTF16("Address line2"))->second); | 138 field_type_map.find(ASCIIToUTF16("Address line2"))->second); |
139 } | 139 } |
140 | 140 |
141 } // namespace autofill | 141 } // namespace autofill |
OLD | NEW |