OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "chrome/common/print_messages.h" | 8 #include "chrome/common/print_messages.h" |
9 #include "chrome/renderer/mock_printer.h" | 9 #include "chrome/renderer/mock_printer.h" |
10 #include "chrome/renderer/printing/print_web_view_helper.h" | 10 #include "chrome/renderer/printing/print_web_view_helper.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 print_web_view_helper->SetScriptedPrintBlocked(true); | 310 print_web_view_helper->SetScriptedPrintBlocked(true); |
311 PrintWithJavaScript(); | 311 PrintWithJavaScript(); |
312 VerifyPagesPrinted(false); | 312 VerifyPagesPrinted(false); |
313 | 313 |
314 print_web_view_helper->SetScriptedPrintBlocked(false); | 314 print_web_view_helper->SetScriptedPrintBlocked(false); |
315 PrintWithJavaScript(); | 315 PrintWithJavaScript(); |
316 VerifyPageCount(1); | 316 VerifyPageCount(1); |
317 VerifyPagesPrinted(true); | 317 VerifyPagesPrinted(true); |
318 } | 318 } |
319 | 319 |
320 #if defined(OS_WIN) || defined(OS_MACOSX) | 320 #if (defined(OS_WIN) && !WIN_PDF_METAFILE_FOR_PRINTING) || defined(OS_MACOSX) |
321 // TODO(estade): I don't think this test is worth porting to Linux. We will have | 321 // TODO(estade): I don't think this test is worth porting to Linux. We will have |
322 // to rip out and replace most of the IPC code if we ever plan to improve | 322 // to rip out and replace most of the IPC code if we ever plan to improve |
323 // printing, and the comment below by sverrir suggests that it doesn't do much | 323 // printing, and the comment below by sverrir suggests that it doesn't do much |
324 // for us anyway. | 324 // for us anyway. |
325 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { | 325 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { |
326 // Document that populates an iframe. | 326 // Document that populates an iframe. |
327 const char html[] = | 327 const char html[] = |
328 "<html><body>Lorem Ipsum:" | 328 "<html><body>Lorem Ipsum:" |
329 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" | 329 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" |
330 " document.write(frames['sub1'].name);" | 330 " document.write(frames['sub1'].name);" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 NULL, | 396 NULL, |
397 NULL, | 397 NULL, |
398 }, | 398 }, |
399 }; | 399 }; |
400 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 400 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
401 } // namespace | 401 } // namespace |
402 | 402 |
403 // TODO(estade): need to port MockPrinter to get this on Linux. This involves | 403 // TODO(estade): need to port MockPrinter to get this on Linux. This involves |
404 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the | 404 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the |
405 // metafile directly. | 405 // metafile directly. |
406 #if defined(OS_WIN) || defined(OS_MACOSX) | 406 // Same for printing via PDF on Windows. |
| 407 #if (defined(OS_WIN) && !WIN_PDF_METAFILE_FOR_PRINTING) || defined(OS_MACOSX) |
407 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { | 408 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { |
408 bool baseline = false; | 409 bool baseline = false; |
409 | 410 |
410 EXPECT_TRUE(chrome_render_thread_->printer() != NULL); | 411 EXPECT_TRUE(chrome_render_thread_->printer() != NULL); |
411 for (size_t i = 0; i < arraysize(kTestPages); ++i) { | 412 for (size_t i = 0; i < arraysize(kTestPages); ++i) { |
412 // Load an HTML page and print it. | 413 // Load an HTML page and print it. |
413 LoadHTML(kTestPages[i].page); | 414 LoadHTML(kTestPages[i].page); |
414 OnPrintPages(); | 415 OnPrintPages(); |
415 VerifyPagesPrinted(true); | 416 VerifyPagesPrinted(true); |
416 | 417 |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 chrome_render_thread_->printer()->ResetPrinter(); | 997 chrome_render_thread_->printer()->ResetPrinter(); |
997 VerifyPagesPrinted(false); | 998 VerifyPagesPrinted(false); |
998 | 999 |
999 // Pretend user will print, should not be throttled. | 1000 // Pretend user will print, should not be throttled. |
1000 chrome_render_thread_->set_print_dialog_user_response(true); | 1001 chrome_render_thread_->set_print_dialog_user_response(true); |
1001 PrintWithJavaScript(); | 1002 PrintWithJavaScript(); |
1002 VerifyPagesPrinted(true); | 1003 VerifyPagesPrinted(true); |
1003 } | 1004 } |
1004 | 1005 |
1005 } // namespace printing | 1006 } // namespace printing |
OLD | NEW |