OLD | NEW |
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 "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // messages. If none is present, returns false. Otherwise, extracts the first | 152 // messages. If none is present, returns false. Otherwise, extracts the first |
153 // matching message, fills the output parameter with the string16 from the | 153 // matching message, fills the output parameter with the string16 from the |
154 // message's parameter, and clears the queue of sent messages. | 154 // message's parameter, and clears the queue of sent messages. |
155 bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) { | 155 bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) { |
156 const IPC::Message* message = | 156 const IPC::Message* message = |
157 process()->sink().GetFirstMessageMatching(messageID); | 157 process()->sink().GetFirstMessageMatching(messageID); |
158 if (!message) | 158 if (!message) |
159 return false; | 159 return false; |
160 Tuple1<base::string16> autofill_param; | 160 Tuple1<base::string16> autofill_param; |
161 switch (messageID) { | 161 switch (messageID) { |
162 case AutofillMsg_SetNodeText::ID: | 162 case AutofillMsg_FillFieldWithValue::ID: |
163 if (!AutofillMsg_SetNodeText::Read(message, &autofill_param)) | 163 if (!AutofillMsg_FillFieldWithValue::Read(message, &autofill_param)) |
| 164 return false; |
| 165 break; |
| 166 case AutofillMsg_PreviewFieldWithValue::ID: |
| 167 if (!AutofillMsg_PreviewFieldWithValue::Read(message, &autofill_param)) |
164 return false; | 168 return false; |
165 break; | 169 break; |
166 case AutofillMsg_AcceptDataListSuggestion::ID: | 170 case AutofillMsg_AcceptDataListSuggestion::ID: |
167 if (!AutofillMsg_AcceptDataListSuggestion::Read(message, | 171 if (!AutofillMsg_AcceptDataListSuggestion::Read(message, |
168 &autofill_param)) | 172 &autofill_param)) |
169 return false; | 173 return false; |
170 break; | 174 break; |
171 case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: | 175 case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: |
172 if (!AutofillMsg_AcceptPasswordAutofillSuggestion::Read( | 176 if (!AutofillMsg_AcceptPasswordAutofillSuggestion::Read( |
173 message, | 177 message, |
174 &autofill_param)) | 178 &autofill_param)) |
175 return false; | 179 return false; |
176 break; | 180 break; |
177 default: | 181 default: |
178 NOTREACHED(); | 182 NOTREACHED(); |
179 } | 183 } |
180 if (value) | 184 if (value) |
181 *value = autofill_param.a; | 185 *value = autofill_param.a; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) { | 315 TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) { |
312 driver_->RendererShouldClearFilledForm(); | 316 driver_->RendererShouldClearFilledForm(); |
313 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); | 317 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); |
314 } | 318 } |
315 | 319 |
316 TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { | 320 TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { |
317 driver_->RendererShouldClearPreviewedForm(); | 321 driver_->RendererShouldClearPreviewedForm(); |
318 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); | 322 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); |
319 } | 323 } |
320 | 324 |
321 TEST_F(AutofillDriverImplTest, SetNodeText) { | 325 TEST_F(AutofillDriverImplTest, FillFieldWithValue) { |
322 base::string16 input_value(base::ASCIIToUTF16("barqux")); | 326 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
323 base::string16 output_value; | 327 base::string16 output_value; |
324 driver_->RendererShouldSetNodeText(input_value); | 328 driver_->RendererShouldFillFieldWithValue(input_value); |
325 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_SetNodeText::ID, | 329 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_FillFieldWithValue::ID, |
326 &output_value)); | 330 &output_value)); |
327 EXPECT_EQ(input_value, output_value); | 331 EXPECT_EQ(input_value, output_value); |
328 } | 332 } |
329 | 333 |
| 334 TEST_F(AutofillDriverImplTest, PreviewFieldWithValue) { |
| 335 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
| 336 base::string16 output_value; |
| 337 driver_->RendererShouldPreviewFieldWithValue(input_value); |
| 338 EXPECT_TRUE(GetString16FromMessageWithID( |
| 339 AutofillMsg_PreviewFieldWithValue::ID, |
| 340 &output_value)); |
| 341 EXPECT_EQ(input_value, output_value); |
| 342 } |
| 343 |
330 } // namespace autofill | 344 } // namespace autofill |
OLD | NEW |