diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-23 03:09:52 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-23 03:09:52 +0000 |
commit | fa8a2b1b050009d67e03cf03a26d7d558afe0ecb (patch) | |
tree | 09108ff8271c1ca005d439213db16a784977175f /chrome/renderer/mock_render_thread.cc | |
parent | b6b60c9b2afa70010fe38ed7c753f4c8e37e7131 (diff) | |
download | chromium_src-fa8a2b1b050009d67e03cf03a26d7d558afe0ecb.zip chromium_src-fa8a2b1b050009d67e03cf03a26d7d558afe0ecb.tar.gz chromium_src-fa8a2b1b050009d67e03cf03a26d7d558afe0ecb.tar.bz2 |
Adds a RenderViewTest.PrintLayoutTest.
This change adds a new test 'RenderViewTest.PrintLayoutTest', which prints an HTML page and verify its output.
To process a print job and verify its output, this change adds a pseudo-printer device "MockPrinter" into the MockRenderThread object. This MockPrinter object receives print-related IPC messages, process print jobs, and store the MD5 checksum of the output data.
The current RenderViewTest.PrintLayoutTest retrieves the MD5 checksum values and just compare them with expected values. Nevertheless, please feel free to give me your ideas to improve this test.
Finally, this change is inspired by PrintingLayoutTextTests (created by maruel) and a RenderViewTest.OnPrintPages (created by Mohamed Mansour). I would like to express my best gratitude to them.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/100255
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/mock_render_thread.cc')
-rw-r--r-- | chrome/renderer/mock_render_thread.cc | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index 7812b31..8ff04a9 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -12,7 +12,8 @@ MockRenderThread::MockRenderThread() : routing_id_(0), opener_id_(0), widget_(NULL), - reply_deserializer_(NULL) { + reply_deserializer_(NULL), + printer_(new MockPrinter) { } MockRenderThread::~MockRenderThread() { @@ -78,6 +79,10 @@ void MockRenderThread::OnMessageReceived(const IPC::Message& msg) { OnGetDefaultPrintSettings); IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptedPrint, OnScriptedPrint); + IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, + OnDidGetPrintedPagesCount) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) + IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection) #endif IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -96,21 +101,34 @@ void MockRenderThread::OnMsgOpenChannelToExtension( *channel_id = 0; } +void MockRenderThread::OnDuplicateSection( + base::SharedMemoryHandle renderer_handle, + base::SharedMemoryHandle* browser_handle) { + // We don't have to duplicate the input handles since RenderViewTest does not + // separate a browser process from a renderer process. + *browser_handle = renderer_handle; +} + void MockRenderThread::OnGetDefaultPrintSettings(ViewMsg_Print_Params* params) { - memset(params, 0, sizeof(ViewMsg_Print_Params)); - params->dpi = 72; - params->desired_dpi = 72; - params->document_cookie = 1; - params->printable_size = gfx::Size(500, 500); + if (printer_.get()) + printer_->GetDefaultPrintSettings(params); } void MockRenderThread::OnScriptedPrint(gfx::NativeViewId host_window, int cookie, int expected_pages_count, ViewMsg_PrintPages_Params* settings) { - memset(settings, 0, sizeof(ViewMsg_PrintPages_Params)); - settings->params.dpi = 72; - settings->params.document_cookie = 1; - settings->params.desired_dpi = 72; - settings->params.printable_size = gfx::Size(500, 500); + if (printer_.get()) + printer_->ScriptedPrint(cookie, expected_pages_count, settings); +} + +void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) { + if (printer_.get()) + printer_->SetPrintedPagesCount(cookie, number_pages); +} + +void MockRenderThread::OnDidPrintPage( + const ViewHostMsg_DidPrintPage_Params& params) { + if (printer_.get()) + printer_->PrintPage(params); } |