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

Side by Side Diff: chrome/renderer/form_manager_unittest.cc

Issue 2078016: AutoFill fill billing address when credit card settings specify a billing address. (Closed)
Patch Set: Addressing review comments. Created 10 years, 7 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
« no previous file with comments | « chrome/browser/autofill/form_structure_unittest.cc ('k') | webkit/glue/form_field.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/form_manager.h" 5 #include "chrome/renderer/form_manager.h"
6 #include "chrome/test/render_view_test.h" 6 #include "chrome/test/render_view_test.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 8 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 49 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
50 EXPECT_EQ(GURL(frame->url()), form.origin); 50 EXPECT_EQ(GURL(frame->url()), form.origin);
51 EXPECT_EQ(GURL("http://cnn.com"), form.action); 51 EXPECT_EQ(GURL("http://cnn.com"), form.action);
52 52
53 const std::vector<FormField>& fields = form.fields; 53 const std::vector<FormField>& fields = form.fields;
54 ASSERT_EQ(3U, fields.size()); 54 ASSERT_EQ(3U, fields.size());
55 EXPECT_EQ(FormField(string16(), 55 EXPECT_EQ(FormField(string16(),
56 ASCIIToUTF16("firstname"), 56 ASCIIToUTF16("firstname"),
57 ASCIIToUTF16("John"), 57 ASCIIToUTF16("John"),
58 ASCIIToUTF16("text"), 58 ASCIIToUTF16("text"),
59 0), 59 20),
60 fields[0]); 60 fields[0]);
61 EXPECT_EQ(FormField(string16(), 61 EXPECT_EQ(FormField(string16(),
62 ASCIIToUTF16("lastname"), 62 ASCIIToUTF16("lastname"),
63 ASCIIToUTF16("Smith"), 63 ASCIIToUTF16("Smith"),
64 ASCIIToUTF16("text"), 64 ASCIIToUTF16("text"),
65 0), 65 20),
66 fields[1]); 66 fields[1]);
67 EXPECT_EQ(FormField(string16(), 67 EXPECT_EQ(FormField(string16(),
68 ASCIIToUTF16("reply-send"), 68 ASCIIToUTF16("reply-send"),
69 ASCIIToUTF16("Send"), 69 ASCIIToUTF16("Send"),
70 ASCIIToUTF16("submit"), 70 ASCIIToUTF16("submit"),
71 0), 71 0),
72 fields[2]); 72 fields[2]);
73 } 73 }
74 74
75 TEST_F(FormManagerTest, ExtractForms) { 75 TEST_F(FormManagerTest, ExtractForms) {
(...skipping 17 matching lines...) Expand all
93 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 93 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
94 EXPECT_EQ(GURL(web_frame->url()), form.origin); 94 EXPECT_EQ(GURL(web_frame->url()), form.origin);
95 EXPECT_EQ(GURL("http://cnn.com"), form.action); 95 EXPECT_EQ(GURL("http://cnn.com"), form.action);
96 96
97 const std::vector<FormField>& fields = form.fields; 97 const std::vector<FormField>& fields = form.fields;
98 ASSERT_EQ(3U, fields.size()); 98 ASSERT_EQ(3U, fields.size());
99 EXPECT_EQ(FormField(string16(), 99 EXPECT_EQ(FormField(string16(),
100 ASCIIToUTF16("firstname"), 100 ASCIIToUTF16("firstname"),
101 ASCIIToUTF16("John"), 101 ASCIIToUTF16("John"),
102 ASCIIToUTF16("text"), 102 ASCIIToUTF16("text"),
103 0), 103 20),
104 fields[0]); 104 fields[0]);
105 EXPECT_EQ(FormField(string16(), 105 EXPECT_EQ(FormField(string16(),
106 ASCIIToUTF16("lastname"), 106 ASCIIToUTF16("lastname"),
107 ASCIIToUTF16("Smith"), 107 ASCIIToUTF16("Smith"),
108 ASCIIToUTF16("text"), 108 ASCIIToUTF16("text"),
109 0), 109 20),
110 fields[1]); 110 fields[1]);
111 EXPECT_EQ(FormField(string16(), 111 EXPECT_EQ(FormField(string16(),
112 ASCIIToUTF16("reply-send"), 112 ASCIIToUTF16("reply-send"),
113 ASCIIToUTF16("Send"), 113 ASCIIToUTF16("Send"),
114 ASCIIToUTF16("submit"), 114 ASCIIToUTF16("submit"),
115 0), 115 0),
116 fields[2]); 116 fields[2]);
117 } 117 }
118 118
119 TEST_F(FormManagerTest, ExtractMultipleForms) { 119 TEST_F(FormManagerTest, ExtractMultipleForms) {
(...skipping 21 matching lines...) Expand all
141 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 141 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
142 EXPECT_EQ(GURL(web_frame->url()), form.origin); 142 EXPECT_EQ(GURL(web_frame->url()), form.origin);
143 EXPECT_EQ(GURL("http://cnn.com"), form.action); 143 EXPECT_EQ(GURL("http://cnn.com"), form.action);
144 144
145 const std::vector<FormField>& fields = form.fields; 145 const std::vector<FormField>& fields = form.fields;
146 ASSERT_EQ(2U, fields.size()); 146 ASSERT_EQ(2U, fields.size());
147 EXPECT_EQ(FormField(string16(), 147 EXPECT_EQ(FormField(string16(),
148 ASCIIToUTF16("firstname"), 148 ASCIIToUTF16("firstname"),
149 ASCIIToUTF16("John"), 149 ASCIIToUTF16("John"),
150 ASCIIToUTF16("text"), 150 ASCIIToUTF16("text"),
151 0), 151 20),
152 fields[0]); 152 fields[0]);
153 EXPECT_EQ(FormField(string16(), 153 EXPECT_EQ(FormField(string16(),
154 ASCIIToUTF16("reply-send"), 154 ASCIIToUTF16("reply-send"),
155 ASCIIToUTF16("Send"), 155 ASCIIToUTF16("Send"),
156 ASCIIToUTF16("submit"), 156 ASCIIToUTF16("submit"),
157 0), 157 0),
158 fields[1]); 158 fields[1]);
159 159
160 // Second form. 160 // Second form.
161 const FormData& form2 = forms[1]; 161 const FormData& form2 = forms[1];
162 EXPECT_EQ(ASCIIToUTF16("TestForm2"), form2.name); 162 EXPECT_EQ(ASCIIToUTF16("TestForm2"), form2.name);
163 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 163 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
164 EXPECT_EQ(GURL("http://zoo.com"), form2.action); 164 EXPECT_EQ(GURL("http://zoo.com"), form2.action);
165 165
166 const std::vector<FormField>& fields2 = form2.fields; 166 const std::vector<FormField>& fields2 = form2.fields;
167 ASSERT_EQ(2U, fields2.size()); 167 ASSERT_EQ(2U, fields2.size());
168 EXPECT_EQ(FormField(string16(), 168 EXPECT_EQ(FormField(string16(),
169 ASCIIToUTF16("lastname"), 169 ASCIIToUTF16("lastname"),
170 ASCIIToUTF16("Smith"), 170 ASCIIToUTF16("Smith"),
171 ASCIIToUTF16("text"), 171 ASCIIToUTF16("text"),
172 0), 172 20),
173 fields2[0]); 173 fields2[0]);
174 EXPECT_EQ(FormField(string16(), 174 EXPECT_EQ(FormField(string16(),
175 ASCIIToUTF16("second"), 175 ASCIIToUTF16("second"),
176 ASCIIToUTF16("Submit"), 176 ASCIIToUTF16("Submit"),
177 ASCIIToUTF16("submit"), 177 ASCIIToUTF16("submit"),
178 0), 178 0),
179 fields2[1]); 179 fields2[1]);
180 } 180 }
181 181
182 TEST_F(FormManagerTest, GetFormsAutocomplete) { 182 TEST_F(FormManagerTest, GetFormsAutocomplete) {
183 // Form is not auto-completable due to autocomplete=off. 183 // Form is not auto-completable due to autocomplete=off.
184 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\"" 184 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\""
185 " autocomplete=off>" 185 " autocomplete=off>"
186 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" 186 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>"
187 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" 187 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
188 "</FORM>"); 188 "</FORM>");
189 189
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 225 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
226 EXPECT_EQ(GURL(web_frame->url()), form.origin); 226 EXPECT_EQ(GURL(web_frame->url()), form.origin);
227 EXPECT_EQ(GURL("http://abc.com"), form.action); 227 EXPECT_EQ(GURL("http://abc.com"), form.action);
228 228
229 const std::vector<FormField>& fields = form.fields; 229 const std::vector<FormField>& fields = form.fields;
230 ASSERT_EQ(2U, fields.size()); 230 ASSERT_EQ(2U, fields.size());
231 EXPECT_EQ(FormField(string16(), 231 EXPECT_EQ(FormField(string16(),
232 ASCIIToUTF16("lastname"), 232 ASCIIToUTF16("lastname"),
233 ASCIIToUTF16("Smith"), 233 ASCIIToUTF16("Smith"),
234 ASCIIToUTF16("text"), 234 ASCIIToUTF16("text"),
235 0), 235 20),
236 fields[0]); 236 fields[0]);
237 EXPECT_EQ(FormField(string16(), 237 EXPECT_EQ(FormField(string16(),
238 ASCIIToUTF16("reply"), 238 ASCIIToUTF16("reply"),
239 ASCIIToUTF16("Send"), 239 ASCIIToUTF16("Send"),
240 ASCIIToUTF16("submit"), 240 ASCIIToUTF16("submit"),
241 0), 241 0),
242 fields[1]); 242 fields[1]);
243 } 243 }
244 244
245 TEST_F(FormManagerTest, GetFormsElementsEnabled) { 245 TEST_F(FormManagerTest, GetFormsElementsEnabled) {
(...skipping 18 matching lines...) Expand all
264 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 264 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
265 EXPECT_EQ(GURL(web_frame->url()), form.origin); 265 EXPECT_EQ(GURL(web_frame->url()), form.origin);
266 EXPECT_EQ(GURL("http://xyz.com"), form.action); 266 EXPECT_EQ(GURL("http://xyz.com"), form.action);
267 267
268 const std::vector<FormField>& fields = form.fields; 268 const std::vector<FormField>& fields = form.fields;
269 ASSERT_EQ(2U, fields.size()); 269 ASSERT_EQ(2U, fields.size());
270 EXPECT_EQ(FormField(string16(), 270 EXPECT_EQ(FormField(string16(),
271 ASCIIToUTF16("lastname"), 271 ASCIIToUTF16("lastname"),
272 ASCIIToUTF16("Smith"), 272 ASCIIToUTF16("Smith"),
273 ASCIIToUTF16("text"), 273 ASCIIToUTF16("text"),
274 0), 274 20),
275 fields[0]); 275 fields[0]);
276 EXPECT_EQ(FormField(string16(), 276 EXPECT_EQ(FormField(string16(),
277 ASCIIToUTF16("submit"), 277 ASCIIToUTF16("submit"),
278 ASCIIToUTF16("Send"), 278 ASCIIToUTF16("Send"),
279 ASCIIToUTF16("submit"), 279 ASCIIToUTF16("submit"),
280 0), 280 0),
281 fields[1]); 281 fields[1]);
282 } 282 }
283 283
284 TEST_F(FormManagerTest, FindForm) { 284 TEST_F(FormManagerTest, FindForm) {
(...skipping 25 matching lines...) Expand all
310 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 310 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
311 EXPECT_EQ(GURL(web_frame->url()), form.origin); 311 EXPECT_EQ(GURL(web_frame->url()), form.origin);
312 EXPECT_EQ(GURL("http://buh.com"), form.action); 312 EXPECT_EQ(GURL("http://buh.com"), form.action);
313 313
314 const std::vector<FormField>& fields = form.fields; 314 const std::vector<FormField>& fields = form.fields;
315 ASSERT_EQ(3U, fields.size()); 315 ASSERT_EQ(3U, fields.size());
316 EXPECT_EQ(FormField(string16(), 316 EXPECT_EQ(FormField(string16(),
317 ASCIIToUTF16("firstname"), 317 ASCIIToUTF16("firstname"),
318 ASCIIToUTF16("John"), 318 ASCIIToUTF16("John"),
319 ASCIIToUTF16("text"), 319 ASCIIToUTF16("text"),
320 0), 320 20),
321 fields[0]); 321 fields[0]);
322 EXPECT_EQ(FormField(string16(), 322 EXPECT_EQ(FormField(string16(),
323 ASCIIToUTF16("lastname"), 323 ASCIIToUTF16("lastname"),
324 ASCIIToUTF16("Smith"), 324 ASCIIToUTF16("Smith"),
325 ASCIIToUTF16("text"), 325 ASCIIToUTF16("text"),
326 0), 326 20),
327 fields[1]); 327 fields[1]);
328 EXPECT_EQ(FormField(string16(), 328 EXPECT_EQ(FormField(string16(),
329 ASCIIToUTF16("reply-send"), 329 ASCIIToUTF16("reply-send"),
330 ASCIIToUTF16("Send"), 330 ASCIIToUTF16("Send"),
331 ASCIIToUTF16("submit"), 331 ASCIIToUTF16("submit"),
332 0), 332 0),
333 fields[2]); 333 fields[2]);
334 } 334 }
335 335
336 TEST_F(FormManagerTest, FillForm) { 336 TEST_F(FormManagerTest, FillForm) {
(...skipping 25 matching lines...) Expand all
362 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 362 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
363 EXPECT_EQ(GURL(web_frame->url()), form.origin); 363 EXPECT_EQ(GURL(web_frame->url()), form.origin);
364 EXPECT_EQ(GURL("http://buh.com"), form.action); 364 EXPECT_EQ(GURL("http://buh.com"), form.action);
365 365
366 const std::vector<FormField>& fields = form.fields; 366 const std::vector<FormField>& fields = form.fields;
367 ASSERT_EQ(3U, fields.size()); 367 ASSERT_EQ(3U, fields.size());
368 EXPECT_EQ(FormField(string16(), 368 EXPECT_EQ(FormField(string16(),
369 ASCIIToUTF16("firstname"), 369 ASCIIToUTF16("firstname"),
370 string16(), 370 string16(),
371 ASCIIToUTF16("text"), 371 ASCIIToUTF16("text"),
372 0), 372 20),
373 fields[0]); 373 fields[0]);
374 EXPECT_EQ(FormField(string16(), 374 EXPECT_EQ(FormField(string16(),
375 ASCIIToUTF16("lastname"), 375 ASCIIToUTF16("lastname"),
376 string16(), 376 string16(),
377 ASCIIToUTF16("text"), 377 ASCIIToUTF16("text"),
378 0), 378 20),
379 fields[1]); 379 fields[1]);
380 EXPECT_EQ(FormField(string16(), 380 EXPECT_EQ(FormField(string16(),
381 ASCIIToUTF16("reply-send"), 381 ASCIIToUTF16("reply-send"),
382 ASCIIToUTF16("Send"), 382 ASCIIToUTF16("Send"),
383 ASCIIToUTF16("submit"), 383 ASCIIToUTF16("submit"),
384 0), 384 0),
385 fields[2]); 385 fields[2]);
386 386
387 // Fill the form. 387 // Fill the form.
388 form.fields[0].set_value(ASCIIToUTF16("Wyatt")); 388 form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
389 form.fields[1].set_value(ASCIIToUTF16("Earp")); 389 form.fields[1].set_value(ASCIIToUTF16("Earp"));
390 EXPECT_TRUE(form_manager.FillForm(form)); 390 EXPECT_TRUE(form_manager.FillForm(form));
391 391
392 // Find the newly-filled form that contains the input element. 392 // Find the newly-filled form that contains the input element.
393 FormData form2; 393 FormData form2;
394 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 394 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
395 input_element, FormManager::REQUIRE_NONE, &form2)); 395 input_element, FormManager::REQUIRE_NONE, &form2));
396 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 396 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
397 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 397 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
398 EXPECT_EQ(GURL("http://buh.com"), form2.action); 398 EXPECT_EQ(GURL("http://buh.com"), form2.action);
399 399
400 const std::vector<FormField>& fields2 = form2.fields; 400 const std::vector<FormField>& fields2 = form2.fields;
401 ASSERT_EQ(3U, fields2.size()); 401 ASSERT_EQ(3U, fields2.size());
402 EXPECT_EQ(FormField(string16(), 402 EXPECT_EQ(FormField(string16(),
403 ASCIIToUTF16("firstname"), 403 ASCIIToUTF16("firstname"),
404 ASCIIToUTF16("Wyatt"), 404 ASCIIToUTF16("Wyatt"),
405 ASCIIToUTF16("text"), 405 ASCIIToUTF16("text"),
406 0), 406 20),
407 fields2[0]); 407 fields2[0]);
408 EXPECT_EQ(FormField(string16(), 408 EXPECT_EQ(FormField(string16(),
409 ASCIIToUTF16("lastname"), 409 ASCIIToUTF16("lastname"),
410 ASCIIToUTF16("Earp"), 410 ASCIIToUTF16("Earp"),
411 ASCIIToUTF16("text"), 411 ASCIIToUTF16("text"),
412 0), 412 20),
413 fields2[1]); 413 fields2[1]);
414 EXPECT_EQ(FormField(string16(), 414 EXPECT_EQ(FormField(string16(),
415 ASCIIToUTF16("reply-send"), 415 ASCIIToUTF16("reply-send"),
416 ASCIIToUTF16("Send"), 416 ASCIIToUTF16("Send"),
417 ASCIIToUTF16("submit"), 417 ASCIIToUTF16("submit"),
418 0), 418 0),
419 fields2[2]); 419 fields2[2]);
420 } 420 }
421 421
422 TEST_F(FormManagerTest, Reset) { 422 TEST_F(FormManagerTest, Reset) {
423 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" 423 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
424 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" 424 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>"
425 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" 425 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>"
426 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" 426 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
427 "</FORM>"); 427 "</FORM>");
428 428
429 WebFrame* web_frame = GetMainFrame(); 429 WebFrame* web_frame = GetMainFrame();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 467 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
468 EXPECT_EQ(GURL(web_frame->url()), form.origin); 468 EXPECT_EQ(GURL(web_frame->url()), form.origin);
469 EXPECT_EQ(GURL("http://cnn.com"), form.action); 469 EXPECT_EQ(GURL("http://cnn.com"), form.action);
470 470
471 const std::vector<FormField>& fields = form.fields; 471 const std::vector<FormField>& fields = form.fields;
472 ASSERT_EQ(3U, fields.size()); 472 ASSERT_EQ(3U, fields.size());
473 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), 473 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
474 ASCIIToUTF16("firstname"), 474 ASCIIToUTF16("firstname"),
475 ASCIIToUTF16("John"), 475 ASCIIToUTF16("John"),
476 ASCIIToUTF16("text"), 476 ASCIIToUTF16("text"),
477 0), 477 20),
478 fields[0]); 478 fields[0]);
479 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 479 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
480 ASCIIToUTF16("lastname"), 480 ASCIIToUTF16("lastname"),
481 ASCIIToUTF16("Smith"), 481 ASCIIToUTF16("Smith"),
482 ASCIIToUTF16("text"), 482 ASCIIToUTF16("text"),
483 0), 483 20),
484 fields[1]); 484 fields[1]);
485 EXPECT_EQ(FormField(string16(), 485 EXPECT_EQ(FormField(string16(),
486 ASCIIToUTF16("reply-send"), 486 ASCIIToUTF16("reply-send"),
487 ASCIIToUTF16("Send"), 487 ASCIIToUTF16("Send"),
488 ASCIIToUTF16("submit"), 488 ASCIIToUTF16("submit"),
489 0), 489 0),
490 fields[2]); 490 fields[2]);
491 } 491 }
492 492
493 TEST_F(FormManagerTest, LabelsWithSpans) { 493 TEST_F(FormManagerTest, LabelsWithSpans) {
(...skipping 19 matching lines...) Expand all
513 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 513 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
514 EXPECT_EQ(GURL(web_frame->url()), form.origin); 514 EXPECT_EQ(GURL(web_frame->url()), form.origin);
515 EXPECT_EQ(GURL("http://cnn.com"), form.action); 515 EXPECT_EQ(GURL("http://cnn.com"), form.action);
516 516
517 const std::vector<FormField>& fields = form.fields; 517 const std::vector<FormField>& fields = form.fields;
518 ASSERT_EQ(3U, fields.size()); 518 ASSERT_EQ(3U, fields.size());
519 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), 519 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
520 ASCIIToUTF16("firstname"), 520 ASCIIToUTF16("firstname"),
521 ASCIIToUTF16("John"), 521 ASCIIToUTF16("John"),
522 ASCIIToUTF16("text"), 522 ASCIIToUTF16("text"),
523 0), 523 20),
524 fields[0]); 524 fields[0]);
525 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 525 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
526 ASCIIToUTF16("lastname"), 526 ASCIIToUTF16("lastname"),
527 ASCIIToUTF16("Smith"), 527 ASCIIToUTF16("Smith"),
528 ASCIIToUTF16("text"), 528 ASCIIToUTF16("text"),
529 0), 529 20),
530 fields[1]); 530 fields[1]);
531 EXPECT_EQ(FormField(string16(), 531 EXPECT_EQ(FormField(string16(),
532 ASCIIToUTF16("reply-send"), 532 ASCIIToUTF16("reply-send"),
533 ASCIIToUTF16("Send"), 533 ASCIIToUTF16("Send"),
534 ASCIIToUTF16("submit"), 534 ASCIIToUTF16("submit"),
535 0), 535 0),
536 fields[2]); 536 fields[2]);
537 } 537 }
538 538
539 // This test is different from FormManagerTest.Labels in that the label elements 539 // This test is different from FormManagerTest.Labels in that the label elements
(...skipping 23 matching lines...) Expand all
563 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 563 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
564 EXPECT_EQ(GURL(web_frame->url()), form.origin); 564 EXPECT_EQ(GURL(web_frame->url()), form.origin);
565 EXPECT_EQ(GURL("http://cnn.com"), form.action); 565 EXPECT_EQ(GURL("http://cnn.com"), form.action);
566 566
567 const std::vector<FormField>& fields = form.fields; 567 const std::vector<FormField>& fields = form.fields;
568 ASSERT_EQ(3U, fields.size()); 568 ASSERT_EQ(3U, fields.size());
569 EXPECT_EQ(FormField(string16(), 569 EXPECT_EQ(FormField(string16(),
570 ASCIIToUTF16("firstname"), 570 ASCIIToUTF16("firstname"),
571 ASCIIToUTF16("John"), 571 ASCIIToUTF16("John"),
572 ASCIIToUTF16("text"), 572 ASCIIToUTF16("text"),
573 0), 573 20),
574 fields[0]); 574 fields[0]);
575 EXPECT_EQ(FormField(string16(), 575 EXPECT_EQ(FormField(string16(),
576 ASCIIToUTF16("lastname"), 576 ASCIIToUTF16("lastname"),
577 ASCIIToUTF16("Smith"), 577 ASCIIToUTF16("Smith"),
578 ASCIIToUTF16("text"), 578 ASCIIToUTF16("text"),
579 0), 579 20),
580 fields[1]); 580 fields[1]);
581 EXPECT_EQ(FormField(string16(), 581 EXPECT_EQ(FormField(string16(),
582 ASCIIToUTF16("reply-send"), 582 ASCIIToUTF16("reply-send"),
583 ASCIIToUTF16("Send"), 583 ASCIIToUTF16("Send"),
584 ASCIIToUTF16("submit"), 584 ASCIIToUTF16("submit"),
585 0), 585 0),
586 fields[2]); 586 fields[2]);
587 } 587 }
588 588
589 // This test has three form control elements, only one of which has a label 589 // This test has three form control elements, only one of which has a label
(...skipping 24 matching lines...) Expand all
614 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 614 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
615 EXPECT_EQ(GURL(web_frame->url()), form.origin); 615 EXPECT_EQ(GURL(web_frame->url()), form.origin);
616 EXPECT_EQ(GURL("http://cnn.com"), form.action); 616 EXPECT_EQ(GURL("http://cnn.com"), form.action);
617 617
618 const std::vector<FormField>& fields = form.fields; 618 const std::vector<FormField>& fields = form.fields;
619 ASSERT_EQ(3U, fields.size()); 619 ASSERT_EQ(3U, fields.size());
620 EXPECT_EQ(FormField(ASCIIToUTF16("Middle name:"), 620 EXPECT_EQ(FormField(ASCIIToUTF16("Middle name:"),
621 ASCIIToUTF16("middlename"), 621 ASCIIToUTF16("middlename"),
622 string16(), 622 string16(),
623 ASCIIToUTF16("text"), 623 ASCIIToUTF16("text"),
624 0), 624 20),
625 fields[0]); 625 fields[0]);
626 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 626 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
627 ASCIIToUTF16("lastname"), 627 ASCIIToUTF16("lastname"),
628 string16(), 628 string16(),
629 ASCIIToUTF16("text"), 629 ASCIIToUTF16("text"),
630 0), 630 20),
631 fields[1]); 631 fields[1]);
632 EXPECT_EQ(FormField(string16(), 632 EXPECT_EQ(FormField(string16(),
633 ASCIIToUTF16("reply-send"), 633 ASCIIToUTF16("reply-send"),
634 ASCIIToUTF16("Send"), 634 ASCIIToUTF16("Send"),
635 ASCIIToUTF16("submit"), 635 ASCIIToUTF16("submit"),
636 0), 636 0),
637 fields[2]); 637 fields[2]);
638 } 638 }
639 639
640 TEST_F(FormManagerTest, LabelsInferredFromText) { 640 TEST_F(FormManagerTest, LabelsInferredFromText) {
(...skipping 19 matching lines...) Expand all
660 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 660 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
661 EXPECT_EQ(GURL(web_frame->url()), form.origin); 661 EXPECT_EQ(GURL(web_frame->url()), form.origin);
662 EXPECT_EQ(GURL("http://cnn.com"), form.action); 662 EXPECT_EQ(GURL("http://cnn.com"), form.action);
663 663
664 const std::vector<FormField>& fields = form.fields; 664 const std::vector<FormField>& fields = form.fields;
665 ASSERT_EQ(3U, fields.size()); 665 ASSERT_EQ(3U, fields.size());
666 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), 666 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
667 ASCIIToUTF16("firstname"), 667 ASCIIToUTF16("firstname"),
668 ASCIIToUTF16("John"), 668 ASCIIToUTF16("John"),
669 ASCIIToUTF16("text"), 669 ASCIIToUTF16("text"),
670 0), 670 20),
671 fields[0]); 671 fields[0]);
672 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 672 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
673 ASCIIToUTF16("lastname"), 673 ASCIIToUTF16("lastname"),
674 ASCIIToUTF16("Smith"), 674 ASCIIToUTF16("Smith"),
675 ASCIIToUTF16("text"), 675 ASCIIToUTF16("text"),
676 0), 676 20),
677 fields[1]); 677 fields[1]);
678 EXPECT_EQ(FormField(string16(), 678 EXPECT_EQ(FormField(string16(),
679 ASCIIToUTF16("reply-send"), 679 ASCIIToUTF16("reply-send"),
680 ASCIIToUTF16("Send"), 680 ASCIIToUTF16("Send"),
681 ASCIIToUTF16("submit"), 681 ASCIIToUTF16("submit"),
682 0), 682 0),
683 fields[2]); 683 fields[2]);
684 } 684 }
685 685
686 TEST_F(FormManagerTest, LabelsInferredFromParagraph) { 686 TEST_F(FormManagerTest, LabelsInferredFromParagraph) {
(...skipping 19 matching lines...) Expand all
706 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 706 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
707 EXPECT_EQ(GURL(web_frame->url()), form.origin); 707 EXPECT_EQ(GURL(web_frame->url()), form.origin);
708 EXPECT_EQ(GURL("http://cnn.com"), form.action); 708 EXPECT_EQ(GURL("http://cnn.com"), form.action);
709 709
710 const std::vector<FormField>& fields = form.fields; 710 const std::vector<FormField>& fields = form.fields;
711 ASSERT_EQ(3U, fields.size()); 711 ASSERT_EQ(3U, fields.size());
712 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), 712 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
713 ASCIIToUTF16("firstname"), 713 ASCIIToUTF16("firstname"),
714 ASCIIToUTF16("John"), 714 ASCIIToUTF16("John"),
715 ASCIIToUTF16("text"), 715 ASCIIToUTF16("text"),
716 0), 716 20),
717 fields[0]); 717 fields[0]);
718 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 718 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
719 ASCIIToUTF16("lastname"), 719 ASCIIToUTF16("lastname"),
720 ASCIIToUTF16("Smith"), 720 ASCIIToUTF16("Smith"),
721 ASCIIToUTF16("text"), 721 ASCIIToUTF16("text"),
722 0), 722 20),
723 fields[1]); 723 fields[1]);
724 EXPECT_EQ(FormField(string16(), 724 EXPECT_EQ(FormField(string16(),
725 ASCIIToUTF16("reply-send"), 725 ASCIIToUTF16("reply-send"),
726 ASCIIToUTF16("Send"), 726 ASCIIToUTF16("Send"),
727 ASCIIToUTF16("submit"), 727 ASCIIToUTF16("submit"),
728 0), 728 0),
729 fields[2]); 729 fields[2]);
730 } 730 }
731 731
732 TEST_F(FormManagerTest, LabelsInferredFromTableCell) { 732 TEST_F(FormManagerTest, LabelsInferredFromTableCell) {
(...skipping 30 matching lines...) Expand all
763 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 763 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
764 EXPECT_EQ(GURL(web_frame->url()), form.origin); 764 EXPECT_EQ(GURL(web_frame->url()), form.origin);
765 EXPECT_EQ(GURL("http://cnn.com"), form.action); 765 EXPECT_EQ(GURL("http://cnn.com"), form.action);
766 766
767 const std::vector<FormField>& fields = form.fields; 767 const std::vector<FormField>& fields = form.fields;
768 ASSERT_EQ(3U, fields.size()); 768 ASSERT_EQ(3U, fields.size());
769 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), 769 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
770 ASCIIToUTF16("firstname"), 770 ASCIIToUTF16("firstname"),
771 ASCIIToUTF16("John"), 771 ASCIIToUTF16("John"),
772 ASCIIToUTF16("text"), 772 ASCIIToUTF16("text"),
773 0), 773 20),
774 fields[0]); 774 fields[0]);
775 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 775 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
776 ASCIIToUTF16("lastname"), 776 ASCIIToUTF16("lastname"),
777 ASCIIToUTF16("Smith"), 777 ASCIIToUTF16("Smith"),
778 ASCIIToUTF16("text"), 778 ASCIIToUTF16("text"),
779 0), 779 20),
780 fields[1]); 780 fields[1]);
781 EXPECT_EQ(FormField(string16(), 781 EXPECT_EQ(FormField(string16(),
782 ASCIIToUTF16("reply-send"), 782 ASCIIToUTF16("reply-send"),
783 ASCIIToUTF16("Send"), 783 ASCIIToUTF16("Send"),
784 ASCIIToUTF16("submit"), 784 ASCIIToUTF16("submit"),
785 0), 785 0),
786 fields[2]); 786 fields[2]);
787 } 787 }
788 788
789 TEST_F(FormManagerTest, LabelsInferredFromTableCellNested) { 789 TEST_F(FormManagerTest, LabelsInferredFromTableCellNested) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 839 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
840 EXPECT_EQ(GURL(web_frame->url()), form.origin); 840 EXPECT_EQ(GURL(web_frame->url()), form.origin);
841 EXPECT_EQ(GURL("http://cnn.com"), form.action); 841 EXPECT_EQ(GURL("http://cnn.com"), form.action);
842 842
843 const std::vector<FormField>& fields = form.fields; 843 const std::vector<FormField>& fields = form.fields;
844 ASSERT_EQ(3U, fields.size()); 844 ASSERT_EQ(3U, fields.size());
845 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), 845 EXPECT_EQ(FormField(ASCIIToUTF16("First name:"),
846 ASCIIToUTF16("firstname"), 846 ASCIIToUTF16("firstname"),
847 ASCIIToUTF16("John"), 847 ASCIIToUTF16("John"),
848 ASCIIToUTF16("text"), 848 ASCIIToUTF16("text"),
849 0), 849 20),
850 fields[0]); 850 fields[0]);
851 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), 851 EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"),
852 ASCIIToUTF16("lastname"), 852 ASCIIToUTF16("lastname"),
853 ASCIIToUTF16("Smith"), 853 ASCIIToUTF16("Smith"),
854 ASCIIToUTF16("text"), 854 ASCIIToUTF16("text"),
855 0), 855 20),
856 fields[1]); 856 fields[1]);
857 EXPECT_EQ(FormField(string16(), 857 EXPECT_EQ(FormField(string16(),
858 ASCIIToUTF16("reply-send"), 858 ASCIIToUTF16("reply-send"),
859 ASCIIToUTF16("Send"), 859 ASCIIToUTF16("Send"),
860 ASCIIToUTF16("submit"), 860 ASCIIToUTF16("submit"),
861 0), 861 0),
862 fields[2]); 862 fields[2]);
863 } 863 }
864 864
865 TEST_F(FormManagerTest, LabelsInferredWithSameName) { 865 TEST_F(FormManagerTest, LabelsInferredWithSameName) {
(...skipping 19 matching lines...) Expand all
885 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 885 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
886 EXPECT_EQ(GURL(web_frame->url()), form.origin); 886 EXPECT_EQ(GURL(web_frame->url()), form.origin);
887 EXPECT_EQ(GURL("http://cnn.com"), form.action); 887 EXPECT_EQ(GURL("http://cnn.com"), form.action);
888 888
889 const std::vector<FormField>& fields = form.fields; 889 const std::vector<FormField>& fields = form.fields;
890 ASSERT_EQ(3U, fields.size()); 890 ASSERT_EQ(3U, fields.size());
891 EXPECT_EQ(FormField(ASCIIToUTF16("Address Line 1:"), 891 EXPECT_EQ(FormField(ASCIIToUTF16("Address Line 1:"),
892 ASCIIToUTF16("Address"), 892 ASCIIToUTF16("Address"),
893 string16(), 893 string16(),
894 ASCIIToUTF16("text"), 894 ASCIIToUTF16("text"),
895 0), 895 20),
896 fields[0]); 896 fields[0]);
897 EXPECT_EQ(FormField(ASCIIToUTF16("Address Line 2:"), 897 EXPECT_EQ(FormField(ASCIIToUTF16("Address Line 2:"),
898 ASCIIToUTF16("Address"), 898 ASCIIToUTF16("Address"),
899 string16(), 899 string16(),
900 ASCIIToUTF16("text"), 900 ASCIIToUTF16("text"),
901 0), 901 20),
902 fields[1]); 902 fields[1]);
903 EXPECT_EQ(FormField(string16(), 903 EXPECT_EQ(FormField(string16(),
904 ASCIIToUTF16("reply-send"), 904 ASCIIToUTF16("reply-send"),
905 ASCIIToUTF16("Send"), 905 ASCIIToUTF16("Send"),
906 ASCIIToUTF16("submit"), 906 ASCIIToUTF16("submit"),
907 0), 907 0),
908 fields[2]); 908 fields[2]);
909 } 909 }
910 910
911 TEST_F(FormManagerTest, LabelsInferredWithImageTags) { 911 TEST_F(FormManagerTest, LabelsInferredWithImageTags) {
(...skipping 29 matching lines...) Expand all
941 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 941 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
942 EXPECT_EQ(GURL(frame->url()), form.origin); 942 EXPECT_EQ(GURL(frame->url()), form.origin);
943 EXPECT_EQ(GURL("http://cnn.com"), form.action); 943 EXPECT_EQ(GURL("http://cnn.com"), form.action);
944 944
945 const std::vector<FormField>& fields = form.fields; 945 const std::vector<FormField>& fields = form.fields;
946 ASSERT_EQ(6U, fields.size()); 946 ASSERT_EQ(6U, fields.size());
947 EXPECT_EQ(FormField(ASCIIToUTF16("Phone:"), 947 EXPECT_EQ(FormField(ASCIIToUTF16("Phone:"),
948 ASCIIToUTF16("dayphone1"), 948 ASCIIToUTF16("dayphone1"),
949 string16(), 949 string16(),
950 ASCIIToUTF16("text"), 950 ASCIIToUTF16("text"),
951 0), 951 20),
952 fields[0]); 952 fields[0]);
953 EXPECT_EQ(FormField(ASCIIToUTF16("-"), 953 EXPECT_EQ(FormField(ASCIIToUTF16("-"),
954 ASCIIToUTF16("dayphone2"), 954 ASCIIToUTF16("dayphone2"),
955 string16(), 955 string16(),
956 ASCIIToUTF16("text"), 956 ASCIIToUTF16("text"),
957 0), 957 20),
958 fields[1]); 958 fields[1]);
959 EXPECT_EQ(FormField(ASCIIToUTF16("-"), 959 EXPECT_EQ(FormField(ASCIIToUTF16("-"),
960 ASCIIToUTF16("dayphone3"), 960 ASCIIToUTF16("dayphone3"),
961 string16(), 961 string16(),
962 ASCIIToUTF16("text"), 962 ASCIIToUTF16("text"),
963 0), 963 20),
964 fields[2]); 964 fields[2]);
965 EXPECT_EQ(FormField(ASCIIToUTF16("ext.:"), 965 EXPECT_EQ(FormField(ASCIIToUTF16("ext.:"),
966 ASCIIToUTF16("dayphone4"), 966 ASCIIToUTF16("dayphone4"),
967 string16(), 967 string16(),
968 ASCIIToUTF16("text"), 968 ASCIIToUTF16("text"),
969 0), 969 20),
970 fields[3]); 970 fields[3]);
971 EXPECT_EQ(FormField(string16(), 971 EXPECT_EQ(FormField(string16(),
972 ASCIIToUTF16("dummy"), 972 ASCIIToUTF16("dummy"),
973 string16(), 973 string16(),
974 ASCIIToUTF16("text"), 974 ASCIIToUTF16("text"),
975 0), 975 20),
976 fields[4]); 976 fields[4]);
977 EXPECT_EQ(FormField(string16(), 977 EXPECT_EQ(FormField(string16(),
978 ASCIIToUTF16("reply-send"), 978 ASCIIToUTF16("reply-send"),
979 ASCIIToUTF16("Send"), 979 ASCIIToUTF16("Send"),
980 ASCIIToUTF16("submit"), 980 ASCIIToUTF16("submit"),
981 0), 981 0),
982 fields[5]); 982 fields[5]);
983 } 983 }
984 984
985 TEST_F(FormManagerTest, FillFormMaxLength) { 985 TEST_F(FormManagerTest, FillFormMaxLength) {
(...skipping 25 matching lines...) Expand all
1011 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 1011 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
1012 EXPECT_EQ(GURL(web_frame->url()), form.origin); 1012 EXPECT_EQ(GURL(web_frame->url()), form.origin);
1013 EXPECT_EQ(GURL("http://buh.com"), form.action); 1013 EXPECT_EQ(GURL("http://buh.com"), form.action);
1014 1014
1015 const std::vector<FormField>& fields = form.fields; 1015 const std::vector<FormField>& fields = form.fields;
1016 ASSERT_EQ(3U, fields.size()); 1016 ASSERT_EQ(3U, fields.size());
1017 EXPECT_EQ(FormField(string16(), 1017 EXPECT_EQ(FormField(string16(),
1018 ASCIIToUTF16("firstname"), 1018 ASCIIToUTF16("firstname"),
1019 string16(), 1019 string16(),
1020 ASCIIToUTF16("text"), 1020 ASCIIToUTF16("text"),
1021 0), 1021 20),
1022 fields[0]); 1022 fields[0]);
1023 EXPECT_EQ(FormField(string16(), 1023 EXPECT_EQ(FormField(string16(),
1024 ASCIIToUTF16("lastname"), 1024 ASCIIToUTF16("lastname"),
1025 string16(), 1025 string16(),
1026 ASCIIToUTF16("text"), 1026 ASCIIToUTF16("text"),
1027 0), 1027 20),
1028 fields[1]); 1028 fields[1]);
1029 EXPECT_EQ(FormField(string16(), 1029 EXPECT_EQ(FormField(string16(),
1030 ASCIIToUTF16("reply-send"), 1030 ASCIIToUTF16("reply-send"),
1031 ASCIIToUTF16("Send"), 1031 ASCIIToUTF16("Send"),
1032 ASCIIToUTF16("submit"), 1032 ASCIIToUTF16("submit"),
1033 0), 1033 0),
1034 fields[2]); 1034 fields[2]);
1035 1035
1036 // Fill the form. 1036 // Fill the form.
1037 form.fields[0].set_value(ASCIIToUTF16("Brother")); 1037 form.fields[0].set_value(ASCIIToUTF16("Brother"));
1038 form.fields[1].set_value(ASCIIToUTF16("Jonathan")); 1038 form.fields[1].set_value(ASCIIToUTF16("Jonathan"));
1039 EXPECT_TRUE(form_manager.FillForm(form)); 1039 EXPECT_TRUE(form_manager.FillForm(form));
1040 1040
1041 // Find the newly-filled form that contains the input element. 1041 // Find the newly-filled form that contains the input element.
1042 FormData form2; 1042 FormData form2;
1043 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1043 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1044 input_element, FormManager::REQUIRE_NONE, &form2)); 1044 input_element, FormManager::REQUIRE_NONE, &form2));
1045 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 1045 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
1046 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 1046 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
1047 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1047 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1048 1048
1049 // TODO(jhawkins): We don't actually compare the value of the field in 1049 // TODO(jhawkins): We don't actually compare the value of the field in
1050 // FormField::operator==()! 1050 // FormField::operator==()!
1051 const std::vector<FormField>& fields2 = form2.fields; 1051 const std::vector<FormField>& fields2 = form2.fields;
1052 EXPECT_EQ(FormField(string16(), 1052 EXPECT_EQ(FormField(string16(),
1053 ASCIIToUTF16("firstname"), 1053 ASCIIToUTF16("firstname"),
1054 ASCIIToUTF16("Broth"), 1054 ASCIIToUTF16("Broth"),
1055 ASCIIToUTF16("text"), 1055 ASCIIToUTF16("text"),
1056 0), 1056 20),
1057 fields2[0]); 1057 fields2[0]);
1058 EXPECT_EQ(ASCIIToUTF16("Broth"), fields2[0].value()); 1058 EXPECT_EQ(ASCIIToUTF16("Broth"), fields2[0].value());
1059 EXPECT_EQ(FormField(string16(), 1059 EXPECT_EQ(FormField(string16(),
1060 ASCIIToUTF16("lastname"), 1060 ASCIIToUTF16("lastname"),
1061 ASCIIToUTF16("Jonat"), 1061 ASCIIToUTF16("Jonat"),
1062 ASCIIToUTF16("text"), 1062 ASCIIToUTF16("text"),
1063 0), 1063 20),
1064 fields2[1]); 1064 fields2[1]);
1065 EXPECT_EQ(ASCIIToUTF16("Jonat"), fields2[1].value()); 1065 EXPECT_EQ(ASCIIToUTF16("Jonat"), fields2[1].value());
1066 EXPECT_EQ(FormField(string16(), 1066 EXPECT_EQ(FormField(string16(),
1067 ASCIIToUTF16("reply-send"), 1067 ASCIIToUTF16("reply-send"),
1068 ASCIIToUTF16("Send"), 1068 ASCIIToUTF16("Send"),
1069 ASCIIToUTF16("submit"), 1069 ASCIIToUTF16("submit"),
1070 0), 1070 0),
1071 fields2[2]); 1071 fields2[2]);
1072 } 1072 }
1073 1073
(...skipping 29 matching lines...) Expand all
1103 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 1103 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
1104 EXPECT_EQ(GURL(web_frame->url()), form.origin); 1104 EXPECT_EQ(GURL(web_frame->url()), form.origin);
1105 EXPECT_EQ(GURL("http://buh.com"), form.action); 1105 EXPECT_EQ(GURL("http://buh.com"), form.action);
1106 1106
1107 const std::vector<FormField>& fields = form.fields; 1107 const std::vector<FormField>& fields = form.fields;
1108 ASSERT_EQ(3U, fields.size()); 1108 ASSERT_EQ(3U, fields.size());
1109 EXPECT_EQ(FormField(string16(), 1109 EXPECT_EQ(FormField(string16(),
1110 ASCIIToUTF16("firstname"), 1110 ASCIIToUTF16("firstname"),
1111 string16(), 1111 string16(),
1112 ASCIIToUTF16("text"), 1112 ASCIIToUTF16("text"),
1113 0), 1113 20),
1114 fields[0]); 1114 fields[0]);
1115 EXPECT_EQ(FormField(string16(), 1115 EXPECT_EQ(FormField(string16(),
1116 ASCIIToUTF16("lastname"), 1116 ASCIIToUTF16("lastname"),
1117 string16(), 1117 string16(),
1118 ASCIIToUTF16("text"), 1118 ASCIIToUTF16("text"),
1119 0), 1119 20),
1120 fields[1]); 1120 fields[1]);
1121 EXPECT_EQ(FormField(string16(), 1121 EXPECT_EQ(FormField(string16(),
1122 ASCIIToUTF16("reply-send"), 1122 ASCIIToUTF16("reply-send"),
1123 ASCIIToUTF16("Send"), 1123 ASCIIToUTF16("Send"),
1124 ASCIIToUTF16("submit"), 1124 ASCIIToUTF16("submit"),
1125 0), 1125 0),
1126 fields[2]); 1126 fields[2]);
1127 1127
1128 // Fill the form. 1128 // Fill the form.
1129 form.fields[0].set_value(ASCIIToUTF16("Brother")); 1129 form.fields[0].set_value(ASCIIToUTF16("Brother"));
1130 form.fields[1].set_value(ASCIIToUTF16("Jonathan")); 1130 form.fields[1].set_value(ASCIIToUTF16("Jonathan"));
1131 EXPECT_TRUE(form_manager.FillForm(form)); 1131 EXPECT_TRUE(form_manager.FillForm(form));
1132 1132
1133 // Find the newly-filled form that contains the input element. 1133 // Find the newly-filled form that contains the input element.
1134 FormData form2; 1134 FormData form2;
1135 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1135 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1136 input_element, FormManager::REQUIRE_NONE, &form2)); 1136 input_element, FormManager::REQUIRE_NONE, &form2));
1137 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 1137 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
1138 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 1138 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
1139 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1139 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1140 1140
1141 // TODO(jhawkins): We don't actually compare the value of the field in 1141 // TODO(jhawkins): We don't actually compare the value of the field in
1142 // FormField::operator==()! 1142 // FormField::operator==()!
1143 const std::vector<FormField>& fields2 = form2.fields; 1143 const std::vector<FormField>& fields2 = form2.fields;
1144 ASSERT_EQ(3U, fields2.size()); 1144 ASSERT_EQ(3U, fields2.size());
1145 EXPECT_EQ(FormField(string16(), 1145 EXPECT_EQ(FormField(string16(),
1146 ASCIIToUTF16("firstname"), 1146 ASCIIToUTF16("firstname"),
1147 ASCIIToUTF16("Brother"), 1147 ASCIIToUTF16("Brother"),
1148 ASCIIToUTF16("text"), 1148 ASCIIToUTF16("text"),
1149 0), 1149 20),
1150 fields2[0]); 1150 fields2[0]);
1151 EXPECT_EQ(ASCIIToUTF16("Brother"), fields2[0].value()); 1151 EXPECT_EQ(ASCIIToUTF16("Brother"), fields2[0].value());
1152 EXPECT_EQ(FormField(string16(), 1152 EXPECT_EQ(FormField(string16(),
1153 ASCIIToUTF16("lastname"), 1153 ASCIIToUTF16("lastname"),
1154 ASCIIToUTF16("Jonathan"), 1154 ASCIIToUTF16("Jonathan"),
1155 ASCIIToUTF16("text"), 1155 ASCIIToUTF16("text"),
1156 0), 1156 20),
1157 fields2[1]); 1157 fields2[1]);
1158 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields2[1].value()); 1158 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields2[1].value());
1159 EXPECT_EQ(FormField(string16(), 1159 EXPECT_EQ(FormField(string16(),
1160 ASCIIToUTF16("reply-send"), 1160 ASCIIToUTF16("reply-send"),
1161 ASCIIToUTF16("Send"), 1161 ASCIIToUTF16("Send"),
1162 ASCIIToUTF16("submit"), 1162 ASCIIToUTF16("submit"),
1163 0), 1163 0),
1164 fields2[2]); 1164 fields2[2]);
1165 } 1165 }
1166 1166
(...skipping 26 matching lines...) Expand all
1193 // middlename 1193 // middlename
1194 // second 1194 // second
1195 // lastname 1195 // lastname
1196 // postfix 1196 // postfix
1197 FormData* form = &forms[0]; 1197 FormData* form = &forms[0];
1198 1198
1199 FormField field1(string16(), 1199 FormField field1(string16(),
1200 ASCIIToUTF16("prefix"), 1200 ASCIIToUTF16("prefix"),
1201 string16(), 1201 string16(),
1202 ASCIIToUTF16("text"), 1202 ASCIIToUTF16("text"),
1203 0); 1203 20);
1204 form->fields.insert(form->fields.begin(), field1); 1204 form->fields.insert(form->fields.begin(), field1);
1205 1205
1206 FormField field2(string16(), 1206 FormField field2(string16(),
1207 ASCIIToUTF16("hidden"), 1207 ASCIIToUTF16("hidden"),
1208 string16(), 1208 string16(),
1209 ASCIIToUTF16("text"), 1209 ASCIIToUTF16("text"),
1210 0); 1210 20);
1211 form->fields.insert(form->fields.begin() + 2, field2); 1211 form->fields.insert(form->fields.begin() + 2, field2);
1212 1212
1213 FormField field3(string16(), 1213 FormField field3(string16(),
1214 ASCIIToUTF16("second"), 1214 ASCIIToUTF16("second"),
1215 string16(), 1215 string16(),
1216 ASCIIToUTF16("text"), 1216 ASCIIToUTF16("text"),
1217 0); 1217 20);
1218 form->fields.insert(form->fields.begin() + 4, field3); 1218 form->fields.insert(form->fields.begin() + 4, field3);
1219 1219
1220 FormField field4(string16(), 1220 FormField field4(string16(),
1221 ASCIIToUTF16("postfix"), 1221 ASCIIToUTF16("postfix"),
1222 string16(), 1222 string16(),
1223 ASCIIToUTF16("text"), 1223 ASCIIToUTF16("text"),
1224 0); 1224 20);
1225 form->fields.insert(form->fields.begin() + 6, field4); 1225 form->fields.insert(form->fields.begin() + 6, field4);
1226 1226
1227 // Fill the form. 1227 // Fill the form.
1228 form->fields[0].set_value(ASCIIToUTF16("Alpha")); 1228 form->fields[0].set_value(ASCIIToUTF16("Alpha"));
1229 form->fields[1].set_value(ASCIIToUTF16("Brother")); 1229 form->fields[1].set_value(ASCIIToUTF16("Brother"));
1230 form->fields[2].set_value(ASCIIToUTF16("Abracadabra")); 1230 form->fields[2].set_value(ASCIIToUTF16("Abracadabra"));
1231 form->fields[3].set_value(ASCIIToUTF16("Joseph")); 1231 form->fields[3].set_value(ASCIIToUTF16("Joseph"));
1232 form->fields[4].set_value(ASCIIToUTF16("Beta")); 1232 form->fields[4].set_value(ASCIIToUTF16("Beta"));
1233 form->fields[5].set_value(ASCIIToUTF16("Jonathan")); 1233 form->fields[5].set_value(ASCIIToUTF16("Jonathan"));
1234 form->fields[6].set_value(ASCIIToUTF16("Omega")); 1234 form->fields[6].set_value(ASCIIToUTF16("Omega"));
(...skipping 12 matching lines...) Expand all
1247 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1247 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1248 1248
1249 // TODO(jhawkins): We don't actually compare the value of the field in 1249 // TODO(jhawkins): We don't actually compare the value of the field in
1250 // FormField::operator==()! 1250 // FormField::operator==()!
1251 const std::vector<FormField>& fields = form2.fields; 1251 const std::vector<FormField>& fields = form2.fields;
1252 ASSERT_EQ(4U, fields.size()); 1252 ASSERT_EQ(4U, fields.size());
1253 EXPECT_EQ(FormField(string16(), 1253 EXPECT_EQ(FormField(string16(),
1254 ASCIIToUTF16("firstname"), 1254 ASCIIToUTF16("firstname"),
1255 ASCIIToUTF16("Brother"), 1255 ASCIIToUTF16("Brother"),
1256 ASCIIToUTF16("text"), 1256 ASCIIToUTF16("text"),
1257 0), 1257 20),
1258 fields[0]); 1258 fields[0]);
1259 EXPECT_EQ(ASCIIToUTF16("Brother"), fields[0].value()); 1259 EXPECT_EQ(ASCIIToUTF16("Brother"), fields[0].value());
1260 EXPECT_EQ(FormField(string16(), 1260 EXPECT_EQ(FormField(string16(),
1261 ASCIIToUTF16("middlename"), 1261 ASCIIToUTF16("middlename"),
1262 ASCIIToUTF16("Joseph"), 1262 ASCIIToUTF16("Joseph"),
1263 ASCIIToUTF16("text"), 1263 ASCIIToUTF16("text"),
1264 0), 1264 20),
1265 fields[1]); 1265 fields[1]);
1266 EXPECT_EQ(ASCIIToUTF16("Joseph"), fields[1].value()); 1266 EXPECT_EQ(ASCIIToUTF16("Joseph"), fields[1].value());
1267 EXPECT_EQ(FormField(string16(), 1267 EXPECT_EQ(FormField(string16(),
1268 ASCIIToUTF16("lastname"), 1268 ASCIIToUTF16("lastname"),
1269 ASCIIToUTF16("Jonathan"), 1269 ASCIIToUTF16("Jonathan"),
1270 ASCIIToUTF16("text"), 1270 ASCIIToUTF16("text"),
1271 0), 1271 20),
1272 fields[2]); 1272 fields[2]);
1273 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields[2].value()); 1273 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields[2].value());
1274 EXPECT_EQ(FormField(string16(), 1274 EXPECT_EQ(FormField(string16(),
1275 ASCIIToUTF16("reply-send"), 1275 ASCIIToUTF16("reply-send"),
1276 ASCIIToUTF16("Send"), 1276 ASCIIToUTF16("Send"),
1277 ASCIIToUTF16("submit"), 1277 ASCIIToUTF16("submit"),
1278 0), 1278 0),
1279 fields[3]); 1279 fields[3]);
1280 } 1280 }
1281 1281
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1334 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1335 1335
1336 // TODO(jhawkins): We don't actually compare the value of the field in 1336 // TODO(jhawkins): We don't actually compare the value of the field in
1337 // FormField::operator==()! 1337 // FormField::operator==()!
1338 const std::vector<FormField>& fields = form2.fields; 1338 const std::vector<FormField>& fields = form2.fields;
1339 ASSERT_EQ(8U, fields.size()); 1339 ASSERT_EQ(8U, fields.size());
1340 EXPECT_EQ(FormField(string16(), 1340 EXPECT_EQ(FormField(string16(),
1341 ASCIIToUTF16("prefix"), 1341 ASCIIToUTF16("prefix"),
1342 string16(), 1342 string16(),
1343 ASCIIToUTF16("text"), 1343 ASCIIToUTF16("text"),
1344 0), 1344 20),
1345 fields[0]); 1345 fields[0]);
1346 EXPECT_EQ(string16(), fields[0].value()); 1346 EXPECT_EQ(string16(), fields[0].value());
1347 EXPECT_EQ(FormField(string16(), 1347 EXPECT_EQ(FormField(string16(),
1348 ASCIIToUTF16("firstname"), 1348 ASCIIToUTF16("firstname"),
1349 ASCIIToUTF16("Brother"), 1349 ASCIIToUTF16("Brother"),
1350 ASCIIToUTF16("text"), 1350 ASCIIToUTF16("text"),
1351 0), 1351 20),
1352 fields[1]); 1352 fields[1]);
1353 EXPECT_EQ(ASCIIToUTF16("Brother"), fields[1].value()); 1353 EXPECT_EQ(ASCIIToUTF16("Brother"), fields[1].value());
1354 EXPECT_EQ(FormField(string16(), 1354 EXPECT_EQ(FormField(string16(),
1355 ASCIIToUTF16("hidden"), 1355 ASCIIToUTF16("hidden"),
1356 string16(), 1356 string16(),
1357 ASCIIToUTF16("text"), 1357 ASCIIToUTF16("text"),
1358 0), 1358 20),
1359 fields[2]); 1359 fields[2]);
1360 EXPECT_EQ(string16(), fields[2].value()); 1360 EXPECT_EQ(string16(), fields[2].value());
1361 EXPECT_EQ(FormField(string16(), 1361 EXPECT_EQ(FormField(string16(),
1362 ASCIIToUTF16("middlename"), 1362 ASCIIToUTF16("middlename"),
1363 ASCIIToUTF16("Joseph"), 1363 ASCIIToUTF16("Joseph"),
1364 ASCIIToUTF16("text"), 1364 ASCIIToUTF16("text"),
1365 0), 1365 20),
1366 fields[3]); 1366 fields[3]);
1367 EXPECT_EQ(ASCIIToUTF16("Joseph"), fields[3].value()); 1367 EXPECT_EQ(ASCIIToUTF16("Joseph"), fields[3].value());
1368 EXPECT_EQ(FormField(string16(), 1368 EXPECT_EQ(FormField(string16(),
1369 ASCIIToUTF16("second"), 1369 ASCIIToUTF16("second"),
1370 string16(), 1370 string16(),
1371 ASCIIToUTF16("text"), 1371 ASCIIToUTF16("text"),
1372 0), 1372 20),
1373 fields[4]); 1373 fields[4]);
1374 EXPECT_EQ(string16(), fields[4].value()); 1374 EXPECT_EQ(string16(), fields[4].value());
1375 EXPECT_EQ(FormField(string16(), 1375 EXPECT_EQ(FormField(string16(),
1376 ASCIIToUTF16("lastname"), 1376 ASCIIToUTF16("lastname"),
1377 ASCIIToUTF16("Jonathan"), 1377 ASCIIToUTF16("Jonathan"),
1378 ASCIIToUTF16("text"), 1378 ASCIIToUTF16("text"),
1379 0), 1379 20),
1380 fields[5]); 1380 fields[5]);
1381 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields[5].value()); 1381 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields[5].value());
1382 EXPECT_EQ(FormField(string16(), 1382 EXPECT_EQ(FormField(string16(),
1383 ASCIIToUTF16("postfix"), 1383 ASCIIToUTF16("postfix"),
1384 string16(), 1384 string16(),
1385 ASCIIToUTF16("text"), 1385 ASCIIToUTF16("text"),
1386 0), 1386 20),
1387 fields[6]); 1387 fields[6]);
1388 EXPECT_EQ(string16(), fields[6].value()); 1388 EXPECT_EQ(string16(), fields[6].value());
1389 EXPECT_EQ(FormField(string16(), 1389 EXPECT_EQ(FormField(string16(),
1390 ASCIIToUTF16("reply-send"), 1390 ASCIIToUTF16("reply-send"),
1391 ASCIIToUTF16("Send"), 1391 ASCIIToUTF16("Send"),
1392 ASCIIToUTF16("submit"), 1392 ASCIIToUTF16("submit"),
1393 0), 1393 0),
1394 fields[7]); 1394 fields[7]);
1395 } 1395 }
1396 1396
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1443 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1444 1444
1445 // TODO(jhawkins): We don't actually compare the value of the field in 1445 // TODO(jhawkins): We don't actually compare the value of the field in
1446 // FormField::operator==()! 1446 // FormField::operator==()!
1447 const std::vector<FormField>& fields = form2.fields; 1447 const std::vector<FormField>& fields = form2.fields;
1448 ASSERT_EQ(5U, fields.size()); 1448 ASSERT_EQ(5U, fields.size());
1449 EXPECT_EQ(FormField(string16(), 1449 EXPECT_EQ(FormField(string16(),
1450 ASCIIToUTF16("firstname"), 1450 ASCIIToUTF16("firstname"),
1451 ASCIIToUTF16("Brother"), 1451 ASCIIToUTF16("Brother"),
1452 ASCIIToUTF16("text"), 1452 ASCIIToUTF16("text"),
1453 0), 1453 20),
1454 fields[0]); 1454 fields[0]);
1455 EXPECT_EQ(ASCIIToUTF16("Brother"), fields[0].value()); 1455 EXPECT_EQ(ASCIIToUTF16("Brother"), fields[0].value());
1456 EXPECT_EQ(FormField(string16(), 1456 EXPECT_EQ(FormField(string16(),
1457 ASCIIToUTF16("middlename"), 1457 ASCIIToUTF16("middlename"),
1458 ASCIIToUTF16("Joseph"), 1458 ASCIIToUTF16("Joseph"),
1459 ASCIIToUTF16("text"), 1459 ASCIIToUTF16("text"),
1460 0), 1460 20),
1461 fields[1]); 1461 fields[1]);
1462 EXPECT_EQ(ASCIIToUTF16("Joseph"), fields[1].value()); 1462 EXPECT_EQ(ASCIIToUTF16("Joseph"), fields[1].value());
1463 EXPECT_EQ(FormField(string16(), 1463 EXPECT_EQ(FormField(string16(),
1464 ASCIIToUTF16("lastname"), 1464 ASCIIToUTF16("lastname"),
1465 ASCIIToUTF16("Jonathan"), 1465 ASCIIToUTF16("Jonathan"),
1466 ASCIIToUTF16("text"), 1466 ASCIIToUTF16("text"),
1467 0), 1467 20),
1468 fields[2]); 1468 fields[2]);
1469 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields[2].value()); 1469 EXPECT_EQ(ASCIIToUTF16("Jonathan"), fields[2].value());
1470 EXPECT_EQ(FormField(string16(), 1470 EXPECT_EQ(FormField(string16(),
1471 ASCIIToUTF16("postfix"), 1471 ASCIIToUTF16("postfix"),
1472 string16(), 1472 string16(),
1473 ASCIIToUTF16("text"), 1473 ASCIIToUTF16("text"),
1474 0), 1474 20),
1475 fields[3]); 1475 fields[3]);
1476 EXPECT_EQ(string16(), fields[3].value()); 1476 EXPECT_EQ(string16(), fields[3].value());
1477 EXPECT_EQ(FormField(string16(), 1477 EXPECT_EQ(FormField(string16(),
1478 ASCIIToUTF16("reply-send"), 1478 ASCIIToUTF16("reply-send"),
1479 ASCIIToUTF16("Send"), 1479 ASCIIToUTF16("Send"),
1480 ASCIIToUTF16("submit"), 1480 ASCIIToUTF16("submit"),
1481 0), 1481 0),
1482 fields[4]); 1482 fields[4]);
1483 } 1483 }
1484 1484
(...skipping 26 matching lines...) Expand all
1511 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 1511 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
1512 EXPECT_EQ(GURL(web_frame->url()), form.origin); 1512 EXPECT_EQ(GURL(web_frame->url()), form.origin);
1513 EXPECT_EQ(GURL("http://buh.com"), form.action); 1513 EXPECT_EQ(GURL("http://buh.com"), form.action);
1514 1514
1515 const std::vector<FormField>& fields = form.fields; 1515 const std::vector<FormField>& fields = form.fields;
1516 ASSERT_EQ(3U, fields.size()); 1516 ASSERT_EQ(3U, fields.size());
1517 EXPECT_EQ(FormField(string16(), 1517 EXPECT_EQ(FormField(string16(),
1518 ASCIIToUTF16("firstname"), 1518 ASCIIToUTF16("firstname"),
1519 string16(), 1519 string16(),
1520 ASCIIToUTF16("text"), 1520 ASCIIToUTF16("text"),
1521 0), 1521 20),
1522 fields[0]); 1522 fields[0]);
1523 EXPECT_EQ(FormField(string16(), 1523 EXPECT_EQ(FormField(string16(),
1524 ASCIIToUTF16("lastname"), 1524 ASCIIToUTF16("lastname"),
1525 string16(), 1525 string16(),
1526 ASCIIToUTF16("text"), 1526 ASCIIToUTF16("text"),
1527 0), 1527 20),
1528 fields[1]); 1528 fields[1]);
1529 EXPECT_EQ(FormField(string16(), 1529 EXPECT_EQ(FormField(string16(),
1530 string16(), 1530 string16(),
1531 ASCIIToUTF16("Send"), 1531 ASCIIToUTF16("Send"),
1532 ASCIIToUTF16("submit"), 1532 ASCIIToUTF16("submit"),
1533 0), 1533 0),
1534 fields[2]); 1534 fields[2]);
1535 1535
1536 // Fill the form. 1536 // Fill the form.
1537 form.fields[0].set_value(ASCIIToUTF16("Wyatt")); 1537 form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
1538 form.fields[1].set_value(ASCIIToUTF16("Earp")); 1538 form.fields[1].set_value(ASCIIToUTF16("Earp"));
1539 EXPECT_TRUE(form_manager.FillForm(form)); 1539 EXPECT_TRUE(form_manager.FillForm(form));
1540 1540
1541 // Find the newly-filled form that contains the input element. 1541 // Find the newly-filled form that contains the input element.
1542 FormData form2; 1542 FormData form2;
1543 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1543 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1544 input_element, FormManager::REQUIRE_NONE, &form2)); 1544 input_element, FormManager::REQUIRE_NONE, &form2));
1545 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 1545 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
1546 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 1546 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
1547 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1547 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1548 1548
1549 const std::vector<FormField>& fields2 = form2.fields; 1549 const std::vector<FormField>& fields2 = form2.fields;
1550 ASSERT_EQ(3U, fields2.size()); 1550 ASSERT_EQ(3U, fields2.size());
1551 EXPECT_EQ(FormField(string16(), 1551 EXPECT_EQ(FormField(string16(),
1552 ASCIIToUTF16("firstname"), 1552 ASCIIToUTF16("firstname"),
1553 ASCIIToUTF16("Wyatt"), 1553 ASCIIToUTF16("Wyatt"),
1554 ASCIIToUTF16("text"), 1554 ASCIIToUTF16("text"),
1555 0), 1555 20),
1556 fields2[0]); 1556 fields2[0]);
1557 EXPECT_EQ(FormField(string16(), 1557 EXPECT_EQ(FormField(string16(),
1558 ASCIIToUTF16("lastname"), 1558 ASCIIToUTF16("lastname"),
1559 ASCIIToUTF16("Earp"), 1559 ASCIIToUTF16("Earp"),
1560 ASCIIToUTF16("text"), 1560 ASCIIToUTF16("text"),
1561 0), 1561 20),
1562 fields2[1]); 1562 fields2[1]);
1563 EXPECT_EQ(FormField(string16(), 1563 EXPECT_EQ(FormField(string16(),
1564 string16(), 1564 string16(),
1565 ASCIIToUTF16("Send"), 1565 ASCIIToUTF16("Send"),
1566 ASCIIToUTF16("submit"), 1566 ASCIIToUTF16("submit"),
1567 0), 1567 0),
1568 fields2[2]); 1568 fields2[2]);
1569 } 1569 }
1570 1570
1571 TEST_F(FormManagerTest, FillFormEmptyFormNames) { 1571 TEST_F(FormManagerTest, FillFormEmptyFormNames) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 EXPECT_EQ(string16(), form.name); 1603 EXPECT_EQ(string16(), form.name);
1604 EXPECT_EQ(GURL(web_frame->url()), form.origin); 1604 EXPECT_EQ(GURL(web_frame->url()), form.origin);
1605 EXPECT_EQ(GURL("http://abc.com"), form.action); 1605 EXPECT_EQ(GURL("http://abc.com"), form.action);
1606 1606
1607 const std::vector<FormField>& fields = form.fields; 1607 const std::vector<FormField>& fields = form.fields;
1608 ASSERT_EQ(3U, fields.size()); 1608 ASSERT_EQ(3U, fields.size());
1609 EXPECT_EQ(FormField(string16(), 1609 EXPECT_EQ(FormField(string16(),
1610 ASCIIToUTF16("apple"), 1610 ASCIIToUTF16("apple"),
1611 string16(), 1611 string16(),
1612 ASCIIToUTF16("text"), 1612 ASCIIToUTF16("text"),
1613 0), 1613 20),
1614 fields[0]); 1614 fields[0]);
1615 EXPECT_EQ(FormField(string16(), 1615 EXPECT_EQ(FormField(string16(),
1616 ASCIIToUTF16("banana"), 1616 ASCIIToUTF16("banana"),
1617 string16(), 1617 string16(),
1618 ASCIIToUTF16("text"), 1618 ASCIIToUTF16("text"),
1619 0), 1619 20),
1620 fields[1]); 1620 fields[1]);
1621 EXPECT_EQ(FormField(string16(), 1621 EXPECT_EQ(FormField(string16(),
1622 string16(), 1622 string16(),
1623 ASCIIToUTF16("Send"), 1623 ASCIIToUTF16("Send"),
1624 ASCIIToUTF16("submit"), 1624 ASCIIToUTF16("submit"),
1625 0), 1625 0),
1626 fields[2]); 1626 fields[2]);
1627 1627
1628 // Fill the form. 1628 // Fill the form.
1629 form.fields[0].set_value(ASCIIToUTF16("Red")); 1629 form.fields[0].set_value(ASCIIToUTF16("Red"));
1630 form.fields[1].set_value(ASCIIToUTF16("Yellow")); 1630 form.fields[1].set_value(ASCIIToUTF16("Yellow"));
1631 EXPECT_TRUE(form_manager.FillForm(form)); 1631 EXPECT_TRUE(form_manager.FillForm(form));
1632 1632
1633 // Find the newly-filled form that contains the input element. 1633 // Find the newly-filled form that contains the input element.
1634 FormData form2; 1634 FormData form2;
1635 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1635 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1636 input_element, FormManager::REQUIRE_NONE, &form2)); 1636 input_element, FormManager::REQUIRE_NONE, &form2));
1637 EXPECT_EQ(string16(), form2.name); 1637 EXPECT_EQ(string16(), form2.name);
1638 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 1638 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
1639 EXPECT_EQ(GURL("http://abc.com"), form2.action); 1639 EXPECT_EQ(GURL("http://abc.com"), form2.action);
1640 1640
1641 const std::vector<FormField>& fields2 = form2.fields; 1641 const std::vector<FormField>& fields2 = form2.fields;
1642 ASSERT_EQ(3U, fields2.size()); 1642 ASSERT_EQ(3U, fields2.size());
1643 EXPECT_EQ(FormField(string16(), 1643 EXPECT_EQ(FormField(string16(),
1644 ASCIIToUTF16("apple"), 1644 ASCIIToUTF16("apple"),
1645 ASCIIToUTF16("Red"), 1645 ASCIIToUTF16("Red"),
1646 ASCIIToUTF16("text"), 1646 ASCIIToUTF16("text"),
1647 0), 1647 20),
1648 fields2[0]); 1648 fields2[0]);
1649 EXPECT_EQ(FormField(string16(), 1649 EXPECT_EQ(FormField(string16(),
1650 ASCIIToUTF16("banana"), 1650 ASCIIToUTF16("banana"),
1651 ASCIIToUTF16("Yellow"), 1651 ASCIIToUTF16("Yellow"),
1652 ASCIIToUTF16("text"), 1652 ASCIIToUTF16("text"),
1653 0), 1653 20),
1654 fields2[1]); 1654 fields2[1]);
1655 EXPECT_EQ(FormField(string16(), 1655 EXPECT_EQ(FormField(string16(),
1656 string16(), 1656 string16(),
1657 ASCIIToUTF16("Send"), 1657 ASCIIToUTF16("Send"),
1658 ASCIIToUTF16("submit"), 1658 ASCIIToUTF16("submit"),
1659 0), 1659 0),
1660 fields2[2]); 1660 fields2[2]);
1661 } 1661 }
1662 1662
1663 TEST_F(FormManagerTest, ThreePartPhone) { 1663 TEST_F(FormManagerTest, ThreePartPhone) {
(...skipping 25 matching lines...) Expand all
1689 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); 1689 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
1690 EXPECT_EQ(GURL(frame->url()), form.origin); 1690 EXPECT_EQ(GURL(frame->url()), form.origin);
1691 EXPECT_EQ(GURL("http://cnn.com"), form.action); 1691 EXPECT_EQ(GURL("http://cnn.com"), form.action);
1692 1692
1693 const std::vector<FormField>& fields = form.fields; 1693 const std::vector<FormField>& fields = form.fields;
1694 ASSERT_EQ(5U, fields.size()); 1694 ASSERT_EQ(5U, fields.size());
1695 EXPECT_EQ(FormField(ASCIIToUTF16("Phone:"), 1695 EXPECT_EQ(FormField(ASCIIToUTF16("Phone:"),
1696 ASCIIToUTF16("dayphone1"), 1696 ASCIIToUTF16("dayphone1"),
1697 string16(), 1697 string16(),
1698 ASCIIToUTF16("text"), 1698 ASCIIToUTF16("text"),
1699 0), 1699 20),
1700 fields[0]); 1700 fields[0]);
1701 EXPECT_EQ(FormField(ASCIIToUTF16("-"), 1701 EXPECT_EQ(FormField(ASCIIToUTF16("-"),
1702 ASCIIToUTF16("dayphone2"), 1702 ASCIIToUTF16("dayphone2"),
1703 string16(), 1703 string16(),
1704 ASCIIToUTF16("text"), 1704 ASCIIToUTF16("text"),
1705 0), 1705 20),
1706 fields[1]); 1706 fields[1]);
1707 EXPECT_EQ(FormField(ASCIIToUTF16("-"), 1707 EXPECT_EQ(FormField(ASCIIToUTF16("-"),
1708 ASCIIToUTF16("dayphone3"), 1708 ASCIIToUTF16("dayphone3"),
1709 string16(), 1709 string16(),
1710 ASCIIToUTF16("text"), 1710 ASCIIToUTF16("text"),
1711 0), 1711 20),
1712 fields[2]); 1712 fields[2]);
1713 EXPECT_EQ(FormField(ASCIIToUTF16("ext.:"), 1713 EXPECT_EQ(FormField(ASCIIToUTF16("ext.:"),
1714 ASCIIToUTF16("dayphone4"), 1714 ASCIIToUTF16("dayphone4"),
1715 string16(), 1715 string16(),
1716 ASCIIToUTF16("text"), 1716 ASCIIToUTF16("text"),
1717 0), 1717 20),
1718 fields[3]); 1718 fields[3]);
1719 EXPECT_EQ(FormField(string16(), 1719 EXPECT_EQ(FormField(string16(),
1720 ASCIIToUTF16("reply-send"), 1720 ASCIIToUTF16("reply-send"),
1721 ASCIIToUTF16("Send"), 1721 ASCIIToUTF16("Send"),
1722 ASCIIToUTF16("submit"), 1722 ASCIIToUTF16("submit"),
1723 0), 1723 0),
1724 fields[4]); 1724 fields[4]);
1725 } 1725 }
1726 1726
1727 1727
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 fields[5]); 1799 fields[5]);
1800 EXPECT_EQ(FormField(string16(), 1800 EXPECT_EQ(FormField(string16(),
1801 ASCIIToUTF16("reply-send"), 1801 ASCIIToUTF16("reply-send"),
1802 ASCIIToUTF16("Send"), 1802 ASCIIToUTF16("Send"),
1803 ASCIIToUTF16("submit"), 1803 ASCIIToUTF16("submit"),
1804 0), 1804 0),
1805 fields[6]); 1805 fields[6]);
1806 } 1806 }
1807 1807
1808 } // namespace 1808 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/form_structure_unittest.cc ('k') | webkit/glue/form_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698