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/autofill_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ASSERT_EQ(base::string16(), field.value); | 191 ASSERT_EQ(base::string16(), field.value); |
192 | 192 |
193 // Field value is empty. | 193 // Field value is empty. |
194 EXPECT_TRUE(field.IsEmpty()); | 194 EXPECT_TRUE(field.IsEmpty()); |
195 | 195 |
196 // Field value is non-empty. | 196 // Field value is non-empty. |
197 field.value = ASCIIToUTF16("Value"); | 197 field.value = ASCIIToUTF16("Value"); |
198 EXPECT_FALSE(field.IsEmpty()); | 198 EXPECT_FALSE(field.IsEmpty()); |
199 } | 199 } |
200 | 200 |
201 TEST_F(AutofillFieldTest, FieldSignature) { | 201 TEST_F(AutofillFieldTest, FieldSignatureAsStr) { |
202 AutofillField field; | 202 AutofillField field; |
203 ASSERT_EQ(base::string16(), field.name); | 203 ASSERT_EQ(base::string16(), field.name); |
204 ASSERT_EQ(std::string(), field.form_control_type); | 204 ASSERT_EQ(std::string(), field.form_control_type); |
205 | 205 |
206 // Signature is empty. | 206 // Signature is empty. |
207 EXPECT_EQ("2085434232", field.FieldSignature()); | 207 EXPECT_EQ("2085434232", field.FieldSignatureAsStr()); |
208 | 208 |
209 // Field name is set. | 209 // Field name is set. |
210 field.name = ASCIIToUTF16("Name"); | 210 field.name = ASCIIToUTF16("Name"); |
211 EXPECT_EQ("1606968241", field.FieldSignature()); | 211 EXPECT_EQ("1606968241", field.FieldSignatureAsStr()); |
212 | 212 |
213 // Field form control type is set. | 213 // Field form control type is set. |
214 field.form_control_type = "text"; | 214 field.form_control_type = "text"; |
215 EXPECT_EQ("502192749", field.FieldSignature()); | 215 EXPECT_EQ("502192749", field.FieldSignatureAsStr()); |
216 | 216 |
217 // Heuristic type does not affect FieldSignature. | 217 // Heuristic type does not affect FieldSignature. |
218 field.set_heuristic_type(NAME_FIRST); | 218 field.set_heuristic_type(NAME_FIRST); |
219 EXPECT_EQ("502192749", field.FieldSignature()); | 219 EXPECT_EQ("502192749", field.FieldSignatureAsStr()); |
220 | 220 |
221 // Server type does not affect FieldSignature. | 221 // Server type does not affect FieldSignature. |
222 field.set_server_type(NAME_LAST); | 222 field.set_server_type(NAME_LAST); |
223 EXPECT_EQ("502192749", field.FieldSignature()); | 223 EXPECT_EQ("502192749", field.FieldSignatureAsStr()); |
224 } | 224 } |
225 | 225 |
226 TEST_F(AutofillFieldTest, IsFieldFillable) { | 226 TEST_F(AutofillFieldTest, IsFieldFillable) { |
227 AutofillField field; | 227 AutofillField field; |
228 ASSERT_EQ(UNKNOWN_TYPE, field.Type().GetStorableType()); | 228 ASSERT_EQ(UNKNOWN_TYPE, field.Type().GetStorableType()); |
229 | 229 |
230 // Type is unknown. | 230 // Type is unknown. |
231 EXPECT_FALSE(field.IsFieldFillable()); | 231 EXPECT_FALSE(field.IsFieldFillable()); |
232 | 232 |
233 // Only heuristic type is set. | 233 // Only heuristic type is set. |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 bool has_filled = AutofillField::FillFormField( | 960 bool has_filled = AutofillField::FillFormField( |
961 field, ASCIIToUTF16(test_case.value_to_fill), "en-US", "en-US", &field); | 961 field, ASCIIToUTF16(test_case.value_to_fill), "en-US", "en-US", &field); |
962 | 962 |
963 EXPECT_EQ(test_case.should_fill, has_filled); | 963 EXPECT_EQ(test_case.should_fill, has_filled); |
964 EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); | 964 EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); |
965 } | 965 } |
966 } | 966 } |
967 | 967 |
968 } // namespace | 968 } // namespace |
969 } // namespace autofill | 969 } // namespace autofill |
OLD | NEW |