OLD | NEW |
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/test/mock_render_thread.h" | 5 #include "content/test/mock_render_thread.h" |
6 | 6 |
7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
9 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
10 #include "ipc/ipc_sync_message.h" | 10 #include "ipc/ipc_sync_message.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 MockRenderThread::MockRenderThread() | 15 MockRenderThread::MockRenderThread() |
16 : routing_id_(0), surface_id_(0), opener_id_(0) { | 16 : routing_id_(0), surface_id_(0), opener_id_(0) { |
17 } | 17 } |
18 | 18 |
19 MockRenderThread::~MockRenderThread() { | 19 MockRenderThread::~MockRenderThread() { |
20 } | 20 } |
21 | 21 |
22 void MockRenderThread::VerifyRunJavaScriptMessageSend( | 22 void MockRenderThread::VerifyRunJavaScriptMessageSend( |
23 const string16& expected_alert_message) { | 23 const string16& expected_alert_message) { |
24 const IPC::Message* alert_msg = | 24 const IPC::Message* alert_msg = |
25 sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID); | 25 sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID); |
26 ASSERT_TRUE(alert_msg); | 26 ASSERT_TRUE(alert_msg); |
27 void* iter = IPC::SyncMessage::GetDataIterator(alert_msg); | 27 PickleIterator iter = IPC::SyncMessage::GetDataIterator(alert_msg); |
28 ViewHostMsg_RunJavaScriptMessage::SendParam alert_param; | 28 ViewHostMsg_RunJavaScriptMessage::SendParam alert_param; |
29 ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param)); | 29 ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param)); |
30 EXPECT_EQ(expected_alert_message, alert_param.a); | 30 EXPECT_EQ(expected_alert_message, alert_param.a); |
31 } | 31 } |
32 | 32 |
33 // Called by the Widget. Used to send messages to the browser. | 33 // Called by the Widget. Used to send messages to the browser. |
34 // We short-circuit the mechanism and handle the messages right here on this | 34 // We short-circuit the mechanism and handle the messages right here on this |
35 // class. | 35 // class. |
36 bool MockRenderThread::Send(IPC::Message* msg) { | 36 bool MockRenderThread::Send(IPC::Message* msg) { |
37 // We need to simulate a synchronous channel, thus we are going to receive | 37 // We need to simulate a synchronous channel, thus we are going to receive |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 void MockRenderThread::OnDuplicateSection( | 197 void MockRenderThread::OnDuplicateSection( |
198 base::SharedMemoryHandle renderer_handle, | 198 base::SharedMemoryHandle renderer_handle, |
199 base::SharedMemoryHandle* browser_handle) { | 199 base::SharedMemoryHandle* browser_handle) { |
200 // We don't have to duplicate the input handles since RenderViewTest does not | 200 // We don't have to duplicate the input handles since RenderViewTest does not |
201 // separate a browser process from a renderer process. | 201 // separate a browser process from a renderer process. |
202 *browser_handle = renderer_handle; | 202 *browser_handle = renderer_handle; |
203 } | 203 } |
204 #endif // defined(OS_WIN) | 204 #endif // defined(OS_WIN) |
205 | 205 |
206 } // namespace content | 206 } // namespace content |
OLD | NEW |