Commit 232d27cb authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Remove dependency on test_web_contents.h from background_tab_navigation_throttle_unittest.cc.

Bug: 796981
Change-Id: I27809072f7d22cccec8977de71ec2312b16def4d
Reviewed-on: https://chromium-review.googlesource.com/923567Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537515}
parent 8aefd688
include_rules = [
# TODO(mash): Remove. http://crbug.com/723881
"+ash/shell.h",
"+content/test/test_web_contents.h",
"+services/resource_coordinator/public",
# No inclusion of WebKit from the browser, other than strictly enum/POD,
# header-only types, and some selected common code.
......
......@@ -15,7 +15,7 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/web_contents.h"
#include "content/test/test_web_contents.h"
#include "content/public/test/web_contents_tester.h"
#include "url/gurl.h"
namespace resource_coordinator {
......@@ -93,12 +93,10 @@ TEST_P(BackgroundTabNavigationThrottleTest, Instantiate) {
else
web_contents()->WasShown();
std::unique_ptr<content::TestWebContents> opener(
content::TestWebContents::Create(browser_context(),
main_rfh()->GetSiteInstance()));
std::unique_ptr<content::WebContents> opener;
if (!no_opener_) {
static_cast<content::TestWebContents*>(web_contents())
->SetOpener(opener.get());
opener.reset(CreateTestWebContents());
content::WebContentsTester::For(web_contents())->SetOpener(opener.get());
}
content::RenderFrameHost* rfh;
......
......@@ -108,6 +108,10 @@ class WebContentsTester {
NavigationHandle* navigation_handle,
scoped_refptr<net::HttpResponseHeaders> response_headers) = 0;
// Simulate this WebContents' main frame having an opener that points to the
// main frame of |opener|.
virtual void SetOpener(WebContents* opener) = 0;
// Returns headers that were passed in the previous SaveFrameWithHeaders(...)
// call.
virtual const std::string& GetSaveFrameHeaders() = 0;
......
......@@ -285,8 +285,9 @@ RenderViewHostDelegateView* TestWebContents::GetDelegateView() {
return WebContentsImpl::GetDelegateView();
}
void TestWebContents::SetOpener(TestWebContents* opener) {
frame_tree_.root()->SetOpener(opener->GetFrameTree()->root());
void TestWebContents::SetOpener(WebContents* opener) {
frame_tree_.root()->SetOpener(
static_cast<WebContentsImpl*>(opener)->GetFrameTree()->root());
}
void TestWebContents::AddPendingContents(TestWebContents* contents) {
......
......@@ -78,6 +78,13 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
bool was_within_same_document,
int item_sequence_number,
int document_sequence_number);
void SetNavigationData(
NavigationHandle* navigation_handle,
std::unique_ptr<NavigationData> navigation_data) override;
void SetHttpResponseHeaders(
NavigationHandle* navigation_handle,
scoped_refptr<net::HttpResponseHeaders> response_headers) override;
void SetOpener(WebContents* opener) override;
const std::string& GetSaveFrameHeaders() override;
bool HasPendingDownloadImage(const GURL& url) override;
bool TestDidDownloadImage(
......@@ -113,10 +120,6 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
delegate_view_override_ = view;
}
// Allows us to simulate this tab's main frame having an opener that points
// to the main frame of the |opener|.
void SetOpener(TestWebContents* opener);
// Allows us to simulate that a contents was created via CreateNewWindow.
void AddPendingContents(TestWebContents* contents);
......@@ -136,14 +139,6 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
int error_code,
const base::string16& error_description);
void SetNavigationData(
NavigationHandle* navigation_handle,
std::unique_ptr<NavigationData> navigation_data) override;
void SetHttpResponseHeaders(
NavigationHandle* navigation_handle,
scoped_refptr<net::HttpResponseHeaders> response_headers) override;
protected:
// The deprecated WebContentsTester still needs to subclass this.
explicit TestWebContents(BrowserContext* browser_context);
......
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