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

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

Issue 17572015: Begin abstracting sending of IPC from autofill core code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 months 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 9b0e5d490a3b083fb08f1bae5dd21149e168d7b5..f8e3ed7ec9b479e362937df22e561c94ab502649 100644
--- a/components/autofill/content/browser/autofill_driver_impl_unittest.cc
+++ b/components/autofill/content/browser/autofill_driver_impl_unittest.cc
@@ -8,12 +8,16 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/autofill/content/browser/autofill_driver_impl.h"
+#include "components/autofill/core/browser/autofill_common_test.h"
#include "components/autofill/core/browser/autofill_external_delegate.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/test_autofill_manager_delegate.h"
+#include "components/autofill/core/common/autofill_messages.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/frame_navigate_params.h"
+#include "content/public/test/mock_render_process_host.h"
+#include "ipc/ipc_test_sink.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -74,6 +78,28 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness {
}
protected:
+ // 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
+ // with the values of the message's parameters, and clears the queue of sent
+ // messages.
+ bool GetAutofillFormDataFilledMessage(int* page_id, FormData* results) {
+ const uint32 kMsgID = AutofillMsg_FormDataFilled::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ if (!message)
+ return false;
+ Tuple2<int, FormData> autofill_param;
+ AutofillMsg_FormDataFilled::Read(message, &autofill_param);
+ if (page_id)
+ *page_id = autofill_param.a;
+ if (results)
+ *results = autofill_param.b;
+
+ process()->sink().ClearMessages();
+ return true;
+ }
+
scoped_ptr<TestAutofillManagerDelegate> test_manager_delegate_;
scoped_ptr<TestAutofillDriverImpl> driver_;
};
@@ -97,4 +123,18 @@ TEST_F(AutofillDriverImplTest, NavigatedWithinSamePage) {
driver_->DidNavigateMainFrame(details, params);
}
+TEST_F(AutofillDriverImplTest, FormDataSentToRenderer) {
+ int input_page_id = 42;
+ FormData input_form_data;
+ test::CreateTestAddressFormData(&input_form_data);
+ driver_->SendFormDataToRenderer(input_page_id, input_form_data);
+
+ int output_page_id = 0;
+ FormData output_form_data;
+ EXPECT_TRUE(GetAutofillFormDataFilledMessage(&output_page_id,
+ &output_form_data));
+ EXPECT_EQ(input_page_id, output_page_id);
+ EXPECT_EQ(input_form_data, output_form_data);
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/content/browser/autofill_driver_impl.cc ('k') | components/autofill/core/browser/autofill_common_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698