summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_view_unittest.cc
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 05:30:54 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 05:30:54 +0000
commitda911550f99db64535a175d62f63d467eec12bbc (patch)
treeb4548469fb74726e28cf5408257f3169eddf662a /chrome/renderer/render_view_unittest.cc
parentdafa920a52965183ce936f0837868f6b6f0cbb6c (diff)
downloadchromium_src-da911550f99db64535a175d62f63d467eec12bbc.zip
chromium_src-da911550f99db64535a175d62f63d467eec12bbc.tar.gz
chromium_src-da911550f99db64535a175d62f63d467eec12bbc.tar.bz2
Introduce printing test case (Step 1)
This CL will just show how to actually execute a full print process from start to finish. It will verify that a page has been printed (successfully). In the next steps, we would need to test whether the elements rendered after printing are correct. (how?) And fixed some lint errors. Thanks for hbono and maruel to lead me in the right direction :) Original patch by Mohamed Mansour (see http://codereview.chromium.org/67036/show), r=me,maruel,sverrir. BUG=? Review URL: http://codereview.chromium.org/67202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view_unittest.cc')
-rw-r--r--chrome/renderer/render_view_unittest.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc
index 3be31bd..85ad59e 100644
--- a/chrome/renderer/render_view_unittest.cc
+++ b/chrome/renderer/render_view_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -276,3 +276,36 @@ TEST_F(RenderViewTest, OnSetTextDirection) {
EXPECT_EQ(output, kTextDirection[i].expected_result);
}
}
+
+// Tests that printing pages work and sending and receiving messages through
+// that channel all works.
+TEST_F(RenderViewTest, OnPrintPages) {
+#if defined(OS_WIN)
+ // Lets simulate a print pages with Hello world.
+ LoadHTML("<body><p>Hello World!</p></body>");
+ view_->OnPrintPages();
+
+ // The renderer should be done calculating the number of rendered pages
+ // according to the specified settings defined in the mock render thread.
+ // Verify the page count is correct.
+ const IPC::Message* page_cnt_msg =
+ render_thread_.sink().GetUniqueMessageMatching(
+ ViewHostMsg_DidGetPrintedPagesCount::ID);
+ EXPECT_TRUE(page_cnt_msg);
+ ViewHostMsg_DidGetPrintedPagesCount::Param post_page_count_param;
+ ViewHostMsg_DidGetPrintedPagesCount::Read(page_cnt_msg,
+ &post_page_count_param);
+ EXPECT_EQ(1, post_page_count_param.b);
+
+ // Verify the rendered "printed page".
+ const IPC::Message* did_print_msg =
+ render_thread_.sink().GetUniqueMessageMatching(
+ ViewHostMsg_DidPrintPage::ID);
+ EXPECT_TRUE(did_print_msg);
+ ViewHostMsg_DidPrintPage::Param post_did_print_page_param;
+ ViewHostMsg_DidPrintPage::Read(did_print_msg, &post_did_print_page_param);
+ EXPECT_EQ(0, post_did_print_page_param.page_number);
+#else
+ NOTIMPLEMENTED();
+#endif
+}