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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 "<body>Lorem Ipsum:" | 73 "<body>Lorem Ipsum:" |
74 "</body></html>"; | 74 "</body></html>"; |
75 | 75 |
76 // A longer web page. | 76 // A longer web page. |
77 const char kLongPageHTML[] = | 77 const char kLongPageHTML[] = |
78 "<body><img src=\"\" width=10 height=10000 /></body>"; | 78 "<body><img src=\"\" width=10 height=10000 /></body>"; |
79 | 79 |
80 // A web page to simulate the print preview page. | 80 // A web page to simulate the print preview page. |
81 const char kPrintPreviewHTML[] = | 81 const char kPrintPreviewHTML[] = |
82 "<body><p id=\"pdf-viewer\">Hello World!</p></body>"; | 82 "<body><p id=\"pdf-viewer\">Hello World!</p></body>"; |
83 #endif // !defined(OS_CHROMEOS) | |
84 | 83 |
85 void CreatePrintSettingsDictionary(base::DictionaryValue* dict) { | 84 void CreatePrintSettingsDictionary(base::DictionaryValue* dict) { |
86 dict->SetBoolean(kSettingLandscape, false); | 85 dict->SetBoolean(kSettingLandscape, false); |
87 dict->SetBoolean(kSettingCollate, false); | 86 dict->SetBoolean(kSettingCollate, false); |
88 dict->SetInteger(kSettingColor, GRAY); | 87 dict->SetInteger(kSettingColor, GRAY); |
89 dict->SetBoolean(kSettingPrintToPDF, true); | 88 dict->SetBoolean(kSettingPrintToPDF, true); |
90 dict->SetInteger(kSettingDuplexMode, SIMPLEX); | 89 dict->SetInteger(kSettingDuplexMode, SIMPLEX); |
91 dict->SetInteger(kSettingCopies, 1); | 90 dict->SetInteger(kSettingCopies, 1); |
92 dict->SetString(kSettingDeviceName, "dummy"); | 91 dict->SetString(kSettingDeviceName, "dummy"); |
93 dict->SetInteger(kPreviewUIID, 4); | 92 dict->SetInteger(kPreviewUIID, 4); |
94 dict->SetInteger(kPreviewRequestID, 12345); | 93 dict->SetInteger(kPreviewRequestID, 12345); |
95 dict->SetBoolean(kIsFirstRequest, true); | 94 dict->SetBoolean(kIsFirstRequest, true); |
96 dict->SetInteger(kSettingMarginsType, DEFAULT_MARGINS); | 95 dict->SetInteger(kSettingMarginsType, DEFAULT_MARGINS); |
97 dict->SetBoolean(kSettingPreviewModifiable, false); | 96 dict->SetBoolean(kSettingPreviewModifiable, false); |
98 dict->SetBoolean(kSettingHeaderFooterEnabled, false); | 97 dict->SetBoolean(kSettingHeaderFooterEnabled, false); |
99 dict->SetBoolean(kSettingGenerateDraftData, true); | 98 dict->SetBoolean(kSettingGenerateDraftData, true); |
100 dict->SetBoolean(kSettingShouldPrintBackgrounds, false); | 99 dict->SetBoolean(kSettingShouldPrintBackgrounds, false); |
101 dict->SetBoolean(kSettingShouldPrintSelectionOnly, false); | 100 dict->SetBoolean(kSettingShouldPrintSelectionOnly, false); |
102 } | 101 } |
| 102 #endif // !defined(OS_CHROMEOS) |
103 | 103 |
104 } // namespace | 104 } // namespace |
105 | 105 |
106 class PrintWebViewHelperTestBase : public ChromeRenderViewTest { | 106 class PrintWebViewHelperTestBase : public ChromeRenderViewTest { |
107 public: | 107 public: |
108 PrintWebViewHelperTestBase() {} | 108 PrintWebViewHelperTestBase() {} |
109 virtual ~PrintWebViewHelperTestBase() {} | 109 virtual ~PrintWebViewHelperTestBase() {} |
110 | 110 |
111 protected: | 111 protected: |
112 void PrintWithJavaScript() { | 112 void PrintWithJavaScript() { |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 chrome_render_thread_->printer()->ResetPrinter(); | 971 chrome_render_thread_->printer()->ResetPrinter(); |
972 VerifyPagesPrinted(false); | 972 VerifyPagesPrinted(false); |
973 | 973 |
974 // Pretend user will print, should not be throttled. | 974 // Pretend user will print, should not be throttled. |
975 chrome_render_thread_->set_print_dialog_user_response(true); | 975 chrome_render_thread_->set_print_dialog_user_response(true); |
976 PrintWithJavaScript(); | 976 PrintWithJavaScript(); |
977 VerifyPagesPrinted(true); | 977 VerifyPagesPrinted(true); |
978 } | 978 } |
979 | 979 |
980 } // namespace printing | 980 } // namespace printing |
OLD | NEW |