OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/test/base/chrome_render_view_test.h" | 6 #include "chrome/test/base/chrome_render_view_test.h" |
7 #include "components/autofill/content/renderer/autofill_agent.h" | 7 #include "components/autofill/content/renderer/autofill_agent.h" |
8 #include "components/autofill/core/common/autofill_messages.h" | 8 #include "components/autofill/core/common/autofill_messages.h" |
9 #include "components/autofill/core/common/form_data.h" | 9 #include "components/autofill/core/common/form_data.h" |
10 #include "components/autofill/core/common/form_field_data.h" | 10 #include "components/autofill/core/common/form_field_data.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); | 50 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); |
51 AutofillHostMsg_FormsSeen::Param params; | 51 AutofillHostMsg_FormsSeen::Param params; |
52 AutofillHostMsg_FormsSeen::Read(message, ¶ms); | 52 AutofillHostMsg_FormsSeen::Read(message, ¶ms); |
53 const std::vector<FormData>& forms = params.a; | 53 const std::vector<FormData>& forms = params.a; |
54 ASSERT_EQ(1UL, forms.size()); | 54 ASSERT_EQ(1UL, forms.size()); |
55 ASSERT_EQ(4UL, forms[0].fields.size()); | 55 ASSERT_EQ(4UL, forms[0].fields.size()); |
56 | 56 |
57 FormFieldData expected; | 57 FormFieldData expected; |
58 | 58 |
59 expected.name = ASCIIToUTF16("firstname"); | 59 expected.name = ASCIIToUTF16("firstname"); |
60 expected.value = string16(); | 60 expected.value = base::string16(); |
61 expected.form_control_type = "text"; | 61 expected.form_control_type = "text"; |
62 expected.max_length = WebInputElement::defaultMaxLength(); | 62 expected.max_length = WebInputElement::defaultMaxLength(); |
63 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); | 63 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); |
64 | 64 |
65 expected.name = ASCIIToUTF16("middlename"); | 65 expected.name = ASCIIToUTF16("middlename"); |
66 expected.value = string16(); | 66 expected.value = base::string16(); |
67 expected.form_control_type = "text"; | 67 expected.form_control_type = "text"; |
68 expected.max_length = WebInputElement::defaultMaxLength(); | 68 expected.max_length = WebInputElement::defaultMaxLength(); |
69 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]); | 69 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]); |
70 | 70 |
71 expected.name = ASCIIToUTF16("lastname"); | 71 expected.name = ASCIIToUTF16("lastname"); |
72 expected.value = string16(); | 72 expected.value = base::string16(); |
73 expected.form_control_type = "text"; | 73 expected.form_control_type = "text"; |
74 expected.autocomplete_attribute = "off"; | 74 expected.autocomplete_attribute = "off"; |
75 expected.max_length = WebInputElement::defaultMaxLength(); | 75 expected.max_length = WebInputElement::defaultMaxLength(); |
76 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); | 76 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); |
77 expected.autocomplete_attribute = std::string(); // reset | 77 expected.autocomplete_attribute = std::string(); // reset |
78 | 78 |
79 expected.name = ASCIIToUTF16("state"); | 79 expected.name = ASCIIToUTF16("state"); |
80 expected.value = ASCIIToUTF16("?"); | 80 expected.value = ASCIIToUTF16("?"); |
81 expected.form_control_type = "select-one"; | 81 expected.form_control_type = "select-one"; |
82 expected.max_length = 0; | 82 expected.max_length = 0; |
(...skipping 23 matching lines...) Expand all Loading... |
106 const IPC::Message* message2 = | 106 const IPC::Message* message2 = |
107 render_thread_->sink().GetUniqueMessageMatching( | 107 render_thread_->sink().GetUniqueMessageMatching( |
108 AutofillHostMsg_FillAutofillFormData::ID); | 108 AutofillHostMsg_FillAutofillFormData::ID); |
109 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); | 109 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); |
110 AutofillHostMsg_FillAutofillFormData::Param params2; | 110 AutofillHostMsg_FillAutofillFormData::Param params2; |
111 AutofillHostMsg_FillAutofillFormData::Read(message2, ¶ms2); | 111 AutofillHostMsg_FillAutofillFormData::Read(message2, ¶ms2); |
112 const FormData& form2 = params2.b; | 112 const FormData& form2 = params2.b; |
113 ASSERT_EQ(3UL, form2.fields.size()); | 113 ASSERT_EQ(3UL, form2.fields.size()); |
114 | 114 |
115 expected.name = ASCIIToUTF16("firstname"); | 115 expected.name = ASCIIToUTF16("firstname"); |
116 expected.value = string16(); | 116 expected.value = base::string16(); |
117 expected.form_control_type = "text"; | 117 expected.form_control_type = "text"; |
118 expected.max_length = WebInputElement::defaultMaxLength(); | 118 expected.max_length = WebInputElement::defaultMaxLength(); |
119 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[0]); | 119 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[0]); |
120 | 120 |
121 expected.name = ASCIIToUTF16("middlename"); | 121 expected.name = ASCIIToUTF16("middlename"); |
122 expected.value = string16(); | 122 expected.value = base::string16(); |
123 expected.form_control_type = "text"; | 123 expected.form_control_type = "text"; |
124 expected.max_length = WebInputElement::defaultMaxLength(); | 124 expected.max_length = WebInputElement::defaultMaxLength(); |
125 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[1]); | 125 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[1]); |
126 | 126 |
127 expected.name = ASCIIToUTF16("state"); | 127 expected.name = ASCIIToUTF16("state"); |
128 expected.value = ASCIIToUTF16("?"); | 128 expected.value = ASCIIToUTF16("?"); |
129 expected.form_control_type = "select-one"; | 129 expected.form_control_type = "select-one"; |
130 expected.max_length = 0; | 130 expected.max_length = 0; |
131 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[2]); | 131 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[2]); |
132 } | 132 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 autofill_agent_->InputElementClicked(middlename, true, true); | 197 autofill_agent_->InputElementClicked(middlename, true, true); |
198 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( | 198 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( |
199 AutofillHostMsg_QueryFormFieldAutofill::ID); | 199 AutofillHostMsg_QueryFormFieldAutofill::ID); |
200 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); | 200 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); |
201 | 201 |
202 AutofillHostMsg_QueryFormFieldAutofill::Read(message2, &query_param); | 202 AutofillHostMsg_QueryFormFieldAutofill::Read(message2, &query_param); |
203 EXPECT_TRUE(query_param.e); | 203 EXPECT_TRUE(query_param.e); |
204 } | 204 } |
205 | 205 |
206 } // namespace autofill | 206 } // namespace autofill |
OLD | NEW |