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/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "app/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
13 #include "chrome/common/native_web_keyboard_event.h" | 13 #include "chrome/common/native_web_keyboard_event.h" |
14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
15 #include "chrome/common/render_messages_params.h" | 15 #include "chrome/common/render_messages_params.h" |
| 16 #include "chrome/renderer/autofill_helper.h" |
16 #include "chrome/renderer/print_web_view_helper.h" | 17 #include "chrome/renderer/print_web_view_helper.h" |
17 #include "chrome/test/render_view_test.h" | 18 #include "chrome/test/render_view_test.h" |
18 #include "gfx/codec/jpeg_codec.h" | 19 #include "gfx/codec/jpeg_codec.h" |
19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
20 #include "printing/image.h" | 21 #include "printing/image.h" |
21 #include "printing/native_metafile.h" | 22 #include "printing/native_metafile.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" |
25 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 26 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // Verify that |didAcceptAutoFillSuggestion()| sends the expected number of | 1059 // Verify that |didAcceptAutoFillSuggestion()| sends the expected number of |
1059 // fields. | 1060 // fields. |
1060 WebFrame* web_frame = GetMainFrame(); | 1061 WebFrame* web_frame = GetMainFrame(); |
1061 WebDocument document = web_frame->document(); | 1062 WebDocument document = web_frame->document(); |
1062 WebInputElement firstname = | 1063 WebInputElement firstname = |
1063 document.getElementById("firstname").to<WebInputElement>(); | 1064 document.getElementById("firstname").to<WebInputElement>(); |
1064 | 1065 |
1065 // Accept suggestion that contains a label. Labeled items indicate AutoFill | 1066 // Accept suggestion that contains a label. Labeled items indicate AutoFill |
1066 // as opposed to Autocomplete. We're testing this distinction below with | 1067 // as opposed to Autocomplete. We're testing this distinction below with |
1067 // the |ViewHostMsg_FillAutoFillFormData::ID| message. | 1068 // the |ViewHostMsg_FillAutoFillFormData::ID| message. |
1068 view_->didAcceptAutoFillSuggestion(firstname, | 1069 autofill_helper_->didAcceptAutoFillSuggestion( |
1069 WebKit::WebString::fromUTF8("Johnny"), | 1070 firstname, |
1070 WebKit::WebString::fromUTF8("Home"), | 1071 WebKit::WebString::fromUTF8("Johnny"), |
1071 1, | 1072 WebKit::WebString::fromUTF8("Home"), |
1072 -1); | 1073 1, |
| 1074 -1); |
1073 | 1075 |
1074 ProcessPendingMessages(); | 1076 ProcessPendingMessages(); |
1075 const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching( | 1077 const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching( |
1076 ViewHostMsg_FillAutoFillFormData::ID); | 1078 ViewHostMsg_FillAutoFillFormData::ID); |
1077 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); | 1079 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); |
1078 ViewHostMsg_FillAutoFillFormData::Param params2; | 1080 ViewHostMsg_FillAutoFillFormData::Param params2; |
1079 ViewHostMsg_FillAutoFillFormData::Read(message2, ¶ms2); | 1081 ViewHostMsg_FillAutoFillFormData::Read(message2, ¶ms2); |
1080 const FormData& form2 = params2.b; | 1082 const FormData& form2 = params2.b; |
1081 ASSERT_EQ(3UL, form2.fields.size()); | 1083 ASSERT_EQ(3UL, form2.fields.size()); |
1082 EXPECT_TRUE(form2.fields[0].StrictlyEqualsHack( | 1084 EXPECT_TRUE(form2.fields[0].StrictlyEqualsHack( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 WebFrame* web_frame = GetMainFrame(); | 1145 WebFrame* web_frame = GetMainFrame(); |
1144 WebDocument document = web_frame->document(); | 1146 WebDocument document = web_frame->document(); |
1145 WebInputElement firstname = | 1147 WebInputElement firstname = |
1146 document.getElementById("firstname").to<WebInputElement>(); | 1148 document.getElementById("firstname").to<WebInputElement>(); |
1147 WebInputElement middlename = | 1149 WebInputElement middlename = |
1148 document.getElementById("middlename").to<WebInputElement>(); | 1150 document.getElementById("middlename").to<WebInputElement>(); |
1149 middlename.setAutofilled(true); | 1151 middlename.setAutofilled(true); |
1150 | 1152 |
1151 // Accept a suggestion in a form that has been auto-filled. This triggers | 1153 // Accept a suggestion in a form that has been auto-filled. This triggers |
1152 // the direct filling of the firstname element with value parameter. | 1154 // the direct filling of the firstname element with value parameter. |
1153 view_->didAcceptAutoFillSuggestion(firstname, | 1155 autofill_helper_->didAcceptAutoFillSuggestion( |
1154 WebKit::WebString::fromUTF8("David"), | 1156 firstname, |
1155 WebKit::WebString(), | 1157 WebKit::WebString::fromUTF8("David"), |
1156 0, | 1158 WebKit::WebString(), |
1157 0); | 1159 0, |
| 1160 0); |
1158 | 1161 |
1159 ProcessPendingMessages(); | 1162 ProcessPendingMessages(); |
1160 const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching( | 1163 const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching( |
1161 ViewHostMsg_FillAutoFillFormData::ID); | 1164 ViewHostMsg_FillAutoFillFormData::ID); |
1162 | 1165 |
1163 // No message should be sent in this case. |firstname| is filled directly. | 1166 // No message should be sent in this case. |firstname| is filled directly. |
1164 ASSERT_EQ(static_cast<IPC::Message*>(NULL), message2); | 1167 ASSERT_EQ(static_cast<IPC::Message*>(NULL), message2); |
1165 EXPECT_EQ(firstname.value(), WebKit::WebString::fromUTF8("David")); | 1168 EXPECT_EQ(firstname.value(), WebKit::WebString::fromUTF8("David")); |
1166 } | 1169 } |
1167 | 1170 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 LoadHTML("<html><head><meta http-equiv=\"content-language\" " | 1229 LoadHTML("<html><head><meta http-equiv=\"content-language\" " |
1227 "content=\" fr , es,en \">" | 1230 "content=\" fr , es,en \">" |
1228 "</head><body>A random page with random content.</body></html>"); | 1231 "</head><body>A random page with random content.</body></html>"); |
1229 ProcessPendingMessages(); | 1232 ProcessPendingMessages(); |
1230 message = render_thread_.sink().GetUniqueMessageMatching( | 1233 message = render_thread_.sink().GetUniqueMessageMatching( |
1231 ViewHostMsg_PageContents::ID); | 1234 ViewHostMsg_PageContents::ID); |
1232 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); | 1235 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); |
1233 ViewHostMsg_PageContents::Read(message, ¶ms); | 1236 ViewHostMsg_PageContents::Read(message, ¶ms); |
1234 EXPECT_EQ("fr", params.d); | 1237 EXPECT_EQ("fr", params.d); |
1235 } | 1238 } |
OLD | NEW |