Commit 46019e6e authored by Sreeja Kamishetty's avatar Sreeja Kamishetty Committed by Chromium LUCI CQ

Remove TestWebContents::TestDidNavigate

This CL removes the following legacy code:
1) TestWebContents::TestDidNavigate
2) TestWebContents::TestDidNavigateWithSequenceNumber

which are used in unittests to directly call the main implementation.

We modify the unittests which use TestWebContents::TestDidNavigate
to use TestRenderFrameHost::SendNavigateWithTransition to perform the
same actions.

Bug: 1163106
Change-Id: Ifd6360c310c8eef537a7628a76c5fd972588786b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2606003
Commit-Queue: Sreeja Kamishetty <sreejakshetty@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844077}
parent f8267016
...@@ -3443,8 +3443,8 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPruneTargetPending2) { ...@@ -3443,8 +3443,8 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPruneTargetPending2) {
EXPECT_EQ(url2b, other_controller.GetPendingEntry()->GetURL()); EXPECT_EQ(url2b, other_controller.GetPendingEntry()->GetURL());
// Let the pending entry commit. // Let the pending entry commit.
other_contents->TestDidNavigate(other_contents->GetMainFrame(), false, url2b, other_contents->GetMainFrame()->SendNavigateWithTransition(
ui::PAGE_TRANSITION_LINK); 0, false, url2b, ui::PAGE_TRANSITION_LINK);
} }
// Test CopyStateFromAndPrune with 2 urls, a back navigation pending in the // Test CopyStateFromAndPrune with 2 urls, a back navigation pending in the
......
...@@ -771,9 +771,8 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) { ...@@ -771,9 +771,8 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) {
EXPECT_TRUE(controller().NeedsReload()); EXPECT_TRUE(controller().NeedsReload());
controller().LoadIfNecessary(); controller().LoadIfNecessary();
orig_rfh->PrepareForCommit(); orig_rfh->SendNavigateWithTransition(0, false, native_url,
contents()->TestDidNavigate(orig_rfh, false, native_url, ui::PAGE_TRANSITION_RELOAD);
ui::PAGE_TRANSITION_RELOAD);
EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL());
EXPECT_FALSE(orig_instance->HasSite()); EXPECT_FALSE(orig_instance->HasSite());
...@@ -814,8 +813,8 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) { ...@@ -814,8 +813,8 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) {
EXPECT_TRUE(controller().NeedsReload()); EXPECT_TRUE(controller().NeedsReload());
controller().LoadIfNecessary(); controller().LoadIfNecessary();
orig_rfh->PrepareForCommit(); orig_rfh->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, false, regular_url, orig_rfh->SendNavigateWithTransition(0, false, regular_url,
ui::PAGE_TRANSITION_RELOAD); ui::PAGE_TRANSITION_RELOAD);
EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
EXPECT_TRUE(orig_instance->HasSite()); EXPECT_TRUE(orig_instance->HasSite());
EXPECT_EQ(AreDefaultSiteInstancesEnabled(), EXPECT_EQ(AreDefaultSiteInstancesEnabled(),
...@@ -1244,8 +1243,8 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackOldNavigationIgnored) { ...@@ -1244,8 +1243,8 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackOldNavigationIgnored) {
EXPECT_EQ(entry1, controller().GetLastCommittedEntry()); EXPECT_EQ(entry1, controller().GetLastCommittedEntry());
// When the second back commits, it should be ignored. // When the second back commits, it should be ignored.
contents()->TestDidNavigate(google_rfh, false, url2, google_rfh->SendNavigateWithTransition(0, false, url2,
ui::PAGE_TRANSITION_TYPED); ui::PAGE_TRANSITION_TYPED);
EXPECT_EQ(entry1, controller().GetLastCommittedEntry()); EXPECT_EQ(entry1, controller().GetLastCommittedEntry());
// The newly created process for url1 should be locked to chrome://gpu. // The newly created process for url1 should be locked to chrome://gpu.
......
...@@ -26,7 +26,6 @@ class Size; ...@@ -26,7 +26,6 @@ class Size;
namespace content { namespace content {
class BrowserContext; class BrowserContext;
class RenderFrameHost;
// This interface allows embedders of content/ to write tests that depend on a // This interface allows embedders of content/ to write tests that depend on a
// test version of WebContents. This interface can be retrieved from any // test version of WebContents. This interface can be retrieved from any
...@@ -93,17 +92,6 @@ class WebContentsTester { ...@@ -93,17 +92,6 @@ class WebContentsTester {
// Sets the loading state to the given value. // Sets the loading state to the given value.
virtual void TestSetIsLoading(bool value) = 0; virtual void TestSetIsLoading(bool value) = 0;
// Simulates a navigation with the given information.
//
// Guidance for calling these:
// - did_create_new_entry should be true if simulating a navigation that
// created a new navigation entry; false for history navigations, reloads,
// and other navigations that don't affect the history list.
virtual void TestDidNavigate(RenderFrameHost* render_frame_host,
bool did_create_new_entry,
const GURL& url,
ui::PageTransition transition) = 0;
// Simulate this WebContents' main frame having an opener that points to the // Simulate this WebContents' main frame having an opener that points to the
// main frame of |opener|. // main frame of |opener|.
virtual void SetOpener(WebContents* opener) = 0; virtual void SetOpener(WebContents* opener) = 0;
......
...@@ -129,65 +129,6 @@ const base::string16& TestWebContents::GetTitle() { ...@@ -129,65 +129,6 @@ const base::string16& TestWebContents::GetTitle() {
return WebContentsImpl::GetTitle(); return WebContentsImpl::GetTitle();
} }
void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host,
bool did_create_new_entry,
const GURL& url,
ui::PageTransition transition) {
TestDidNavigateWithSequenceNumber(render_frame_host, did_create_new_entry,
url, Referrer(), transition, false, -1, -1);
}
void TestWebContents::TestDidNavigateWithSequenceNumber(
RenderFrameHost* render_frame_host,
bool did_create_new_entry,
const GURL& url,
const Referrer& referrer,
ui::PageTransition transition,
bool was_within_same_document,
int item_sequence_number,
int document_sequence_number) {
TestRenderFrameHost* rfh =
static_cast<TestRenderFrameHost*>(render_frame_host);
rfh->InitializeRenderFrameIfNeeded();
if (!rfh->is_loading())
rfh->SimulateNavigationStart(url);
auto params = mojom::DidCommitProvisionalLoadParams::New();
params->item_sequence_number = item_sequence_number;
params->document_sequence_number = document_sequence_number;
params->url = url;
params->base_url = GURL();
params->referrer = blink::mojom::Referrer::From(referrer);
params->transition = transition;
params->redirects = std::vector<GURL>();
params->should_update_history = true;
params->contents_mime_type = std::string("text/html");
params->intended_as_new_entry = did_create_new_entry;
params->did_create_new_entry = did_create_new_entry;
params->should_replace_current_entry = false;
params->gesture = NavigationGestureUser;
params->method = "GET";
params->post_id = 0;
params->http_status_code = 200;
params->url_is_unreachable = false;
if (item_sequence_number != -1 && document_sequence_number != -1) {
params->page_state = blink::PageState::CreateForTestingWithSequenceNumbers(
url, item_sequence_number, document_sequence_number);
} else {
params->page_state = blink::PageState::CreateFromURL(url);
}
params->original_request_url = GURL();
params->is_overriding_user_agent = false;
params->history_list_was_cleared = false;
params->origin = url::Origin::Create(url);
params->insecure_request_policy =
blink::mojom::InsecureRequestPolicy::kLeaveInsecureRequestsAlone;
params->has_potentially_trustworthy_unique_origin = false;
rfh->SendNavigateWithParams(std::move(params), was_within_same_document);
}
const std::string& TestWebContents::GetSaveFrameHeaders() { const std::string& TestWebContents::GetSaveFrameHeaders() {
return save_frame_headers_; return save_frame_headers_;
} }
......
...@@ -74,18 +74,6 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester { ...@@ -74,18 +74,6 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
void NavigateAndFail(const GURL& url, int error_code) override; void NavigateAndFail(const GURL& url, int error_code) override;
void TestSetIsLoading(bool value) override; void TestSetIsLoading(bool value) override;
void TestDidNavigate(RenderFrameHost* render_frame_host,
bool did_create_new_entry,
const GURL& url,
ui::PageTransition transition) override;
void TestDidNavigateWithSequenceNumber(RenderFrameHost* render_frame_host,
bool did_create_new_entry,
const GURL& url,
const Referrer& referrer,
ui::PageTransition transition,
bool was_within_same_document,
int item_sequence_number,
int document_sequence_number);
void SetOpener(WebContents* opener) override; void SetOpener(WebContents* opener) override;
const std::string& GetSaveFrameHeaders() override; const std::string& GetSaveFrameHeaders() override;
const base::string16& GetSuggestedFileName() override; const base::string16& GetSuggestedFileName() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment