| 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/public/test/mock_render_thread.h" | 5 #include "content/public/test/mock_render_thread.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "content/common/frame_messages.h" | 8 #include "content/common/frame_messages.h" |
| 9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 10 #include "content/public/renderer/render_process_observer.h" | 10 #include "content/public/renderer/render_process_observer.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 MockRenderThread::~MockRenderThread() { | 28 MockRenderThread::~MockRenderThread() { |
| 29 while (!filters_.empty()) { | 29 while (!filters_.empty()) { |
| 30 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter = filters_.back(); | 30 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter = filters_.back(); |
| 31 filters_.pop_back(); | 31 filters_.pop_back(); |
| 32 filter->OnFilterRemoved(); | 32 filter->OnFilterRemoved(); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 void MockRenderThread::VerifyRunJavaScriptMessageSend( | |
| 37 const base::string16& expected_alert_message) { | |
| 38 const IPC::Message* alert_msg = | |
| 39 sink_.GetUniqueMessageMatching(ViewHostMsg_RunJavaScriptMessage::ID); | |
| 40 ASSERT_TRUE(alert_msg); | |
| 41 PickleIterator iter = IPC::SyncMessage::GetDataIterator(alert_msg); | |
| 42 ViewHostMsg_RunJavaScriptMessage::SendParam alert_param; | |
| 43 ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param)); | |
| 44 EXPECT_EQ(expected_alert_message, alert_param.a); | |
| 45 } | |
| 46 | |
| 47 // Called by the Widget. Used to send messages to the browser. | 36 // Called by the Widget. Used to send messages to the browser. |
| 48 // We short-circuit the mechanism and handle the messages right here on this | 37 // We short-circuit the mechanism and handle the messages right here on this |
| 49 // class. | 38 // class. |
| 50 bool MockRenderThread::Send(IPC::Message* msg) { | 39 bool MockRenderThread::Send(IPC::Message* msg) { |
| 51 // We need to simulate a synchronous channel, thus we are going to receive | 40 // We need to simulate a synchronous channel, thus we are going to receive |
| 52 // through this function messages, messages with reply and reply messages. | 41 // through this function messages, messages with reply and reply messages. |
| 53 // We can only handle one synchronous message at a time. | 42 // We can only handle one synchronous message at a time. |
| 54 if (msg->is_reply()) { | 43 if (msg->is_reply()) { |
| 55 if (reply_deserializer_) { | 44 if (reply_deserializer_) { |
| 56 reply_deserializer_->SerializeOutputParameters(*msg); | 45 reply_deserializer_->SerializeOutputParameters(*msg); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 void MockRenderThread::OnDuplicateSection( | 251 void MockRenderThread::OnDuplicateSection( |
| 263 base::SharedMemoryHandle renderer_handle, | 252 base::SharedMemoryHandle renderer_handle, |
| 264 base::SharedMemoryHandle* browser_handle) { | 253 base::SharedMemoryHandle* browser_handle) { |
| 265 // We don't have to duplicate the input handles since RenderViewTest does not | 254 // We don't have to duplicate the input handles since RenderViewTest does not |
| 266 // separate a browser process from a renderer process. | 255 // separate a browser process from a renderer process. |
| 267 *browser_handle = renderer_handle; | 256 *browser_handle = renderer_handle; |
| 268 } | 257 } |
| 269 #endif // defined(OS_WIN) | 258 #endif // defined(OS_WIN) |
| 270 | 259 |
| 271 } // namespace content | 260 } // namespace content |
| OLD | NEW |