diff options
Diffstat (limited to 'chrome/renderer/render_view_unittest.cc')
-rw-r--r-- | chrome/renderer/render_view_unittest.cc | 79 |
1 files changed, 18 insertions, 61 deletions
diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index f80a834..4420f70 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/basictypes.h" + #include "base/file_util.h" #include "base/keyboard_codes.h" #include "base/shared_memory.h" @@ -293,70 +295,30 @@ TEST_F(RenderViewTest, OnSetTextDirection) { // Tests that printing pages work and sending and receiving messages through // that channel all works. TEST_F(RenderViewTest, OnPrintPages) { -#if defined(OS_WIN) || defined(OS_MACOSX) // 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.a.page_number); -#else - NOTIMPLEMENTED(); -#endif + VerifyPageCount(1); + VerifyPagesPrinted(); } // Duplicate of OnPrintPagesTest only using javascript to print. TEST_F(RenderViewTest, PrintWithJavascript) { -#if defined(OS_WIN) || defined(OS_MACOSX) // 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 + VerifyPageCount(1); + VerifyPagesPrinted(); } -TEST_F(RenderViewTest, PrintWithIframe) { #if defined(OS_WIN) || defined(OS_MACOSX) - // Document that populates an iframe.. +// TODO(estade): I don't think this test is worth porting to Linux. We will have +// to rip out and replace most of the IPC code if we ever plan to improve +// printing, and the comment below by sverrir suggests that it doesn't do much +// for us anyway. +TEST_F(RenderViewTest, PrintWithIframe) { + // Document that populates an iframe. const char html[] = "<html><body>Lorem Ipsum:" "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" @@ -389,10 +351,8 @@ TEST_F(RenderViewTest, PrintWithIframe) { // page. EXPECT_NE(0, image1.size().width()); EXPECT_NE(0, image1.size().height()); -#else - NOTIMPLEMENTED(); -#endif } +#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, @@ -432,8 +392,11 @@ const TestPageData kTestPages[] = { }; } // namespace -TEST_F(RenderViewTest, PrintLayoutTest) { +// TODO(estade): need to port MockPrinter to get this on Linux. This involves +// hooking up Cairo to read a pdf stream, or accessing the cairo surface in the +// metafile directly. #if defined(OS_WIN) || defined(OS_MACOSX) +TEST_F(RenderViewTest, PrintLayoutTest) { bool baseline = false; EXPECT_TRUE(render_thread_.printer() != NULL); @@ -482,14 +445,11 @@ TEST_F(RenderViewTest, PrintLayoutTest) { render_thread_.printer()->SaveBitmap(0, bitmap_path); } } -#else - NOTIMPLEMENTED(); -#endif } +#endif // Print page as bitmap test. TEST_F(RenderViewTest, OnPrintPageAsBitmap) { -#if defined(OS_WIN) || defined(OS_MACOSX) // Lets simulate a print pages with Hello world. LoadHTML("<body><p>Hello world!</p></body>"); @@ -525,9 +485,6 @@ TEST_F(RenderViewTest, OnPrintPageAsBitmap) { } } ASSERT_TRUE(!is_white); -#else - NOTIMPLEMENTED(); -#endif } // Test that we can receive correct DOM events when we send input events |