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

Side by Side Diff: components/autofill/browser/form_field_unittest.cc

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/string16.h" 6 #include "base/string16.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "components/autofill/browser/autofill_field.h" 8 #include "components/autofill/browser/autofill_field.h"
9 #include "components/autofill/browser/form_field.h" 9 #include "components/autofill/browser/form_field.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 TEST(FormFieldTest, Match) { 12 TEST(FormFieldTest, Match) {
13 AutofillField field; 13 AutofillField field;
14 14
15 // Empty strings match. 15 // Empty strings match.
16 EXPECT_TRUE(FormField::Match(&field, string16(), FormField::MATCH_LABEL)); 16 EXPECT_TRUE(FormField::Match(&field, base::string16(),
17 FormField::MATCH_LABEL));
17 18
18 // Empty pattern matches non-empty string. 19 // Empty pattern matches non-empty string.
19 field.label = ASCIIToUTF16("a"); 20 field.label = ASCIIToUTF16("a");
20 EXPECT_TRUE(FormField::Match(&field, string16(), FormField::MATCH_LABEL)); 21 EXPECT_TRUE(FormField::Match(&field, base::string16(),
22 FormField::MATCH_LABEL));
21 23
22 // Strictly empty pattern matches empty string. 24 // Strictly empty pattern matches empty string.
23 field.label = string16(); 25 field.label = base::string16();
24 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"), 26 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"),
25 FormField::MATCH_LABEL)); 27 FormField::MATCH_LABEL));
26 28
27 // Strictly empty pattern does not match non-empty string. 29 // Strictly empty pattern does not match non-empty string.
28 field.label = ASCIIToUTF16("a"); 30 field.label = ASCIIToUTF16("a");
29 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"), 31 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"),
30 FormField::MATCH_LABEL)); 32 FormField::MATCH_LABEL));
31 33
32 // Non-empty pattern doesn't match empty string. 34 // Non-empty pattern doesn't match empty string.
33 field.label = string16(); 35 field.label = base::string16();
34 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("a"), 36 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("a"),
35 FormField::MATCH_LABEL)); 37 FormField::MATCH_LABEL));
36 38
37 // Beginning of line. 39 // Beginning of line.
38 field.label = ASCIIToUTF16("head_tail"); 40 field.label = ASCIIToUTF16("head_tail");
39 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head"), 41 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head"),
40 FormField::MATCH_LABEL)); 42 FormField::MATCH_LABEL));
41 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail"), 43 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail"),
42 FormField::MATCH_LABEL)); 44 FormField::MATCH_LABEL));
43 45
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 FieldTypeMap field_type_map; 139 FieldTypeMap field_type_map;
138 FormField::ParseFormFields(fields.get(), &field_type_map); 140 FormField::ParseFormFields(fields.get(), &field_type_map);
139 // Checkable element shouldn't interfere with inference of Address line2. 141 // Checkable element shouldn't interfere with inference of Address line2.
140 EXPECT_EQ(2U, field_type_map.size()); 142 EXPECT_EQ(2U, field_type_map.size());
141 143
142 EXPECT_EQ(ADDRESS_HOME_LINE1, 144 EXPECT_EQ(ADDRESS_HOME_LINE1,
143 field_type_map.find(ASCIIToUTF16("Address line1"))->second); 145 field_type_map.find(ASCIIToUTF16("Address line1"))->second);
144 EXPECT_EQ(ADDRESS_HOME_LINE2, 146 EXPECT_EQ(ADDRESS_HOME_LINE2,
145 field_type_map.find(ASCIIToUTF16("Address line2"))->second); 147 field_type_map.find(ASCIIToUTF16("Address line2"))->second);
146 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698