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

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

Issue 6633001: Convert autofill messages to use the new IPC macros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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) 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 <vector> 5 #include <vector>
6 6
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/renderer/autofill/form_manager.h" 10 #include "chrome/renderer/autofill/form_manager.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 FormField result3; 242 FormField result3;
243 FormManager::WebFormControlElementToFormField(element, 243 FormManager::WebFormControlElementToFormField(element,
244 FormManager::EXTRACT_OPTIONS, 244 FormManager::EXTRACT_OPTIONS,
245 &result3); 245 &result3);
246 EXPECT_TRUE(result3.StrictlyEqualsHack(FormField(string16(), 246 EXPECT_TRUE(result3.StrictlyEqualsHack(FormField(string16(),
247 ASCIIToUTF16("element"), 247 ASCIIToUTF16("element"),
248 string16(), 248 string16(),
249 ASCIIToUTF16("select-one"), 249 ASCIIToUTF16("select-one"),
250 0, 250 0,
251 false))); 251 false)));
252 ASSERT_EQ(2U, result3.option_strings().size()); 252 ASSERT_EQ(2U, result3.option_strings.size());
253 EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_strings()[0]); 253 EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_strings[0]);
254 EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_strings()[1]); 254 EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_strings[1]);
255 } 255 }
256 256
257 // We should be not extract the value for non-text and non-select fields. 257 // We should be not extract the value for non-text and non-select fields.
258 TEST_F(FormManagerTest, WebFormControlElementToFormFieldInvalidType) { 258 TEST_F(FormManagerTest, WebFormControlElementToFormFieldInvalidType) {
259 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" 259 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
260 " <INPUT type=\"hidden\" id=\"hidden\" value=\"apple\"/>" 260 " <INPUT type=\"hidden\" id=\"hidden\" value=\"apple\"/>"
261 " <INPUT type=\"password\" id=\"password\" value=\"secret\"/>" 261 " <INPUT type=\"password\" id=\"password\" value=\"secret\"/>"
262 " <INPUT type=\"checkbox\" id=\"checkbox\" value=\"mail\"/>" 262 " <INPUT type=\"checkbox\" id=\"checkbox\" value=\"mail\"/>"
263 " <INPUT type=\"radio\" id=\"radio\" value=\"male\"/>" 263 " <INPUT type=\"radio\" id=\"radio\" value=\"male\"/>"
264 " <INPUT type=\"submit\" id=\"submit\" value=\"Send\"/>" 264 " <INPUT type=\"submit\" id=\"submit\" value=\"Send\"/>"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 fields[3]); 786 fields[3]);
787 EXPECT_EQ(FormField(string16(), 787 EXPECT_EQ(FormField(string16(),
788 ASCIIToUTF16("notenabled"), 788 ASCIIToUTF16("notenabled"),
789 string16(), 789 string16(),
790 ASCIIToUTF16("text"), 790 ASCIIToUTF16("text"),
791 WebInputElement::defaultMaxLength(), 791 WebInputElement::defaultMaxLength(),
792 false), 792 false),
793 fields[4]); 793 fields[4]);
794 794
795 // Fill the form. 795 // Fill the form.
796 form.fields[0].set_value(ASCIIToUTF16("Wyatt")); 796 form.fields[0].value = ASCIIToUTF16("Wyatt");
797 form.fields[1].set_value(ASCIIToUTF16("Earp")); 797 form.fields[1].value = ASCIIToUTF16("Earp");
798 form.fields[2].set_value(ASCIIToUTF16("Alpha")); 798 form.fields[2].value = ASCIIToUTF16("Alpha");
799 form.fields[3].set_value(ASCIIToUTF16("Beta")); 799 form.fields[3].value = ASCIIToUTF16("Beta");
800 form.fields[4].set_value(ASCIIToUTF16("Gamma")); 800 form.fields[4].value = ASCIIToUTF16("Gamma");
801 EXPECT_TRUE(form_manager.FillForm(form, input_element)); 801 EXPECT_TRUE(form_manager.FillForm(form, input_element));
802 802
803 // Verify the filled elements. 803 // Verify the filled elements.
804 WebDocument document = web_frame->document(); 804 WebDocument document = web_frame->document();
805 WebInputElement firstname = 805 WebInputElement firstname =
806 document.getElementById("firstname").to<WebInputElement>(); 806 document.getElementById("firstname").to<WebInputElement>();
807 EXPECT_TRUE(firstname.isAutofilled()); 807 EXPECT_TRUE(firstname.isAutofilled());
808 EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.value()); 808 EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.value());
809 EXPECT_EQ(5, firstname.selectionStart()); 809 EXPECT_EQ(5, firstname.selectionStart());
810 EXPECT_EQ(5, firstname.selectionEnd()); 810 EXPECT_EQ(5, firstname.selectionEnd());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 fields[3]); 898 fields[3]);
899 EXPECT_EQ(FormField(string16(), 899 EXPECT_EQ(FormField(string16(),
900 ASCIIToUTF16("notenabled"), 900 ASCIIToUTF16("notenabled"),
901 string16(), 901 string16(),
902 ASCIIToUTF16("text"), 902 ASCIIToUTF16("text"),
903 WebInputElement::defaultMaxLength(), 903 WebInputElement::defaultMaxLength(),
904 false), 904 false),
905 fields[4]); 905 fields[4]);
906 906
907 // Preview the form. 907 // Preview the form.
908 form.fields[0].set_value(ASCIIToUTF16("Wyatt")); 908 form.fields[0].value = ASCIIToUTF16("Wyatt");
909 form.fields[1].set_value(ASCIIToUTF16("Earp")); 909 form.fields[1].value = ASCIIToUTF16("Earp");
910 form.fields[2].set_value(ASCIIToUTF16("Alpha")); 910 form.fields[2].value = ASCIIToUTF16("Alpha");
911 form.fields[3].set_value(ASCIIToUTF16("Beta")); 911 form.fields[3].value = ASCIIToUTF16("Beta");
912 form.fields[4].set_value(ASCIIToUTF16("Gamma")); 912 form.fields[4].value = ASCIIToUTF16("Gamma");
913 EXPECT_TRUE(form_manager.PreviewForm(form, input_element)); 913 EXPECT_TRUE(form_manager.PreviewForm(form, input_element));
914 914
915 // Verify the previewed elements. 915 // Verify the previewed elements.
916 WebDocument document = web_frame->document(); 916 WebDocument document = web_frame->document();
917 WebInputElement firstname = 917 WebInputElement firstname =
918 document.getElementById("firstname").to<WebInputElement>(); 918 document.getElementById("firstname").to<WebInputElement>();
919 EXPECT_TRUE(firstname.isAutofilled()); 919 EXPECT_TRUE(firstname.isAutofilled());
920 EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.suggestedValue()); 920 EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.suggestedValue());
921 EXPECT_EQ(0, firstname.selectionStart()); 921 EXPECT_EQ(0, firstname.selectionStart());
922 EXPECT_EQ(5, firstname.selectionEnd()); 922 EXPECT_EQ(5, firstname.selectionEnd());
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 fields[1]); 1477 fields[1]);
1478 EXPECT_EQ(FormField(string16(), 1478 EXPECT_EQ(FormField(string16(),
1479 ASCIIToUTF16("email"), 1479 ASCIIToUTF16("email"),
1480 string16(), 1480 string16(),
1481 ASCIIToUTF16("text"), 1481 ASCIIToUTF16("text"),
1482 9, 1482 9,
1483 false), 1483 false),
1484 fields[2]); 1484 fields[2]);
1485 1485
1486 // Fill the form. 1486 // Fill the form.
1487 form.fields[0].set_value(ASCIIToUTF16("Brother")); 1487 form.fields[0].value = ASCIIToUTF16("Brother");
1488 form.fields[1].set_value(ASCIIToUTF16("Jonathan")); 1488 form.fields[1].value = ASCIIToUTF16("Jonathan");
1489 form.fields[2].set_value(ASCIIToUTF16("brotherj@example.com")); 1489 form.fields[2].value = ASCIIToUTF16("brotherj@example.com");
1490 EXPECT_TRUE(form_manager.FillForm(form, WebNode())); 1490 EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
1491 1491
1492 // Find the newly-filled form that contains the input element. 1492 // Find the newly-filled form that contains the input element.
1493 FormData form2; 1493 FormData form2;
1494 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1494 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1495 input_element, FormManager::REQUIRE_NONE, &form2)); 1495 input_element, FormManager::REQUIRE_NONE, &form2));
1496 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 1496 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
1497 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 1497 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
1498 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1498 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1499 1499
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 fields[1]); 1571 fields[1]);
1572 EXPECT_EQ(FormField(string16(), 1572 EXPECT_EQ(FormField(string16(),
1573 ASCIIToUTF16("email"), 1573 ASCIIToUTF16("email"),
1574 string16(), 1574 string16(),
1575 ASCIIToUTF16("text"), 1575 ASCIIToUTF16("text"),
1576 WebInputElement::defaultMaxLength(), 1576 WebInputElement::defaultMaxLength(),
1577 false), 1577 false),
1578 fields[2]); 1578 fields[2]);
1579 1579
1580 // Fill the form. 1580 // Fill the form.
1581 form.fields[0].set_value(ASCIIToUTF16("Brother")); 1581 form.fields[0].value = ASCIIToUTF16("Brother");
1582 form.fields[1].set_value(ASCIIToUTF16("Jonathan")); 1582 form.fields[1].value = ASCIIToUTF16("Jonathan");
1583 form.fields[2].set_value(ASCIIToUTF16("brotherj@example.com")); 1583 form.fields[2].value = ASCIIToUTF16("brotherj@example.com");
1584 EXPECT_TRUE(form_manager.FillForm(form, WebNode())); 1584 EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
1585 1585
1586 // Find the newly-filled form that contains the input element. 1586 // Find the newly-filled form that contains the input element.
1587 FormData form2; 1587 FormData form2;
1588 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1588 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1589 input_element, FormManager::REQUIRE_NONE, &form2)); 1589 input_element, FormManager::REQUIRE_NONE, &form2));
1590 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 1590 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
1591 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 1591 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
1592 EXPECT_EQ(GURL("http://buh.com"), form2.action); 1592 EXPECT_EQ(GURL("http://buh.com"), form2.action);
1593 1593
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 1674
1675 FormField field4(string16(), 1675 FormField field4(string16(),
1676 ASCIIToUTF16("postfix"), 1676 ASCIIToUTF16("postfix"),
1677 string16(), 1677 string16(),
1678 ASCIIToUTF16("text"), 1678 ASCIIToUTF16("text"),
1679 WebInputElement::defaultMaxLength(), 1679 WebInputElement::defaultMaxLength(),
1680 false); 1680 false);
1681 form->fields.insert(form->fields.begin() + 6, field4); 1681 form->fields.insert(form->fields.begin() + 6, field4);
1682 1682
1683 // Fill the form. 1683 // Fill the form.
1684 form->fields[0].set_value(ASCIIToUTF16("Alpha")); 1684 form->fields[0].value = ASCIIToUTF16("Alpha");
1685 form->fields[1].set_value(ASCIIToUTF16("Brother")); 1685 form->fields[1].value = ASCIIToUTF16("Brother");
1686 form->fields[2].set_value(ASCIIToUTF16("Abracadabra")); 1686 form->fields[2].value = ASCIIToUTF16("Abracadabra");
1687 form->fields[3].set_value(ASCIIToUTF16("Joseph")); 1687 form->fields[3].value = ASCIIToUTF16("Joseph");
1688 form->fields[4].set_value(ASCIIToUTF16("Beta")); 1688 form->fields[4].value = ASCIIToUTF16("Beta");
1689 form->fields[5].set_value(ASCIIToUTF16("Jonathan")); 1689 form->fields[5].value = ASCIIToUTF16("Jonathan");
1690 form->fields[6].set_value(ASCIIToUTF16("Omega")); 1690 form->fields[6].value = ASCIIToUTF16("Omega");
1691 EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); 1691 EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
1692 1692
1693 // Get the input element we want to find. 1693 // Get the input element we want to find.
1694 WebElement element = web_frame->document().getElementById("firstname"); 1694 WebElement element = web_frame->document().getElementById("firstname");
1695 WebInputElement input_element = element.to<WebInputElement>(); 1695 WebInputElement input_element = element.to<WebInputElement>();
1696 1696
1697 // Find the newly-filled form that contains the input element. 1697 // Find the newly-filled form that contains the input element.
1698 FormData form2; 1698 FormData form2;
1699 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1699 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1700 input_element, FormManager::REQUIRE_NONE, &form2)); 1700 input_element, FormManager::REQUIRE_NONE, &form2));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 // firstname 1757 // firstname
1758 // middlename 1758 // middlename
1759 // lastname 1759 // lastname
1760 FormData* form = &forms[0]; 1760 FormData* form = &forms[0];
1761 form->fields.erase(form->fields.begin()); 1761 form->fields.erase(form->fields.begin());
1762 form->fields.erase(form->fields.begin() + 1); 1762 form->fields.erase(form->fields.begin() + 1);
1763 form->fields.erase(form->fields.begin() + 2); 1763 form->fields.erase(form->fields.begin() + 2);
1764 form->fields.erase(form->fields.begin() + 3); 1764 form->fields.erase(form->fields.begin() + 3);
1765 1765
1766 // Fill the form. 1766 // Fill the form.
1767 form->fields[0].set_value(ASCIIToUTF16("Brother")); 1767 form->fields[0].value = ASCIIToUTF16("Brother");
1768 form->fields[1].set_value(ASCIIToUTF16("Joseph")); 1768 form->fields[1].value = ASCIIToUTF16("Joseph");
1769 form->fields[2].set_value(ASCIIToUTF16("Jonathan")); 1769 form->fields[2].value = ASCIIToUTF16("Jonathan");
1770 EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); 1770 EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
1771 1771
1772 // Get the input element we want to find. 1772 // Get the input element we want to find.
1773 WebElement element = web_frame->document().getElementById("firstname"); 1773 WebElement element = web_frame->document().getElementById("firstname");
1774 WebInputElement input_element = element.to<WebInputElement>(); 1774 WebInputElement input_element = element.to<WebInputElement>();
1775 1775
1776 // Find the newly-filled form that contains the input element. 1776 // Find the newly-filled form that contains the input element.
1777 FormData form2; 1777 FormData form2;
1778 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1778 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1779 input_element, FormManager::REQUIRE_NONE, &form2)); 1779 input_element, FormManager::REQUIRE_NONE, &form2));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms); 1856 form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
1857 ASSERT_EQ(1U, forms.size()); 1857 ASSERT_EQ(1U, forms.size());
1858 1858
1859 // After the field modification, the fields in |form| will look like: 1859 // After the field modification, the fields in |form| will look like:
1860 // firstname 1860 // firstname
1861 // middlename 1861 // middlename
1862 // lastname 1862 // lastname
1863 FormData* form = &forms[0]; 1863 FormData* form = &forms[0];
1864 1864
1865 // Fill the form. 1865 // Fill the form.
1866 form->fields[0].set_value(ASCIIToUTF16("Brother")); 1866 form->fields[0].value = ASCIIToUTF16("Brother");
1867 form->fields[1].set_value(ASCIIToUTF16("Joseph")); 1867 form->fields[1].value = ASCIIToUTF16("Joseph");
1868 form->fields[2].set_value(ASCIIToUTF16("Jonathan")); 1868 form->fields[2].value = ASCIIToUTF16("Jonathan");
1869 1869
1870 // Alter the label and name used for matching. 1870 // Alter the label and name used for matching.
1871 form->fields[1].set_label(ASCIIToUTF16("bogus")); 1871 form->fields[1].label = ASCIIToUTF16("bogus");
1872 form->fields[1].set_name(ASCIIToUTF16("bogus")); 1872 form->fields[1].name = ASCIIToUTF16("bogus");
1873 1873
1874 EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); 1874 EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
1875 1875
1876 // Get the input element we want to find. 1876 // Get the input element we want to find.
1877 WebElement element = web_frame->document().getElementById("firstname"); 1877 WebElement element = web_frame->document().getElementById("firstname");
1878 WebInputElement input_element = element.to<WebInputElement>(); 1878 WebInputElement input_element = element.to<WebInputElement>();
1879 1879
1880 // Find the newly-filled form that contains the input element. 1880 // Find the newly-filled form that contains the input element.
1881 FormData form2; 1881 FormData form2;
1882 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1882 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 ASSERT_EQ(1U, forms.size()); 1931 ASSERT_EQ(1U, forms.size());
1932 1932
1933 // After the field modification, the fields in |form| will look like: 1933 // After the field modification, the fields in |form| will look like:
1934 // firstname 1934 // firstname
1935 // middlename 1935 // middlename
1936 // lastname 1936 // lastname
1937 FormData* form = &forms[0]; 1937 FormData* form = &forms[0];
1938 form->fields.pop_back(); 1938 form->fields.pop_back();
1939 1939
1940 // Fill the form. 1940 // Fill the form.
1941 form->fields[0].set_value(ASCIIToUTF16("Brother")); 1941 form->fields[0].value = ASCIIToUTF16("Brother");
1942 form->fields[1].set_value(ASCIIToUTF16("Joseph")); 1942 form->fields[1].value = ASCIIToUTF16("Joseph");
1943 form->fields[2].set_value(ASCIIToUTF16("Jonathan")); 1943 form->fields[2].value = ASCIIToUTF16("Jonathan");
1944 EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); 1944 EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
1945 1945
1946 // Get the input element we want to find. 1946 // Get the input element we want to find.
1947 WebElement element = web_frame->document().getElementById("firstname"); 1947 WebElement element = web_frame->document().getElementById("firstname");
1948 WebInputElement input_element = element.to<WebInputElement>(); 1948 WebInputElement input_element = element.to<WebInputElement>();
1949 1949
1950 // Find the newly-filled form that contains the input element. 1950 // Find the newly-filled form that contains the input element.
1951 FormData form2; 1951 FormData form2;
1952 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 1952 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
1953 input_element, FormManager::REQUIRE_NONE, &form2)); 1953 input_element, FormManager::REQUIRE_NONE, &form2));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 fields[1]); 2036 fields[1]);
2037 EXPECT_EQ(FormField(string16(), 2037 EXPECT_EQ(FormField(string16(),
2038 ASCIIToUTF16("email"), 2038 ASCIIToUTF16("email"),
2039 string16(), 2039 string16(),
2040 ASCIIToUTF16("text"), 2040 ASCIIToUTF16("text"),
2041 WebInputElement::defaultMaxLength(), 2041 WebInputElement::defaultMaxLength(),
2042 false), 2042 false),
2043 fields[2]); 2043 fields[2]);
2044 2044
2045 // Fill the form. 2045 // Fill the form.
2046 form.fields[0].set_value(ASCIIToUTF16("Wyatt")); 2046 form.fields[0].value = ASCIIToUTF16("Wyatt");
2047 form.fields[1].set_value(ASCIIToUTF16("Earp")); 2047 form.fields[1].value = ASCIIToUTF16("Earp");
2048 form.fields[2].set_value(ASCIIToUTF16("wyatt@example.com")); 2048 form.fields[2].value = ASCIIToUTF16("wyatt@example.com");
2049 EXPECT_TRUE(form_manager.FillForm(form, WebNode())); 2049 EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
2050 2050
2051 // Find the newly-filled form that contains the input element. 2051 // Find the newly-filled form that contains the input element.
2052 FormData form2; 2052 FormData form2;
2053 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 2053 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
2054 input_element, FormManager::REQUIRE_NONE, &form2)); 2054 input_element, FormManager::REQUIRE_NONE, &form2));
2055 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); 2055 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name);
2056 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 2056 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
2057 EXPECT_EQ(GURL("http://buh.com"), form2.action); 2057 EXPECT_EQ(GURL("http://buh.com"), form2.action);
2058 2058
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 fields[1]); 2136 fields[1]);
2137 EXPECT_EQ(FormField(string16(), 2137 EXPECT_EQ(FormField(string16(),
2138 ASCIIToUTF16("cantelope"), 2138 ASCIIToUTF16("cantelope"),
2139 string16(), 2139 string16(),
2140 ASCIIToUTF16("text"), 2140 ASCIIToUTF16("text"),
2141 WebInputElement::defaultMaxLength(), 2141 WebInputElement::defaultMaxLength(),
2142 false), 2142 false),
2143 fields[2]); 2143 fields[2]);
2144 2144
2145 // Fill the form. 2145 // Fill the form.
2146 form.fields[0].set_value(ASCIIToUTF16("Red")); 2146 form.fields[0].value = ASCIIToUTF16("Red");
2147 form.fields[1].set_value(ASCIIToUTF16("Yellow")); 2147 form.fields[1].value = ASCIIToUTF16("Yellow");
2148 form.fields[2].set_value(ASCIIToUTF16("Also Yellow")); 2148 form.fields[2].value = ASCIIToUTF16("Also Yellow");
2149 EXPECT_TRUE(form_manager.FillForm(form, WebNode())); 2149 EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
2150 2150
2151 // Find the newly-filled form that contains the input element. 2151 // Find the newly-filled form that contains the input element.
2152 FormData form2; 2152 FormData form2;
2153 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 2153 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
2154 input_element, FormManager::REQUIRE_NONE, &form2)); 2154 input_element, FormManager::REQUIRE_NONE, &form2));
2155 EXPECT_EQ(string16(), form2.name); 2155 EXPECT_EQ(string16(), form2.name);
2156 EXPECT_EQ(GURL(web_frame->url()), form2.origin); 2156 EXPECT_EQ(GURL(web_frame->url()), form2.origin);
2157 EXPECT_EQ(GURL("http://abc.com"), form2.action); 2157 EXPECT_EQ(GURL("http://abc.com"), form2.action);
2158 2158
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 fields[1]); 2379 fields[1]);
2380 EXPECT_EQ(FormField(string16(), 2380 EXPECT_EQ(FormField(string16(),
2381 ASCIIToUTF16("email"), 2381 ASCIIToUTF16("email"),
2382 string16(), 2382 string16(),
2383 ASCIIToUTF16("text"), 2383 ASCIIToUTF16("text"),
2384 WebInputElement::defaultMaxLength(), 2384 WebInputElement::defaultMaxLength(),
2385 false), 2385 false),
2386 fields[2]); 2386 fields[2]);
2387 2387
2388 // Preview the form and verify that the cursor position has been updated. 2388 // Preview the form and verify that the cursor position has been updated.
2389 form.fields[0].set_value(ASCIIToUTF16("Wyatt")); 2389 form.fields[0].value = ASCIIToUTF16("Wyatt");
2390 form.fields[1].set_value(ASCIIToUTF16("Earp")); 2390 form.fields[1].value = ASCIIToUTF16("Earp");
2391 form.fields[2].set_value(ASCIIToUTF16("wyatt@example.com")); 2391 form.fields[2].value = ASCIIToUTF16("wyatt@example.com");
2392 EXPECT_TRUE(form_manager.PreviewForm(form, input_element)); 2392 EXPECT_TRUE(form_manager.PreviewForm(form, input_element));
2393 EXPECT_EQ(2, input_element.selectionStart()); 2393 EXPECT_EQ(2, input_element.selectionStart());
2394 EXPECT_EQ(5, input_element.selectionEnd()); 2394 EXPECT_EQ(5, input_element.selectionEnd());
2395 2395
2396 // Fill the form. 2396 // Fill the form.
2397 EXPECT_TRUE(form_manager.FillForm(form, input_element)); 2397 EXPECT_TRUE(form_manager.FillForm(form, input_element));
2398 2398
2399 // Find the newly-filled form that contains the input element. 2399 // Find the newly-filled form that contains the input element.
2400 FormData form2; 2400 FormData form2;
2401 EXPECT_TRUE(form_manager.FindFormWithFormControlElement( 2401 EXPECT_TRUE(form_manager.FindFormWithFormControlElement(
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 WebInputElement::defaultMaxLength(), 2943 WebInputElement::defaultMaxLength(),
2944 false))); 2944 false)));
2945 EXPECT_TRUE(fields[2].StrictlyEqualsHack( 2945 EXPECT_TRUE(fields[2].StrictlyEqualsHack(
2946 FormField(string16(), 2946 FormField(string16(),
2947 ASCIIToUTF16("country"), 2947 ASCIIToUTF16("country"),
2948 ASCIIToUTF16("AL"), 2948 ASCIIToUTF16("AL"),
2949 ASCIIToUTF16("select-one"), 2949 ASCIIToUTF16("select-one"),
2950 0, 2950 0,
2951 false))); 2951 false)));
2952 } 2952 }
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/form_manager.cc ('k') | chrome/renderer/autofill/password_autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698