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