Chromium Code Reviews| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 // messages. If none is present, returns false. Otherwise, extracts the first | 129 // messages. If none is present, returns false. Otherwise, extracts the first |
| 130 // matching message, fills the output parameter with the string16 from the | 130 // matching message, fills the output parameter with the string16 from the |
| 131 // message's parameter, and clears the queue of sent messages. | 131 // message's parameter, and clears the queue of sent messages. |
| 132 bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) { | 132 bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) { |
| 133 const IPC::Message* message = | 133 const IPC::Message* message = |
| 134 process()->sink().GetFirstMessageMatching(messageID); | 134 process()->sink().GetFirstMessageMatching(messageID); |
| 135 if (!message) | 135 if (!message) |
| 136 return false; | 136 return false; |
| 137 Tuple1<base::string16> autofill_param; | 137 Tuple1<base::string16> autofill_param; |
| 138 switch (messageID) { | 138 switch (messageID) { |
| 139 case AutofillMsg_SetNodeText::ID: | 139 case AutofillMsg_FillFieldWithValue::ID: |
| 140 AutofillMsg_SetNodeText::Read(message, &autofill_param); | 140 AutofillMsg_FillFieldWithValue::Read(message, &autofill_param); |
|
Ilya Sherman
2014/03/01 02:57:37
Please check the return value of Read(), and retur
ziran.sun
2014/03/04 15:30:19
Done.
| |
| 141 break; | |
| 142 case AutofillMsg_PreviewFieldWithValue::ID: | |
| 143 AutofillMsg_PreviewFieldWithValue::Read(message, &autofill_param); | |
|
Ilya Sherman
2014/03/01 02:57:37
Ditto
ziran.sun
2014/03/04 15:30:19
Done.
| |
| 141 break; | 144 break; |
| 142 case AutofillMsg_AcceptDataListSuggestion::ID: | 145 case AutofillMsg_AcceptDataListSuggestion::ID: |
| 143 AutofillMsg_AcceptDataListSuggestion::Read(message, &autofill_param); | 146 AutofillMsg_AcceptDataListSuggestion::Read(message, &autofill_param); |
| 144 break; | 147 break; |
| 145 case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: | 148 case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: |
| 146 AutofillMsg_AcceptPasswordAutofillSuggestion::Read( | 149 AutofillMsg_AcceptPasswordAutofillSuggestion::Read( |
| 147 message, | 150 message, |
| 148 &autofill_param); | 151 &autofill_param); |
| 149 break; | 152 break; |
| 150 default: | 153 default: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) { | 277 TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) { |
| 275 driver_->RendererShouldClearFilledForm(); | 278 driver_->RendererShouldClearFilledForm(); |
| 276 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); | 279 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); |
| 277 } | 280 } |
| 278 | 281 |
| 279 TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { | 282 TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { |
| 280 driver_->RendererShouldClearPreviewedForm(); | 283 driver_->RendererShouldClearPreviewedForm(); |
| 281 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); | 284 EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); |
| 282 } | 285 } |
| 283 | 286 |
| 284 TEST_F(AutofillDriverImplTest, SetNodeText) { | 287 TEST_F(AutofillDriverImplTest, FillFieldWithValue) { |
| 285 base::string16 input_value(base::ASCIIToUTF16("barqux")); | 288 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
| 286 base::string16 output_value; | 289 base::string16 output_value; |
| 287 driver_->RendererShouldSetNodeText(input_value); | 290 driver_->RendererShouldFillFieldWithValue(input_value); |
| 288 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_SetNodeText::ID, | 291 EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_FillFieldWithValue::ID, |
| 289 &output_value)); | 292 &output_value)); |
| 290 EXPECT_EQ(input_value, output_value); | 293 EXPECT_EQ(input_value, output_value); |
| 291 } | 294 } |
| 292 | 295 |
| 296 TEST_F(AutofillDriverImplTest, PreviewFieldWithValue) { | |
| 297 base::string16 input_value(base::ASCIIToUTF16("barqux")); | |
| 298 base::string16 output_value; | |
| 299 driver_->RendererShouldPreviewFieldWithValue(input_value); | |
| 300 EXPECT_TRUE(GetString16FromMessageWithID( | |
| 301 AutofillMsg_PreviewFieldWithValue::ID, | |
| 302 &output_value)); | |
| 303 EXPECT_EQ(input_value, output_value); | |
| 304 } | |
| 305 | |
| 293 } // namespace autofill | 306 } // namespace autofill |
| OLD | NEW |