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