OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // messages. If none is present, returns false. Otherwise, extracts the first | 150 // messages. If none is present, returns false. Otherwise, extracts the first |
151 // matching message, fills the output parameter with the string16 from the | 151 // matching message, fills the output parameter with the string16 from the |
152 // message's parameter, and clears the queue of sent messages. | 152 // message's parameter, and clears the queue of sent messages. |
153 bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) { | 153 bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) { |
154 const IPC::Message* message = | 154 const IPC::Message* message = |
155 process()->sink().GetFirstMessageMatching(messageID); | 155 process()->sink().GetFirstMessageMatching(messageID); |
156 if (!message) | 156 if (!message) |
157 return false; | 157 return false; |
158 Tuple1<base::string16> autofill_param; | 158 Tuple1<base::string16> autofill_param; |
159 switch (messageID) { | 159 switch (messageID) { |
160 case AutofillMsg_SetNodeText::ID: | 160 case AutofillMsg_FillFieldWithValue::ID: |
161 if (!AutofillMsg_SetNodeText::Read(message, &autofill_param)) | 161 if (!AutofillMsg_FillFieldWithValue::Read(message, &autofill_param)) |
| 162 return false; |
| 163 break; |
| 164 case AutofillMsg_PreviewFieldWithValue::ID: |
| 165 if (!AutofillMsg_PreviewFieldWithValue::Read(message, &autofill_param)) |
162 return false; | 166 return false; |
163 break; | 167 break; |
164 case AutofillMsg_AcceptDataListSuggestion::ID: | 168 case AutofillMsg_AcceptDataListSuggestion::ID: |
165 if (!AutofillMsg_AcceptDataListSuggestion::Read(message, | 169 if (!AutofillMsg_AcceptDataListSuggestion::Read(message, |
166 &autofill_param)) | 170 &autofill_param)) |
167 return false; | 171 return false; |
168 break; | 172 break; |
169 case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: | 173 case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: |
170 if (!AutofillMsg_AcceptPasswordAutofillSuggestion::Read( | 174 if (!AutofillMsg_AcceptPasswordAutofillSuggestion::Read( |
171 message, &autofill_param)) | 175 message, &autofill_param)) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 TEST_F(ContentAutofillDriverTest, ClearFilledFormSentToRenderer) { | 307 TEST_F(ContentAutofillDriverTest, ClearFilledFormSentToRenderer) { |
304 driver_->RendererShouldClearFilledForm(); | 308 driver_->RendererShouldClearFilledForm(); |
305 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); | 309 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); |
306 } | 310 } |
307 | 311 |
308 TEST_F(ContentAutofillDriverTest, ClearPreviewedFormSentToRenderer) { | 312 TEST_F(ContentAutofillDriverTest, ClearPreviewedFormSentToRenderer) { |
309 driver_->RendererShouldClearPreviewedForm(); | 313 driver_->RendererShouldClearPreviewedForm(); |
310 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); | 314 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); |
311 } | 315 } |
312 | 316 |
313 TEST_F(ContentAutofillDriverTest, SetNodeText) { | 317 TEST_F(ContentAutofillDriverTest, FillFieldWithValue) { |
314 base::string16 input_value(base::ASCIIToUTF16("barqux")); | 318 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
315 base::string16 output_value; | 319 base::string16 output_value; |
316 driver_->RendererShouldSetNodeText(input_value); | 320 |
317 EXPECT_TRUE( | 321 driver_->RendererShouldFillFieldWithValue(input_value); |
318 GetString16FromMessageWithID(AutofillMsg_SetNodeText::ID, &output_value)); | 322 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_FillFieldWithValue::ID, |
| 323 &output_value)); |
319 EXPECT_EQ(input_value, output_value); | 324 EXPECT_EQ(input_value, output_value); |
320 } | 325 } |
321 | 326 |
| 327 TEST_F(ContentAutofillDriverTest, PreviewFieldWithValue) { |
| 328 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
| 329 base::string16 output_value; |
| 330 driver_->RendererShouldPreviewFieldWithValue(input_value); |
| 331 EXPECT_TRUE(GetString16FromMessageWithID( |
| 332 AutofillMsg_PreviewFieldWithValue::ID, |
| 333 &output_value)); |
| 334 EXPECT_EQ(input_value, output_value); |
| 335 } |
| 336 |
322 } // namespace autofill | 337 } // namespace autofill |
OLD | NEW |