Index: content/public/test/mock_render_thread.cc |
diff --git a/content/public/test/mock_render_thread.cc b/content/public/test/mock_render_thread.cc |
index ceeac534f8a171be31e881f60998b0bf67afe166..b8cc7a21f2144a56242907fd8f40a4092fd30ac8 100644 |
--- a/content/public/test/mock_render_thread.cc |
+++ b/content/public/test/mock_render_thread.cc |
@@ -9,8 +9,10 @@ |
#include "base/threading/thread_task_runner_handle.h" |
#include "build/build_config.h" |
#include "content/common/frame_messages.h" |
+#include "content/common/render_message_filter.mojom.h" |
#include "content/common/view_messages.h" |
#include "content/public/renderer/render_thread_observer.h" |
+#include "content/renderer/render_thread_impl.h" |
#include "content/renderer/render_view_impl.h" |
#include "ipc/ipc_message_utils.h" |
#include "ipc/ipc_sync_message.h" |
@@ -22,13 +24,43 @@ |
namespace content { |
+namespace { |
+ |
+class MockRenderMessageFilterImpl : public mojom::RenderMessageFilter { |
+ public: |
+ explicit MockRenderMessageFilterImpl(MockRenderThread* thread) |
+ : thread_(thread) {} |
+ ~MockRenderMessageFilterImpl() override {} |
+ |
+ // mojom::RenderMessageFilter: |
+ void GenerateRoutingID(const GenerateRoutingIDCallback& callback) override { |
+ NOTREACHED(); |
+ } |
+ |
+ void CreateWindow(mojom::CreateWindowParamsPtr params, |
+ const CreateWindowCallback& callback) override { |
+ mojom::CreateWindowReplyPtr reply = mojom::CreateWindowReply::New(); |
+ thread_->OnCreateWindow(*params, reply.get()); |
+ callback.Run(std::move(reply)); |
+ } |
+ |
+ private: |
+ MockRenderThread* const thread_; |
+}; |
+ |
+} // namespace |
+ |
MockRenderThread::MockRenderThread() |
: routing_id_(0), |
opener_id_(0), |
new_window_routing_id_(0), |
new_window_main_frame_routing_id_(0), |
new_window_main_frame_widget_routing_id_(0), |
- new_frame_routing_id_(0) {} |
+ new_frame_routing_id_(0), |
+ mock_render_message_filter_(new MockRenderMessageFilterImpl(this)) { |
+ RenderThreadImpl::SetRenderMessageFilterForTesting( |
+ mock_render_message_filter_.get()); |
+} |
MockRenderThread::~MockRenderThread() { |
while (!filters_.empty()) { |
@@ -218,16 +250,6 @@ void MockRenderThread::OnCreateWidget(int opener_id, |
*route_id = routing_id_; |
} |
-// The View expects to be returned a valid route_id different from its own. |
-void MockRenderThread::OnCreateWindow( |
- const ViewHostMsg_CreateWindow_Params& params, |
- ViewHostMsg_CreateWindow_Reply* reply) { |
- reply->route_id = new_window_routing_id_; |
- reply->main_frame_route_id = new_window_main_frame_routing_id_; |
- reply->main_frame_widget_route_id = new_window_main_frame_widget_routing_id_; |
- reply->cloned_session_storage_namespace_id = 0; |
-} |
- |
// The Frame expects to be returned a valid route_id different from its own. |
void MockRenderThread::OnCreateChildFrame( |
const FrameHostMsg_CreateChildFrame_Params& params, |
@@ -252,7 +274,6 @@ bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(MockRenderThread, msg) |
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnCreateWidget) |
- IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow) |
IPC_MESSAGE_HANDLER(FrameHostMsg_CreateChildFrame, OnCreateChildFrame) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
@@ -269,4 +290,13 @@ void MockRenderThread::OnDuplicateSection( |
} |
#endif // defined(OS_WIN) |
+// The View expects to be returned a valid route_id different from its own. |
+void MockRenderThread::OnCreateWindow(const mojom::CreateWindowParams& params, |
+ mojom::CreateWindowReply* reply) { |
+ reply->route_id = new_window_routing_id_; |
+ reply->main_frame_route_id = new_window_main_frame_routing_id_; |
+ reply->main_frame_widget_route_id = new_window_main_frame_widget_routing_id_; |
+ reply->cloned_session_storage_namespace_id = 0; |
+} |
+ |
} // namespace content |