summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/mock_printer.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 20:31:41 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 20:31:41 +0000
commit4d9160ff743804acf89a5a50a0b43c113aecc1ab (patch)
treec486f956118f396d6be94569f485632bb313ce21 /chrome/renderer/mock_printer.cc
parentcf5f25681e397cf802147868f04322f588bd80a2 (diff)
downloadchromium_src-4d9160ff743804acf89a5a50a0b43c113aecc1ab.zip
chromium_src-4d9160ff743804acf89a5a50a0b43c113aecc1ab.tar.gz
chromium_src-4d9160ff743804acf89a5a50a0b43c113aecc1ab.tar.bz2
Add tests for print preview code in PrintWebViewHelper.
BUG=none TEST=included Review URL: http://codereview.chromium.org/6929032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/mock_printer.cc')
-rw-r--r--chrome/renderer/mock_printer.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc
index 1a9236c..3117a87 100644
--- a/chrome/renderer/mock_printer.cc
+++ b/chrome/renderer/mock_printer.cc
@@ -59,16 +59,7 @@ void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) {
// Assign a unit document cookie and set the print settings.
document_cookie_ = CreateDocumentCookie();
memset(params, 0, sizeof(PrintMsg_Print_Params));
- params->dpi = dpi_;
- params->max_shrink = max_shrink_;
- params->min_shrink = min_shrink_;
- params->desired_dpi = desired_dpi_;
- params->selection_only = selection_only_;
- params->document_cookie = document_cookie_;
- params->page_size = page_size_;
- params->printable_size = printable_size_;
- params->margin_left = margin_left_;
- params->margin_top = margin_top_;
+ SetPrintParams(params);
}
void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) {
@@ -102,6 +93,14 @@ void MockPrinter::ScriptedPrint(int cookie,
printer_status_ = PRINTER_PRINTING;
}
+void MockPrinter::UpdateSettings(int cookie,
+ PrintMsg_PrintPages_Params* params) {
+ EXPECT_EQ(document_cookie_, cookie);
+
+ memset(params, 0, sizeof(PrintMsg_PrintPages_Params));
+ SetPrintParams(&(params->params));
+}
+
void MockPrinter::SetPrintedPagesCount(int cookie, int number_pages) {
// Verify the input parameter and update the printer status so that the
// RenderViewTest class can verify the this function finishes without errors.
@@ -214,3 +213,16 @@ bool MockPrinter::SaveBitmap(
int MockPrinter::CreateDocumentCookie() {
return ++current_document_cookie_;
}
+
+void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) {
+ params->dpi = dpi_;
+ params->max_shrink = max_shrink_;
+ params->min_shrink = min_shrink_;
+ params->desired_dpi = desired_dpi_;
+ params->selection_only = selection_only_;
+ params->document_cookie = document_cookie_;
+ params->page_size = page_size_;
+ params->printable_size = printable_size_;
+ params->margin_left = margin_left_;
+ params->margin_top = margin_top_;
+}