Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Side by Side Diff: content/public/test/mock_render_thread.cc

Issue 16032007: Create RenderFrame/RenderFrameHost for the main frame of a page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing routing ID expectations. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/test/mock_render_thread.h ('k') | content/public/test/render_view_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/test/mock_render_thread.h" 5 #include "content/public/test/mock_render_thread.h"
6 6
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
10 #include "ipc/ipc_message_utils.h" 10 #include "ipc/ipc_message_utils.h"
11 #include "ipc/ipc_sync_message.h" 11 #include "ipc/ipc_sync_message.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 MockRenderThread::MockRenderThread() 16 MockRenderThread::MockRenderThread()
17 : routing_id_(0), surface_id_(0), opener_id_(0), new_window_routing_id_(0) { 17 : routing_id_(0),
18 surface_id_(0),
19 opener_id_(0),
20 new_window_routing_id_(0),
21 new_window_main_frame_routing_id_(0) {
18 } 22 }
19 23
20 MockRenderThread::~MockRenderThread() { 24 MockRenderThread::~MockRenderThread() {
21 } 25 }
22 26
23 void MockRenderThread::VerifyRunJavaScriptMessageSend( 27 void MockRenderThread::VerifyRunJavaScriptMessageSend(
24 const string16& expected_alert_message) { 28 const string16& expected_alert_message) {
25 const IPC::Message* alert_msg = 29 const IPC::Message* alert_msg =
26 sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID); 30 sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID);
27 ASSERT_TRUE(alert_msg); 31 ASSERT_TRUE(alert_msg);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 int* surface_id) { 205 int* surface_id) {
202 opener_id_ = opener_id; 206 opener_id_ = opener_id;
203 *route_id = routing_id_; 207 *route_id = routing_id_;
204 *surface_id = surface_id_; 208 *surface_id = surface_id_;
205 } 209 }
206 210
207 // The View expects to be returned a valid route_id different from its own. 211 // The View expects to be returned a valid route_id different from its own.
208 void MockRenderThread::OnCreateWindow( 212 void MockRenderThread::OnCreateWindow(
209 const ViewHostMsg_CreateWindow_Params& params, 213 const ViewHostMsg_CreateWindow_Params& params,
210 int* route_id, 214 int* route_id,
215 int* main_frame_route_id,
211 int* surface_id, 216 int* surface_id,
212 int64* cloned_session_storage_namespace_id) { 217 int64* cloned_session_storage_namespace_id) {
213 *route_id = new_window_routing_id_; 218 *route_id = new_window_routing_id_;
219 *main_frame_route_id = new_window_main_frame_routing_id_;
214 *surface_id = surface_id_; 220 *surface_id = surface_id_;
215 *cloned_session_storage_namespace_id = 0; 221 *cloned_session_storage_namespace_id = 0;
216 } 222 }
217 223
218 bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) { 224 bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) {
219 // Save the message in the sink. 225 // Save the message in the sink.
220 sink_.OnMessageReceived(msg); 226 sink_.OnMessageReceived(msg);
221 227
222 bool handled = true; 228 bool handled = true;
223 bool msg_is_ok = true; 229 bool msg_is_ok = true;
224 IPC_BEGIN_MESSAGE_MAP_EX(MockRenderThread, msg, msg_is_ok) 230 IPC_BEGIN_MESSAGE_MAP_EX(MockRenderThread, msg, msg_is_ok)
225 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnCreateWidget) 231 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnCreateWidget)
226 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow) 232 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow)
227 IPC_MESSAGE_UNHANDLED(handled = false) 233 IPC_MESSAGE_UNHANDLED(handled = false)
228 IPC_END_MESSAGE_MAP_EX() 234 IPC_END_MESSAGE_MAP_EX()
229 return handled; 235 return handled;
230 } 236 }
231 237
232 #if defined(OS_WIN) 238 #if defined(OS_WIN)
233 void MockRenderThread::OnDuplicateSection( 239 void MockRenderThread::OnDuplicateSection(
234 base::SharedMemoryHandle renderer_handle, 240 base::SharedMemoryHandle renderer_handle,
235 base::SharedMemoryHandle* browser_handle) { 241 base::SharedMemoryHandle* browser_handle) {
236 // We don't have to duplicate the input handles since RenderViewTest does not 242 // We don't have to duplicate the input handles since RenderViewTest does not
237 // separate a browser process from a renderer process. 243 // separate a browser process from a renderer process.
238 *browser_handle = renderer_handle; 244 *browser_handle = renderer_handle;
239 } 245 }
240 #endif // defined(OS_WIN) 246 #endif // defined(OS_WIN)
241 247
242 } // namespace content 248 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/mock_render_thread.h ('k') | content/public/test/render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698