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

Side by Side Diff: components/printing/test/print_mock_render_thread.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 (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 "components/printing/test/print_mock_render_thread.h" 5 #include "components/printing/test/print_mock_render_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "components/printing/test/mock_printer.h" 13 #include "components/printing/test/mock_printer.h"
14 #include "ipc/ipc_sync_message.h" 14 #include "ipc/ipc_sync_message.h"
15 #include "printing/features/features.h" 15 #include "printing/features/features.h"
16 #include "printing/page_range.h" 16 #include "printing/page_range.h"
17 #include "printing/print_job_constants.h" 17 #include "printing/print_job_constants.h"
18 #include "printing/units.h"
19 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
20 19
21 #if BUILDFLAG(ENABLE_PRINTING) 20 #if BUILDFLAG(ENABLE_PRINTING)
22 #include "components/printing/common/print_messages.h" 21 #include "components/printing/common/print_messages.h"
23 #endif 22 #endif
24 23
25 PrintMockRenderThread::PrintMockRenderThread() 24 PrintMockRenderThread::PrintMockRenderThread()
26 #if BUILDFLAG(ENABLE_PRINTING) 25 #if BUILDFLAG(ENABLE_PRINTING)
27 : printer_(new MockPrinter), 26 : printer_(new MockPrinter),
28 print_dialog_user_response_(true), 27 print_dialog_user_response_(true),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 !dict->GetInteger(printing::kSettingPageRangeTo, &range.to)) { 155 !dict->GetInteger(printing::kSettingPageRangeTo, &range.to)) {
157 continue; 156 continue;
158 } 157 }
159 // Page numbers are 1-based in the dictionary. 158 // Page numbers are 1-based in the dictionary.
160 // Page numbers are 0-based for the printing context. 159 // Page numbers are 0-based for the printing context.
161 range.from--; 160 range.from--;
162 range.to--; 161 range.to--;
163 new_ranges.push_back(range); 162 new_ranges.push_back(range);
164 } 163 }
165 } 164 }
165 std::vector<int> pages(printing::PageRange::GetPages(new_ranges));
166 printer_->UpdateSettings(document_cookie, params, pages, margins_type);
166 167
167 // Get media size
168 const base::DictionaryValue* media_size_value = nullptr;
169 gfx::Size page_size;
170 if (job_settings.GetDictionary(printing::kSettingMediaSize,
171 &media_size_value)) {
172 int width_microns = 0;
173 int height_microns = 0;
174 if (media_size_value->GetInteger(printing::kSettingMediaSizeWidthMicrons,
175 &width_microns) &&
176 media_size_value->GetInteger(printing::kSettingMediaSizeHeightMicrons,
177 &height_microns)) {
178 float device_microns_per_unit =
179 (printing::kHundrethsMMPerInch * 10.0f) / printing::kDefaultPdfDpi;
180 page_size = gfx::Size(width_microns / device_microns_per_unit,
181 height_microns / device_microns_per_unit);
182 }
183 }
184
185 // Get scaling
186 int scale_factor = 100;
187 job_settings.GetInteger(printing::kSettingScaleFactor, &scale_factor);
188
189 std::vector<int> pages(printing::PageRange::GetPages(new_ranges));
190 printer_->UpdateSettings(document_cookie, params, pages, margins_type,
191 page_size, scale_factor);
192 job_settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly, 168 job_settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly,
193 &params->params.selection_only); 169 &params->params.selection_only);
194 job_settings.GetBoolean(printing::kSettingShouldPrintBackgrounds, 170 job_settings.GetBoolean(printing::kSettingShouldPrintBackgrounds,
195 &params->params.should_print_backgrounds); 171 &params->params.should_print_backgrounds);
196 } 172 }
197 173
198 MockPrinter* PrintMockRenderThread::printer() { 174 MockPrinter* PrintMockRenderThread::printer() {
199 return printer_.get(); 175 return printer_.get();
200 } 176 }
201 177
202 void PrintMockRenderThread::set_print_dialog_user_response(bool response) { 178 void PrintMockRenderThread::set_print_dialog_user_response(bool response) {
203 print_dialog_user_response_ = response; 179 print_dialog_user_response_ = response;
204 } 180 }
205 181
206 void PrintMockRenderThread::set_print_preview_cancel_page_number(int page) { 182 void PrintMockRenderThread::set_print_preview_cancel_page_number(int page) {
207 print_preview_cancel_page_number_ = page; 183 print_preview_cancel_page_number_ = page;
208 } 184 }
209 185
210 int PrintMockRenderThread::print_preview_pages_remaining() const { 186 int PrintMockRenderThread::print_preview_pages_remaining() const {
211 return print_preview_pages_remaining_; 187 return print_preview_pages_remaining_;
212 } 188 }
213 #endif // BUILDFLAG(ENABLE_PRINTING) 189 #endif // BUILDFLAG(ENABLE_PRINTING)
OLDNEW
« no previous file with comments | « components/printing/test/mock_printer.cc ('k') | components/printing/test/print_web_view_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698