OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/gfx/gdi_util.h" | 7 #include "base/gfx/gdi_util.h" |
8 #include "skia/ext/platform_device.h" | 8 #include "skia/ext/platform_device.h" |
9 #include "base/gfx/png_decoder.h" | 9 #include "base/gfx/png_decoder.h" |
10 #include "base/gfx/png_encoder.h" | 10 #include "base/gfx/png_encoder.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 if (dialog_window) { | 450 if (dialog_window) { |
451 LRESULT res = SendMessage(dialog_window, DM_GETDEFID, 0, 0); | 451 LRESULT res = SendMessage(dialog_window, DM_GETDEFID, 0, 0); |
452 if (!res) | 452 if (!res) |
453 return; | 453 return; |
454 EXPECT_EQ(DC_HASDEFID, HIWORD(res)); | 454 EXPECT_EQ(DC_HASDEFID, HIWORD(res)); |
455 WORD print_button_id = LOWORD(res); | 455 WORD print_button_id = LOWORD(res); |
456 res = SendMessage( | 456 res = SendMessage( |
457 dialog_window, | 457 dialog_window, |
458 WM_COMMAND, | 458 WM_COMMAND, |
459 print_button_id, | 459 print_button_id, |
460 reinterpret_cast<LPARAM>(GetDlgItem(dialog_window, | 460 reinterpret_cast<LPARAM>(GetDlgItem(dialog_window, print_button_id))
); |
461 print_button_id))); | |
462 // Try again. | 461 // Try again. |
463 if (res) | 462 if (res) |
464 return; | 463 return; |
465 | 464 |
466 // Ok it succeeded. | 465 // Ok it succeeded. |
467 dialog_window_ = dialog_window; | 466 dialog_window_ = dialog_window; |
468 dialog_was_found_ = true; | 467 dialog_was_found_ = true; |
469 return; | 468 return; |
470 } | 469 } |
471 if (!dialog_was_found_) | 470 if (!dialog_was_found_) |
(...skipping 20 matching lines...) Expand all Loading... |
492 }; | 491 }; |
493 | 492 |
494 } // namespace | 493 } // namespace |
495 | 494 |
496 // This test is disable because it fails. See bug 1353559. | 495 // This test is disable because it fails. See bug 1353559. |
497 TEST_F(PrintingLayoutTextTest, DISABLED_Complex) { | 496 TEST_F(PrintingLayoutTextTest, DISABLED_Complex) { |
498 if (IsTestCaseDisabled()) | 497 if (IsTestCaseDisabled()) |
499 return; | 498 return; |
500 | 499 |
501 // Print a document, check its output. | 500 // Print a document, check its output. |
502 scoped_refptr<HTTPTestServer> server = | 501 TestServer server(kDocRoot); |
503 HTTPTestServer::CreateServer(kDocRoot); | 502 NavigateToURL(server.TestServerPage("files/printing/test1.html")); |
504 ASSERT_TRUE(NULL != server.get()); | |
505 | |
506 NavigateToURL(server->TestServerPage("files/printing/test1.html")); | |
507 PrintNowTab(); | 503 PrintNowTab(); |
508 EXPECT_EQ(0., CompareWithResult(L"test1")); | 504 EXPECT_EQ(0., CompareWithResult(L"test1")); |
509 } | 505 } |
510 | 506 |
511 struct TestPool { | 507 struct TestPool { |
512 const wchar_t* source; | 508 const wchar_t* source; |
513 const wchar_t* result; | 509 const wchar_t* result; |
514 }; | 510 }; |
515 | 511 |
516 const TestPool kTestPool[] = { | 512 const TestPool kTestPool[] = { |
517 // ImagesB&W | 513 // ImagesB&W |
518 L"files/printing/test2.html", L"test2", | 514 L"files/printing/test2.html", L"test2", |
519 // ImagesTransparent | 515 // ImagesTransparent |
520 L"files/printing/test3.html", L"test3", | 516 L"files/printing/test3.html", L"test3", |
521 // ImageColor | 517 // ImageColor |
522 L"files/printing/test4.html", L"test4", | 518 L"files/printing/test4.html", L"test4", |
523 // TODO(maruel): http://b/1171450 Transparent overlays are drawn opaque | 519 // TODO(maruel): http://b/1171450 Transparent overlays are drawn opaque |
524 // L"files/printing/test5.html", L"test5", | 520 // L"files/printing/test5.html", L"test5", |
525 }; | 521 }; |
526 | 522 |
527 TEST_F(PrintingLayoutTestHidden, ManyTimes) { | 523 TEST_F(PrintingLayoutTestHidden, ManyTimes) { |
528 if (IsTestCaseDisabled()) | 524 if (IsTestCaseDisabled()) |
529 return; | 525 return; |
530 | 526 |
531 scoped_refptr<HTTPTestServer> server = | 527 TestServer server(kDocRoot); |
532 HTTPTestServer::CreateServer(kDocRoot); | |
533 ASSERT_TRUE(NULL != server.get()); | |
534 | |
535 ASSERT_GT(arraysize(kTestPool), 0u); | 528 ASSERT_GT(arraysize(kTestPool), 0u); |
536 for (int i = 0; i < arraysize(kTestPool); ++i) { | 529 for (int i = 0; i < arraysize(kTestPool); ++i) { |
537 if (i) | 530 if (i) |
538 CleanupDumpDirectory(); | 531 CleanupDumpDirectory(); |
539 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; | 532 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; |
540 NavigateToURL(server->TestServerPageW(test.source)); | 533 NavigateToURL(server.TestServerPageW(test.source)); |
541 PrintNowTab(); | 534 PrintNowTab(); |
542 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 535 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
543 CleanupDumpDirectory(); | 536 CleanupDumpDirectory(); |
544 PrintNowTab(); | 537 PrintNowTab(); |
545 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 538 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
546 CleanupDumpDirectory(); | 539 CleanupDumpDirectory(); |
547 PrintNowTab(); | 540 PrintNowTab(); |
548 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 541 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
549 CleanupDumpDirectory(); | 542 CleanupDumpDirectory(); |
550 PrintNowTab(); | 543 PrintNowTab(); |
551 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 544 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
552 } | 545 } |
553 } | 546 } |
554 | 547 |
555 // Prints a popup and immediately closes it. | 548 // Prints a popup and immediately closes it. |
556 TEST_F(PrintingLayoutTest, DISABLED_Delayed) { | 549 TEST_F(PrintingLayoutTest, DISABLED_Delayed) { |
557 if (IsTestCaseDisabled()) | 550 if (IsTestCaseDisabled()) |
558 return; | 551 return; |
559 // TODO(maruel): This test is failing on Windows 2000. I haven't investigated | 552 // TODO(maruel): This test is failing on Windows 2000. I haven't investigated |
560 // why. | 553 // why. |
561 if (win_util::GetWinVersion() < win_util::WINVERSION_XP) | 554 if (win_util::GetWinVersion() < win_util::WINVERSION_XP) |
562 return; | 555 return; |
563 | 556 |
564 scoped_refptr<HTTPTestServer> server = | 557 TestServer server(kDocRoot); |
565 HTTPTestServer::CreateServer(kDocRoot); | |
566 ASSERT_TRUE(NULL != server.get()); | |
567 | 558 |
568 { | 559 { |
569 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); | 560 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); |
570 ASSERT_TRUE(tab_proxy.get()); | 561 ASSERT_TRUE(tab_proxy.get()); |
571 bool is_timeout = true; | 562 bool is_timeout = true; |
572 GURL url = server->TestServerPage("files/printing/popup_delayed_print.htm"); | 563 GURL url = server.TestServerPage("files/printing/popup_delayed_print.htm"); |
573 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 564 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
574 tab_proxy->NavigateToURL(url)); | 565 tab_proxy->NavigateToURL(url)); |
575 | 566 |
576 | 567 |
577 scoped_ptr<base::Thread> worker( | 568 scoped_ptr<base::Thread> worker( |
578 new base::Thread("PrintingLayoutTest_worker")); | 569 new base::Thread("PrintingLayoutTest_worker")); |
579 scoped_refptr<DismissTheWindow> dismiss_task = | 570 scoped_refptr<DismissTheWindow> dismiss_task = |
580 new DismissTheWindow(base::GetProcId(process())); | 571 new DismissTheWindow(base::GetProcId(process())); |
581 // We need to start the thread to be able to set the timer. | 572 // We need to start the thread to be able to set the timer. |
582 worker->Start(); | 573 worker->Start(); |
583 worker->message_loop()->PostTask(FROM_HERE, | 574 worker->message_loop()->PostTask(FROM_HERE, |
584 NewRunnableMethod(dismiss_task.get(), &DismissTheWindow::Start)); | 575 NewRunnableMethod(dismiss_task.get(), &DismissTheWindow::Start)); |
585 | 576 |
586 MessageLoop::current()->Run(); | 577 MessageLoop::current()->Run(); |
587 | 578 |
588 worker->Stop(); | 579 worker->Stop(); |
589 | 580 |
590 // Force a navigation elsewhere to verify that it's fine with it. | 581 // Force a navigation elsewhere to verify that it's fine with it. |
591 url = server->TestServerPage("files/printing/test1.html"); | 582 url = server.TestServerPage("files/printing/test1.html"); |
592 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 583 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
593 tab_proxy->NavigateToURL(url)); | 584 tab_proxy->NavigateToURL(url)); |
594 } | 585 } |
595 CloseBrowserAndServer(); | 586 CloseBrowserAndServer(); |
596 | 587 |
597 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) | 588 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) |
598 << L"popup_delayed_print"; | 589 << L"popup_delayed_print"; |
599 } | 590 } |
600 | 591 |
601 // Prints a popup and immediately closes it. | 592 // Prints a popup and immediately closes it. |
602 TEST_F(PrintingLayoutTest, DISABLED_IFrame) { | 593 TEST_F(PrintingLayoutTest, DISABLED_IFrame) { |
603 if (IsTestCaseDisabled()) | 594 if (IsTestCaseDisabled()) |
604 return; | 595 return; |
605 | 596 |
606 scoped_refptr<HTTPTestServer> server = | 597 TestServer server(kDocRoot); |
607 HTTPTestServer::CreateServer(kDocRoot); | |
608 ASSERT_TRUE(NULL != server.get()); | |
609 | 598 |
610 { | 599 { |
611 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); | 600 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); |
612 ASSERT_TRUE(tab_proxy.get()); | 601 ASSERT_TRUE(tab_proxy.get()); |
613 GURL url = server->TestServerPage("files/printing/iframe.htm"); | 602 GURL url = server.TestServerPage("files/printing/iframe.htm"); |
614 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 603 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
615 tab_proxy->NavigateToURL(url)); | 604 tab_proxy->NavigateToURL(url)); |
616 | 605 |
617 scoped_ptr<base::Thread> worker( | 606 scoped_ptr<base::Thread> worker( |
618 new base::Thread("PrintingLayoutTest_worker")); | 607 new base::Thread("PrintingLayoutTest_worker")); |
619 scoped_refptr<DismissTheWindow> dismiss_task = | 608 scoped_refptr<DismissTheWindow> dismiss_task = |
620 new DismissTheWindow(base::GetProcId(process())); | 609 new DismissTheWindow(base::GetProcId(process())); |
621 // We need to start the thread to be able to set the timer. | 610 // We need to start the thread to be able to set the timer. |
622 worker->Start(); | 611 worker->Start(); |
623 worker->message_loop()->PostTask(FROM_HERE, | 612 worker->message_loop()->PostTask(FROM_HERE, |
624 NewRunnableMethod(dismiss_task.get(), &DismissTheWindow::Start)); | 613 NewRunnableMethod(dismiss_task.get(), &DismissTheWindow::Start)); |
625 | 614 |
626 MessageLoop::current()->Run(); | 615 MessageLoop::current()->Run(); |
627 | 616 |
628 worker->Stop(); | 617 worker->Stop(); |
629 | 618 |
630 // Force a navigation elsewhere to verify that it's fine with it. | 619 // Force a navigation elsewhere to verify that it's fine with it. |
631 url = server->TestServerPage("files/printing/test1.html"); | 620 url = server.TestServerPage("files/printing/test1.html"); |
632 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 621 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
633 tab_proxy->NavigateToURL(url)); | 622 tab_proxy->NavigateToURL(url)); |
634 } | 623 } |
635 CloseBrowserAndServer(); | 624 CloseBrowserAndServer(); |
636 | 625 |
637 EXPECT_EQ(0., CompareWithResult(L"iframe")) | 626 EXPECT_EQ(0., CompareWithResult(L"iframe")) |
638 << L"iframe"; | 627 << L"iframe"; |
639 } | 628 } |
640 | 629 |
OLD | NEW |