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

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

Issue 2718513003: Revert of Add automated testing to check for page size with scaling (Closed)
Patch Set: Created 3 years, 9 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 22 matching lines...) Expand all
33 params->margin_left = static_cast<int>(0.25 * dpi); 33 params->margin_left = static_cast<int>(0.25 * dpi);
34 params->margin_top = static_cast<int>(0.25 * dpi); 34 params->margin_top = static_cast<int>(0.25 * dpi);
35 } else if (margins_type == printing::CUSTOM_MARGINS) { 35 } else if (margins_type == printing::CUSTOM_MARGINS) {
36 params->content_size.SetSize(static_cast<int>((7.9 * dpi)), 36 params->content_size.SetSize(static_cast<int>((7.9 * dpi)),
37 static_cast<int>((10.4 * dpi))); 37 static_cast<int>((10.4 * dpi)));
38 params->margin_left = static_cast<int>(0.30 * dpi); 38 params->margin_left = static_cast<int>(0.30 * dpi);
39 params->margin_top = static_cast<int>(0.30 * dpi); 39 params->margin_top = static_cast<int>(0.30 * dpi);
40 } 40 }
41 } 41 }
42 42
43 void UpdatePageSizeAndScaling(const gfx::Size& page_size,
44 int scale_factor,
45 PrintMsg_Print_Params* params) {
46 params->page_size = page_size;
47 params->scale_factor = static_cast<double>(scale_factor) / 100.0;
48 }
49
50 } // namespace 43 } // namespace
51 44
52 MockPrinterPage::MockPrinterPage(const void* source_data, 45 MockPrinterPage::MockPrinterPage(const void* source_data,
53 uint32_t source_size, 46 uint32_t source_size,
54 const printing::Image& image) 47 const printing::Image& image)
55 : source_size_(source_size), image_(image) { 48 : source_size_(source_size), image_(image) {
56 // Create copies of the source data 49 // Create copies of the source data
57 source_data_.reset(new uint8_t[source_size]); 50 source_data_.reset(new uint8_t[source_size]);
58 if (source_data_.get()) 51 if (source_data_.get())
59 memcpy(source_data_.get(), source_data, source_size); 52 memcpy(source_data_.get(), source_data, source_size);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 settings->params.preview_request_id = preview_request_id_; 154 settings->params.preview_request_id = preview_request_id_;
162 settings->params.display_header_footer = display_header_footer_; 155 settings->params.display_header_footer = display_header_footer_;
163 settings->params.title = title_; 156 settings->params.title = title_;
164 settings->params.url = url_; 157 settings->params.url = url_;
165 printer_status_ = PRINTER_PRINTING; 158 printer_status_ = PRINTER_PRINTING;
166 } 159 }
167 160
168 void MockPrinter::UpdateSettings(int cookie, 161 void MockPrinter::UpdateSettings(int cookie,
169 PrintMsg_PrintPages_Params* params, 162 PrintMsg_PrintPages_Params* params,
170 const std::vector<int>& pages, 163 const std::vector<int>& pages,
171 int margins_type, 164 int margins_type) {
172 const gfx::Size& page_size,
173 int scale_factor) {
174 if (document_cookie_ == -1) { 165 if (document_cookie_ == -1) {
175 document_cookie_ = CreateDocumentCookie(); 166 document_cookie_ = CreateDocumentCookie();
176 } 167 }
177 params->Reset(); 168 params->Reset();
178 params->pages = pages; 169 params->pages = pages;
179 SetPrintParams(&(params->params)); 170 SetPrintParams(&(params->params));
180 UpdateMargins(margins_type, dpi_, &(params->params)); 171 UpdateMargins(margins_type, dpi_, &(params->params));
181 if (!page_size.IsEmpty())
182 UpdatePageSizeAndScaling(page_size, scale_factor, &params->params);
183 printer_status_ = PRINTER_PRINTING; 172 printer_status_ = PRINTER_PRINTING;
184 } 173 }
185 174
186 void MockPrinter::SetPrintedPagesCount(int cookie, int number_pages) { 175 void MockPrinter::SetPrintedPagesCount(int cookie, int number_pages) {
187 // Verify the input parameter and update the printer status so that the 176 // Verify the input parameter and update the printer status so that the
188 // RenderViewTest class can verify the this function finishes without errors. 177 // RenderViewTest class can verify the this function finishes without errors.
189 EXPECT_EQ(document_cookie_, cookie); 178 EXPECT_EQ(document_cookie_, cookie);
190 EXPECT_EQ(PRINTER_PRINTING, printer_status_); 179 EXPECT_EQ(PRINTER_PRINTING, printer_status_);
191 EXPECT_EQ(0, number_pages_); 180 EXPECT_EQ(0, number_pages_);
192 EXPECT_EQ(0, page_number_); 181 EXPECT_EQ(0, page_number_);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 params->margin_left = margin_left_; 289 params->margin_left = margin_left_;
301 params->margin_top = margin_top_; 290 params->margin_top = margin_top_;
302 params->is_first_request = is_first_request_; 291 params->is_first_request = is_first_request_;
303 params->print_scaling_option = print_scaling_option_; 292 params->print_scaling_option = print_scaling_option_;
304 params->print_to_pdf = print_to_pdf_; 293 params->print_to_pdf = print_to_pdf_;
305 params->preview_request_id = preview_request_id_; 294 params->preview_request_id = preview_request_id_;
306 params->display_header_footer = display_header_footer_; 295 params->display_header_footer = display_header_footer_;
307 params->title = title_; 296 params->title = title_;
308 params->url = url_; 297 params->url = url_;
309 } 298 }
OLDNEW
« no previous file with comments | « components/printing/test/mock_printer.h ('k') | components/printing/test/print_mock_render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698