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

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

Issue 2672243002: Convert ContentAutofillDriverFactory to use the new navigation callbacks. (Closed)
Patch Set: review comment Created 3 years, 10 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
« no previous file with comments | « components/autofill/content/browser/content_autofill_driver_factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9d7fcb2a767fa0e37cd744c391d66a0eb5ac22be 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,12 @@ 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);
- 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) {
« no previous file with comments | « components/autofill/content/browser/content_autofill_driver_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698