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 "chrome/common/chrome_switches.h" | 6 #include "chrome/common/chrome_switches.h" |
7 #include "chrome/common/print_messages.h" | 7 #include "chrome/common/print_messages.h" |
8 #include "chrome/renderer/mock_printer.h" | 8 #include "chrome/renderer/mock_printer.h" |
9 #include "chrome/renderer/printing/print_web_view_helper.h" | 9 #include "chrome/renderer/printing/print_web_view_helper.h" |
10 #include "chrome/test/base/chrome_render_view_test.h" | 10 #include "chrome/test/base/chrome_render_view_test.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Test cases used in this test. | 340 // Test cases used in this test. |
341 struct TestPageData { | 341 struct TestPageData { |
342 const char* page; | 342 const char* page; |
343 size_t printed_pages; | 343 size_t printed_pages; |
344 int width; | 344 int width; |
345 int height; | 345 int height; |
346 const char* checksum; | 346 const char* checksum; |
347 const wchar_t* file; | 347 const wchar_t* file; |
348 }; | 348 }; |
349 | 349 |
| 350 #if defined(OS_WIN) || defined(OS_MACOSX) |
350 const TestPageData kTestPages[] = { | 351 const TestPageData kTestPages[] = { |
351 {"<html>" | 352 {"<html>" |
352 "<head>" | 353 "<head>" |
353 "<meta" | 354 "<meta" |
354 " http-equiv=\"Content-Type\"" | 355 " http-equiv=\"Content-Type\"" |
355 " content=\"text/html; charset=utf-8\"/>" | 356 " content=\"text/html; charset=utf-8\"/>" |
356 "<title>Test 1</title>" | 357 "<title>Test 1</title>" |
357 "</head>" | 358 "</head>" |
358 "<body style=\"background-color: white;\">" | 359 "<body style=\"background-color: white;\">" |
359 "<p style=\"font-family: arial;\">Hello World!</p>" | 360 "<p style=\"font-family: arial;\">Hello World!</p>" |
360 "</body>", | 361 "</body>", |
361 #if defined(OS_MACOSX) | 362 #if defined(OS_MACOSX) |
362 // Mac printing code compensates for the WebKit scale factor while generating | 363 // Mac printing code compensates for the WebKit scale factor while generating |
363 // the metafile, so we expect smaller pages. | 364 // the metafile, so we expect smaller pages. |
364 1, 600, 780, | 365 1, 600, 780, |
365 #else | 366 #else |
366 1, 675, 900, | 367 1, 675, 900, |
367 #endif | 368 #endif |
368 NULL, | 369 NULL, |
369 NULL, | 370 NULL, |
370 }, | 371 }, |
371 }; | 372 }; |
| 373 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
372 } // namespace | 374 } // namespace |
373 | 375 |
374 // TODO(estade): need to port MockPrinter to get this on Linux. This involves | 376 // TODO(estade): need to port MockPrinter to get this on Linux. This involves |
375 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the | 377 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the |
376 // metafile directly. | 378 // metafile directly. |
377 #if defined(OS_WIN) || defined(OS_MACOSX) | 379 #if defined(OS_WIN) || defined(OS_MACOSX) |
378 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { | 380 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { |
379 bool baseline = false; | 381 bool baseline = false; |
380 | 382 |
381 EXPECT_TRUE(chrome_render_thread_->printer() != NULL); | 383 EXPECT_TRUE(chrome_render_thread_->printer() != NULL); |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 chrome_render_thread_->printer()->ResetPrinter(); | 969 chrome_render_thread_->printer()->ResetPrinter(); |
968 VerifyPagesPrinted(false); | 970 VerifyPagesPrinted(false); |
969 | 971 |
970 // Pretend user will print, should not be throttled. | 972 // Pretend user will print, should not be throttled. |
971 chrome_render_thread_->set_print_dialog_user_response(true); | 973 chrome_render_thread_->set_print_dialog_user_response(true); |
972 PrintWithJavaScript(); | 974 PrintWithJavaScript(); |
973 VerifyPagesPrinted(true); | 975 VerifyPagesPrinted(true); |
974 } | 976 } |
975 | 977 |
976 } // namespace printing | 978 } // namespace printing |
OLD | NEW |