Chromium Code Reviews| Index: components/autofill/content/browser/autofill_driver_impl_unittest.cc |
| diff --git a/components/autofill/content/browser/autofill_driver_impl_unittest.cc b/components/autofill/content/browser/autofill_driver_impl_unittest.cc |
| index f213d568d12b539854dc7a4d6ab99c388544193a..68ae5a38fcfdc06e2f6b0ca5c41b7dfef16c7ea3 100644 |
| --- a/components/autofill/content/browser/autofill_driver_impl_unittest.cc |
| +++ b/components/autofill/content/browser/autofill_driver_impl_unittest.cc |
| @@ -82,26 +82,6 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { |
| } |
| protected: |
| - // Searches for an |AutofillMsg_AcceptDataListSuggestion| message in the queue |
| - // of sent IPC messages. If none is present, returns false. Otherwise, |
| - // extracts the first |AutofillMsg_AcceptDataListSuggestion| message, fills |
| - // the output parameter with the value of the message's parameter, and clears |
| - // the queue of sent messages. |
| - bool GetAcceptDataListSuggestion( |
| - base::string16* value) { |
| - const uint32 kMsgID = AutofillMsg_AcceptDataListSuggestion::ID; |
| - const IPC::Message* message = |
| - process()->sink().GetFirstMessageMatching(kMsgID); |
| - if (!message) |
| - return false; |
| - Tuple1<base::string16> autofill_param; |
| - AutofillMsg_AcceptDataListSuggestion::Read(message, &autofill_param); |
| - if (value) |
| - *value = autofill_param.a; |
| - process()->sink().ClearMessages(); |
| - return true; |
| - } |
| - |
| // Searches for an |AutofillMsg_FormDataFilled| message in the queue of sent |
| // IPC messages. If none is present, returns false. Otherwise, extracts the |
| // first |AutofillMsg_FormDataFilled| message, fills the output parameters |
| @@ -145,6 +125,32 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { |
| } |
| // Searches for a message matching |messageID| in the queue of sent IPC |
| + // messages. If none is present, returns false. Otherwise, extracts the first |
| + // matching message, fills the output parameter with the value of the |
| + // message's parameter, and clears the queue of sent messages. |
|
blundell
2013/11/13 15:26:49
Mention that this is specific to the parameter bei
jif-google
2013/11/14 13:52:04
Done.
|
| + bool GetValueFromMessageWithID(uint32 messageID, base::string16* value) { |
|
blundell
2013/11/13 15:26:49
Actually I guess this should be something like |Ge
jif-google
2013/11/14 13:52:04
Done.
|
| + const IPC::Message* message = |
| + process()->sink().GetFirstMessageMatching(messageID); |
| + if (!message) |
| + return false; |
| + Tuple1<base::string16> autofill_param; |
| + switch (messageID) { |
| + case AutofillMsg_SetNodeText::ID: |
| + AutofillMsg_SetNodeText::Read(message, &autofill_param); |
| + break; |
| + case AutofillMsg_AcceptDataListSuggestion::ID: |
| + AutofillMsg_AcceptDataListSuggestion::Read(message, &autofill_param); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| + if (value) |
| + *value = autofill_param.a; |
| + process()->sink().ClearMessages(); |
| + return true; |
| + } |
| + |
| + // Searches for a message matching |messageID| in the queue of sent IPC |
| // messages. If none is present, returns false. Otherwise, clears the queue |
| // of sent messages and returns true. |
| bool HasMessageMatchingID(uint32 messageID) { |
| @@ -235,7 +241,9 @@ TEST_F(AutofillDriverImplTest, AcceptDataListSuggestion) { |
| base::string16 inputValue(UTF8ToUTF16("barfoo")); |
| base::string16 outputValue; |
| driver_->RendererShouldAcceptDataListSuggestion(inputValue); |
| - EXPECT_TRUE(GetAcceptDataListSuggestion(&outputValue)); |
| + EXPECT_TRUE(GetValueFromMessageWithID( |
| + AutofillMsg_AcceptDataListSuggestion::ID, |
| + &outputValue)); |
| EXPECT_EQ(inputValue, outputValue); |
| } |
| @@ -249,4 +257,13 @@ TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { |
| EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); |
| } |
| +TEST_F(AutofillDriverImplTest, SetNodeText) { |
| + base::string16 inputValue(UTF8ToUTF16("barqux")); |
|
Ilya Sherman
2013/11/14 01:26:14
nit: ASCIIToUTF16 (slightly cheaper)
jif-google
2013/11/14 13:52:04
Done.
|
| + base::string16 outputValue; |
| + driver_->RendererShouldSetNodeText(inputValue); |
| + EXPECT_TRUE(GetValueFromMessageWithID(AutofillMsg_SetNodeText::ID, |
| + &outputValue)); |
| + EXPECT_EQ(inputValue, outputValue); |
| +} |
| + |
| } // namespace autofill |