Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: components/autofill/content/browser/autofill_driver_impl_unittest.cc

Issue 69293007: Abstracted AutofillMsg_SetNodeText IPC out of core autofill code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1195020eb1e0724566439f8268d9c6f8a6ebd5be 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 string16 from the
+ // message's parameter, and clears the queue of sent messages.
+ bool GetString16FromMessageWithID(uint32 messageID, base::string16* value) {
+ 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) {
@@ -232,11 +238,13 @@ TEST_F(AutofillDriverImplTest, FillActionSentToRenderer) {
}
TEST_F(AutofillDriverImplTest, AcceptDataListSuggestion) {
- base::string16 inputValue(UTF8ToUTF16("barfoo"));
- base::string16 outputValue;
- driver_->RendererShouldAcceptDataListSuggestion(inputValue);
- EXPECT_TRUE(GetAcceptDataListSuggestion(&outputValue));
- EXPECT_EQ(inputValue, outputValue);
+ base::string16 input_value(ASCIIToUTF16("barfoo"));
+ base::string16 output_value;
+ driver_->RendererShouldAcceptDataListSuggestion(input_value);
+ EXPECT_TRUE(GetString16FromMessageWithID(
+ AutofillMsg_AcceptDataListSuggestion::ID,
+ &output_value));
+ EXPECT_EQ(input_value, output_value);
}
TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) {
@@ -249,4 +257,13 @@ TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) {
EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID));
}
+TEST_F(AutofillDriverImplTest, SetNodeText) {
+ base::string16 input_value(ASCIIToUTF16("barqux"));
+ base::string16 output_value;
+ driver_->RendererShouldSetNodeText(input_value);
+ EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_SetNodeText::ID,
+ &output_value));
+ EXPECT_EQ(input_value, output_value);
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/content/browser/autofill_driver_impl.cc ('k') | components/autofill/core/browser/autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698