summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/web_navigation
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 04:25:35 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 04:25:35 +0000
commita88f63686baa4751ab6638413ca7b62f8a3c2738 (patch)
tree0b8a7e13326055789131f47ef4dd60ba707d33f7 /chrome/browser/extensions/api/web_navigation
parentd75d14350f6875855cc465ba06a2e3807b879269 (diff)
downloadchromium_src-a88f63686baa4751ab6638413ca7b62f8a3c2738.zip
chromium_src-a88f63686baa4751ab6638413ca7b62f8a3c2738.tar.gz
chromium_src-a88f63686baa4751ab6638413ca7b62f8a3c2738.tar.bz2
Run ContentMain in a browser_test's browser process. This removes duplication of code in the browser test harness for setting up the browser process, and also ensures that initialization code in ContentMainRunner runs.
Most of the changes are to unit tests which run in browser test executables. These were getting all the setup that these binaries did for browser tests even though they were unit tests. Now they have to explicitly setup objects that they need. This would be done automatically if they were in a unit test binary and therefore using the unit test harness. The goal should be to move these tests to unit test binaries, and make them support launching some tests in separate processes building on the work that Pawel did. BUG=350550 R=sky@chromium.org Review URL: https://codereview.chromium.org/190663012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257597 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/web_navigation')
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc91
1 files changed, 11 insertions, 80 deletions
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
index 6b7cc87..60c1012 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
@@ -257,75 +257,6 @@ class TestResourceDispatcherHostDelegate
DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate);
};
-// Used to manage the lifetime of the TestResourceDispatcherHostDelegate which
-// needs to be deleted before the threads are stopped.
-class TestBrowserMainExtraParts : public ChromeBrowserMainExtraParts {
- public:
- explicit TestBrowserMainExtraParts(
- TestNavigationListener* test_navigation_listener)
- : test_navigation_listener_(test_navigation_listener) {
- }
- virtual ~TestBrowserMainExtraParts() {}
-
- TestResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() {
- if (!resource_dispatcher_host_delegate_.get()) {
- resource_dispatcher_host_delegate_.reset(
- new TestResourceDispatcherHostDelegate(
- g_browser_process->prerender_tracker(),
- test_navigation_listener_.get()));
- }
- return resource_dispatcher_host_delegate_.get();
- }
-
- // ChromeBrowserMainExtraParts implementation.
- virtual void PostMainMessageLoopRun() OVERRIDE {
- resource_dispatcher_host_delegate_.reset();
- }
-
- private:
- scoped_refptr<TestNavigationListener> test_navigation_listener_;
- scoped_ptr<TestResourceDispatcherHostDelegate>
- resource_dispatcher_host_delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(TestBrowserMainExtraParts);
-};
-
-// A ContentBrowserClient that doesn't forward the RDH created signal.
-class TestContentBrowserClient : public chrome::ChromeContentBrowserClient {
- public:
- explicit TestContentBrowserClient(
- TestNavigationListener* test_navigation_listener)
- : test_navigation_listener_(test_navigation_listener) {
- }
- virtual ~TestContentBrowserClient() {}
-
- virtual void ResourceDispatcherHostCreated() OVERRIDE {
- // Don't invoke ChromeContentBrowserClient::ResourceDispatcherHostCreated.
- // It would notify BrowserProcessImpl which would create a
- // ChromeResourceDispatcherHostDelegate and other objects. Not creating
- // other objects might turn out to be a problem in the future.
- content::ResourceDispatcherHost::Get()->SetDelegate(
- browser_main_extra_parts_->resource_dispatcher_host_delegate());
- }
-
- virtual content::BrowserMainParts* CreateBrowserMainParts(
- const content::MainFunctionParams& parameters) OVERRIDE {
- ChromeBrowserMainParts* main_parts = static_cast<ChromeBrowserMainParts*>(
- ChromeContentBrowserClient::CreateBrowserMainParts(parameters));
-
- browser_main_extra_parts_ =
- new TestBrowserMainExtraParts(test_navigation_listener_.get());
- main_parts->AddParts(browser_main_extra_parts_);
- return main_parts;
- }
-
- private:
- scoped_refptr<TestNavigationListener> test_navigation_listener_;
- TestBrowserMainExtraParts* browser_main_extra_parts_;
-
- DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient);
-};
-
} // namespace
class WebNavigationApiTest : public ExtensionApiTest {
@@ -336,12 +267,6 @@ class WebNavigationApiTest : public ExtensionApiTest {
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
ExtensionApiTest::SetUpInProcessBrowserTestFixture();
- test_navigation_listener_ = new TestNavigationListener();
- content_browser_client_.reset(
- new TestContentBrowserClient(test_navigation_listener_.get()));
- original_content_browser_client_ = content::SetBrowserClientForTesting(
- content_browser_client_.get());
-
FrameNavigationState::set_allow_extension_scheme(true);
CommandLine::ForCurrentProcess()->AppendSwitch(
@@ -350,9 +275,15 @@ class WebNavigationApiTest : public ExtensionApiTest {
host_resolver()->AddRule("*", "127.0.0.1");
}
- virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
- ExtensionApiTest::TearDownInProcessBrowserTestFixture();
- content::SetBrowserClientForTesting(original_content_browser_client_);
+ virtual void SetUpOnMainThread() OVERRIDE {
+ ExtensionApiTest::SetUpOnMainThread();
+ test_navigation_listener_ = new TestNavigationListener();
+ resource_dispatcher_host_delegate_.reset(
+ new TestResourceDispatcherHostDelegate(
+ g_browser_process->prerender_tracker(),
+ test_navigation_listener_.get()));
+ content::ResourceDispatcherHost::Get()->SetDelegate(
+ resource_dispatcher_host_delegate_.get());
}
TestNavigationListener* test_navigation_listener() {
@@ -361,8 +292,8 @@ class WebNavigationApiTest : public ExtensionApiTest {
private:
scoped_refptr<TestNavigationListener> test_navigation_listener_;
- scoped_ptr<TestContentBrowserClient> content_browser_client_;
- content::ContentBrowserClient* original_content_browser_client_;
+ scoped_ptr<TestResourceDispatcherHostDelegate>
+ resource_dispatcher_host_delegate_;
DISALLOW_COPY_AND_ASSIGN(WebNavigationApiTest);
};