| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/form_structure.h" | 8 #include "chrome/browser/autofill/form_structure.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
| 12 #include "webkit/glue/form_data.h" | 12 #include "webkit/forms/form_data.h" |
| 13 #include "webkit/glue/form_field.h" | 13 #include "webkit/forms/form_field.h" |
| 14 | 14 |
| 15 using webkit_glue::FormData; | 15 using webkit::forms::FormData; |
| 16 using webkit_glue::FormField; | 16 using webkit::forms::FormField; |
| 17 using WebKit::WebInputElement; | 17 using WebKit::WebInputElement; |
| 18 | 18 |
| 19 namespace webkit_glue { | 19 namespace webkit { |
| 20 namespace forms { |
| 20 | 21 |
| 21 std::ostream& operator<<(std::ostream& os, const FormData& form) { | 22 std::ostream& operator<<(std::ostream& os, const FormData& form) { |
| 22 os << UTF16ToUTF8(form.name) | 23 os << UTF16ToUTF8(form.name) |
| 23 << " " | 24 << " " |
| 24 << UTF16ToUTF8(form.method) | 25 << UTF16ToUTF8(form.method) |
| 25 << " " | 26 << " " |
| 26 << form.origin.spec() | 27 << form.origin.spec() |
| 27 << " " | 28 << " " |
| 28 << form.action.spec() | 29 << form.action.spec() |
| 29 << " "; | 30 << " "; |
| 30 | 31 |
| 31 for (std::vector<webkit_glue::FormField>::const_iterator iter = | 32 for (std::vector<webkit::forms::FormField>::const_iterator iter = |
| 32 form.fields.begin(); | 33 form.fields.begin(); |
| 33 iter != form.fields.end(); ++iter) { | 34 iter != form.fields.end(); ++iter) { |
| 34 os << *iter | 35 os << *iter |
| 35 << " "; | 36 << " "; |
| 36 } | 37 } |
| 37 | 38 |
| 38 return os; | 39 return os; |
| 39 } | 40 } |
| 40 | 41 |
| 42 } // namespace forms |
| 41 } // namespace webkit_glue | 43 } // namespace webkit_glue |
| 42 | 44 |
| 43 class FormStructureTest { | 45 class FormStructureTest { |
| 44 public: | 46 public: |
| 45 static std::string Hash64Bit(const std::string& str) { | 47 static std::string Hash64Bit(const std::string& str) { |
| 46 return FormStructure::Hash64Bit(str); | 48 return FormStructure::Hash64Bit(str); |
| 47 } | 49 } |
| 48 }; | 50 }; |
| 49 | 51 |
| 50 TEST(FormStructureTest, FieldCount) { | 52 TEST(FormStructureTest, FieldCount) { |
| (...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1985 EXPECT_EQ(FormStructureTest::Hash64Bit( | 1987 EXPECT_EQ(FormStructureTest::Hash64Bit( |
| 1986 std::string("https://login.facebook.com&&email&first")), | 1988 std::string("https://login.facebook.com&&email&first")), |
| 1987 form_structure->FormSignature()); | 1989 form_structure->FormSignature()); |
| 1988 | 1990 |
| 1989 form.name = ASCIIToUTF16("login_form"); | 1991 form.name = ASCIIToUTF16("login_form"); |
| 1990 form_structure.reset(new FormStructure(form)); | 1992 form_structure.reset(new FormStructure(form)); |
| 1991 EXPECT_EQ(FormStructureTest::Hash64Bit( | 1993 EXPECT_EQ(FormStructureTest::Hash64Bit( |
| 1992 std::string("https://login.facebook.com&login_form&email&first")), | 1994 std::string("https://login.facebook.com&login_form&email&first")), |
| 1993 form_structure->FormSignature()); | 1995 form_structure->FormSignature()); |
| 1994 } | 1996 } |
| OLD | NEW |