OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/test/base/chrome_render_view_test.h" | 11 #include "chrome/test/base/chrome_render_view_test.h" |
12 #include "components/autofill/content/renderer/form_autofill_util.h" | 12 #include "components/autofill/content/renderer/form_autofill_util.h" |
13 #include "components/autofill/content/renderer/form_cache.h" | 13 #include "components/autofill/content/renderer/form_cache.h" |
14 #include "components/autofill/core/common/autofill_data_validation.h" | 14 #include "components/autofill/core/common/autofill_data_validation.h" |
15 #include "components/autofill/core/common/form_data.h" | 15 #include "components/autofill/core/common/form_data.h" |
16 #include "components/autofill/core/common/web_element_descriptor.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
19 #include "third_party/WebKit/public/platform/WebVector.h" | 18 #include "third_party/WebKit/public/platform/WebVector.h" |
20 #include "third_party/WebKit/public/web/WebDocument.h" | 19 #include "third_party/WebKit/public/web/WebDocument.h" |
21 #include "third_party/WebKit/public/web/WebElement.h" | 20 #include "third_party/WebKit/public/web/WebElement.h" |
22 #include "third_party/WebKit/public/web/WebElementCollection.h" | 21 #include "third_party/WebKit/public/web/WebElementCollection.h" |
23 #include "third_party/WebKit/public/web/WebExceptionCode.h" | 22 #include "third_party/WebKit/public/web/WebExceptionCode.h" |
24 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 23 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
25 #include "third_party/WebKit/public/web/WebFormElement.h" | 24 #include "third_party/WebKit/public/web/WebFormElement.h" |
26 #include "third_party/WebKit/public/web/WebInputElement.h" | 25 #include "third_party/WebKit/public/web/WebInputElement.h" |
(...skipping 22 matching lines...) Expand all Loading... |
49 const char* const name; | 48 const char* const name; |
50 const char* const initial_value; | 49 const char* const initial_value; |
51 const char* const autocomplete_attribute; // The autocomplete attribute of | 50 const char* const autocomplete_attribute; // The autocomplete attribute of |
52 // the element. | 51 // the element. |
53 bool should_be_autofilled; // Whether the filed should be autofilled. | 52 bool should_be_autofilled; // Whether the filed should be autofilled. |
54 const char* const autofill_value; // The value being used to fill the field. | 53 const char* const autofill_value; // The value being used to fill the field. |
55 const char* const expected_value; // The expected value after Autofill | 54 const char* const expected_value; // The expected value after Autofill |
56 // or Preview. | 55 // or Preview. |
57 }; | 56 }; |
58 | 57 |
| 58 struct WebElementDescriptor { |
| 59 enum RetrievalMethod { |
| 60 CSS_SELECTOR, |
| 61 ID, |
| 62 NONE, |
| 63 }; |
| 64 |
| 65 // Information to retrieve element with. |
| 66 std::string descriptor; |
| 67 |
| 68 // Which retrieval method to use. |
| 69 RetrievalMethod retrieval_method = NONE; |
| 70 }; |
| 71 |
59 const char kFormHtml[] = | 72 const char kFormHtml[] = |
60 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 73 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
61 " <INPUT type='text' id='firstname'/>" | 74 " <INPUT type='text' id='firstname'/>" |
62 " <INPUT type='text' id='lastname'/>" | 75 " <INPUT type='text' id='lastname'/>" |
63 " <INPUT type='hidden' id='imhidden'/>" | 76 " <INPUT type='hidden' id='imhidden'/>" |
64 " <INPUT type='text' id='notempty' value='Hi'/>" | 77 " <INPUT type='text' id='notempty' value='Hi'/>" |
65 " <INPUT type='text' autocomplete='off' id='noautocomplete'/>" | 78 " <INPUT type='text' autocomplete='off' id='noautocomplete'/>" |
66 " <INPUT type='text' disabled='disabled' id='notenabled'/>" | 79 " <INPUT type='text' disabled='disabled' id='notenabled'/>" |
67 " <INPUT type='text' readonly id='readonly'/>" | 80 " <INPUT type='text' readonly id='readonly'/>" |
68 " <INPUT type='text' style='visibility: hidden'" | 81 " <INPUT type='text' style='visibility: hidden'" |
(...skipping 4097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4166 ASSERT_NE(nullptr, web_frame); | 4179 ASSERT_NE(nullptr, web_frame); |
4167 | 4180 |
4168 FormCache form_cache(*web_frame); | 4181 FormCache form_cache(*web_frame); |
4169 std::vector<FormData> forms = form_cache.ExtractNewForms(); | 4182 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
4170 EXPECT_EQ(test_case.expected_forms, forms.size()); | 4183 EXPECT_EQ(test_case.expected_forms, forms.size()); |
4171 } | 4184 } |
4172 } | 4185 } |
4173 | 4186 |
4174 } // namespace form_util | 4187 } // namespace form_util |
4175 } // namespace autofill | 4188 } // namespace autofill |
OLD | NEW |