diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-14 07:38:17 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-14 07:38:17 +0000 |
commit | 93ab5934cb37e79ed6367237eca98cf2ff9d3320 (patch) | |
tree | b355a6f82446d075a8c78d50161863873a06844c /content | |
parent | 9ab0ea353453e0f9a2e97132d86d415ea4192977 (diff) | |
download | chromium_src-93ab5934cb37e79ed6367237eca98cf2ff9d3320.zip chromium_src-93ab5934cb37e79ed6367237eca98cf2ff9d3320.tar.gz chromium_src-93ab5934cb37e79ed6367237eca98cf2ff9d3320.tar.bz2 |
Add ChromeRenderViewHostTestHarness to get rid of the dependency from RVHTH to profile
BUG=90443
TEST=everything still works
Review URL: http://codereview.chromium.org/7892007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/browser_context.h | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/test_render_view_host.cc | 23 | ||||
-rw-r--r-- | content/browser/renderer_host/test_render_view_host.h | 16 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_controller_unittest.cc | 4 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager_unittest.cc | 32 | ||||
-rw-r--r-- | content/content_tests.gypi | 10 |
6 files changed, 52 insertions, 35 deletions
diff --git a/content/browser/browser_context.h b/content/browser/browser_context.h index 15125ca..feda556 100644 --- a/content/browser/browser_context.h +++ b/content/browser/browser_context.h @@ -41,6 +41,8 @@ class ResourceContext; // It lives on the UI thread. class BrowserContext { public: + virtual ~BrowserContext() {}; + // Returns the path of the directory where this context's data is stored. virtual FilePath GetPath() = 0; diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index 1ddb875..9303f86 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/test/base/testing_profile.h" #include "content/browser/browser_url_handler.h" #include "content/browser/renderer_host/test_backing_store.h" #include "content/browser/renderer_host/test_render_view_host.h" @@ -12,6 +11,7 @@ #include "content/common/content_client.h" #include "content/common/dom_storage_common.h" #include "content/common/view_messages.h" +#include "content/test/test_browser_context.h" #include "ui/gfx/rect.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" @@ -307,8 +307,8 @@ TestRenderViewHost* RenderViewHostTestHarness::active_rvh() { return pending_rvh() ? pending_rvh() : rvh(); } -TestingProfile* RenderViewHostTestHarness::profile() { - return profile_.get(); +content::BrowserContext* RenderViewHostTestHarness::browser_context() { + return browser_context_.get(); } MockRenderProcessHost* RenderViewHostTestHarness::process() { @@ -326,14 +326,15 @@ void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { } TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() { - // See comment above profile_ decl for why we check for NULL here. - if (!profile_.get()) - profile_.reset(new TestingProfile()); + // See comment above browser_context_ decl for why we check for NULL here. + if (!browser_context_.get()) + browser_context_.reset(new TestBrowserContext()); // This will be deleted when the TabContents goes away. - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); + SiteInstance* instance = + SiteInstance::CreateSiteInstance(browser_context_.get()); - return new TestTabContents(profile_.get(), instance); + return new TestTabContents(browser_context_.get(), instance); } void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { @@ -355,10 +356,10 @@ void RenderViewHostTestHarness::TearDown() { SetContents(NULL); // Make sure that we flush any messages related to TabContents destruction - // before we destroy the profile. + // before we destroy the browser context. MessageLoop::current()->RunAllPending(); - // Release the profile on the UI thread. - message_loop_.DeleteSoon(FROM_HERE, profile_.release()); + // Release the browser context on the UI thread. + message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); message_loop_.RunAllPending(); } diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 8761a93..8c66291 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -17,13 +17,16 @@ #include "content/common/page_transition_types.h" #include "testing/gtest/include/gtest/gtest.h" +namespace content { +class BrowserContext; +} + namespace gfx { class Rect; } class NavigationController; class SiteInstance; -class TestingProfile; class TestTabContents; struct WebMenuItem; struct ViewHostMsg_FrameNavigate_Params; @@ -292,7 +295,7 @@ class RenderViewHostTestHarness : public testing::Test { TestRenderViewHost* rvh(); TestRenderViewHost* pending_rvh(); TestRenderViewHost* active_rvh(); - TestingProfile* profile(); + content::BrowserContext* browser_context(); MockRenderProcessHost* process(); // Frees the current tab contents for tests that want to test destruction. @@ -317,10 +320,11 @@ class RenderViewHostTestHarness : public testing::Test { virtual void SetUp(); virtual void TearDown(); - // This profile will be created in SetUp if it has not already been created. - // This allows tests to override the profile if they so choose in their own - // SetUp function before calling the base class's (us) SetUp(). - scoped_ptr<TestingProfile> profile_; + // This browser context will be created in SetUp if it has not already been + // created. This allows tests to override the browser context if they so + // choose in their own SetUp function before calling the base class's (us) + // SetUp(). + scoped_ptr<content::BrowserContext> browser_context_; MessageLoopForUI message_loop_; diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc index 5d6d953..88ad37b 100644 --- a/content/browser/tab_contents/navigation_controller_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_unittest.cc @@ -16,8 +16,8 @@ // #include "chrome/browser/sessions/session_service_factory.h" // #include "chrome/browser/sessions/session_service_test_helper.h" // #include "chrome/browser/sessions/session_types.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/navigation_details.h" @@ -36,7 +36,7 @@ using base::Time; // NavigationControllerTest ---------------------------------------------------- -class NavigationControllerTest : public RenderViewHostTestHarness { +class NavigationControllerTest : public ChromeRenderViewHostTestHarness { public: NavigationControllerTest() {} }; diff --git a/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc index b9ed739..4b07ea18 100644 --- a/content/browser/tab_contents/render_view_host_manager_unittest.cc +++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/browser_thread.h" #include "content/browser/browser_url_handler.h" -#include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/navigation_entry.h" @@ -20,7 +20,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webkit/glue/webkit_glue.h" -class RenderViewHostManagerTest : public RenderViewHostTestHarness { +class RenderViewHostManagerTest : public ChromeRenderViewHostTestHarness { public: void NavigateActiveAndCommit(const GURL& url) { // Note: we navigate the active RenderViewHost because previous navigations @@ -67,7 +67,7 @@ TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { NavigateActiveAndCommit(kDestUrl); // Make a second tab. - TestTabContents contents2(profile_.get(), NULL); + TestTabContents contents2(profile(), NULL); // Load the two URLs in the second tab. Note that the first navigation creates // a RVH that's not pending (since there is no cross-site transition), so @@ -167,13 +167,13 @@ TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { // Tests the Init function by checking the initial RenderViewHost. TEST_F(RenderViewHostManagerTest, Init) { // Using TestingProfile. - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); + SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); EXPECT_FALSE(instance->has_site()); - TestTabContents tab_contents(profile_.get(), instance); + TestTabContents tab_contents(profile(), instance); RenderViewHostManager manager(&tab_contents, &tab_contents); - manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); + manager.Init(profile(), instance, MSG_ROUTING_NONE); RenderViewHost* host = manager.current_host(); ASSERT_TRUE(host); @@ -188,16 +188,16 @@ TEST_F(RenderViewHostManagerTest, Init) { TEST_F(RenderViewHostManagerTest, Navigate) { TestNotificationTracker notifications; - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); + SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); - TestTabContents tab_contents(profile_.get(), instance); + TestTabContents tab_contents(profile(), instance); notifications.ListenFor(content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, Source<NavigationController>(&tab_contents.controller())); // Create. RenderViewHostManager manager(&tab_contents, &tab_contents); - manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); + manager.Init(profile(), instance, MSG_ROUTING_NONE); RenderViewHost* host; @@ -266,12 +266,12 @@ TEST_F(RenderViewHostManagerTest, Navigate) { // Tests WebUI creation. TEST_F(RenderViewHostManagerTest, WebUI) { BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); + SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); - TestTabContents tab_contents(profile_.get(), instance); + TestTabContents tab_contents(profile(), instance); RenderViewHostManager manager(&tab_contents, &tab_contents); - manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); + manager.Init(profile(), instance, MSG_ROUTING_NONE); const GURL kUrl(chrome::kTestNewTabURL); NavigationEntry entry(NULL /* instance */, -1 /* page_id */, kUrl, @@ -305,10 +305,10 @@ TEST_F(RenderViewHostManagerTest, WebUI) { // Regression test for bug 46290. TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { BrowserThread thread(BrowserThread::UI, &message_loop_); - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); - TestTabContents tab_contents(profile_.get(), instance); + SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); + TestTabContents tab_contents(profile(), instance); RenderViewHostManager manager(&tab_contents, &tab_contents); - manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); + manager.Init(profile(), instance, MSG_ROUTING_NONE); // NTP is a Web UI page. const GURL kNtpUrl(chrome::kTestNewTabURL); @@ -321,7 +321,7 @@ TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { // Rewrite so it looks like chrome://about/memory bool reverse_on_redirect = false; BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( - &about_url, profile_.get(), &reverse_on_redirect); + &about_url, profile(), &reverse_on_redirect); NavigationEntry about_entry(NULL /* instance */, -1 /* page_id */, about_url, GURL() /* referrer */, string16() /* title */, PageTransition::TYPED); diff --git a/content/content_tests.gypi b/content/content_tests.gypi index fb1f4e0..c8bdd38 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -34,6 +34,14 @@ 'browser/renderer_host/dummy_resource_handler.h', 'browser/renderer_host/media/mock_media_observer.cc', 'browser/renderer_host/media/mock_media_observer.h', + 'browser/renderer_host/test_backing_store.cc', + 'browser/renderer_host/test_backing_store.h', + 'browser/renderer_host/test_render_view_host.cc', + 'browser/renderer_host/test_render_view_host.h', + 'browser/renderer_host/mock_render_process_host.cc', + 'browser/renderer_host/mock_render_process_host.h', + 'browser/tab_contents/test_tab_contents.cc', + 'browser/tab_contents/test_tab_contents.h', 'common/test_url_constants.cc', 'common/test_url_constants.h', 'gpu/gpu_idirect3d9_mock_win.cc', @@ -93,6 +101,7 @@ 'browser/device_orientation/provider_unittest.cc', 'browser/download/base_file_unittest.cc', 'browser/download/download_status_updater_unittest.cc', + 'browser/download/save_package_unittest.cc', 'browser/geolocation/device_data_provider_unittest.cc', 'browser/geolocation/geolocation_provider_unittest.cc', 'browser/geolocation/gps_location_provider_unittest_linux.cc', @@ -113,6 +122,7 @@ 'browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc', 'browser/renderer_host/media/video_capture_host_unittest.cc', 'browser/renderer_host/media/video_capture_manager_unittest.cc', + 'browser/renderer_host/render_view_host_unittest.cc', 'browser/renderer_host/resource_dispatcher_host_unittest.cc', 'browser/renderer_host/resource_queue_unittest.cc', 'browser/resolve_proxy_msg_helper_unittest.cc', |