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

Unified Diff: components/printing/test/print_mock_render_thread.cc

Issue 2719443003: Reland of Add automated testing to check for page size with scaling (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/printing/test/print_mock_render_thread.cc
diff --git a/components/printing/test/print_mock_render_thread.cc b/components/printing/test/print_mock_render_thread.cc
index cc8205aeafaf7574903d7439168e1563cecbd1a3..74013e349f20a7bc52b739beb2c14fb762735408 100644
--- a/components/printing/test/print_mock_render_thread.cc
+++ b/components/printing/test/print_mock_render_thread.cc
@@ -15,6 +15,7 @@
#include "printing/features/features.h"
#include "printing/page_range.h"
#include "printing/print_job_constants.h"
+#include "printing/units.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(ENABLE_PRINTING)
@@ -162,9 +163,32 @@
new_ranges.push_back(range);
}
}
+
+ // Get media size
+ const base::DictionaryValue* media_size_value = nullptr;
+ gfx::Size page_size;
+ if (job_settings.GetDictionary(printing::kSettingMediaSize,
+ &media_size_value)) {
+ int width_microns = 0;
+ int height_microns = 0;
+ if (media_size_value->GetInteger(printing::kSettingMediaSizeWidthMicrons,
+ &width_microns) &&
+ media_size_value->GetInteger(printing::kSettingMediaSizeHeightMicrons,
+ &height_microns)) {
+ float device_microns_per_unit =
+ (printing::kHundrethsMMPerInch * 10.0f) / printing::kDefaultPdfDpi;
+ page_size = gfx::Size(width_microns / device_microns_per_unit,
+ height_microns / device_microns_per_unit);
+ }
+ }
+
+ // Get scaling
+ int scale_factor = 100;
+ job_settings.GetInteger(printing::kSettingScaleFactor, &scale_factor);
+
std::vector<int> pages(printing::PageRange::GetPages(new_ranges));
- printer_->UpdateSettings(document_cookie, params, pages, margins_type);
-
+ printer_->UpdateSettings(document_cookie, params, pages, margins_type,
+ page_size, scale_factor);
job_settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly,
&params->params.selection_only);
job_settings.GetBoolean(printing::kSettingShouldPrintBackgrounds,
« 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