From b47e1ba821a7bb312b2bd3927d333574f70d76e6 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Sun, 18 Jan 2009 07:10:37 +0000 Subject: Reverting 8262. Review URL: http://codereview.chromium.org/18190 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8263 0039d316-1c4b-4281-b951-d872f2087c98 --- .../renderer_host/mock_render_process_host.cc | 65 --------------- .../renderer_host/mock_render_process_host.h | 56 ------------- .../renderer_host/render_view_host_unittest.cc | 21 ----- .../browser/renderer_host/test_render_view_host.cc | 41 ---------- .../browser/renderer_host/test_render_view_host.h | 93 ---------------------- 5 files changed, 276 deletions(-) delete mode 100644 chrome/browser/renderer_host/mock_render_process_host.cc delete mode 100644 chrome/browser/renderer_host/mock_render_process_host.h delete mode 100644 chrome/browser/renderer_host/render_view_host_unittest.cc delete mode 100644 chrome/browser/renderer_host/test_render_view_host.cc delete mode 100644 chrome/browser/renderer_host/test_render_view_host.h (limited to 'chrome/browser/renderer_host') diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc deleted file mode 100644 index 4b8d1b2..0000000 --- a/chrome/browser/renderer_host/mock_render_process_host.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/mock_render_process_host.h" - -MockRenderProcessHost::MockRenderProcessHost(Profile* profile) - : RenderProcessHost(profile) { -} - -MockRenderProcessHost::~MockRenderProcessHost() { -} - -bool MockRenderProcessHost::Init() { - return true; -} - -int MockRenderProcessHost::GetNextRoutingID() { - return 5; -} - -void MockRenderProcessHost::CancelResourceRequests(int render_widget_id) { -} - -void MockRenderProcessHost::CrossSiteClosePageACK( - int new_render_process_host_id, - int new_request_id) { -} - -bool MockRenderProcessHost::WaitForPaintMsg(int render_widget_id, - const base::TimeDelta& max_delay, - IPC::Message* msg) { - return true; -} - -void MockRenderProcessHost::ReceivedBadMessage(uint16 msg_type) { -} - -void MockRenderProcessHost::WidgetRestored() { -} - -void MockRenderProcessHost::WidgetHidden() { -} - -void MockRenderProcessHost::AddWord(const std::wstring& word) { -} - -bool MockRenderProcessHost::FastShutdownIfPossible() { - return false; -} - -bool MockRenderProcessHost::Send(IPC::Message* msg) { - // Save the message in the sink. - sink_.OnMessageReceived(*msg); - return true; -} - -void MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { -} - -void MockRenderProcessHost::OnChannelConnected(int32 peer_pid) { -} - -void MockRenderProcessHost::Unregister() { -} diff --git a/chrome/browser/renderer_host/mock_render_process_host.h b/chrome/browser/renderer_host/mock_render_process_host.h deleted file mode 100644 index a50d32e..0000000 --- a/chrome/browser/renderer_host/mock_render_process_host.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_ -#define CHROME_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_ - -#include "base/basictypes.h" -#include "chrome/browser/renderer_host/render_process_host.h" -#include "chrome/common/ipc_test_sink.h" - -// A mock render process host that has no corresponding renderer process. The -// process() refers to the current process, and all IPC messages are sent into -// the message sink for inspection by tests. -class MockRenderProcessHost : public RenderProcessHost { - public: - MockRenderProcessHost(Profile* profile); - virtual ~MockRenderProcessHost(); - - // Provides access to all IPC messages that would have been sent to the - // renderer via this RenderProcessHost. - IPC::TestSink& sink() { return sink_; } - - // RenderProcessHost implementation (public portion). - virtual bool Init(); - virtual int GetNextRoutingID(); - virtual void CancelResourceRequests(int render_widget_id); - virtual void CrossSiteClosePageACK(int new_render_process_host_id, - int new_request_id); - virtual bool WaitForPaintMsg(int render_widget_id, - const base::TimeDelta& max_delay, - IPC::Message* msg); - virtual void ReceivedBadMessage(uint16 msg_type); - virtual void WidgetRestored(); - virtual void WidgetHidden(); - virtual void AddWord(const std::wstring& word); - virtual bool FastShutdownIfPossible(); - - // IPC::Channel::Sender via RenderProcessHost. - virtual bool Send(IPC::Message* msg); - - // IPC::Channel::Listener via RenderProcessHost. - virtual void OnMessageReceived(const IPC::Message& msg); - virtual void OnChannelConnected(int32 peer_pid); - - private: - // RenderProcessHost implementation (protected portion). - virtual void Unregister(); - - // Stores IPC messages that would have been sent to the renderer. - IPC::TestSink sink_; - - DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_ diff --git a/chrome/browser/renderer_host/render_view_host_unittest.cc b/chrome/browser/renderer_host/render_view_host_unittest.cc deleted file mode 100644 index 0ae9e46..0000000 --- a/chrome/browser/renderer_host/render_view_host_unittest.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/test_render_view_host.h" -#include "chrome/browser/tab_contents/navigation_entry.h" - -namespace { - -class RenderViewHostTest : public RenderViewHostTestHarness { -}; - -} // namespace - -// All about URLs reported by the renderer should get rewritten to about:blank. -// See RenderViewHost::OnMsgNavigate for a discussion. -TEST_F(RenderViewHostTest, FilterAbout) { - rvh()->SendNavigate(1, GURL("about:cache")); - ASSERT_TRUE(controller_->GetActiveEntry()); - EXPECT_EQ(GURL("about:blank"), controller_->GetActiveEntry()->url()); -} diff --git a/chrome/browser/renderer_host/test_render_view_host.cc b/chrome/browser/renderer_host/test_render_view_host.cc deleted file mode 100644 index bd01ca9..0000000 --- a/chrome/browser/renderer_host/test_render_view_host.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/test_render_view_host.h" - -void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { - ViewHostMsg_FrameNavigate_Params params; - params.is_post = false; - params.page_id = page_id; - params.is_content_filtered = false; - params.url = url; - params.should_update_history = true; - params.transition = PageTransition::LINK; - params.is_post = false; - - ViewHostMsg_FrameNavigate msg(1, params); - OnMsgNavigate(msg); -} - -void RenderViewHostTestHarness::SetUp() { - // This will be deleted when the WebContents goes away. - SiteInstance* instance = SiteInstance::CreateSiteInstance(&profile_); - - // Make the SiteInstance use our RenderProcessHost as its own. - process_ = new MockRenderProcessHost(&profile_); - instance->set_process_host_id(process_->host_id()); - - contents_ = new WebContents(&profile_, instance, &rvh_factory_, 12, NULL); - controller_ = new NavigationController(contents_, &profile_); -} - -void RenderViewHostTestHarness::TearDown() { - contents_->CloseContents(); - contents_ = NULL; - controller_ = NULL; - - // Make sure that we flush any messages related to WebContents destruction - // before we destroy the profile. - MessageLoop::current()->RunAllPending(); -} diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h deleted file mode 100644 index 5aa8703..0000000 --- a/chrome/browser/renderer_host/test_render_view_host.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ -#define CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ - -#include "base/basictypes.h" -#include "base/message_loop.h" -#include "chrome/browser/tab_contents/navigation_controller.h" -#include "chrome/browser/tab_contents/web_contents.h" -#include "chrome/browser/renderer_host/mock_render_process_host.h" -#include "chrome/test/testing_profile.h" -#include "testing/gtest/include/gtest/gtest.h" - -// This file provides a testing framework for mocking out the RenderProcessHost -// layer. It allows you to test RenderViewHost, WebContents, -// NavigationController, and other layers above that without running an actual -// renderer process. -// -// To use, derive your test base class from RenderViewHostTestHarness. - -class TestRenderViewHost : public RenderViewHost { - public: - TestRenderViewHost(SiteInstance* instance, - RenderViewHostDelegate* delegate, - int routing_id, - base::WaitableEvent* modal_dialog_event) - : RenderViewHost(instance, delegate, routing_id, modal_dialog_event) { - } - - // Calls OnMsgNavigate on the RenderViewHost with the given information, - // setting the rest of the parameters in the message to the "typical" values. - // This is a helper function for simulating the most common types of loads. - void SendNavigate(int page_id, const GURL& url); - - private: - FRIEND_TEST(RenderViewHostTest, FilterNavigate); - - DISALLOW_COPY_AND_ASSIGN(TestRenderViewHost); -}; - -class TestRenderViewHostFactory : public RenderViewHostFactory { - public: - TestRenderViewHostFactory() {} - virtual ~TestRenderViewHostFactory() {} - - virtual RenderViewHost* CreateRenderViewHost( - SiteInstance* instance, - RenderViewHostDelegate* delegate, - int routing_id, - base::WaitableEvent* modal_dialog_event) { - return new TestRenderViewHost(instance, delegate, routing_id, - modal_dialog_event); - } - - private: - - DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory); -}; - -class RenderViewHostTestHarness : public testing::Test { - public: - RenderViewHostTestHarness() - : process_(NULL), - contents_(NULL), - controller_(NULL) {} - ~RenderViewHostTestHarness() {} - - TestRenderViewHost* rvh() { - return reinterpret_cast(contents_->render_view_host()); - } - - protected: - // testing::Test - virtual void SetUp(); - virtual void TearDown(); - - MessageLoopForUI message_loop_; - TestingProfile profile_; - - TestRenderViewHostFactory rvh_factory_; - - // We clean up the WebContents by calling CloseContents, which deletes itself. - // This in turn causes the destruction of these other things. - MockRenderProcessHost* process_; - WebContents* contents_; - NavigationController* controller_; - - DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ -- cgit v1.1