| Index: chrome/renderer/render_view_unittest.cc
|
| ===================================================================
|
| --- chrome/renderer/render_view_unittest.cc (revision 19487)
|
| +++ chrome/renderer/render_view_unittest.cc (working copy)
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/file_util.h"
|
| +#include "chrome/common/gfx/emf.h"
|
| #include "chrome/common/native_web_keyboard_event.h"
|
| #include "chrome/common/render_messages.h"
|
| #include "chrome/test/render_view_test.h"
|
| @@ -347,6 +348,59 @@
|
| #endif
|
| }
|
|
|
| +// Test printing an iframe. This tests we only print the currently focused
|
| +// frame.
|
| +TEST_F(RenderViewTest, PrintWithIframe) {
|
| +#if defined(OS_WIN)
|
| + // Document that populates an iframe..
|
| + const char html[] =
|
| + "<html><body>Lorem Ipsum:"
|
| + "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>"
|
| + " document.write(frames['sub1'].name);"
|
| + " frames['sub1'].document.write("
|
| + " '<p>Cras tempus ante eu felis semper luctus!</p>');"
|
| + "</script></body></html>";
|
| +
|
| + LoadHTML(html);
|
| +
|
| + // Find the frame and set it as the focused one. This should mean that that
|
| + // the printout should only contain the contents of that frame.
|
| + WebFrame* sub1_frame = view_->webview()->GetFrameWithName(L"sub1");
|
| + ASSERT_TRUE(sub1_frame);
|
| +
|
| + view_->webview()->SetFocusedFrame(sub1_frame);
|
| + ASSERT_NE(view_->webview()->GetFocusedFrame(),
|
| + view_->webview()->GetMainFrame());
|
| +
|
| + // Initiate printing.
|
| + 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);
|
| + 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.
|
|
|