Chromium Code Reviews| Index: components/autofill/content/browser/content_autofill_driver_unittest.cc |
| diff --git a/components/autofill/content/browser/content_autofill_driver_unittest.cc b/components/autofill/content/browser/content_autofill_driver_unittest.cc |
| index 3dbbd572f3c684364d9d1b4862b645c751bd3109..70c3222105f17178649423675283bf284522c6d6 100644 |
| --- a/components/autofill/content/browser/content_autofill_driver_unittest.cc |
| +++ b/components/autofill/content/browser/content_autofill_driver_unittest.cc |
| @@ -21,8 +21,8 @@ |
| #include "components/autofill/core/common/autofill_switches.h" |
| #include "components/autofill/core/common/form_data_predictions.h" |
| #include "content/public/browser/browser_context.h" |
| -#include "content/public/browser/navigation_details.h" |
| #include "content/public/browser/navigation_entry.h" |
| +#include "content/public/browser/navigation_handle.h" |
| #include "content/public/browser/ssl_status.h" |
| #include "content/public/browser/storage_partition.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -264,6 +264,9 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness { |
| public: |
| void SetUp() override { |
| content::RenderViewHostTestHarness::SetUp(); |
| + // This needed to keep the WebContentsObserverSanityChecker checks happy for |
| + // when AppendChild is called. |
| + NavigateAndCommit(GURL("about:blank")); |
| test_autofill_client_.reset(new MockAutofillClient()); |
| driver_.reset(new TestContentAutofillDriver(web_contents()->GetMainFrame(), |
| @@ -284,6 +287,18 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness { |
| content::RenderViewHostTestHarness::TearDown(); |
| } |
| + void Navigate(bool main_frame) { |
| + content::RenderFrameHost* rfh = main_rfh(); |
| + content::RenderFrameHostTester* rfh_tester = |
| + content::RenderFrameHostTester::For(rfh); |
| + if (!main_frame) |
| + rfh = rfh_tester->AppendChild("subframe"); |
| + std::unique_ptr<content::NavigationHandle> navigation_handle = |
| + content::NavigationHandle::CreateNavigationHandleForTesting( |
| + GURL(), rfh, true); |
| + driver_->DidNavigateFrame(navigation_handle.get()); |
| + } |
| + |
| protected: |
| std::unique_ptr<MockAutofillClient> test_autofill_client_; |
| std::unique_ptr<TestContentAutofillDriver> driver_; |
| @@ -302,21 +317,11 @@ TEST_F(ContentAutofillDriverTest, GetURLRequestContext) { |
| TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) { |
| EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); |
| - content::LoadCommittedDetails details = content::LoadCommittedDetails(); |
| - details.is_main_frame = true; |
| - details.is_in_page = false; |
| - ASSERT_TRUE(details.is_navigation_to_different_page()); |
| - content::FrameNavigateParams params = content::FrameNavigateParams(); |
| - driver_->DidNavigateFrame(details, params); |
| + Navigate(true); |
| } |
| TEST_F(ContentAutofillDriverTest, NavigatedWithinSamePage) { |
| - EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()).Times(0); |
|
Evan Stade
2017/02/06 16:09:23
did you mean to delete this expectation?
jam
2017/02/06 16:58:06
oops, no that was a mistake, thanks for pointing i
|
| - content::LoadCommittedDetails details = content::LoadCommittedDetails(); |
| - details.is_main_frame = false; |
| - ASSERT_TRUE(!details.is_navigation_to_different_page()); |
| - content::FrameNavigateParams params = content::FrameNavigateParams(); |
| - driver_->DidNavigateFrame(details, params); |
| + Navigate(false); |
| } |
| TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) { |