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

Side by Side Diff: components/autofill/content/browser/autofill_driver_impl_unittest.cc

Issue 18693005: Move AutofillMsg_ClearPreviewedForm IPC send to AutofillDriverImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return false; 117 return false;
118 Tuple1<std::vector<FormDataPredictions> > autofill_param; 118 Tuple1<std::vector<FormDataPredictions> > autofill_param;
119 AutofillMsg_FieldTypePredictionsAvailable::Read(message, &autofill_param); 119 AutofillMsg_FieldTypePredictionsAvailable::Read(message, &autofill_param);
120 if (predictions) 120 if (predictions)
121 *predictions = autofill_param.a; 121 *predictions = autofill_param.a;
122 122
123 process()->sink().ClearMessages(); 123 process()->sink().ClearMessages();
124 return true; 124 return true;
125 } 125 }
126 126
127 // Searches for an |AutofillMsg_SetAutofillActionPreview| message in the 127 // Searches for a message matching |messageID| in the queue of sent IPC
128 // queue of sent IPC messages. If none is present, returns false. Otherwise, 128 // messages. If none is present, returns false. Otherwise, clears the queue
129 // clears the queue of sent messages and returns true. 129 // of sent messages and returns true.
130 bool GetSetAutofillActionPreviewMessage() { 130 bool GetMessageMatchingID(const uint32 messageID) {
Ilya Sherman 2013/07/09 22:45:36 nit: Perhaps name this "HasMessageMatchingID" rath
Ilya Sherman 2013/07/09 22:45:36 nit: For whatever reason, the common style is to n
blundell 2013/07/10 08:35:20 Done.
blundell 2013/07/10 08:35:20 Done.
131 const uint32 kMsgID = AutofillMsg_SetAutofillActionPreview::ID;
132 const IPC::Message* message = 131 const IPC::Message* message =
133 process()->sink().GetFirstMessageMatching(kMsgID); 132 process()->sink().GetFirstMessageMatching(messageID);
134 if (!message) 133 if (!message)
135 return false; 134 return false;
136 process()->sink().ClearMessages(); 135 process()->sink().ClearMessages();
137 return true;
138 }
139
140 // Searches for an |AutofillMsg_SetAutofillActionFill| message in the
141 // queue of sent IPC messages. If none is present, returns false. Otherwise,
142 // clears the queue of sent messages and returns true.
143 bool GetSetAutofillActionFillMessage() {
144 const uint32 kMsgID = AutofillMsg_SetAutofillActionFill::ID;
145 const IPC::Message* message =
146 process()->sink().GetFirstMessageMatching(kMsgID);
147 if (!message)
148 return false;
149 process()->sink().ClearMessages();
150 return true;
151 }
152
153 // Searches for an |AutofillMsg_ClearForm| message in the queue of sent IPC
154 // messages. If none is present, returns false. Otherwise, clears the queue
155 // of sent messages and returns true.
156 bool GetClearFormMessage() {
157 const uint32 kMsgID = AutofillMsg_ClearForm::ID;
158 const IPC::Message* message =
159 process()->sink().GetFirstMessageMatching(kMsgID);
160 if (!message)
161 return false;
162 process()->sink().ClearMessages();
163 return true; 136 return true;
164 } 137 }
165 138
166 scoped_ptr<TestAutofillManagerDelegate> test_manager_delegate_; 139 scoped_ptr<TestAutofillManagerDelegate> test_manager_delegate_;
167 scoped_ptr<TestAutofillDriverImpl> driver_; 140 scoped_ptr<TestAutofillDriverImpl> driver_;
168 }; 141 };
169 142
170 TEST_F(AutofillDriverImplTest, NavigatedToDifferentPage) { 143 TEST_F(AutofillDriverImplTest, NavigatedToDifferentPage) {
171 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); 144 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset());
172 content::LoadCommittedDetails details = content::LoadCommittedDetails(); 145 content::LoadCommittedDetails details = content::LoadCommittedDetails();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 driver_->SendAutofillTypePredictionsToRenderer(forms); 195 driver_->SendAutofillTypePredictionsToRenderer(forms);
223 196
224 std::vector<FormDataPredictions> output_type_predictions; 197 std::vector<FormDataPredictions> output_type_predictions;
225 EXPECT_TRUE(GetFieldTypePredictionsAvailable(&output_type_predictions)); 198 EXPECT_TRUE(GetFieldTypePredictionsAvailable(&output_type_predictions));
226 EXPECT_EQ(expected_type_predictions, output_type_predictions); 199 EXPECT_EQ(expected_type_predictions, output_type_predictions);
227 } 200 }
228 201
229 TEST_F(AutofillDriverImplTest, PreviewActionSentToRenderer) { 202 TEST_F(AutofillDriverImplTest, PreviewActionSentToRenderer) {
230 driver_->SetRendererActionOnFormDataReception( 203 driver_->SetRendererActionOnFormDataReception(
231 AutofillDriver::FORM_DATA_ACTION_PREVIEW); 204 AutofillDriver::FORM_DATA_ACTION_PREVIEW);
232 EXPECT_TRUE(GetSetAutofillActionPreviewMessage()); 205 EXPECT_TRUE(GetMessageMatchingID(AutofillMsg_SetAutofillActionPreview::ID));
233 } 206 }
234 207
235 TEST_F(AutofillDriverImplTest, FillActionSentToRenderer) { 208 TEST_F(AutofillDriverImplTest, FillActionSentToRenderer) {
236 driver_->SetRendererActionOnFormDataReception( 209 driver_->SetRendererActionOnFormDataReception(
237 AutofillDriver::FORM_DATA_ACTION_FILL); 210 AutofillDriver::FORM_DATA_ACTION_FILL);
238 EXPECT_TRUE(GetSetAutofillActionFillMessage()); 211 EXPECT_TRUE(GetMessageMatchingID(AutofillMsg_SetAutofillActionFill::ID));
239 } 212 }
240 213
241 TEST_F(AutofillDriverImplTest, ClearFormSentToRenderer) { 214 TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) {
242 driver_->RendererShouldClearForm(); 215 driver_->RendererShouldClearFilledForm();
243 EXPECT_TRUE(GetClearFormMessage()); 216 EXPECT_TRUE(GetMessageMatchingID(AutofillMsg_ClearForm::ID));
217 }
218
219 TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) {
220 driver_->RendererShouldClearPreviewedForm();
221 EXPECT_TRUE(GetMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID));
244 } 222 }
245 223
246 } // namespace autofill 224 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/browser/autofill_driver_impl.cc ('k') | components/autofill/core/browser/autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698