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 "chrome/renderer/mock_printer.h" | 5 #include "chrome/renderer/mock_printer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 MockPrinterPage::~MockPrinterPage() {} | 52 MockPrinterPage::~MockPrinterPage() {} |
53 | 53 |
54 MockPrinter::MockPrinter() | 54 MockPrinter::MockPrinter() |
55 : dpi_(printing::kPointsPerInch), | 55 : dpi_(printing::kPointsPerInch), |
56 max_shrink_(2.0), | 56 max_shrink_(2.0), |
57 min_shrink_(1.25), | 57 min_shrink_(1.25), |
58 desired_dpi_(printing::kPointsPerInch), | 58 desired_dpi_(printing::kPointsPerInch), |
59 selection_only_(false), | 59 selection_only_(false), |
| 60 should_print_backgrounds_(false), |
60 document_cookie_(-1), | 61 document_cookie_(-1), |
61 current_document_cookie_(0), | 62 current_document_cookie_(0), |
62 printer_status_(PRINTER_READY), | 63 printer_status_(PRINTER_READY), |
63 number_pages_(0), | 64 number_pages_(0), |
64 page_number_(0), | 65 page_number_(0), |
65 is_first_request_(true), | 66 is_first_request_(true), |
66 print_to_pdf_(false), | 67 print_to_pdf_(false), |
67 preview_request_id_(0), | 68 preview_request_id_(0), |
68 print_scaling_option_(WebKit::WebPrintScalingOptionSourceSize), | 69 print_scaling_option_(WebKit::WebPrintScalingOptionSourceSize), |
69 display_header_footer_(false), | 70 display_header_footer_(false), |
(...skipping 30 matching lines...) Expand all Loading... |
100 params->Reset(); | 101 params->Reset(); |
101 SetPrintParams(params); | 102 SetPrintParams(params); |
102 } | 103 } |
103 | 104 |
104 void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { | 105 void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { |
105 dpi_ = params.dpi; | 106 dpi_ = params.dpi; |
106 max_shrink_ = params.max_shrink; | 107 max_shrink_ = params.max_shrink; |
107 min_shrink_ = params.min_shrink; | 108 min_shrink_ = params.min_shrink; |
108 desired_dpi_ = params.desired_dpi; | 109 desired_dpi_ = params.desired_dpi; |
109 selection_only_ = params.selection_only; | 110 selection_only_ = params.selection_only; |
| 111 should_print_backgrounds_ = params.should_print_backgrounds; |
110 page_size_ = params.page_size; | 112 page_size_ = params.page_size; |
111 content_size_ = params.content_size; | 113 content_size_ = params.content_size; |
112 printable_area_ = params.printable_area; | 114 printable_area_ = params.printable_area; |
113 margin_left_ = params.margin_left; | 115 margin_left_ = params.margin_left; |
114 margin_top_ = params.margin_top; | 116 margin_top_ = params.margin_top; |
115 display_header_footer_ = params.display_header_footer; | 117 display_header_footer_ = params.display_header_footer; |
116 date_ = params.date; | 118 date_ = params.date; |
117 title_ = params.title; | 119 title_ = params.title; |
118 url_ = params.url; | 120 url_ = params.url; |
119 } | 121 } |
(...skipping 19 matching lines...) Expand all Loading... |
139 // Verify the input parameters. | 141 // Verify the input parameters. |
140 EXPECT_EQ(document_cookie_, cookie); | 142 EXPECT_EQ(document_cookie_, cookie); |
141 | 143 |
142 settings->Reset(); | 144 settings->Reset(); |
143 | 145 |
144 settings->params.dpi = dpi_; | 146 settings->params.dpi = dpi_; |
145 settings->params.max_shrink = max_shrink_; | 147 settings->params.max_shrink = max_shrink_; |
146 settings->params.min_shrink = min_shrink_; | 148 settings->params.min_shrink = min_shrink_; |
147 settings->params.desired_dpi = desired_dpi_; | 149 settings->params.desired_dpi = desired_dpi_; |
148 settings->params.selection_only = selection_only_; | 150 settings->params.selection_only = selection_only_; |
| 151 settings->params.should_print_backgrounds = should_print_backgrounds_; |
149 settings->params.document_cookie = document_cookie_; | 152 settings->params.document_cookie = document_cookie_; |
150 settings->params.page_size = page_size_; | 153 settings->params.page_size = page_size_; |
151 settings->params.content_size = content_size_; | 154 settings->params.content_size = content_size_; |
152 settings->params.printable_area = printable_area_; | 155 settings->params.printable_area = printable_area_; |
153 settings->params.is_first_request = is_first_request_; | 156 settings->params.is_first_request = is_first_request_; |
154 settings->params.print_scaling_option = print_scaling_option_; | 157 settings->params.print_scaling_option = print_scaling_option_; |
155 settings->params.print_to_pdf = print_to_pdf_; | 158 settings->params.print_to_pdf = print_to_pdf_; |
156 settings->params.preview_request_id = preview_request_id_; | 159 settings->params.preview_request_id = preview_request_id_; |
157 settings->params.display_header_footer = display_header_footer_; | 160 settings->params.display_header_footer = display_header_footer_; |
158 settings->params.date = date_; | 161 settings->params.date = date_; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 int MockPrinter::CreateDocumentCookie() { | 294 int MockPrinter::CreateDocumentCookie() { |
292 return use_invalid_settings_ ? 0 : ++current_document_cookie_; | 295 return use_invalid_settings_ ? 0 : ++current_document_cookie_; |
293 } | 296 } |
294 | 297 |
295 void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { | 298 void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { |
296 params->dpi = dpi_; | 299 params->dpi = dpi_; |
297 params->max_shrink = max_shrink_; | 300 params->max_shrink = max_shrink_; |
298 params->min_shrink = min_shrink_; | 301 params->min_shrink = min_shrink_; |
299 params->desired_dpi = desired_dpi_; | 302 params->desired_dpi = desired_dpi_; |
300 params->selection_only = selection_only_; | 303 params->selection_only = selection_only_; |
| 304 params->should_print_backgrounds = should_print_backgrounds_; |
301 params->document_cookie = document_cookie_; | 305 params->document_cookie = document_cookie_; |
302 params->page_size = page_size_; | 306 params->page_size = page_size_; |
303 params->content_size = content_size_; | 307 params->content_size = content_size_; |
304 params->printable_area = printable_area_; | 308 params->printable_area = printable_area_; |
305 params->margin_left = margin_left_; | 309 params->margin_left = margin_left_; |
306 params->margin_top = margin_top_; | 310 params->margin_top = margin_top_; |
307 params->is_first_request = is_first_request_; | 311 params->is_first_request = is_first_request_; |
308 params->print_scaling_option = print_scaling_option_; | 312 params->print_scaling_option = print_scaling_option_; |
309 params->print_to_pdf = print_to_pdf_; | 313 params->print_to_pdf = print_to_pdf_; |
310 params->preview_request_id = preview_request_id_; | 314 params->preview_request_id = preview_request_id_; |
311 params->display_header_footer = display_header_footer_; | 315 params->display_header_footer = display_header_footer_; |
312 params->date = date_; | 316 params->date = date_; |
313 params->title = title_; | 317 params->title = title_; |
314 params->url = url_; | 318 params->url = url_; |
315 } | 319 } |
OLD | NEW |