Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: components/printing/test/mock_printer.cc

Issue 2812263002: clean up printing::Image and printing::Metafile (Closed)
Patch Set: const and impl in cc Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/printing/test/mock_printer.h" 5 #include "components/printing/test/mock_printer.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 EXPECT_EQ(page_number_, params.page_number); 202 EXPECT_EQ(page_number_, params.page_number);
203 EXPECT_LE(params.page_number, number_pages_); 203 EXPECT_LE(params.page_number, number_pages_);
204 204
205 #if defined(OS_WIN) || defined(OS_MACOSX) 205 #if defined(OS_WIN) || defined(OS_MACOSX)
206 // Load the data sent from a RenderView object and create a PageData object. 206 // Load the data sent from a RenderView object and create a PageData object.
207 // We duplicate the given file handle when creating a base::SharedMemory 207 // We duplicate the given file handle when creating a base::SharedMemory
208 // instance so that its destructor closes the copy. 208 // instance so that its destructor closes the copy.
209 EXPECT_GT(params.data_size, 0U); 209 EXPECT_GT(params.data_size, 0U);
210 base::SharedMemory metafile_data(params.metafile_data_handle, true); 210 base::SharedMemory metafile_data(params.metafile_data_handle, true);
211 metafile_data.Map(params.data_size); 211 metafile_data.Map(params.data_size);
212 #if defined(OS_MACOSX) 212 printing::Image image(metafile_data.memory(), params.data_size);
213 printing::PdfMetafileCg metafile;
214 #else
215 printing::PdfMetafileSkia metafile(printing::PDF_SKIA_DOCUMENT_TYPE);
216 #endif
217 metafile.InitFromData(metafile_data.memory(), params.data_size);
218 printing::Image image(metafile);
219 MockPrinterPage* page_data = 213 MockPrinterPage* page_data =
220 new MockPrinterPage(metafile_data.memory(), params.data_size, image); 214 new MockPrinterPage(metafile_data.memory(), params.data_size, image);
221 scoped_refptr<MockPrinterPage> page(page_data); 215 scoped_refptr<MockPrinterPage> page(page_data);
222 pages_.push_back(page); 216 pages_.push_back(page);
223 #endif 217 #endif
224 218
225 // We finish printing a printing job. 219 // We finish printing a printing job.
226 // Reset the job status and the printer status. 220 // Reset the job status and the printer status.
227 ++page_number_; 221 ++page_number_;
228 if (number_pages_ == page_number_) 222 if (number_pages_ == page_number_)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 params->margin_left = margin_left_; 290 params->margin_left = margin_left_;
297 params->margin_top = margin_top_; 291 params->margin_top = margin_top_;
298 params->is_first_request = is_first_request_; 292 params->is_first_request = is_first_request_;
299 params->print_scaling_option = print_scaling_option_; 293 params->print_scaling_option = print_scaling_option_;
300 params->print_to_pdf = print_to_pdf_; 294 params->print_to_pdf = print_to_pdf_;
301 params->preview_request_id = preview_request_id_; 295 params->preview_request_id = preview_request_id_;
302 params->display_header_footer = display_header_footer_; 296 params->display_header_footer = display_header_footer_;
303 params->title = title_; 297 params->title = title_;
304 params->url = url_; 298 params->url = url_;
305 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698