OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/autofill/form_structure.h" | 5 #include "chrome/browser/autofill/form_structure.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.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/browser/autofill/autofill_metrics.h" | 10 #include "chrome/browser/autofill/autofill_metrics.h" |
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 EXPECT_EQ(FormStructureTest::Hash64Bit( | 2056 EXPECT_EQ(FormStructureTest::Hash64Bit( |
2057 std::string("https://login.facebook.com&&email&first")), | 2057 std::string("https://login.facebook.com&&email&first")), |
2058 form_structure->FormSignature()); | 2058 form_structure->FormSignature()); |
2059 | 2059 |
2060 form.name = ASCIIToUTF16("login_form"); | 2060 form.name = ASCIIToUTF16("login_form"); |
2061 form_structure.reset(new FormStructure(form)); | 2061 form_structure.reset(new FormStructure(form)); |
2062 EXPECT_EQ(FormStructureTest::Hash64Bit( | 2062 EXPECT_EQ(FormStructureTest::Hash64Bit( |
2063 std::string("https://login.facebook.com&login_form&email&first")), | 2063 std::string("https://login.facebook.com&login_form&email&first")), |
2064 form_structure->FormSignature()); | 2064 form_structure->FormSignature()); |
2065 } | 2065 } |
| 2066 |
| 2067 TEST(FormStructureTest, ToFormData) { |
| 2068 FormData form; |
| 2069 form.name = ASCIIToUTF16("the-name"); |
| 2070 form.method = ASCIIToUTF16("POST"); |
| 2071 form.origin = GURL("http://cool.com"); |
| 2072 form.action = form.origin.Resolve("/login"); |
| 2073 |
| 2074 FormFieldData field; |
| 2075 field.label = ASCIIToUTF16("username"); |
| 2076 field.name = ASCIIToUTF16("username"); |
| 2077 field.form_control_type = "text"; |
| 2078 form.fields.push_back(field); |
| 2079 |
| 2080 field.label = ASCIIToUTF16("password"); |
| 2081 field.name = ASCIIToUTF16("password"); |
| 2082 field.form_control_type = "password"; |
| 2083 form.fields.push_back(field); |
| 2084 |
| 2085 field.label = string16(); |
| 2086 field.name = ASCIIToUTF16("Submit"); |
| 2087 field.form_control_type = "submit"; |
| 2088 form.fields.push_back(field); |
| 2089 |
| 2090 //LOG(ERROR) << "form: " << form; |
| 2091 //LOG(ERROR) << "ToFormData(): " << FormStructure(form).ToFormData(); |
| 2092 EXPECT_EQ(form, FormStructure(form).ToFormData()); |
| 2093 } |
OLD | NEW |