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..157ee17dd11b77dd79ff35027e6e7d7f1e2b9e48 100644 |
--- a/components/autofill/content/browser/autofill_driver_impl_unittest.cc |
+++ b/components/autofill/content/browser/autofill_driver_impl_unittest.cc |
@@ -144,6 +144,24 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { |
return true; |
} |
+ // Searches for an |AutofillMsg_SetNodeText| message in the queue of sent IPC |
+ // messages. If none is present, returns false. Otherwise, extracts the first |
+ // |AutofillMsg_SetNodeText| message, fills the output parameter with the |
+ // value of the message's parameter, and clears the queue of sent messages. |
+ bool GetSetNodeText(base::string16* value) { |
jif-google
2013/11/13 08:24:45
GetSetNodeText could be factored with GetAcceptDat
blundell
2013/11/13 11:55:45
I think it would be worth doing a |GetValueFromMes
jif-google
2013/11/13 14:20:25
Done.
|
+ const uint32 kMsgID = AutofillMsg_SetNodeText::ID; |
+ const IPC::Message* message = |
+ process()->sink().GetFirstMessageMatching(kMsgID); |
+ if (!message) |
+ return false; |
+ Tuple1<base::string16> autofill_param; |
+ AutofillMsg_SetNodeText::Read(message, &autofill_param); |
+ 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. |
@@ -249,4 +267,12 @@ TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { |
EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); |
} |
+TEST_F(AutofillDriverImplTest, SetNodeText) { |
+ base::string16 inputValue(UTF8ToUTF16("barqux")); |
+ base::string16 outputValue; |
+ driver_->RendererShouldSetNodeText(inputValue); |
+ EXPECT_TRUE(GetSetNodeText(&outputValue)); |
+ EXPECT_EQ(inputValue, outputValue); |
+} |
+ |
} // namespace autofill |