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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 page_size_ = params.page_size; | 80 page_size_ = params.page_size; |
81 printable_size_ = params.printable_size; | 81 printable_size_ = params.printable_size; |
82 margin_left_ = params.margin_left; | 82 margin_left_ = params.margin_left; |
83 margin_top_ = params.margin_top; | 83 margin_top_ = params.margin_top; |
84 display_header_footer_ = params.display_header_footer; | 84 display_header_footer_ = params.display_header_footer; |
85 date_ = params.date; | 85 date_ = params.date; |
86 title_ = params.title; | 86 title_ = params.title; |
87 url_ = params.url; | 87 url_ = params.url; |
88 } | 88 } |
89 | 89 |
90 void MockPrinter::SetBadSettings(bool be_evil) { | |
kmadhusu
2011/08/26 18:50:40
How about UseInvalidSettings()? This function will
arthurhsu
2011/08/29 22:53:16
Added a value in parameter, since we need to flip
| |
91 evil_ = be_evil; | |
92 } | |
93 | |
90 void MockPrinter::ScriptedPrint(int cookie, | 94 void MockPrinter::ScriptedPrint(int cookie, |
91 int expected_pages_count, | 95 int expected_pages_count, |
92 bool has_selection, | 96 bool has_selection, |
93 PrintMsg_PrintPages_Params* settings) { | 97 PrintMsg_PrintPages_Params* settings) { |
94 // Verify the input parameters. | 98 // Verify the input parameters. |
95 EXPECT_EQ(document_cookie_, cookie); | 99 EXPECT_EQ(document_cookie_, cookie); |
96 | 100 |
97 settings->Reset(); | 101 settings->Reset(); |
98 | 102 |
99 settings->params.dpi = dpi_; | 103 settings->params.dpi = dpi_; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 bool MockPrinter::SaveBitmap( | 233 bool MockPrinter::SaveBitmap( |
230 unsigned int page, const FilePath& filepath) const { | 234 unsigned int page, const FilePath& filepath) const { |
231 if (printer_status_ != PRINTER_READY || page >= pages_.size()) | 235 if (printer_status_ != PRINTER_READY || page >= pages_.size()) |
232 return false; | 236 return false; |
233 | 237 |
234 pages_[page]->image().SaveToPng(filepath); | 238 pages_[page]->image().SaveToPng(filepath); |
235 return true; | 239 return true; |
236 } | 240 } |
237 | 241 |
238 int MockPrinter::CreateDocumentCookie() { | 242 int MockPrinter::CreateDocumentCookie() { |
239 return ++current_document_cookie_; | 243 return evil_ ? 0 : ++current_document_cookie_; |
kmadhusu
2011/08/26 18:50:40
document_cookie is not a printer setting. So its b
arthurhsu
2011/08/29 22:53:16
It is used to determine if the printer settings is
| |
240 } | 244 } |
241 | 245 |
242 void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { | 246 void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { |
243 params->dpi = dpi_; | 247 params->dpi = dpi_; |
244 params->max_shrink = max_shrink_; | 248 params->max_shrink = max_shrink_; |
245 params->min_shrink = min_shrink_; | 249 params->min_shrink = min_shrink_; |
246 params->desired_dpi = desired_dpi_; | 250 params->desired_dpi = desired_dpi_; |
247 params->selection_only = selection_only_; | 251 params->selection_only = selection_only_; |
248 params->document_cookie = document_cookie_; | 252 params->document_cookie = document_cookie_; |
249 params->page_size = page_size_; | 253 params->page_size = page_size_; |
250 params->printable_size = printable_size_; | 254 params->printable_size = printable_size_; |
251 params->margin_left = margin_left_; | 255 params->margin_left = margin_left_; |
252 params->margin_top = margin_top_; | 256 params->margin_top = margin_top_; |
253 params->is_first_request = is_first_request_; | 257 params->is_first_request = is_first_request_; |
254 params->preview_request_id = preview_request_id_; | 258 params->preview_request_id = preview_request_id_; |
255 params->display_header_footer = display_header_footer_; | 259 params->display_header_footer = display_header_footer_; |
256 params->date = date_; | 260 params->date = date_; |
257 params->title = title_; | 261 params->title = title_; |
258 params->url = url_; | 262 params->url = url_; |
259 } | 263 } |
OLD | NEW |