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

Side by Side Diff: chrome/renderer/autofill/autofill_renderer_browsertest.cc

Issue 23033016: Remove autocheckout code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Even more deletes, and Ilya review. Created 7 years, 3 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) 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
133 133
134 TEST_F(ChromeRenderViewTest, SendDynamicForms) {
135 // Don't want any delay for form state sync changes. This will still post a
136 // message so updates will get coalesced, but as soon as we spin the message
137 // loop, it will generate an update.
138 SendContentStateImmediately();
139
140 LoadHTML("<form method=\"POST\" id=\"testform\">"
141 " <input type=\"text\" id=\"firstname\"/>"
142 " <input type=\"text\" id=\"middlename\"/>"
143 " <input type=\"text\" id=\"lastname\" autoComplete=\"off\"/>"
144 " <input type=\"hidden\" id=\"email\"/>"
145 " <select id=\"state\"/>"
146 " <option>?</option>"
147 " <option>California</option>"
148 " <option>Texas</option>"
149 " </select>"
150 "</form>");
151
152 // Verify that "FormsSeen" sends the expected number of fields.
153 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
154 AutofillHostMsg_FormsSeen::ID);
155 ASSERT_NE(static_cast<IPC::Message*>(NULL), message);
156 AutofillHostMsg_FormsSeen::Param params;
157 AutofillHostMsg_FormsSeen::Read(message, &params);
158 const std::vector<FormData>& forms = params.a;
159 ASSERT_EQ(1UL, forms.size());
160 ASSERT_EQ(4UL, forms[0].fields.size());
161
162 autofill_agent_->OnAutocheckoutSupported();
163 render_thread_->sink().ClearMessages();
164 ExecuteJavaScript("var newInput=document.createElement(\"input\");"
165 "newInput.setAttribute(\"type\",\"text\");"
166 "newInput.setAttribute(\"id\", \"telephone\");"
167 "document.getElementById(\"testform\")"
168 ".appendChild(newInput);");
169 msg_loop_.RunUntilIdle();
170
171 // Verify that FormsSeen is present with the new field.
172 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching(
173 AutofillHostMsg_FormsSeen::ID);
174 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2);
175 AutofillHostMsg_FormsSeen::Read(message2, &params);
176 const std::vector<FormData>& new_forms = params.a;
177 ASSERT_EQ(1UL, new_forms.size());
178 ASSERT_EQ(5UL, new_forms[0].fields.size());
179
180 FormFieldData expected;
181
182 expected.name = ASCIIToUTF16("telephone");
183 expected.value = string16();
184 expected.form_control_type = "text";
185 expected.max_length = WebInputElement::defaultMaxLength();
186 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[4]);
187 }
188
189 TEST_F(ChromeRenderViewTest, EnsureNoFormSeenIfTooFewFields) { 134 TEST_F(ChromeRenderViewTest, EnsureNoFormSeenIfTooFewFields) {
190 // Don't want any delay for form state sync changes. This will still post a 135 // Don't want any delay for form state sync changes. This will still post a
191 // message so updates will get coalesced, but as soon as we spin the message 136 // message so updates will get coalesced, but as soon as we spin the message
192 // loop, it will generate an update. 137 // loop, it will generate an update.
193 SendContentStateImmediately(); 138 SendContentStateImmediately();
194 139
195 LoadHTML("<form method=\"POST\">" 140 LoadHTML("<form method=\"POST\">"
196 " <input type=\"text\" id=\"firstname\"/>" 141 " <input type=\"text\" id=\"firstname\"/>"
197 " <input type=\"text\" id=\"middlename\"/>" 142 " <input type=\"text\" id=\"middlename\"/>"
198 "</form>"); 143 "</form>");
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 autofill_agent_->InputElementClicked(middlename, true, true); 197 autofill_agent_->InputElementClicked(middlename, true, true);
253 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( 198 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching(
254 AutofillHostMsg_QueryFormFieldAutofill::ID); 199 AutofillHostMsg_QueryFormFieldAutofill::ID);
255 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); 200 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2);
256 201
257 AutofillHostMsg_QueryFormFieldAutofill::Read(message2, &query_param); 202 AutofillHostMsg_QueryFormFieldAutofill::Read(message2, &query_param);
258 EXPECT_TRUE(query_param.e); 203 EXPECT_TRUE(query_param.e);
259 } 204 }
260 205
261 } // namespace autofill 206 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698