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 9b0e5d490a3b083fb08f1bae5dd21149e168d7b5..6a958ffafe736a5cd71380f7c66098e8a7b5dba3 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,23 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { |
| } |
| protected: |
| + bool GetAutofillFormDataFilledMessage(int* page_id, FormData* results) { |
|
Ilya Sherman
2013/06/26 22:54:58
nit: Docs, please.
blundell
2013/06/27 21:58:27
Done.
|
| + 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 +118,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 |