summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.