diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 19:48:17 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 19:48:17 +0000 |
commit | 68b16b9650dcfa49c7d8d79e384bbcc30b26311a (patch) | |
tree | e27f79b0cfab13a0df7d7db15418865184fb63d5 | |
parent | a945841f6a3c2adcabe2a830f0c9e0b18e1574ac (diff) | |
download | chromium_src-68b16b9650dcfa49c7d8d79e384bbcc30b26311a.zip chromium_src-68b16b9650dcfa49c7d8d79e384bbcc30b26311a.tar.gz chromium_src-68b16b9650dcfa49c7d8d79e384bbcc30b26311a.tar.bz2 |
Printing: MockPrinter should return valid default printer settings.
Review URL: http://codereview.chromium.org/6673038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78262 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/mock_printer.cc | 31 | ||||
-rw-r--r-- | chrome/renderer/mock_printer.h | 9 | ||||
-rw-r--r-- | chrome/renderer/render_view_browsertest.cc | 13 |
3 files changed, 27 insertions, 26 deletions
diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc index 4510bfc..be9aec4 100644 --- a/chrome/renderer/mock_printer.cc +++ b/chrome/renderer/mock_printer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,20 +28,21 @@ MockPrinterPage::MockPrinterPage(const void* source_data, MockPrinterPage::~MockPrinterPage() {} MockPrinter::MockPrinter() - : printable_width_(0), - printable_height_(0), - dpi_(printing::kPointsPerInch), + : dpi_(printing::kPointsPerInch), max_shrink_(2.0), min_shrink_(1.25), - desired_dpi_(72), + desired_dpi_(printing::kPointsPerInch), selection_only_(false), document_cookie_(-1), current_document_cookie_(0), printer_status_(PRINTER_READY), number_pages_(0), page_number_(0) { - printable_width_ = static_cast<int>(dpi_ * 8.5); - printable_height_ = static_cast<int>(dpi_ * 11.0); + page_size_.SetSize(static_cast<int>(8.5 * dpi_), + static_cast<int>(11.0 * dpi_)); + printable_size_.SetSize(static_cast<int>((7.5 * dpi_)), + static_cast<int>((10.0 * dpi_))); + margin_left_ = margin_top_ = static_cast<int>(0.5 * dpi_); } MockPrinter::~MockPrinter() { @@ -66,8 +67,10 @@ void MockPrinter::GetDefaultPrintSettings(ViewMsg_Print_Params* params) { params->desired_dpi = desired_dpi_; params->selection_only = selection_only_; params->document_cookie = document_cookie_; - params->printable_size.set_width(printable_width_); - params->printable_size.set_height(printable_height_); + params->page_size = page_size_; + params->printable_size = printable_size_; + params->margin_left = margin_left_; + params->margin_top = margin_top_; } void MockPrinter::SetDefaultPrintSettings(const ViewMsg_Print_Params& params) { @@ -76,8 +79,10 @@ void MockPrinter::SetDefaultPrintSettings(const ViewMsg_Print_Params& params) { min_shrink_ = params.min_shrink; desired_dpi_ = params.desired_dpi; selection_only_ = params.selection_only; - printable_width_ = params.printable_size.width(); - printable_height_ = params.printable_size.height(); + page_size_ = params.page_size; + printable_size_ = params.printable_size; + margin_left_ = params.margin_left; + margin_top_ = params.margin_top; } void MockPrinter::ScriptedPrint(int cookie, @@ -94,8 +99,8 @@ void MockPrinter::ScriptedPrint(int cookie, settings->params.desired_dpi = desired_dpi_; settings->params.selection_only = selection_only_; settings->params.document_cookie = document_cookie_; - settings->params.printable_size.set_width(printable_width_); - settings->params.printable_size.set_height(printable_height_); + settings->params.page_size = page_size_; + settings->params.printable_size = printable_size_; printer_status_ = PRINTER_PRINTING; } diff --git a/chrome/renderer/mock_printer.h b/chrome/renderer/mock_printer.h index ddd55ac..c1faad0 100644 --- a/chrome/renderer/mock_printer.h +++ b/chrome/renderer/mock_printer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +13,7 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "printing/image.h" +#include "ui/gfx/size.h" struct ViewMsg_Print_Params; struct ViewMsg_PrintPages_Params; @@ -99,8 +100,10 @@ class MockPrinter { private: // In pixels according to dpi_x and dpi_y. - int printable_width_; - int printable_height_; + gfx::Size page_size_; + gfx::Size printable_size_; + int margin_left_; + int margin_top_; // Specifies dots per inch. double dpi_; diff --git a/chrome/renderer/render_view_browsertest.cc b/chrome/renderer/render_view_browsertest.cc index 73d2446..b446b39 100644 --- a/chrome/renderer/render_view_browsertest.cc +++ b/chrome/renderer/render_view_browsertest.cc @@ -479,9 +479,9 @@ const TestPageData kTestPages[] = { #if defined(OS_MACOSX) // Mac printing code compensates for the WebKit scale factor while generating // the metafile, so we expect smaller pages. - 1, 612, 792, + 1, 540, 720, #else - 1, 764, 972, + 1, 675, 900, #endif NULL, NULL, @@ -489,18 +489,11 @@ const TestPageData kTestPages[] = { }; } // namespace -// Failing on windows. http://crbug.com/56246 -#if defined(OS_WIN) -#define MAYBE_PrintLayoutTest DISABLED_PrintLayoutTest -#else -#define MAYBE_PrintLayoutTest PrintLayoutTest -#endif - // TODO(estade): need to port MockPrinter to get this on Linux. This involves // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the // metafile directly. #if defined(OS_WIN) || defined(OS_MACOSX) -TEST_F(RenderViewTest, MAYBE_PrintLayoutTest) { +TEST_F(RenderViewTest, PrintLayoutTest) { bool baseline = false; EXPECT_TRUE(render_thread_.printer() != NULL); |