summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_view_unittest.cc
diff options
context:
space:
mode:
authorsverrir@google.com <sverrir@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 19:00:00 +0000
committersverrir@google.com <sverrir@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 19:00:00 +0000
commitb981effe484cfb2ebe09a6903a8bc6a3e1f4c05c (patch)
tree78557090148a83493bf8ef5af8b3f155146a7aa1 /chrome/renderer/render_view_unittest.cc
parentf1c7d7792ca01a8c80cd42240716772ee46c700b (diff)
downloadchromium_src-b981effe484cfb2ebe09a6903a8bc6a3e1f4c05c.zip
chromium_src-b981effe484cfb2ebe09a6903a8bc6a3e1f4c05c.tar.gz
chromium_src-b981effe484cfb2ebe09a6903a8bc6a3e1f4c05c.tar.bz2
Add a test to print using javascript. This is to make sure I don't break anything when I start to do the async printing.
BUG=none TEST=run unit tests Review URL: http://codereview.chromium.org/119245 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view_unittest.cc')
-rw-r--r--chrome/renderer/render_view_unittest.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc
index 331b6e6..95a468c 100644
--- a/chrome/renderer/render_view_unittest.cc
+++ b/chrome/renderer/render_view_unittest.cc
@@ -312,6 +312,37 @@ TEST_F(RenderViewTest, OnPrintPages) {
#endif
}
+// Duplicate of OnPrintPagesTest only using javascript to print.
+TEST_F(RenderViewTest, PrintWithJavascript) {
+#if defined(OS_WIN)
+ // HTML contains a call to window.print()
+ LoadHTML("<body>Hello<script>window.print()</script>World</body>");
+
+ // 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);
+ ASSERT_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.a.page_number);
+#else
+ NOTIMPLEMENTED();
+#endif
+}
+
// Tests if we can print a page and verify its results.
// This test prints HTML pages into a pseudo printer and check their outputs,
// i.e. a simplified version of the PrintingLayoutTextTest UI test.