OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 22 matching lines...) Expand all Loading... |
33 max_shrink_(2.0), | 33 max_shrink_(2.0), |
34 min_shrink_(1.25), | 34 min_shrink_(1.25), |
35 desired_dpi_(printing::kPointsPerInch), | 35 desired_dpi_(printing::kPointsPerInch), |
36 selection_only_(false), | 36 selection_only_(false), |
37 document_cookie_(-1), | 37 document_cookie_(-1), |
38 current_document_cookie_(0), | 38 current_document_cookie_(0), |
39 printer_status_(PRINTER_READY), | 39 printer_status_(PRINTER_READY), |
40 number_pages_(0), | 40 number_pages_(0), |
41 page_number_(0), | 41 page_number_(0), |
42 is_first_request_(true), | 42 is_first_request_(true), |
| 43 print_to_pdf_(false), |
43 preview_request_id_(0), | 44 preview_request_id_(0), |
44 display_header_footer_(false), | 45 display_header_footer_(false), |
45 date_(ASCIIToUTF16("date")), | 46 date_(ASCIIToUTF16("date")), |
46 title_(ASCIIToUTF16("title")), | 47 title_(ASCIIToUTF16("title")), |
47 url_(ASCIIToUTF16("url")), | 48 url_(ASCIIToUTF16("url")), |
48 use_invalid_settings_(false) { | 49 use_invalid_settings_(false) { |
49 page_size_.SetSize(static_cast<int>(8.5 * dpi_), | 50 page_size_.SetSize(static_cast<int>(8.5 * dpi_), |
50 static_cast<int>(11.0 * dpi_)); | 51 static_cast<int>(11.0 * dpi_)); |
51 printable_size_.SetSize(static_cast<int>((7.5 * dpi_)), | 52 printable_size_.SetSize(static_cast<int>((7.5 * dpi_)), |
52 static_cast<int>((10.0 * dpi_))); | 53 static_cast<int>((10.0 * dpi_))); |
53 margin_left_ = margin_top_ = static_cast<int>(0.5 * dpi_); | 54 margin_left_ = margin_top_ = static_cast<int>(0.5 * dpi_); |
| 55 printable_area_.SetSize(static_cast<int>(0.25 * dpi_), |
| 56 static_cast<int>(0.25 *dpi_), |
| 57 static_cast<int>(8 * dpi_), |
| 58 static_cast<int>(10.5 * dpi_)); |
54 } | 59 } |
55 | 60 |
56 MockPrinter::~MockPrinter() { | 61 MockPrinter::~MockPrinter() { |
57 } | 62 } |
58 | 63 |
59 void MockPrinter::ResetPrinter() { | 64 void MockPrinter::ResetPrinter() { |
60 printer_status_ = PRINTER_READY; | 65 printer_status_ = PRINTER_READY; |
61 document_cookie_ = -1; | 66 document_cookie_ = -1; |
62 } | 67 } |
63 | 68 |
64 void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) { | 69 void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) { |
65 // Verify this printer is not processing a job. | 70 // Verify this printer is not processing a job. |
66 // Sorry, this mock printer is very fragile. | 71 // Sorry, this mock printer is very fragile. |
67 EXPECT_EQ(-1, document_cookie_); | 72 EXPECT_EQ(-1, document_cookie_); |
68 | 73 |
69 // Assign a unit document cookie and set the print settings. | 74 // Assign a unit document cookie and set the print settings. |
70 document_cookie_ = CreateDocumentCookie(); | 75 document_cookie_ = CreateDocumentCookie(); |
71 params->Reset(); | 76 params->Reset(); |
72 SetPrintParams(params); | 77 SetPrintParams(params); |
73 } | 78 } |
74 | 79 |
75 void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { | 80 void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { |
76 dpi_ = params.dpi; | 81 dpi_ = params.dpi; |
77 max_shrink_ = params.max_shrink; | 82 max_shrink_ = params.max_shrink; |
78 min_shrink_ = params.min_shrink; | 83 min_shrink_ = params.min_shrink; |
79 desired_dpi_ = params.desired_dpi; | 84 desired_dpi_ = params.desired_dpi; |
80 selection_only_ = params.selection_only; | 85 selection_only_ = params.selection_only; |
81 page_size_ = params.page_size; | 86 page_size_ = params.page_size; |
82 printable_size_ = params.printable_size; | 87 printable_size_ = params.printable_size; |
| 88 printable_area_ = params.printable_area; |
83 margin_left_ = params.margin_left; | 89 margin_left_ = params.margin_left; |
84 margin_top_ = params.margin_top; | 90 margin_top_ = params.margin_top; |
85 display_header_footer_ = params.display_header_footer; | 91 display_header_footer_ = params.display_header_footer; |
86 date_ = params.date; | 92 date_ = params.date; |
87 title_ = params.title; | 93 title_ = params.title; |
88 url_ = params.url; | 94 url_ = params.url; |
89 } | 95 } |
90 | 96 |
91 void MockPrinter::UseInvalidSettings() { | 97 void MockPrinter::UseInvalidSettings() { |
92 use_invalid_settings_ = true; | 98 use_invalid_settings_ = true; |
(...skipping 11 matching lines...) Expand all Loading... |
104 settings->Reset(); | 110 settings->Reset(); |
105 | 111 |
106 settings->params.dpi = dpi_; | 112 settings->params.dpi = dpi_; |
107 settings->params.max_shrink = max_shrink_; | 113 settings->params.max_shrink = max_shrink_; |
108 settings->params.min_shrink = min_shrink_; | 114 settings->params.min_shrink = min_shrink_; |
109 settings->params.desired_dpi = desired_dpi_; | 115 settings->params.desired_dpi = desired_dpi_; |
110 settings->params.selection_only = selection_only_; | 116 settings->params.selection_only = selection_only_; |
111 settings->params.document_cookie = document_cookie_; | 117 settings->params.document_cookie = document_cookie_; |
112 settings->params.page_size = page_size_; | 118 settings->params.page_size = page_size_; |
113 settings->params.printable_size = printable_size_; | 119 settings->params.printable_size = printable_size_; |
| 120 settings->params.printable_area = printable_area_; |
114 settings->params.is_first_request = is_first_request_; | 121 settings->params.is_first_request = is_first_request_; |
| 122 settings->params.print_to_pdf = print_to_pdf_; |
115 settings->params.preview_request_id = preview_request_id_; | 123 settings->params.preview_request_id = preview_request_id_; |
116 settings->params.display_header_footer = display_header_footer_; | 124 settings->params.display_header_footer = display_header_footer_; |
117 settings->params.date = date_; | 125 settings->params.date = date_; |
118 settings->params.title = title_; | 126 settings->params.title = title_; |
119 settings->params.url = url_; | 127 settings->params.url = url_; |
120 printer_status_ = PRINTER_PRINTING; | 128 printer_status_ = PRINTER_PRINTING; |
121 } | 129 } |
122 | 130 |
123 void MockPrinter::UpdateSettings(int cookie, | 131 void MockPrinter::UpdateSettings(int cookie, |
124 PrintMsg_PrintPages_Params* params, | 132 PrintMsg_PrintPages_Params* params, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 259 |
252 void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { | 260 void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { |
253 params->dpi = dpi_; | 261 params->dpi = dpi_; |
254 params->max_shrink = max_shrink_; | 262 params->max_shrink = max_shrink_; |
255 params->min_shrink = min_shrink_; | 263 params->min_shrink = min_shrink_; |
256 params->desired_dpi = desired_dpi_; | 264 params->desired_dpi = desired_dpi_; |
257 params->selection_only = selection_only_; | 265 params->selection_only = selection_only_; |
258 params->document_cookie = document_cookie_; | 266 params->document_cookie = document_cookie_; |
259 params->page_size = page_size_; | 267 params->page_size = page_size_; |
260 params->printable_size = printable_size_; | 268 params->printable_size = printable_size_; |
| 269 params->printable_area = printable_area_; |
261 params->margin_left = margin_left_; | 270 params->margin_left = margin_left_; |
262 params->margin_top = margin_top_; | 271 params->margin_top = margin_top_; |
263 params->is_first_request = is_first_request_; | 272 params->is_first_request = is_first_request_; |
| 273 params->print_to_pdf = print_to_pdf_; |
264 params->preview_request_id = preview_request_id_; | 274 params->preview_request_id = preview_request_id_; |
265 params->display_header_footer = display_header_footer_; | 275 params->display_header_footer = display_header_footer_; |
266 params->date = date_; | 276 params->date = date_; |
267 params->title = title_; | 277 params->title = title_; |
268 params->url = url_; | 278 params->url = url_; |
269 } | 279 } |
OLD | NEW |