| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/renderer/mock_render_thread.h" | 5 #include "chrome/renderer/mock_render_thread.h" |
| 6 | 6 |
| 7 #include "chrome/common/ipc_message_utils.h" | 7 #include "chrome/common/ipc_message_utils.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 MockRenderThread::MockRenderThread() | 11 MockRenderThread::MockRenderThread() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Save the message in the sink. | 66 // Save the message in the sink. |
| 67 sink_.OnMessageReceived(msg); | 67 sink_.OnMessageReceived(msg); |
| 68 | 68 |
| 69 // Some messages we do special handling. | 69 // Some messages we do special handling. |
| 70 bool handled = true; | 70 bool handled = true; |
| 71 bool msg_is_ok = true; | 71 bool msg_is_ok = true; |
| 72 IPC_BEGIN_MESSAGE_MAP_EX(MockRenderThread, msg, msg_is_ok) | 72 IPC_BEGIN_MESSAGE_MAP_EX(MockRenderThread, msg, msg_is_ok) |
| 73 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget); | 73 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget); |
| 74 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, | 74 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, |
| 75 OnMsgOpenChannelToExtension); | 75 OnMsgOpenChannelToExtension); |
| 76 #if defined(OS_WIN) |
| 77 IPC_MESSAGE_HANDLER(ViewHostMsg_GetDefaultPrintSettings, |
| 78 OnGetDefaultPrintSettings); |
| 79 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptedPrint, |
| 80 OnScriptedPrint); |
| 81 #endif |
| 76 IPC_MESSAGE_UNHANDLED(handled = false) | 82 IPC_MESSAGE_UNHANDLED(handled = false) |
| 77 IPC_END_MESSAGE_MAP_EX() | 83 IPC_END_MESSAGE_MAP_EX() |
| 78 } | 84 } |
| 79 | 85 |
| 80 // The Widget expects to be returned valid route_id. | 86 // The Widget expects to be returned valid route_id. |
| 81 void MockRenderThread::OnMsgCreateWidget(int opener_id, | 87 void MockRenderThread::OnMsgCreateWidget(int opener_id, |
| 82 bool activatable, | 88 bool activatable, |
| 83 int* route_id) { | 89 int* route_id) { |
| 84 opener_id_ = opener_id; | 90 opener_id_ = opener_id; |
| 85 *route_id = routing_id_; | 91 *route_id = routing_id_; |
| 86 } | 92 } |
| 87 | 93 |
| 88 void MockRenderThread::OnMsgOpenChannelToExtension( | 94 void MockRenderThread::OnMsgOpenChannelToExtension( |
| 89 const std::string& extension_id, int* channel_id) { | 95 const std::string& extension_id, int* channel_id) { |
| 90 *channel_id = 0; | 96 *channel_id = 0; |
| 91 } | 97 } |
| 98 |
| 99 void MockRenderThread::OnGetDefaultPrintSettings(ViewMsg_Print_Params* params) { |
| 100 memset(params, 0, sizeof(ViewMsg_Print_Params)); |
| 101 params->dpi = 72; |
| 102 params->desired_dpi = 72; |
| 103 params->document_cookie = 1; |
| 104 params->printable_size = gfx::Size(500, 500); |
| 105 } |
| 106 |
| 107 void MockRenderThread::OnScriptedPrint(gfx::NativeViewId host_window, |
| 108 int cookie, |
| 109 int expected_pages_count, |
| 110 ViewMsg_PrintPages_Params* settings) { |
| 111 memset(settings, 0, sizeof(ViewMsg_PrintPages_Params)); |
| 112 settings->params.dpi = 72; |
| 113 settings->params.document_cookie = 1; |
| 114 settings->params.desired_dpi = 72; |
| 115 settings->params.printable_size = gfx::Size(500, 500); |
| 116 } |
| OLD | NEW |