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/files/file_enumerator.h" | 6 #include "base/files/file_enumerator.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/test/test_file_util.h" | 14 #include "base/test/test_file_util.h" |
15 #include "base/threading/simple_thread.h" | 15 #include "base/threading/simple_thread.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/printing/print_job.h" | 17 #include "chrome/browser/printing/print_job.h" |
18 #include "chrome/browser/printing/print_view_manager.h" | 18 #include "chrome/browser/printing/print_view_manager.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
26 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
27 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "net/test/spawned_test_server/spawned_test_server.h" | |
30 #include "printing/image.h" | 29 #include "printing/image.h" |
31 #include "printing/printing_test.h" | 30 #include "printing/printing_test.h" |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 using printing::Image; | 34 using printing::Image; |
36 | 35 |
37 const char kGenerateSwitch[] = "print-layout-generate"; | 36 const char kGenerateSwitch[] = "print-layout-generate"; |
38 | 37 |
39 class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>, | 38 class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>, |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // Fails, see http://crbug.com/7721. | 331 // Fails, see http://crbug.com/7721. |
333 IN_PROC_BROWSER_TEST_F(PrintingLayoutTextTest, DISABLED_Complex) { | 332 IN_PROC_BROWSER_TEST_F(PrintingLayoutTextTest, DISABLED_Complex) { |
334 if (IsTestCaseDisabled()) | 333 if (IsTestCaseDisabled()) |
335 return; | 334 return; |
336 | 335 |
337 DismissTheWindow dismisser; | 336 DismissTheWindow dismisser; |
338 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 337 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
339 "close_printdlg_thread"); | 338 "close_printdlg_thread"); |
340 | 339 |
341 // Print a document, check its output. | 340 // Print a document, check its output. |
342 ASSERT_TRUE(test_server()->Start()); | 341 ASSERT_TRUE(embedded_test_server()->Start()); |
343 | 342 |
344 ui_test_utils::NavigateToURL( | 343 ui_test_utils::NavigateToURL( |
345 browser(), test_server()->GetURL("files/printing/test1.html")); | 344 browser(), embedded_test_server()->GetURL("/printing/test1.html")); |
346 close_printdlg_thread.Start(); | 345 close_printdlg_thread.Start(); |
347 PrintNowTab(); | 346 PrintNowTab(); |
348 close_printdlg_thread.Join(); | 347 close_printdlg_thread.Join(); |
349 EXPECT_EQ(0., CompareWithResult(L"test1")); | 348 EXPECT_EQ(0., CompareWithResult(L"test1")); |
350 } | 349 } |
351 | 350 |
352 struct TestPool { | 351 struct TestPool { |
353 const char* source; | 352 const char* source; |
354 const wchar_t* result; | 353 const wchar_t* result; |
355 }; | 354 }; |
356 | 355 |
357 const TestPool kTestPool[] = { | 356 const TestPool kTestPool[] = { |
358 // ImagesB&W | 357 // ImagesB&W |
359 "files/printing/test2.html", L"test2", | 358 "/printing/test2.html", L"test2", |
360 // ImagesTransparent | 359 // ImagesTransparent |
361 "files/printing/test3.html", L"test3", | 360 "/printing/test3.html", L"test3", |
362 // ImageColor | 361 // ImageColor |
363 "files/printing/test4.html", L"test4", | 362 "/printing/test4.html", L"test4", |
364 }; | 363 }; |
365 | 364 |
366 // http://crbug.com/7721 | 365 // http://crbug.com/7721 |
367 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_ManyTimes) { | 366 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_ManyTimes) { |
368 if (IsTestCaseDisabled()) | 367 if (IsTestCaseDisabled()) |
369 return; | 368 return; |
370 | 369 |
371 ASSERT_TRUE(test_server()->Start()); | 370 ASSERT_TRUE(embedded_test_server()->Start()); |
372 | 371 |
373 DismissTheWindow dismisser; | 372 DismissTheWindow dismisser; |
374 | 373 |
375 ASSERT_GT(arraysize(kTestPool), 0u); | 374 ASSERT_GT(arraysize(kTestPool), 0u); |
376 for (int i = 0; i < arraysize(kTestPool); ++i) { | 375 for (int i = 0; i < arraysize(kTestPool); ++i) { |
377 if (i) | 376 if (i) |
378 CleanupDumpDirectory(); | 377 CleanupDumpDirectory(); |
379 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; | 378 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; |
380 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(test.source)); | 379 ui_test_utils::NavigateToURL(browser(), |
| 380 embedded_test_server()->GetURL(test.source)); |
381 base::DelegateSimpleThread close_printdlg_thread1(&dismisser, | 381 base::DelegateSimpleThread close_printdlg_thread1(&dismisser, |
382 "close_printdlg_thread"); | 382 "close_printdlg_thread"); |
383 EXPECT_EQ(NULL, FindDialogWindow(dismisser.owner_process())); | 383 EXPECT_EQ(NULL, FindDialogWindow(dismisser.owner_process())); |
384 close_printdlg_thread1.Start(); | 384 close_printdlg_thread1.Start(); |
385 PrintNowTab(); | 385 PrintNowTab(); |
386 close_printdlg_thread1.Join(); | 386 close_printdlg_thread1.Join(); |
387 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 387 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
388 CleanupDumpDirectory(); | 388 CleanupDumpDirectory(); |
389 base::DelegateSimpleThread close_printdlg_thread2(&dismisser, | 389 base::DelegateSimpleThread close_printdlg_thread2(&dismisser, |
390 "close_printdlg_thread"); | 390 "close_printdlg_thread"); |
(...skipping 19 matching lines...) Expand all Loading... |
410 close_printdlg_thread4.Join(); | 410 close_printdlg_thread4.Join(); |
411 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 411 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
412 } | 412 } |
413 } | 413 } |
414 | 414 |
415 // Prints a popup and immediately closes it. Disabled because it crashes. | 415 // Prints a popup and immediately closes it. Disabled because it crashes. |
416 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_Delayed) { | 416 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_Delayed) { |
417 if (IsTestCaseDisabled()) | 417 if (IsTestCaseDisabled()) |
418 return; | 418 return; |
419 | 419 |
420 ASSERT_TRUE(test_server()->Start()); | 420 ASSERT_TRUE(embedded_test_server()->Start()); |
421 | 421 |
422 { | 422 { |
423 bool is_timeout = true; | 423 bool is_timeout = true; |
424 GURL url = test_server()->GetURL("files/printing/popup_delayed_print.htm"); | 424 GURL url = |
| 425 embedded_test_server()->GetURL("/printing/popup_delayed_print.htm"); |
425 ui_test_utils::NavigateToURL(browser(), url); | 426 ui_test_utils::NavigateToURL(browser(), url); |
426 | 427 |
427 DismissTheWindow dismisser; | 428 DismissTheWindow dismisser; |
428 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 429 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
429 "close_printdlg_thread"); | 430 "close_printdlg_thread"); |
430 close_printdlg_thread.Start(); | 431 close_printdlg_thread.Start(); |
431 close_printdlg_thread.Join(); | 432 close_printdlg_thread.Join(); |
432 | 433 |
433 // Force a navigation elsewhere to verify that it's fine with it. | 434 // Force a navigation elsewhere to verify that it's fine with it. |
434 url = test_server()->GetURL("files/printing/test1.html"); | 435 url = embedded_test_server()->GetURL("/printing/test1.html"); |
435 ui_test_utils::NavigateToURL(browser(), url); | 436 ui_test_utils::NavigateToURL(browser(), url); |
436 } | 437 } |
437 chrome::CloseWindow(browser()); | 438 chrome::CloseWindow(browser()); |
438 content::RunAllPendingInMessageLoop(); | 439 content::RunAllPendingInMessageLoop(); |
439 | 440 |
440 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) | 441 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) |
441 << L"popup_delayed_print"; | 442 << L"popup_delayed_print"; |
442 } | 443 } |
443 | 444 |
444 // Prints a popup and immediately closes it. http://crbug.com/7721 | 445 // Prints a popup and immediately closes it. http://crbug.com/7721 |
445 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_IFrame) { | 446 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_IFrame) { |
446 if (IsTestCaseDisabled()) | 447 if (IsTestCaseDisabled()) |
447 return; | 448 return; |
448 | 449 |
449 ASSERT_TRUE(test_server()->Start()); | 450 ASSERT_TRUE(embedded_test_server()->Start()); |
450 | 451 |
451 { | 452 { |
452 GURL url = test_server()->GetURL("files/printing/iframe.htm"); | 453 GURL url = embedded_test_server()->GetURL("/printing/iframe.htm"); |
453 ui_test_utils::NavigateToURL(browser(), url); | 454 ui_test_utils::NavigateToURL(browser(), url); |
454 | 455 |
455 DismissTheWindow dismisser; | 456 DismissTheWindow dismisser; |
456 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 457 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
457 "close_printdlg_thread"); | 458 "close_printdlg_thread"); |
458 close_printdlg_thread.Start(); | 459 close_printdlg_thread.Start(); |
459 close_printdlg_thread.Join(); | 460 close_printdlg_thread.Join(); |
460 | 461 |
461 // Force a navigation elsewhere to verify that it's fine with it. | 462 // Force a navigation elsewhere to verify that it's fine with it. |
462 url = test_server()->GetURL("files/printing/test1.html"); | 463 url = embedded_test_server()->GetURL("/printing/test1.html"); |
463 ui_test_utils::NavigateToURL(browser(), url); | 464 ui_test_utils::NavigateToURL(browser(), url); |
464 } | 465 } |
465 chrome::CloseWindow(browser()); | 466 chrome::CloseWindow(browser()); |
466 content::RunAllPendingInMessageLoop(); | 467 content::RunAllPendingInMessageLoop(); |
467 | 468 |
468 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 469 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
469 } | 470 } |
OLD | NEW |