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 13 matching lines...) Expand all Loading... |
24 using WebKit::WebString; | 24 using WebKit::WebString; |
25 #endif | 25 #endif |
26 | 26 |
27 namespace printing { | 27 namespace printing { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // A simple web page. | 31 // A simple web page. |
32 const char kHelloWorldHTML[] = "<body><p>Hello World!</p></body>"; | 32 const char kHelloWorldHTML[] = "<body><p>Hello World!</p></body>"; |
33 | 33 |
| 34 // A simple webpage with a button to print itself with. |
| 35 const char kPrintOnUserAction[] = |
| 36 "<body>" |
| 37 " <button id=\"print\" onclick=\"window.print();\">Hello World!</button>" |
| 38 "</body>"; |
| 39 |
| 40 #if !defined(OS_CHROMEOS) |
34 // HTML with 3 pages. | 41 // HTML with 3 pages. |
35 const char kMultipageHTML[] = | 42 const char kMultipageHTML[] = |
36 "<html><head><style>" | 43 "<html><head><style>" |
37 ".break { page-break-after: always; }" | 44 ".break { page-break-after: always; }" |
38 "</style></head>" | 45 "</style></head>" |
39 "<body>" | 46 "<body>" |
40 "<div class='break'>page1</div>" | 47 "<div class='break'>page1</div>" |
41 "<div class='break'>page2</div>" | 48 "<div class='break'>page2</div>" |
42 "<div>page3</div>" | 49 "<div>page3</div>" |
43 "</body></html>"; | 50 "</body></html>"; |
(...skipping 15 matching lines...) Expand all Loading... |
59 "<html><head><style>" | 66 "<html><head><style>" |
60 "@media print {" | 67 "@media print {" |
61 " @page {" | 68 " @page {" |
62 " size: landscape;" | 69 " size: landscape;" |
63 " }" | 70 " }" |
64 "}" | 71 "}" |
65 "</style></head>" | 72 "</style></head>" |
66 "<body>Lorem Ipsum:" | 73 "<body>Lorem Ipsum:" |
67 "</body></html>"; | 74 "</body></html>"; |
68 | 75 |
69 // A simple webpage with a button to print itself with. | |
70 const char kPrintOnUserAction[] = | |
71 "<body>" | |
72 " <button id=\"print\" onclick=\"window.print();\">Hello World!</button>" | |
73 "</body>"; | |
74 | |
75 // A longer web page. | 76 // A longer web page. |
76 const char kLongPageHTML[] = | 77 const char kLongPageHTML[] = |
77 "<body><img src=\"\" width=10 height=10000 /></body>"; | 78 "<body><img src=\"\" width=10 height=10000 /></body>"; |
78 | 79 |
79 // A web page to simulate the print preview page. | 80 // A web page to simulate the print preview page. |
80 const char kPrintPreviewHTML[] = | 81 const char kPrintPreviewHTML[] = |
81 "<body><p id=\"pdf-viewer\">Hello World!</p></body>"; | 82 "<body><p id=\"pdf-viewer\">Hello World!</p></body>"; |
| 83 #endif // !defined(OS_CHROMEOS) |
82 | 84 |
83 void CreatePrintSettingsDictionary(base::DictionaryValue* dict) { | 85 void CreatePrintSettingsDictionary(base::DictionaryValue* dict) { |
84 dict->SetBoolean(kSettingLandscape, false); | 86 dict->SetBoolean(kSettingLandscape, false); |
85 dict->SetBoolean(kSettingCollate, false); | 87 dict->SetBoolean(kSettingCollate, false); |
86 dict->SetInteger(kSettingColor, GRAY); | 88 dict->SetInteger(kSettingColor, GRAY); |
87 dict->SetBoolean(kSettingPrintToPDF, true); | 89 dict->SetBoolean(kSettingPrintToPDF, true); |
88 dict->SetInteger(kSettingDuplexMode, SIMPLEX); | 90 dict->SetInteger(kSettingDuplexMode, SIMPLEX); |
89 dict->SetInteger(kSettingCopies, 1); | 91 dict->SetInteger(kSettingCopies, 1); |
90 dict->SetString(kSettingDeviceName, "dummy"); | 92 dict->SetString(kSettingDeviceName, "dummy"); |
91 dict->SetInteger(kPreviewUIID, 4); | 93 dict->SetInteger(kPreviewUIID, 4); |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 chrome_render_thread_->printer()->ResetPrinter(); | 971 chrome_render_thread_->printer()->ResetPrinter(); |
970 VerifyPagesPrinted(false); | 972 VerifyPagesPrinted(false); |
971 | 973 |
972 // Pretend user will print, should not be throttled. | 974 // Pretend user will print, should not be throttled. |
973 chrome_render_thread_->set_print_dialog_user_response(true); | 975 chrome_render_thread_->set_print_dialog_user_response(true); |
974 PrintWithJavaScript(); | 976 PrintWithJavaScript(); |
975 VerifyPagesPrinted(true); | 977 VerifyPagesPrinted(true); |
976 } | 978 } |
977 | 979 |
978 } // namespace printing | 980 } // namespace printing |
OLD | NEW |