Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/renderer/autofill/form_autocomplete_browsertest.cc

Issue 8230034: Split most of RenderViewTest and associated classes into content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build breaks. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/time.h" 5 #include "base/time.h"
6 #include "chrome/common/autofill_messages.h" 6 #include "chrome/common/autofill_messages.h"
7 #include "chrome/test/base/render_view_test.h" 7 #include "chrome/test/base/chrome_render_view_test.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
13 #include "webkit/glue/form_data.h" 13 #include "webkit/glue/form_data.h"
14 #include "webkit/glue/web_io_operators.h" 14 #include "webkit/glue/web_io_operators.h"
15 15
16 using webkit_glue::FormData; 16 using webkit_glue::FormData;
17 using WebKit::WebFrame; 17 using WebKit::WebFrame;
18 using WebKit::WebString; 18 using WebKit::WebString;
19 using WebKit::WebTextDirection; 19 using WebKit::WebTextDirection;
20 using WebKit::WebURLError; 20 using WebKit::WebURLError;
21 21
22 typedef RenderViewTest FormAutocompleteTest; 22 typedef ChromeRenderViewTest FormAutocompleteTest;
23 23
24 // Tests that submitting a form generates a FormSubmitted message 24 // Tests that submitting a form generates a FormSubmitted message
25 // with the form fields. 25 // with the form fields.
26 TEST_F(FormAutocompleteTest, NormalFormSubmit) { 26 TEST_F(FormAutocompleteTest, NormalFormSubmit) {
27 // Load a form. 27 // Load a form.
28 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>" 28 LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>"
29 "<input name='lname' value='Deckard'/></form></html>"); 29 "<input name='lname' value='Deckard'/></form></html>");
30 30
31 // Submit the form. 31 // Submit the form.
32 ExecuteJavaScript("document.getElementById('myForm').submit();"); 32 ExecuteJavaScript("document.getElementById('myForm').submit();");
33 ProcessPendingMessages(); 33 ProcessPendingMessages();
34 34
35 const IPC::Message* message = render_thread_.sink().GetFirstMessageMatching( 35 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
36 AutofillHostMsg_FormSubmitted::ID); 36 AutofillHostMsg_FormSubmitted::ID);
37 ASSERT_TRUE(message != NULL); 37 ASSERT_TRUE(message != NULL);
38 38
39 // The tuple also includes a timestamp, which is ignored. 39 // The tuple also includes a timestamp, which is ignored.
40 Tuple2<FormData, base::TimeTicks> forms; 40 Tuple2<FormData, base::TimeTicks> forms;
41 AutofillHostMsg_FormSubmitted::Read(message, &forms); 41 AutofillHostMsg_FormSubmitted::Read(message, &forms);
42 ASSERT_EQ(2U, forms.a.fields.size()); 42 ASSERT_EQ(2U, forms.a.fields.size());
43 43
44 webkit_glue::FormField& form_field = forms.a.fields[0]; 44 webkit_glue::FormField& form_field = forms.a.fields[0];
45 EXPECT_EQ(WebString("fname"), form_field.name); 45 EXPECT_EQ(WebString("fname"), form_field.name);
(...skipping 11 matching lines...) Expand all
57 LoadHTML("<html><form id='myForm' autocomplete='off'>" 57 LoadHTML("<html><form id='myForm' autocomplete='off'>"
58 "<input name='fname' value='Rick'/>" 58 "<input name='fname' value='Rick'/>"
59 "<input name='lname' value='Deckard'/>" 59 "<input name='lname' value='Deckard'/>"
60 "</form></html>"); 60 "</form></html>");
61 61
62 // Submit the form. 62 // Submit the form.
63 ExecuteJavaScript("document.getElementById('myForm').submit();"); 63 ExecuteJavaScript("document.getElementById('myForm').submit();");
64 ProcessPendingMessages(); 64 ProcessPendingMessages();
65 65
66 // No FormSubmitted message should have been sent. 66 // No FormSubmitted message should have been sent.
67 EXPECT_FALSE(render_thread_.sink().GetFirstMessageMatching( 67 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
68 AutofillHostMsg_FormSubmitted::ID)); 68 AutofillHostMsg_FormSubmitted::ID));
69 } 69 }
70 70
71 // Tests that fields with autocomplete off are not submitted. 71 // Tests that fields with autocomplete off are not submitted.
72 TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) { 72 TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) {
73 // Load a form. 73 // Load a form.
74 LoadHTML("<html><form id='myForm'>" 74 LoadHTML("<html><form id='myForm'>"
75 "<input name='fname' value='Rick'/>" 75 "<input name='fname' value='Rick'/>"
76 "<input name='lname' value='Deckard' autocomplete='off'/>" 76 "<input name='lname' value='Deckard' autocomplete='off'/>"
77 "</form></html>"); 77 "</form></html>");
78 78
79 // Submit the form. 79 // Submit the form.
80 ExecuteJavaScript("document.getElementById('myForm').submit();"); 80 ExecuteJavaScript("document.getElementById('myForm').submit();");
81 ProcessPendingMessages(); 81 ProcessPendingMessages();
82 82
83 // No FormSubmitted message should have been sent. 83 // No FormSubmitted message should have been sent.
84 const IPC::Message* message = render_thread_.sink().GetFirstMessageMatching( 84 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
85 AutofillHostMsg_FormSubmitted::ID); 85 AutofillHostMsg_FormSubmitted::ID);
86 ASSERT_TRUE(message != NULL); 86 ASSERT_TRUE(message != NULL);
87 87
88 // The tuple also includes a timestamp, which is ignored. 88 // The tuple also includes a timestamp, which is ignored.
89 Tuple2<FormData, base::TimeTicks> forms; 89 Tuple2<FormData, base::TimeTicks> forms;
90 AutofillHostMsg_FormSubmitted::Read(message, &forms); 90 AutofillHostMsg_FormSubmitted::Read(message, &forms);
91 ASSERT_EQ(1U, forms.a.fields.size()); 91 ASSERT_EQ(1U, forms.a.fields.size());
92 92
93 webkit_glue::FormField& form_field = forms.a.fields[0]; 93 webkit_glue::FormField& form_field = forms.a.fields[0];
94 EXPECT_EQ(WebString("fname"), form_field.name); 94 EXPECT_EQ(WebString("fname"), form_field.name);
(...skipping 17 matching lines...) Expand all
112 ExecuteJavaScript("document.getElementById('myForm')." 112 ExecuteJavaScript("document.getElementById('myForm')."
113 "setAttribute('autocomplete', 'off');"); 113 "setAttribute('autocomplete', 'off');");
114 ProcessPendingMessages(); 114 ProcessPendingMessages();
115 EXPECT_FALSE(form.autoComplete()); 115 EXPECT_FALSE(form.autoComplete());
116 116
117 // Submit the form. 117 // Submit the form.
118 ExecuteJavaScript("document.getElementById('myForm').submit();"); 118 ExecuteJavaScript("document.getElementById('myForm').submit();");
119 ProcessPendingMessages(); 119 ProcessPendingMessages();
120 120
121 // No FormSubmitted message should have been sent. 121 // No FormSubmitted message should have been sent.
122 EXPECT_FALSE(render_thread_.sink().GetFirstMessageMatching( 122 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
123 AutofillHostMsg_FormSubmitted::ID)); 123 AutofillHostMsg_FormSubmitted::ID));
124 } 124 }
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/autofill_browsertest.cc ('k') | chrome/renderer/autofill/form_autofill_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698