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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::Tuple<base::string16> autofill_param; | 158 base::Tuple<base::string16> autofill_param; |
159 switch (messageID) { | 159 switch (messageID) { |
160 case AutofillMsg_FillFieldWithValue::ID: | 160 case AutofillMsg_FillFieldWithValue::ID: |
161 if (!AutofillMsg_FillFieldWithValue::Read(message, &autofill_param)) | 161 if (!AutofillMsg_FillFieldWithValue::Read(message, &autofill_param)) |
162 return false; | 162 return false; |
163 break; | 163 break; |
164 case AutofillMsg_PreviewFieldWithValue::ID: | 164 case AutofillMsg_PreviewFieldWithValue::ID: { |
165 if (!AutofillMsg_PreviewFieldWithValue::Read(message, &autofill_param)) | 165 base::Tuple<base::string16, int> autofill_param_preview; |
| 166 if (AutofillMsg_PreviewFieldWithValue::Read(message, |
| 167 &autofill_param_preview)) { |
| 168 if (value) |
| 169 *value = base::get<0>(autofill_param); |
| 170 process()->sink().ClearMessages(); |
| 171 return true; |
| 172 } |
166 return false; | 173 return false; |
167 break; | 174 } break; |
168 case AutofillMsg_AcceptDataListSuggestion::ID: | 175 case AutofillMsg_AcceptDataListSuggestion::ID: |
169 if (!AutofillMsg_AcceptDataListSuggestion::Read(message, | 176 if (!AutofillMsg_AcceptDataListSuggestion::Read(message, |
170 &autofill_param)) | 177 &autofill_param)) |
171 return false; | 178 return false; |
172 break; | 179 break; |
173 default: | 180 default: |
174 NOTREACHED(); | 181 NOTREACHED(); |
175 } | 182 } |
176 if (value) | 183 if (value) |
177 *value = base::get<0>(autofill_param); | 184 *value = base::get<0>(autofill_param); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 313 |
307 driver_->RendererShouldFillFieldWithValue(input_value); | 314 driver_->RendererShouldFillFieldWithValue(input_value); |
308 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_FillFieldWithValue::ID, | 315 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_FillFieldWithValue::ID, |
309 &output_value)); | 316 &output_value)); |
310 EXPECT_EQ(input_value, output_value); | 317 EXPECT_EQ(input_value, output_value); |
311 } | 318 } |
312 | 319 |
313 TEST_F(ContentAutofillDriverTest, PreviewFieldWithValue) { | 320 TEST_F(ContentAutofillDriverTest, PreviewFieldWithValue) { |
314 base::string16 input_value(base::ASCIIToUTF16("barqux")); | 321 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
315 base::string16 output_value; | 322 base::string16 output_value; |
316 driver_->RendererShouldPreviewFieldWithValue(input_value); | 323 size_t match_start = 0; |
| 324 driver_->RendererShouldPreviewFieldWithValue(input_value, match_start); |
317 EXPECT_TRUE(GetString16FromMessageWithID( | 325 EXPECT_TRUE(GetString16FromMessageWithID( |
318 AutofillMsg_PreviewFieldWithValue::ID, | 326 AutofillMsg_PreviewFieldWithValue::ID, |
319 &output_value)); | 327 &output_value)); |
320 EXPECT_EQ(input_value, output_value); | 328 EXPECT_EQ(input_value, output_value); |
321 } | 329 } |
322 | 330 |
323 } // namespace autofill | 331 } // namespace autofill |
OLD | NEW |