Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(765)

Side by Side Diff: components/printing/test/print_web_view_helper_browsertest.cc

Issue 1075783002: Enable components_browsertests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN build and add java dependency to components/test/DEPS Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/printing/renderer/print_web_view_helper.h ('k') | components/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/printing/common/print_messages.h" 7 #include "components/printing/common/print_messages.h"
8 #include "components/printing/renderer/print_web_view_helper.h" 8 #include "components/printing/renderer/print_web_view_helper.h"
9 #include "components/printing/test/mock_printer.h" 9 #include "components/printing/test/mock_printer.h"
10 #include "components/printing/test/print_mock_render_thread.h" 10 #include "components/printing/test/print_mock_render_thread.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(dict); 241 PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(dict);
242 ProcessPendingMessages(); 242 ProcessPendingMessages();
243 } 243 }
244 244
245 // Naked pointer as ownership is with content::RenderViewTest::render_thread_. 245 // Naked pointer as ownership is with content::RenderViewTest::render_thread_.
246 PrintMockRenderThread* print_render_thread_; 246 PrintMockRenderThread* print_render_thread_;
247 247
248 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTestBase); 248 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTestBase);
249 }; 249 };
250 250
251 class PrintWebViewHelperTest : public PrintWebViewHelperTestBase { 251 // RenderVIewTest-based tests crash on Android
252 // http://crbug.com/187500
253 #if defined(OS_ANDROID)
254 #define MAYBE_PrintWebViewHelperTest DISABLED_PrintWebViewHelperTest
255 #else
256 #define MAYBE_PrintWebViewHelperTest PrintWebViewHelperTest
257 #endif // defined(OS_ANDROID)
258
259 class MAYBE_PrintWebViewHelperTest : public PrintWebViewHelperTestBase {
252 public: 260 public:
253 PrintWebViewHelperTest() {} 261 MAYBE_PrintWebViewHelperTest() {}
254 ~PrintWebViewHelperTest() override {} 262 ~MAYBE_PrintWebViewHelperTest() override {}
255 263
256 void SetUp() override { PrintWebViewHelperTestBase::SetUp(); } 264 void SetUp() override { PrintWebViewHelperTestBase::SetUp(); }
257 265
258 protected: 266 protected:
259 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest); 267 DISALLOW_COPY_AND_ASSIGN(MAYBE_PrintWebViewHelperTest);
260 }; 268 };
261 269
262 // This tests only for platforms without print preview. 270 // This tests only for platforms without print preview.
263 #if !defined(ENABLE_PRINT_PREVIEW) 271 #if !defined(ENABLE_PRINT_PREVIEW)
264 // Tests that the renderer blocks window.print() calls if they occur too 272 // Tests that the renderer blocks window.print() calls if they occur too
265 // frequently. 273 // frequently.
266 TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrinting) { 274 TEST_F(MAYBE_PrintWebViewHelperTest, BlockScriptInitiatedPrinting) {
267 // Pretend user will cancel printing. 275 // Pretend user will cancel printing.
268 print_render_thread_->set_print_dialog_user_response(false); 276 print_render_thread_->set_print_dialog_user_response(false);
269 // Try to print with window.print() a few times. 277 // Try to print with window.print() a few times.
270 PrintWithJavaScript(); 278 PrintWithJavaScript();
271 PrintWithJavaScript(); 279 PrintWithJavaScript();
272 PrintWithJavaScript(); 280 PrintWithJavaScript();
273 VerifyPagesPrinted(false); 281 VerifyPagesPrinted(false);
274 282
275 // Pretend user will print. (but printing is blocked.) 283 // Pretend user will print. (but printing is blocked.)
276 print_render_thread_->set_print_dialog_user_response(true); 284 print_render_thread_->set_print_dialog_user_response(true);
277 PrintWithJavaScript(); 285 PrintWithJavaScript();
278 VerifyPagesPrinted(false); 286 VerifyPagesPrinted(false);
279 287
280 // Unblock script initiated printing and verify printing works. 288 // Unblock script initiated printing and verify printing works.
281 PrintWebViewHelper::Get(view_)->scripting_throttler_.Reset(); 289 PrintWebViewHelper::Get(view_)->scripting_throttler_.Reset();
282 print_render_thread_->printer()->ResetPrinter(); 290 print_render_thread_->printer()->ResetPrinter();
283 PrintWithJavaScript(); 291 PrintWithJavaScript();
284 VerifyPageCount(1); 292 VerifyPageCount(1);
285 VerifyPagesPrinted(true); 293 VerifyPagesPrinted(true);
286 } 294 }
287 295
288 // Tests that the renderer always allows window.print() calls if they are user 296 // Tests that the renderer always allows window.print() calls if they are user
289 // initiated. 297 // initiated.
290 TEST_F(PrintWebViewHelperTest, AllowUserOriginatedPrinting) { 298 TEST_F(MAYBE_PrintWebViewHelperTest, AllowUserOriginatedPrinting) {
291 // Pretend user will cancel printing. 299 // Pretend user will cancel printing.
292 print_render_thread_->set_print_dialog_user_response(false); 300 print_render_thread_->set_print_dialog_user_response(false);
293 // Try to print with window.print() a few times. 301 // Try to print with window.print() a few times.
294 PrintWithJavaScript(); 302 PrintWithJavaScript();
295 PrintWithJavaScript(); 303 PrintWithJavaScript();
296 PrintWithJavaScript(); 304 PrintWithJavaScript();
297 VerifyPagesPrinted(false); 305 VerifyPagesPrinted(false);
298 306
299 // Pretend user will print. (but printing is blocked.) 307 // Pretend user will print. (but printing is blocked.)
300 print_render_thread_->set_print_dialog_user_response(true); 308 print_render_thread_->set_print_dialog_user_response(true);
(...skipping 17 matching lines...) Expand all
318 SendWebMouseEvent(mouse_event); 326 SendWebMouseEvent(mouse_event);
319 mouse_event.type = blink::WebInputEvent::MouseUp; 327 mouse_event.type = blink::WebInputEvent::MouseUp;
320 SendWebMouseEvent(mouse_event); 328 SendWebMouseEvent(mouse_event);
321 ProcessPendingMessages(); 329 ProcessPendingMessages();
322 330
323 VerifyPageCount(1); 331 VerifyPageCount(1);
324 VerifyPagesPrinted(true); 332 VerifyPagesPrinted(true);
325 } 333 }
326 334
327 // Duplicate of OnPrintPagesTest only using javascript to print. 335 // Duplicate of OnPrintPagesTest only using javascript to print.
328 TEST_F(PrintWebViewHelperTest, PrintWithJavascript) { 336 TEST_F(MAYBE_PrintWebViewHelperTest, PrintWithJavascript) {
329 PrintWithJavaScript(); 337 PrintWithJavaScript();
330 338
331 VerifyPageCount(1); 339 VerifyPageCount(1);
332 VerifyPagesPrinted(true); 340 VerifyPagesPrinted(true);
333 } 341 }
334 #endif // !ENABLE_PRINT_PREVIEW 342 #endif // !ENABLE_PRINT_PREVIEW
335 343
336 #if defined(ENABLE_BASIC_PRINTING) 344 #if defined(ENABLE_BASIC_PRINTING)
337 // Tests that printing pages work and sending and receiving messages through 345 // Tests that printing pages work and sending and receiving messages through
338 // that channel all works. 346 // that channel all works.
339 TEST_F(PrintWebViewHelperTest, OnPrintPages) { 347 TEST_F(MAYBE_PrintWebViewHelperTest, OnPrintPages) {
340 LoadHTML(kHelloWorldHTML); 348 LoadHTML(kHelloWorldHTML);
341 OnPrintPages(); 349 OnPrintPages();
342 350
343 VerifyPageCount(1); 351 VerifyPageCount(1);
344 VerifyPagesPrinted(true); 352 VerifyPagesPrinted(true);
345 } 353 }
346 #endif // ENABLE_BASIC_PRINTING 354 #endif // ENABLE_BASIC_PRINTING
347 355
348 #if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING) 356 #if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING)
349 // TODO(estade): I don't think this test is worth porting to Linux. We will have 357 // TODO(estade): I don't think this test is worth porting to Linux. We will have
350 // to rip out and replace most of the IPC code if we ever plan to improve 358 // to rip out and replace most of the IPC code if we ever plan to improve
351 // printing, and the comment below by sverrir suggests that it doesn't do much 359 // printing, and the comment below by sverrir suggests that it doesn't do much
352 // for us anyway. 360 // for us anyway.
353 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { 361 TEST_F(MAYBE_PrintWebViewHelperTest, PrintWithIframe) {
354 // Document that populates an iframe. 362 // Document that populates an iframe.
355 const char html[] = 363 const char html[] =
356 "<html><body>Lorem Ipsum:" 364 "<html><body>Lorem Ipsum:"
357 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" 365 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>"
358 " document.write(frames['sub1'].name);" 366 " document.write(frames['sub1'].name);"
359 " frames['sub1'].document.write(" 367 " frames['sub1'].document.write("
360 " '<p>Cras tempus ante eu felis semper luctus!</p>');" 368 " '<p>Cras tempus ante eu felis semper luctus!</p>');"
361 " frames['sub1'].document.close();" 369 " frames['sub1'].document.close();"
362 "</script></body></html>"; 370 "</script></body></html>";
363 371
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 }, 441 },
434 }; 442 };
435 #endif // defined(OS_WIN) || defined(OS_MACOSX) 443 #endif // defined(OS_WIN) || defined(OS_MACOSX)
436 } // namespace 444 } // namespace
437 445
438 // TODO(estade): need to port MockPrinter to get this on Linux. This involves 446 // TODO(estade): need to port MockPrinter to get this on Linux. This involves
439 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the 447 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the
440 // metafile directly. 448 // metafile directly.
441 // Same for printing via PDF on Windows. 449 // Same for printing via PDF on Windows.
442 #if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING) 450 #if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING)
443 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { 451 TEST_F(MAYBE_PrintWebViewHelperTest, PrintLayoutTest) {
444 bool baseline = false; 452 bool baseline = false;
445 453
446 EXPECT_TRUE(print_render_thread_->printer() != NULL); 454 EXPECT_TRUE(print_render_thread_->printer() != NULL);
447 for (size_t i = 0; i < arraysize(kTestPages); ++i) { 455 for (size_t i = 0; i < arraysize(kTestPages); ++i) {
448 // Load an HTML page and print it. 456 // Load an HTML page and print it.
449 LoadHTML(kTestPages[i].page); 457 LoadHTML(kTestPages[i].page);
450 OnPrintPages(); 458 OnPrintPages();
451 VerifyPagesPrinted(true); 459 VerifyPagesPrinted(true);
452 460
453 // MockRenderThread::Send() just calls MockRenderThread::OnReceived(). 461 // MockRenderThread::Send() just calls MockRenderThread::OnReceived().
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 base::FilePath bitmap_path; 497 base::FilePath bitmap_path;
490 base::CreateTemporaryFile(&bitmap_path); 498 base::CreateTemporaryFile(&bitmap_path);
491 print_render_thread_->printer()->SaveBitmap(0, bitmap_path); 499 print_render_thread_->printer()->SaveBitmap(0, bitmap_path);
492 } 500 }
493 } 501 }
494 } 502 }
495 #endif // OS_MACOSX && ENABLE_BASIC_PRINTING 503 #endif // OS_MACOSX && ENABLE_BASIC_PRINTING
496 504
497 // These print preview tests do not work on Chrome OS yet. 505 // These print preview tests do not work on Chrome OS yet.
498 #if !defined(OS_CHROMEOS) 506 #if !defined(OS_CHROMEOS)
499 class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { 507
508 // RenderVIewTest-based tests crash on Android
509 // http://crbug.com/187500
510 #if defined(OS_ANDROID)
511 #define MAYBE_PrintWebViewHelperPreviewTest \
512 DISABLED_PrintWebViewHelperPreviewTest
513 #else
514 #define MAYBE_PrintWebViewHelperPreviewTest PrintWebViewHelperPreviewTest
515 #endif // defined(OS_ANDROID)
516
517 class MAYBE_PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase {
500 public: 518 public:
501 PrintWebViewHelperPreviewTest() {} 519 MAYBE_PrintWebViewHelperPreviewTest() {}
502 ~PrintWebViewHelperPreviewTest() override {} 520 ~MAYBE_PrintWebViewHelperPreviewTest() override {}
503 521
504 protected: 522 protected:
505 void VerifyPrintPreviewCancelled(bool did_cancel) { 523 void VerifyPrintPreviewCancelled(bool did_cancel) {
506 bool print_preview_cancelled = 524 bool print_preview_cancelled =
507 (render_thread_->sink().GetUniqueMessageMatching( 525 (render_thread_->sink().GetUniqueMessageMatching(
508 PrintHostMsg_PrintPreviewCancelled::ID) != NULL); 526 PrintHostMsg_PrintPreviewCancelled::ID) != NULL);
509 EXPECT_EQ(did_cancel, print_preview_cancelled); 527 EXPECT_EQ(did_cancel, print_preview_cancelled);
510 } 528 }
511 529
512 void VerifyPrintPreviewFailed(bool did_fail) { 530 void VerifyPrintPreviewFailed(bool did_fail) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 EXPECT_EQ(content_width, get<0>(param).content_width); 602 EXPECT_EQ(content_width, get<0>(param).content_width);
585 EXPECT_EQ(content_height, get<0>(param).content_height); 603 EXPECT_EQ(content_height, get<0>(param).content_height);
586 EXPECT_EQ(margin_top, get<0>(param).margin_top); 604 EXPECT_EQ(margin_top, get<0>(param).margin_top);
587 EXPECT_EQ(margin_right, get<0>(param).margin_right); 605 EXPECT_EQ(margin_right, get<0>(param).margin_right);
588 EXPECT_EQ(margin_left, get<0>(param).margin_left); 606 EXPECT_EQ(margin_left, get<0>(param).margin_left);
589 EXPECT_EQ(margin_bottom, get<0>(param).margin_bottom); 607 EXPECT_EQ(margin_bottom, get<0>(param).margin_bottom);
590 EXPECT_EQ(page_has_print_css, get<2>(param)); 608 EXPECT_EQ(page_has_print_css, get<2>(param));
591 } 609 }
592 } 610 }
593 611
594 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperPreviewTest); 612 DISALLOW_COPY_AND_ASSIGN(MAYBE_PrintWebViewHelperPreviewTest);
595 }; 613 };
596 614
597 #if defined(ENABLE_PRINT_PREVIEW) 615 #if defined(ENABLE_PRINT_PREVIEW)
598 TEST_F(PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { 616 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) {
599 LoadHTML(kHelloWorldHTML); 617 LoadHTML(kHelloWorldHTML);
600 PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_); 618 PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_);
601 print_web_view_helper->SetScriptedPrintBlocked(true); 619 print_web_view_helper->SetScriptedPrintBlocked(true);
602 PrintWithJavaScript(); 620 PrintWithJavaScript();
603 VerifyPreviewRequest(false); 621 VerifyPreviewRequest(false);
604 622
605 print_web_view_helper->SetScriptedPrintBlocked(false); 623 print_web_view_helper->SetScriptedPrintBlocked(false);
606 PrintWithJavaScript(); 624 PrintWithJavaScript();
607 VerifyPreviewRequest(true); 625 VerifyPreviewRequest(true);
608 } 626 }
609 627
610 TEST_F(PrintWebViewHelperPreviewTest, PrintWithJavaScript) { 628 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintWithJavaScript) {
611 LoadHTML(kPrintOnUserAction); 629 LoadHTML(kPrintOnUserAction);
612 gfx::Size new_size(200, 100); 630 gfx::Size new_size(200, 100);
613 Resize(new_size, gfx::Rect(), false); 631 Resize(new_size, gfx::Rect(), false);
614 632
615 gfx::Rect bounds = GetElementBounds("print"); 633 gfx::Rect bounds = GetElementBounds("print");
616 EXPECT_FALSE(bounds.IsEmpty()); 634 EXPECT_FALSE(bounds.IsEmpty());
617 blink::WebMouseEvent mouse_event; 635 blink::WebMouseEvent mouse_event;
618 mouse_event.type = blink::WebInputEvent::MouseDown; 636 mouse_event.type = blink::WebInputEvent::MouseDown;
619 mouse_event.button = blink::WebMouseEvent::ButtonLeft; 637 mouse_event.button = blink::WebMouseEvent::ButtonLeft;
620 mouse_event.x = bounds.CenterPoint().x(); 638 mouse_event.x = bounds.CenterPoint().x();
621 mouse_event.y = bounds.CenterPoint().y(); 639 mouse_event.y = bounds.CenterPoint().y();
622 mouse_event.clickCount = 1; 640 mouse_event.clickCount = 1;
623 SendWebMouseEvent(mouse_event); 641 SendWebMouseEvent(mouse_event);
624 mouse_event.type = blink::WebInputEvent::MouseUp; 642 mouse_event.type = blink::WebInputEvent::MouseUp;
625 SendWebMouseEvent(mouse_event); 643 SendWebMouseEvent(mouse_event);
626 644
627 VerifyPreviewRequest(true); 645 VerifyPreviewRequest(true);
628 } 646 }
629 #endif // ENABLE_PRINT_PREVIEW 647 #endif // ENABLE_PRINT_PREVIEW
630 648
631 // Tests that print preview work and sending and receiving messages through 649 // Tests that print preview work and sending and receiving messages through
632 // that channel all works. 650 // that channel all works.
633 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreview) { 651 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreview) {
634 LoadHTML(kHelloWorldHTML); 652 LoadHTML(kHelloWorldHTML);
635 653
636 // Fill in some dummy values. 654 // Fill in some dummy values.
637 base::DictionaryValue dict; 655 base::DictionaryValue dict;
638 CreatePrintSettingsDictionary(&dict); 656 CreatePrintSettingsDictionary(&dict);
639 OnPrintPreview(dict); 657 OnPrintPreview(dict);
640 658
641 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 659 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
642 VerifyDefaultPageLayout(540, 720, 36, 36, 36, 36, false); 660 VerifyDefaultPageLayout(540, 720, 36, 36, 36, 36, false);
643 VerifyPrintPreviewCancelled(false); 661 VerifyPrintPreviewCancelled(false);
644 VerifyPrintPreviewFailed(false); 662 VerifyPrintPreviewFailed(false);
645 VerifyPrintPreviewGenerated(true); 663 VerifyPrintPreviewGenerated(true);
646 VerifyPagesPrinted(false); 664 VerifyPagesPrinted(false);
647 } 665 }
648 666
649 TEST_F(PrintWebViewHelperPreviewTest, PrintPreviewHTMLWithPageMarginsCss) { 667 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
668 PrintPreviewHTMLWithPageMarginsCss) {
650 // A simple web page with print margins css. 669 // A simple web page with print margins css.
651 const char kHTMLWithPageMarginsCss[] = 670 const char kHTMLWithPageMarginsCss[] =
652 "<html><head><style>" 671 "<html><head><style>"
653 "@media print {" 672 "@media print {"
654 " @page {" 673 " @page {"
655 " margin: 3in 1in 2in 0.3in;" 674 " margin: 3in 1in 2in 0.3in;"
656 " }" 675 " }"
657 "}" 676 "}"
658 "</style></head>" 677 "</style></head>"
659 "<body>Lorem Ipsum:" 678 "<body>Lorem Ipsum:"
(...skipping 10 matching lines...) Expand all
670 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 689 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
671 VerifyDefaultPageLayout(519, 432, 216, 144, 21, 72, false); 690 VerifyDefaultPageLayout(519, 432, 216, 144, 21, 72, false);
672 VerifyPrintPreviewCancelled(false); 691 VerifyPrintPreviewCancelled(false);
673 VerifyPrintPreviewFailed(false); 692 VerifyPrintPreviewFailed(false);
674 VerifyPrintPreviewGenerated(true); 693 VerifyPrintPreviewGenerated(true);
675 VerifyPagesPrinted(false); 694 VerifyPagesPrinted(false);
676 } 695 }
677 696
678 // Test to verify that print preview ignores print media css when non-default 697 // Test to verify that print preview ignores print media css when non-default
679 // margin is selected. 698 // margin is selected.
680 TEST_F(PrintWebViewHelperPreviewTest, NonDefaultMarginsSelectedIgnorePrintCss) { 699 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
700 NonDefaultMarginsSelectedIgnorePrintCss) {
681 LoadHTML(kHTMLWithPageSizeCss); 701 LoadHTML(kHTMLWithPageSizeCss);
682 702
683 // Fill in some dummy values. 703 // Fill in some dummy values.
684 base::DictionaryValue dict; 704 base::DictionaryValue dict;
685 CreatePrintSettingsDictionary(&dict); 705 CreatePrintSettingsDictionary(&dict);
686 dict.SetBoolean(kSettingPrintToPDF, false); 706 dict.SetBoolean(kSettingPrintToPDF, false);
687 dict.SetInteger(kSettingMarginsType, NO_MARGINS); 707 dict.SetInteger(kSettingMarginsType, NO_MARGINS);
688 OnPrintPreview(dict); 708 OnPrintPreview(dict);
689 709
690 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 710 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
691 VerifyDefaultPageLayout(612, 792, 0, 0, 0, 0, true); 711 VerifyDefaultPageLayout(612, 792, 0, 0, 0, 0, true);
692 VerifyPrintPreviewCancelled(false); 712 VerifyPrintPreviewCancelled(false);
693 VerifyPrintPreviewFailed(false); 713 VerifyPrintPreviewFailed(false);
694 VerifyPrintPreviewGenerated(true); 714 VerifyPrintPreviewGenerated(true);
695 VerifyPagesPrinted(false); 715 VerifyPagesPrinted(false);
696 } 716 }
697 717
698 // Test to verify that print preview honor print media size css when 718 // Test to verify that print preview honor print media size css when
699 // PRINT_TO_PDF is selected and doesn't fit to printer default paper size. 719 // PRINT_TO_PDF is selected and doesn't fit to printer default paper size.
700 TEST_F(PrintWebViewHelperPreviewTest, PrintToPDFSelectedHonorPrintCss) { 720 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintToPDFSelectedHonorPrintCss) {
701 LoadHTML(kHTMLWithPageSizeCss); 721 LoadHTML(kHTMLWithPageSizeCss);
702 722
703 // Fill in some dummy values. 723 // Fill in some dummy values.
704 base::DictionaryValue dict; 724 base::DictionaryValue dict;
705 CreatePrintSettingsDictionary(&dict); 725 CreatePrintSettingsDictionary(&dict);
706 dict.SetBoolean(kSettingPrintToPDF, true); 726 dict.SetBoolean(kSettingPrintToPDF, true);
707 dict.SetInteger(kSettingMarginsType, PRINTABLE_AREA_MARGINS); 727 dict.SetInteger(kSettingMarginsType, PRINTABLE_AREA_MARGINS);
708 OnPrintPreview(dict); 728 OnPrintPreview(dict);
709 729
710 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 730 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
711 // Since PRINT_TO_PDF is selected, pdf page size is equal to print media page 731 // Since PRINT_TO_PDF is selected, pdf page size is equal to print media page
712 // size. 732 // size.
713 VerifyDefaultPageLayout(252, 252, 18, 18, 18, 18, true); 733 VerifyDefaultPageLayout(252, 252, 18, 18, 18, 18, true);
714 VerifyPrintPreviewCancelled(false); 734 VerifyPrintPreviewCancelled(false);
715 VerifyPrintPreviewFailed(false); 735 VerifyPrintPreviewFailed(false);
716 } 736 }
717 737
718 // Test to verify that print preview honor print margin css when PRINT_TO_PDF 738 // Test to verify that print preview honor print margin css when PRINT_TO_PDF
719 // is selected and doesn't fit to printer default paper size. 739 // is selected and doesn't fit to printer default paper size.
720 TEST_F(PrintWebViewHelperPreviewTest, PrintToPDFSelectedHonorPageMarginsCss) { 740 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
741 PrintToPDFSelectedHonorPageMarginsCss) {
721 // A simple web page with print margins css. 742 // A simple web page with print margins css.
722 const char kHTMLWithPageCss[] = 743 const char kHTMLWithPageCss[] =
723 "<html><head><style>" 744 "<html><head><style>"
724 "@media print {" 745 "@media print {"
725 " @page {" 746 " @page {"
726 " margin: 3in 1in 2in 0.3in;" 747 " margin: 3in 1in 2in 0.3in;"
727 " size: 14in 14in;" 748 " size: 14in 14in;"
728 " }" 749 " }"
729 "}" 750 "}"
730 "</style></head>" 751 "</style></head>"
(...skipping 11 matching lines...) Expand all
742 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 763 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
743 // Since PRINT_TO_PDF is selected, pdf page size is equal to print media page 764 // Since PRINT_TO_PDF is selected, pdf page size is equal to print media page
744 // size. 765 // size.
745 VerifyDefaultPageLayout(915, 648, 216, 144, 21, 72, true); 766 VerifyDefaultPageLayout(915, 648, 216, 144, 21, 72, true);
746 VerifyPrintPreviewCancelled(false); 767 VerifyPrintPreviewCancelled(false);
747 VerifyPrintPreviewFailed(false); 768 VerifyPrintPreviewFailed(false);
748 } 769 }
749 770
750 // Test to verify that print preview workflow center the html page contents to 771 // Test to verify that print preview workflow center the html page contents to
751 // fit the page size. 772 // fit the page size.
752 TEST_F(PrintWebViewHelperPreviewTest, PrintPreviewCenterToFitPage) { 773 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintPreviewCenterToFitPage) {
753 LoadHTML(kHTMLWithPageSizeCss); 774 LoadHTML(kHTMLWithPageSizeCss);
754 775
755 // Fill in some dummy values. 776 // Fill in some dummy values.
756 base::DictionaryValue dict; 777 base::DictionaryValue dict;
757 CreatePrintSettingsDictionary(&dict); 778 CreatePrintSettingsDictionary(&dict);
758 dict.SetBoolean(kSettingPrintToPDF, false); 779 dict.SetBoolean(kSettingPrintToPDF, false);
759 dict.SetInteger(kSettingMarginsType, DEFAULT_MARGINS); 780 dict.SetInteger(kSettingMarginsType, DEFAULT_MARGINS);
760 OnPrintPreview(dict); 781 OnPrintPreview(dict);
761 782
762 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 783 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
763 VerifyDefaultPageLayout(216, 216, 288, 288, 198, 198, true); 784 VerifyDefaultPageLayout(216, 216, 288, 288, 198, 198, true);
764 VerifyPrintPreviewCancelled(false); 785 VerifyPrintPreviewCancelled(false);
765 VerifyPrintPreviewFailed(false); 786 VerifyPrintPreviewFailed(false);
766 VerifyPrintPreviewGenerated(true); 787 VerifyPrintPreviewGenerated(true);
767 } 788 }
768 789
769 // Test to verify that print preview workflow scale the html page contents to 790 // Test to verify that print preview workflow scale the html page contents to
770 // fit the page size. 791 // fit the page size.
771 TEST_F(PrintWebViewHelperPreviewTest, PrintPreviewShrinkToFitPage) { 792 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintPreviewShrinkToFitPage) {
772 // A simple web page with print margins css. 793 // A simple web page with print margins css.
773 const char kHTMLWithPageCss[] = 794 const char kHTMLWithPageCss[] =
774 "<html><head><style>" 795 "<html><head><style>"
775 "@media print {" 796 "@media print {"
776 " @page {" 797 " @page {"
777 " size: 15in 17in;" 798 " size: 15in 17in;"
778 " }" 799 " }"
779 "}" 800 "}"
780 "</style></head>" 801 "</style></head>"
781 "<body>Lorem Ipsum:" 802 "<body>Lorem Ipsum:"
782 "</body></html>"; 803 "</body></html>";
783 LoadHTML(kHTMLWithPageCss); 804 LoadHTML(kHTMLWithPageCss);
784 805
785 // Fill in some dummy values. 806 // Fill in some dummy values.
786 base::DictionaryValue dict; 807 base::DictionaryValue dict;
787 CreatePrintSettingsDictionary(&dict); 808 CreatePrintSettingsDictionary(&dict);
788 dict.SetBoolean(kSettingPrintToPDF, false); 809 dict.SetBoolean(kSettingPrintToPDF, false);
789 dict.SetInteger(kSettingMarginsType, DEFAULT_MARGINS); 810 dict.SetInteger(kSettingMarginsType, DEFAULT_MARGINS);
790 OnPrintPreview(dict); 811 OnPrintPreview(dict);
791 812
792 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 813 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
793 VerifyDefaultPageLayout(571, 652, 69, 71, 20, 21, true); 814 VerifyDefaultPageLayout(571, 652, 69, 71, 20, 21, true);
794 VerifyPrintPreviewCancelled(false); 815 VerifyPrintPreviewCancelled(false);
795 VerifyPrintPreviewFailed(false); 816 VerifyPrintPreviewFailed(false);
796 } 817 }
797 818
798 // Test to verify that print preview workflow honor the orientation settings 819 // Test to verify that print preview workflow honor the orientation settings
799 // specified in css. 820 // specified in css.
800 TEST_F(PrintWebViewHelperPreviewTest, PrintPreviewHonorsOrientationCss) { 821 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintPreviewHonorsOrientationCss) {
801 LoadHTML(kHTMLWithLandscapePageCss); 822 LoadHTML(kHTMLWithLandscapePageCss);
802 823
803 // Fill in some dummy values. 824 // Fill in some dummy values.
804 base::DictionaryValue dict; 825 base::DictionaryValue dict;
805 CreatePrintSettingsDictionary(&dict); 826 CreatePrintSettingsDictionary(&dict);
806 dict.SetBoolean(kSettingPrintToPDF, false); 827 dict.SetBoolean(kSettingPrintToPDF, false);
807 dict.SetInteger(kSettingMarginsType, NO_MARGINS); 828 dict.SetInteger(kSettingMarginsType, NO_MARGINS);
808 OnPrintPreview(dict); 829 OnPrintPreview(dict);
809 830
810 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 831 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
811 VerifyDefaultPageLayout(792, 612, 0, 0, 0, 0, true); 832 VerifyDefaultPageLayout(792, 612, 0, 0, 0, 0, true);
812 VerifyPrintPreviewCancelled(false); 833 VerifyPrintPreviewCancelled(false);
813 VerifyPrintPreviewFailed(false); 834 VerifyPrintPreviewFailed(false);
814 } 835 }
815 836
816 // Test to verify that print preview workflow honors the orientation settings 837 // Test to verify that print preview workflow honors the orientation settings
817 // specified in css when PRINT_TO_PDF is selected. 838 // specified in css when PRINT_TO_PDF is selected.
818 TEST_F(PrintWebViewHelperPreviewTest, PrintToPDFSelectedHonorOrientationCss) { 839 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
840 PrintToPDFSelectedHonorOrientationCss) {
819 LoadHTML(kHTMLWithLandscapePageCss); 841 LoadHTML(kHTMLWithLandscapePageCss);
820 842
821 // Fill in some dummy values. 843 // Fill in some dummy values.
822 base::DictionaryValue dict; 844 base::DictionaryValue dict;
823 CreatePrintSettingsDictionary(&dict); 845 CreatePrintSettingsDictionary(&dict);
824 dict.SetBoolean(kSettingPrintToPDF, true); 846 dict.SetBoolean(kSettingPrintToPDF, true);
825 dict.SetInteger(kSettingMarginsType, CUSTOM_MARGINS); 847 dict.SetInteger(kSettingMarginsType, CUSTOM_MARGINS);
826 OnPrintPreview(dict); 848 OnPrintPreview(dict);
827 849
828 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 850 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
829 VerifyDefaultPageLayout(748, 568, 21, 23, 21, 23, true); 851 VerifyDefaultPageLayout(748, 568, 21, 23, 21, 23, true);
830 VerifyPrintPreviewCancelled(false); 852 VerifyPrintPreviewCancelled(false);
831 VerifyPrintPreviewFailed(false); 853 VerifyPrintPreviewFailed(false);
832 } 854 }
833 855
834 // Test to verify that complete metafile is generated for a subset of pages 856 // Test to verify that complete metafile is generated for a subset of pages
835 // without creating draft pages. 857 // without creating draft pages.
836 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewForSelectedPages) { 858 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreviewForSelectedPages) {
837 LoadHTML(kMultipageHTML); 859 LoadHTML(kMultipageHTML);
838 860
839 // Fill in some dummy values. 861 // Fill in some dummy values.
840 base::DictionaryValue dict; 862 base::DictionaryValue dict;
841 CreatePrintSettingsDictionary(&dict); 863 CreatePrintSettingsDictionary(&dict);
842 864
843 // Set a page range and update the dictionary to generate only the complete 865 // Set a page range and update the dictionary to generate only the complete
844 // metafile with the selected pages. Page numbers used in the dictionary 866 // metafile with the selected pages. Page numbers used in the dictionary
845 // are 1-based. 867 // are 1-based.
846 base::DictionaryValue* page_range = new base::DictionaryValue(); 868 base::DictionaryValue* page_range = new base::DictionaryValue();
(...skipping 12 matching lines...) Expand all
859 VerifyDidPreviewPage(false, 1); 881 VerifyDidPreviewPage(false, 1);
860 VerifyDidPreviewPage(false, 2); 882 VerifyDidPreviewPage(false, 2);
861 VerifyPreviewPageCount(3); 883 VerifyPreviewPageCount(3);
862 VerifyPrintPreviewCancelled(false); 884 VerifyPrintPreviewCancelled(false);
863 VerifyPrintPreviewFailed(false); 885 VerifyPrintPreviewFailed(false);
864 VerifyPrintPreviewGenerated(true); 886 VerifyPrintPreviewGenerated(true);
865 VerifyPagesPrinted(false); 887 VerifyPagesPrinted(false);
866 } 888 }
867 889
868 // Test to verify that preview generated only for one page. 890 // Test to verify that preview generated only for one page.
869 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewForSelectedText) { 891 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreviewForSelectedText) {
870 LoadHTML(kMultipageHTML); 892 LoadHTML(kMultipageHTML);
871 GetMainFrame()->selectRange( 893 GetMainFrame()->selectRange(
872 blink::WebRange::fromDocumentRange(GetMainFrame(), 1, 3)); 894 blink::WebRange::fromDocumentRange(GetMainFrame(), 1, 3));
873 895
874 // Fill in some dummy values. 896 // Fill in some dummy values.
875 base::DictionaryValue dict; 897 base::DictionaryValue dict;
876 CreatePrintSettingsDictionary(&dict); 898 CreatePrintSettingsDictionary(&dict);
877 dict.SetBoolean(kSettingShouldPrintSelectionOnly, true); 899 dict.SetBoolean(kSettingShouldPrintSelectionOnly, true);
878 900
879 OnPrintPreview(dict); 901 OnPrintPreview(dict);
880 902
881 VerifyPreviewPageCount(1); 903 VerifyPreviewPageCount(1);
882 VerifyPrintPreviewCancelled(false); 904 VerifyPrintPreviewCancelled(false);
883 VerifyPrintPreviewFailed(false); 905 VerifyPrintPreviewFailed(false);
884 VerifyPrintPreviewGenerated(true); 906 VerifyPrintPreviewGenerated(true);
885 VerifyPagesPrinted(false); 907 VerifyPagesPrinted(false);
886 } 908 }
887 909
888 // Tests that print preview fails and receiving error messages through 910 // Tests that print preview fails and receiving error messages through
889 // that channel all works. 911 // that channel all works.
890 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewFail) { 912 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreviewFail) {
891 LoadHTML(kHelloWorldHTML); 913 LoadHTML(kHelloWorldHTML);
892 914
893 // An empty dictionary should fail. 915 // An empty dictionary should fail.
894 base::DictionaryValue empty_dict; 916 base::DictionaryValue empty_dict;
895 OnPrintPreview(empty_dict); 917 OnPrintPreview(empty_dict);
896 918
897 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 919 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
898 VerifyPrintPreviewCancelled(false); 920 VerifyPrintPreviewCancelled(false);
899 VerifyPrintPreviewFailed(true); 921 VerifyPrintPreviewFailed(true);
900 VerifyPrintPreviewGenerated(false); 922 VerifyPrintPreviewGenerated(false);
901 VerifyPagesPrinted(false); 923 VerifyPagesPrinted(false);
902 } 924 }
903 925
904 // Tests that cancelling print preview works. 926 // Tests that cancelling print preview works.
905 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewCancel) { 927 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreviewCancel) {
906 LoadHTML(kLongPageHTML); 928 LoadHTML(kLongPageHTML);
907 929
908 const int kCancelPage = 3; 930 const int kCancelPage = 3;
909 print_render_thread_->set_print_preview_cancel_page_number(kCancelPage); 931 print_render_thread_->set_print_preview_cancel_page_number(kCancelPage);
910 // Fill in some dummy values. 932 // Fill in some dummy values.
911 base::DictionaryValue dict; 933 base::DictionaryValue dict;
912 CreatePrintSettingsDictionary(&dict); 934 CreatePrintSettingsDictionary(&dict);
913 OnPrintPreview(dict); 935 OnPrintPreview(dict);
914 936
915 EXPECT_EQ(kCancelPage, print_render_thread_->print_preview_pages_remaining()); 937 EXPECT_EQ(kCancelPage, print_render_thread_->print_preview_pages_remaining());
916 VerifyPrintPreviewCancelled(true); 938 VerifyPrintPreviewCancelled(true);
917 VerifyPrintPreviewFailed(false); 939 VerifyPrintPreviewFailed(false);
918 VerifyPrintPreviewGenerated(false); 940 VerifyPrintPreviewGenerated(false);
919 VerifyPagesPrinted(false); 941 VerifyPagesPrinted(false);
920 } 942 }
921 943
922 // Tests that printing from print preview works and sending and receiving 944 // Tests that printing from print preview works and sending and receiving
923 // messages through that channel all works. 945 // messages through that channel all works.
924 TEST_F(PrintWebViewHelperPreviewTest, OnPrintForPrintPreview) { 946 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintForPrintPreview) {
925 LoadHTML(kPrintPreviewHTML); 947 LoadHTML(kPrintPreviewHTML);
926 948
927 // Fill in some dummy values. 949 // Fill in some dummy values.
928 base::DictionaryValue dict; 950 base::DictionaryValue dict;
929 CreatePrintSettingsDictionary(&dict); 951 CreatePrintSettingsDictionary(&dict);
930 OnPrintForPrintPreview(dict); 952 OnPrintForPrintPreview(dict);
931 953
932 VerifyPrintFailed(false); 954 VerifyPrintFailed(false);
933 VerifyPagesPrinted(true); 955 VerifyPagesPrinted(true);
934 } 956 }
935 957
936 // Tests that printing from print preview fails and receiving error messages 958 // Tests that printing from print preview fails and receiving error messages
937 // through that channel all works. 959 // through that channel all works.
938 TEST_F(PrintWebViewHelperPreviewTest, OnPrintForPrintPreviewFail) { 960 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintForPrintPreviewFail) {
939 LoadHTML(kPrintPreviewHTML); 961 LoadHTML(kPrintPreviewHTML);
940 962
941 // An empty dictionary should fail. 963 // An empty dictionary should fail.
942 base::DictionaryValue empty_dict; 964 base::DictionaryValue empty_dict;
943 OnPrintForPrintPreview(empty_dict); 965 OnPrintForPrintPreview(empty_dict);
944 966
945 VerifyPagesPrinted(false); 967 VerifyPagesPrinted(false);
946 } 968 }
947 969
948 // Tests that when default printer has invalid printer settings, print preview 970 // Tests that when default printer has invalid printer settings, print preview
949 // receives error message. 971 // receives error message.
950 TEST_F(PrintWebViewHelperPreviewTest, 972 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
951 OnPrintPreviewUsingInvalidPrinterSettings) { 973 OnPrintPreviewUsingInvalidPrinterSettings) {
952 LoadHTML(kPrintPreviewHTML); 974 LoadHTML(kPrintPreviewHTML);
953 975
954 // Set mock printer to provide invalid settings. 976 // Set mock printer to provide invalid settings.
955 print_render_thread_->printer()->UseInvalidSettings(); 977 print_render_thread_->printer()->UseInvalidSettings();
956 978
957 // Fill in some dummy values. 979 // Fill in some dummy values.
958 base::DictionaryValue dict; 980 base::DictionaryValue dict;
959 CreatePrintSettingsDictionary(&dict); 981 CreatePrintSettingsDictionary(&dict);
960 OnPrintPreview(dict); 982 OnPrintPreview(dict);
961 983
962 // We should have received invalid printer settings from |printer_|. 984 // We should have received invalid printer settings from |printer_|.
963 VerifyPrintPreviewInvalidPrinterSettings(true); 985 VerifyPrintPreviewInvalidPrinterSettings(true);
964 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 986 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
965 987
966 // It should receive the invalid printer settings message only. 988 // It should receive the invalid printer settings message only.
967 VerifyPrintPreviewFailed(false); 989 VerifyPrintPreviewFailed(false);
968 VerifyPrintPreviewGenerated(false); 990 VerifyPrintPreviewGenerated(false);
969 } 991 }
970 992
971 // Tests that when the selected printer has invalid page settings, print preview 993 // Tests that when the selected printer has invalid page settings, print preview
972 // receives error message. 994 // receives error message.
973 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewUsingInvalidPageSize) { 995 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
996 OnPrintPreviewUsingInvalidPageSize) {
974 LoadHTML(kPrintPreviewHTML); 997 LoadHTML(kPrintPreviewHTML);
975 998
976 print_render_thread_->printer()->UseInvalidPageSize(); 999 print_render_thread_->printer()->UseInvalidPageSize();
977 1000
978 base::DictionaryValue dict; 1001 base::DictionaryValue dict;
979 CreatePrintSettingsDictionary(&dict); 1002 CreatePrintSettingsDictionary(&dict);
980 OnPrintPreview(dict); 1003 OnPrintPreview(dict);
981 1004
982 VerifyPrintPreviewInvalidPrinterSettings(true); 1005 VerifyPrintPreviewInvalidPrinterSettings(true);
983 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 1006 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
984 1007
985 // It should receive the invalid printer settings message only. 1008 // It should receive the invalid printer settings message only.
986 VerifyPrintPreviewFailed(false); 1009 VerifyPrintPreviewFailed(false);
987 VerifyPrintPreviewGenerated(false); 1010 VerifyPrintPreviewGenerated(false);
988 } 1011 }
989 1012
990 // Tests that when the selected printer has invalid content settings, print 1013 // Tests that when the selected printer has invalid content settings, print
991 // preview receives error message. 1014 // preview receives error message.
992 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewUsingInvalidContentSize) { 1015 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
1016 OnPrintPreviewUsingInvalidContentSize) {
993 LoadHTML(kPrintPreviewHTML); 1017 LoadHTML(kPrintPreviewHTML);
994 1018
995 print_render_thread_->printer()->UseInvalidContentSize(); 1019 print_render_thread_->printer()->UseInvalidContentSize();
996 1020
997 base::DictionaryValue dict; 1021 base::DictionaryValue dict;
998 CreatePrintSettingsDictionary(&dict); 1022 CreatePrintSettingsDictionary(&dict);
999 OnPrintPreview(dict); 1023 OnPrintPreview(dict);
1000 1024
1001 VerifyPrintPreviewInvalidPrinterSettings(true); 1025 VerifyPrintPreviewInvalidPrinterSettings(true);
1002 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining()); 1026 EXPECT_EQ(0, print_render_thread_->print_preview_pages_remaining());
1003 1027
1004 // It should receive the invalid printer settings message only. 1028 // It should receive the invalid printer settings message only.
1005 VerifyPrintPreviewFailed(false); 1029 VerifyPrintPreviewFailed(false);
1006 VerifyPrintPreviewGenerated(false); 1030 VerifyPrintPreviewGenerated(false);
1007 } 1031 }
1008 1032
1009 TEST_F(PrintWebViewHelperPreviewTest, 1033 TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
1010 OnPrintForPrintPreviewUsingInvalidPrinterSettings) { 1034 OnPrintForPrintPreviewUsingInvalidPrinterSettings) {
1011 LoadHTML(kPrintPreviewHTML); 1035 LoadHTML(kPrintPreviewHTML);
1012 1036
1013 // Set mock printer to provide invalid settings. 1037 // Set mock printer to provide invalid settings.
1014 print_render_thread_->printer()->UseInvalidSettings(); 1038 print_render_thread_->printer()->UseInvalidSettings();
1015 1039
1016 // Fill in some dummy values. 1040 // Fill in some dummy values.
1017 base::DictionaryValue dict; 1041 base::DictionaryValue dict;
1018 CreatePrintSettingsDictionary(&dict); 1042 CreatePrintSettingsDictionary(&dict);
1019 OnPrintForPrintPreview(dict); 1043 OnPrintForPrintPreview(dict);
1020 1044
1021 VerifyPrintFailed(true); 1045 VerifyPrintFailed(true);
1022 VerifyPagesPrinted(false); 1046 VerifyPagesPrinted(false);
1023 } 1047 }
1024 1048
1025 #endif // !defined(OS_CHROMEOS) 1049 #endif // !defined(OS_CHROMEOS)
1026 1050
1027 } // namespace printing 1051 } // namespace printing
OLDNEW
« no previous file with comments | « components/printing/renderer/print_web_view_helper.h ('k') | components/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698