OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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), opener_id_(0) { | 16 : routing_id_(0), opener_id_(0) { |
17 } | 17 } |
18 | 18 |
19 MockRenderThread::~MockRenderThread() { | 19 MockRenderThread::~MockRenderThread() { |
20 } | 20 } |
21 | 21 |
| 22 void MockRenderThread::VerifyRunJavaScriptMessageSend( |
| 23 const string16& expected_alert_message) { |
| 24 const IPC::Message* alert_msg = |
| 25 sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID); |
| 26 ASSERT_TRUE(alert_msg); |
| 27 void* iter = IPC::SyncMessage::GetDataIterator(alert_msg); |
| 28 ViewHostMsg_RunJavaScriptMessage::SendParam alert_param; |
| 29 ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param)); |
| 30 EXPECT_EQ(expected_alert_message, alert_param.a); |
| 31 } |
| 32 |
22 // Called by the Widget. Used to send messages to the browser. | 33 // Called by the Widget. Used to send messages to the browser. |
23 // 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 |
24 // class. | 35 // class. |
25 bool MockRenderThread::Send(IPC::Message* msg) { | 36 bool MockRenderThread::Send(IPC::Message* msg) { |
26 // 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 |
27 // through this function messages, messages with reply and reply messages. | 38 // through this function messages, messages with reply and reply messages. |
28 // We can only handle one synchronous message at a time. | 39 // We can only handle one synchronous message at a time. |
29 if (msg->is_reply()) { | 40 if (msg->is_reply()) { |
30 if (reply_deserializer_.get()) { | 41 if (reply_deserializer_.get()) { |
31 reply_deserializer_->SerializeOutputParameters(*msg); | 42 reply_deserializer_->SerializeOutputParameters(*msg); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void MockRenderThread::OnDuplicateSection( | 191 void MockRenderThread::OnDuplicateSection( |
181 base::SharedMemoryHandle renderer_handle, | 192 base::SharedMemoryHandle renderer_handle, |
182 base::SharedMemoryHandle* browser_handle) { | 193 base::SharedMemoryHandle* browser_handle) { |
183 // We don't have to duplicate the input handles since RenderViewTest does not | 194 // We don't have to duplicate the input handles since RenderViewTest does not |
184 // separate a browser process from a renderer process. | 195 // separate a browser process from a renderer process. |
185 *browser_handle = renderer_handle; | 196 *browser_handle = renderer_handle; |
186 } | 197 } |
187 #endif // defined(OS_WIN) | 198 #endif // defined(OS_WIN) |
188 | 199 |
189 } // namespace content | 200 } // namespace content |
OLD | NEW |