OLD | NEW |
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 "base/scoped_ptr.h" | 5 #include "base/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/WebKit/chromium/public/WebInputElement.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" |
12 #include "webkit/glue/form_data.h" | 12 #include "webkit/glue/form_data.h" |
13 #include "webkit/glue/form_field.h" | 13 #include "webkit/glue/form_field.h" |
14 | 14 |
15 using webkit_glue::FormData; | 15 using webkit_glue::FormData; |
16 using WebKit::WebInputElement; | 16 using WebKit::WebInputElement; |
17 | 17 |
18 namespace { | 18 namespace webkit_glue { |
19 | |
20 std::ostream& operator<<(std::ostream& os, const FormData& form) { | 19 std::ostream& operator<<(std::ostream& os, const FormData& form) { |
21 os << UTF16ToUTF8(form.name) | 20 os << UTF16ToUTF8(form.name) |
22 << " " | 21 << " " |
23 << UTF16ToUTF8(form.method) | 22 << UTF16ToUTF8(form.method) |
24 << " " | 23 << " " |
25 << form.origin.spec() | 24 << form.origin.spec() |
26 << " " | 25 << " " |
27 << form.action.spec() | 26 << form.action.spec() |
28 << " "; | 27 << " "; |
29 | 28 |
30 for (std::vector<webkit_glue::FormField>::const_iterator iter = | 29 for (std::vector<webkit_glue::FormField>::const_iterator iter = |
31 form.fields.begin(); | 30 form.fields.begin(); |
32 iter != form.fields.end(); ++iter) { | 31 iter != form.fields.end(); ++iter) { |
33 os << *iter | 32 os << *iter |
34 << " "; | 33 << " "; |
35 } | 34 } |
36 | 35 |
37 return os; | 36 return os; |
38 } | 37 } |
| 38 } |
| 39 |
| 40 namespace { |
39 | 41 |
40 TEST(FormStructureTest, FieldCount) { | 42 TEST(FormStructureTest, FieldCount) { |
41 FormData form; | 43 FormData form; |
42 form.method = ASCIIToUTF16("post"); | 44 form.method = ASCIIToUTF16("post"); |
43 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), | 45 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), |
44 ASCIIToUTF16("username"), | 46 ASCIIToUTF16("username"), |
45 string16(), | 47 string16(), |
46 ASCIIToUTF16("text"), | 48 ASCIIToUTF16("text"), |
47 0)); | 49 0)); |
48 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), | 50 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 EXPECT_EQ(PHONE_HOME_NUMBER, | 913 EXPECT_EQ(PHONE_HOME_NUMBER, |
912 form_structure->field(1)->heuristic_type()); | 914 form_structure->field(1)->heuristic_type()); |
913 // Phone number suffix. | 915 // Phone number suffix. |
914 EXPECT_EQ(PHONE_HOME_NUMBER, | 916 EXPECT_EQ(PHONE_HOME_NUMBER, |
915 form_structure->field(2)->heuristic_type()); | 917 form_structure->field(2)->heuristic_type()); |
916 // Unknown. | 918 // Unknown. |
917 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type()); | 919 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type()); |
918 } | 920 } |
919 | 921 |
920 } // namespace | 922 } // namespace |
OLD | NEW |