std::ostream& operator<<(std::ostream& os, const FormData& form) {
os << base::UTF16ToUTF8(form.name)
<< " "
- << base::UTF16ToUTF8(form.method)
- << " "
<< form.origin.spec()
<< " "
<< form.action.spec()
TEST(FormStructureTest, FieldCount) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.label = ASCIIToUTF16("username");
TEST(FormStructureTest, AutofillCount) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.label = ASCIIToUTF16("username");
TEST(FormStructureTest, SourceURL) {
FormData form;
form.origin = GURL("http://www.foo.com/");
- form.method = ASCIIToUTF16("post");
FormStructure form_structure(form);
EXPECT_EQ(form.origin, form_structure.source_url());
FormData form;
// We need at least three text fields to be auto-fillable.
- form.method = ASCIIToUTF16("post");
-
FormFieldData field;
field.label = ASCIIToUTF16("username");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_FALSE(form_structure->IsAutofillable(true));
+ EXPECT_FALSE(form_structure->IsAutofillable());
// We now have three text fields, but only two auto-fillable fields.
field.label = ASCIIToUTF16("First Name");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_FALSE(form_structure->IsAutofillable(true));
+ EXPECT_FALSE(form_structure->IsAutofillable());
// We now have three auto-fillable fields.
field.label = ASCIIToUTF16("Email");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
-
- // The method must be 'post', though we can intentionally ignore this
- // criterion for the sake of providing a helpful warning message to the user.
- form.method = ASCIIToUTF16("get");
- form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_FALSE(form_structure->IsAutofillable(true));
- EXPECT_TRUE(form_structure->IsAutofillable(false));
+ EXPECT_TRUE(form_structure->IsAutofillable());
// The target cannot include http(s)://*/search...
- form.method = ASCIIToUTF16("post");
form.action = GURL("http://google.com/search?q=hello");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_FALSE(form_structure->IsAutofillable(true));
+ EXPECT_FALSE(form_structure->IsAutofillable());
// But search can be in the URL.
form.action = GURL("http://search.com/?q=hello");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
}
TEST(FormStructureTest, ShouldBeParsed) {
FormData form;
// We need at least three text fields to be parseable.
- form.method = ASCIIToUTF16("post");
-
FormFieldData field;
field.label = ASCIIToUTF16("username");
field.name = ASCIIToUTF16("username");
// We have only one text field, should not be parsed.
form_structure.reset(new FormStructure(form));
- EXPECT_FALSE(form_structure->ShouldBeParsed(true));
+ EXPECT_FALSE(form_structure->ShouldBeParsed());
// We now have three text fields, though only two are auto-fillable.
field.label = ASCIIToUTF16("First Name");
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- EXPECT_TRUE(form_structure->ShouldBeParsed(true));
+ EXPECT_TRUE(form_structure->ShouldBeParsed());
- // The method must be 'post', though we can intentionally ignore this
- // criterion for the sake of providing a helpful warning message to the user.
- form.method = ASCIIToUTF16("get");
form_structure.reset(new FormStructure(form));
- EXPECT_FALSE(form_structure->IsAutofillable(true));
- EXPECT_TRUE(form_structure->ShouldBeParsed(false));
+ EXPECT_FALSE(form_structure->IsAutofillable());
+ EXPECT_TRUE(form_structure->ShouldBeParsed());
// The target cannot include http(s)://*/search...
- form.method = ASCIIToUTF16("post");
form.action = GURL("http://google.com/search?q=hello");
form_structure.reset(new FormStructure(form));
- EXPECT_FALSE(form_structure->ShouldBeParsed(true));
+ EXPECT_FALSE(form_structure->ShouldBeParsed());
// But search can be in the URL.
form.action = GURL("http://search.com/?q=hello");
form_structure.reset(new FormStructure(form));
- EXPECT_TRUE(form_structure->ShouldBeParsed(true));
+ EXPECT_TRUE(form_structure->ShouldBeParsed());
// The form need only have three fields, but at least one must be a text
// field.
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- EXPECT_TRUE(form_structure->ShouldBeParsed(true));
+ EXPECT_TRUE(form_structure->ShouldBeParsed());
form.fields[0].form_control_type = "select-one";
// Now, no text fields.
form_structure.reset(new FormStructure(form));
- EXPECT_FALSE(form_structure->ShouldBeParsed(true));
+ EXPECT_FALSE(form_structure->ShouldBeParsed());
}
TEST(FormStructureTest, HeuristicsContactInfo) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
ASSERT_EQ(8U, form_structure->field_count());
TEST(FormStructureTest, HeuristicsAutocompleteAttribute) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
ASSERT_EQ(3U, form_structure->field_count());
TEST(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
ASSERT_EQ(3U, form_structure->field_count());
TEST(FormStructureTest, AutocompleteAttributeOverridesOtherHeuristics) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
// Start with a regular contact form.
FormFieldData field;
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
ASSERT_EQ(3U, form_structure->field_count());
form.fields.front().autocomplete_attribute = "x-other";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_FALSE(form_structure->IsAutofillable(true));
+ EXPECT_FALSE(form_structure->IsAutofillable());
EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
ASSERT_EQ(3U, form_structure->field_count());
// attribute.
TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) {
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
FormStructure form_structure(form);
form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure.IsAutofillable(true));
+ EXPECT_TRUE(form_structure.IsAutofillable());
// Expect the correct number of fields.
ASSERT_EQ(9U, form_structure.field_count());
// |autocomplete| attribute.
TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsDegenerate) {
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
// |autocomplete| attribute.
TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) {
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
// local heuristics.
TEST(FormStructureTest, HeuristicsDontOverrideAutocompleteAttributeSections) {
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
TEST(FormStructureTest, HeuristicsSample8) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(10U, form_structure->field_count());
ASSERT_EQ(9U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsSample6) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(7U, form_structure->field_count());
ASSERT_EQ(6U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsLabelsOnly) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(8U, form_structure->field_count());
ASSERT_EQ(7U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsCreditCardInfo) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(6U, form_structure->field_count());
ASSERT_EQ(5U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(7U, form_structure->field_count());
ASSERT_EQ(5U, form_structure->autofill_count());
TEST(FormStructureTest, ThreeAddressLines) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(4U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
TEST(FormStructureTest, SurplusAddressLinesIgnored) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
TEST(FormStructureTest, ThreeAddressLinesExpedia) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(4U, form_structure->field_count());
EXPECT_EQ(3U, form_structure->autofill_count());
TEST(FormStructureTest, TwoAddressLinesEbay) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(3U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsStateWithProvince) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(3U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsWithBilling) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(11U, form_structure->field_count());
ASSERT_EQ(11U, form_structure->autofill_count());
TEST(FormStructureTest, ThreePartPhoneNumber) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(4U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
TEST(FormStructureTest, HeuristicsInfernoCC) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
ASSERT_EQ(5U, form_structure->field_count());
TEST(FormStructureTest, CVCCodeClash) {
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
- EXPECT_TRUE(form_structure->IsAutofillable(true));
+ EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
ASSERT_EQ(6U, form_structure->field_count());
TEST(FormStructureTest, EncodeQueryRequest) {
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
scoped_ptr<FormStructure> form_structure;
std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
- form.method = ASCIIToUTF16("post");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
scoped_ptr<FormStructure> form_structure;
std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
- form.method = ASCIIToUTF16("post");
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
// |available_types|.
TEST(FormStructureTest, CheckDataPresence) {
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
scoped_ptr<FormStructure> form_structure;
std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
// Check that form signature is created correctly.
scoped_ptr<FormStructure> form_structure;
FormData form;
- form.method = ASCIIToUTF16("post");
FormFieldData field;
field.form_control_type = "text";
TEST(FormStructureTest, ToFormData) {
FormData form;
form.name = ASCIIToUTF16("the-name");
- form.method = ASCIIToUTF16("POST");
form.origin = GURL("http://cool.com");
form.action = form.origin.Resolve("/login");
TEST(FormStructureTest, SkipFieldTest) {
FormData form;
form.name = ASCIIToUTF16("the-name");
- form.method = ASCIIToUTF16("POST");
form.origin = GURL("http://cool.com");
form.action = form.origin.Resolve("/login");