OLD | NEW |
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/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/autofill/autofill_field.h" | 7 #include "chrome/browser/autofill/autofill_field.h" |
8 #include "chrome/browser/autofill/field_types.h" | 8 #include "chrome/browser/autofill/field_types.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 EXPECT_TRUE(field.IsEmpty()); | 39 EXPECT_TRUE(field.IsEmpty()); |
40 | 40 |
41 // Field value is non-empty. | 41 // Field value is non-empty. |
42 field.value = ASCIIToUTF16("Value"); | 42 field.value = ASCIIToUTF16("Value"); |
43 EXPECT_FALSE(field.IsEmpty()); | 43 EXPECT_FALSE(field.IsEmpty()); |
44 } | 44 } |
45 | 45 |
46 TEST(AutofillFieldTest, FieldSignature) { | 46 TEST(AutofillFieldTest, FieldSignature) { |
47 AutofillField field; | 47 AutofillField field; |
48 ASSERT_EQ(string16(), field.name); | 48 ASSERT_EQ(string16(), field.name); |
49 ASSERT_EQ(string16(), field.form_control_type); | 49 ASSERT_EQ(std::string(), field.form_control_type); |
50 | 50 |
51 // Signature is empty. | 51 // Signature is empty. |
52 EXPECT_EQ("2085434232", field.FieldSignature()); | 52 EXPECT_EQ("2085434232", field.FieldSignature()); |
53 | 53 |
54 // Field name is set. | 54 // Field name is set. |
55 field.name = ASCIIToUTF16("Name"); | 55 field.name = ASCIIToUTF16("Name"); |
56 EXPECT_EQ("1606968241", field.FieldSignature()); | 56 EXPECT_EQ("1606968241", field.FieldSignature()); |
57 | 57 |
58 // Field form control type is set. | 58 // Field form control type is set. |
59 field.form_control_type = ASCIIToUTF16("Text"); | 59 field.form_control_type = "text"; |
60 EXPECT_EQ("4246049809", field.FieldSignature()); | 60 EXPECT_EQ("502192749", field.FieldSignature()); |
61 | 61 |
62 // Heuristic type does not affect FieldSignature. | 62 // Heuristic type does not affect FieldSignature. |
63 field.set_heuristic_type(NAME_FIRST); | 63 field.set_heuristic_type(NAME_FIRST); |
64 EXPECT_EQ("4246049809", field.FieldSignature()); | 64 EXPECT_EQ("502192749", field.FieldSignature()); |
65 | 65 |
66 // Server type does not affect FieldSignature. | 66 // Server type does not affect FieldSignature. |
67 field.set_server_type(NAME_LAST); | 67 field.set_server_type(NAME_LAST); |
68 EXPECT_EQ("4246049809", field.FieldSignature()); | 68 EXPECT_EQ("502192749", field.FieldSignature()); |
69 } | 69 } |
70 | 70 |
71 TEST(AutofillFieldTest, IsFieldFillable) { | 71 TEST(AutofillFieldTest, IsFieldFillable) { |
72 AutofillField field; | 72 AutofillField field; |
73 ASSERT_EQ(UNKNOWN_TYPE, field.type()); | 73 ASSERT_EQ(UNKNOWN_TYPE, field.type()); |
74 | 74 |
75 // Type is unknown. | 75 // Type is unknown. |
76 EXPECT_FALSE(field.IsFieldFillable()); | 76 EXPECT_FALSE(field.IsFieldFillable()); |
77 | 77 |
78 // Only heuristic type is set. | 78 // Only heuristic type is set. |
79 field.set_heuristic_type(NAME_FIRST); | 79 field.set_heuristic_type(NAME_FIRST); |
80 EXPECT_TRUE(field.IsFieldFillable()); | 80 EXPECT_TRUE(field.IsFieldFillable()); |
81 | 81 |
82 // Only server type is set. | 82 // Only server type is set. |
83 field.set_heuristic_type(UNKNOWN_TYPE); | 83 field.set_heuristic_type(UNKNOWN_TYPE); |
84 field.set_server_type(NAME_LAST); | 84 field.set_server_type(NAME_LAST); |
85 EXPECT_TRUE(field.IsFieldFillable()); | 85 EXPECT_TRUE(field.IsFieldFillable()); |
86 | 86 |
87 // Both types set. | 87 // Both types set. |
88 field.set_heuristic_type(NAME_FIRST); | 88 field.set_heuristic_type(NAME_FIRST); |
89 field.set_server_type(NAME_LAST); | 89 field.set_server_type(NAME_LAST); |
90 EXPECT_TRUE(field.IsFieldFillable()); | 90 EXPECT_TRUE(field.IsFieldFillable()); |
91 } | 91 } |
92 | 92 |
93 } // namespace | 93 } // namespace |
OLD | NEW |