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

Side by Side Diff: chrome/renderer/mock_printer.cc

Issue 7747033: Merge 97702, 97820, 97976 (Closed) Base URL: svn://chrome-svn/chrome/branches/835/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/print_messages.h ('k') | chrome/renderer/mock_render_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/renderer/mock_printer.h" 5 #include "chrome/renderer/mock_printer.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/shared_memory.h" 8 #include "base/shared_memory.h"
9 #include "chrome/common/print_messages.h" 9 #include "chrome/common/print_messages.h"
10 #include "ipc/ipc_message_utils.h" 10 #include "ipc/ipc_message_utils.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 document_cookie_ = -1; 53 document_cookie_ = -1;
54 } 54 }
55 55
56 void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) { 56 void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) {
57 // Verify this printer is not processing a job. 57 // Verify this printer is not processing a job.
58 // Sorry, this mock printer is very fragile. 58 // Sorry, this mock printer is very fragile.
59 EXPECT_EQ(-1, document_cookie_); 59 EXPECT_EQ(-1, document_cookie_);
60 60
61 // Assign a unit document cookie and set the print settings. 61 // Assign a unit document cookie and set the print settings.
62 document_cookie_ = CreateDocumentCookie(); 62 document_cookie_ = CreateDocumentCookie();
63 memset(params, 0, sizeof(PrintMsg_Print_Params)); 63 params->Reset();
64 SetPrintParams(params); 64 SetPrintParams(params);
65 } 65 }
66 66
67 void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { 67 void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) {
68 dpi_ = params.dpi; 68 dpi_ = params.dpi;
69 max_shrink_ = params.max_shrink; 69 max_shrink_ = params.max_shrink;
70 min_shrink_ = params.min_shrink; 70 min_shrink_ = params.min_shrink;
71 desired_dpi_ = params.desired_dpi; 71 desired_dpi_ = params.desired_dpi;
72 selection_only_ = params.selection_only; 72 selection_only_ = params.selection_only;
73 page_size_ = params.page_size; 73 page_size_ = params.page_size;
74 printable_size_ = params.printable_size; 74 printable_size_ = params.printable_size;
75 margin_left_ = params.margin_left; 75 margin_left_ = params.margin_left;
76 margin_top_ = params.margin_top; 76 margin_top_ = params.margin_top;
77 } 77 }
78 78
79 void MockPrinter::ScriptedPrint(int cookie, 79 void MockPrinter::ScriptedPrint(int cookie,
80 int expected_pages_count, 80 int expected_pages_count,
81 bool has_selection, 81 bool has_selection,
82 PrintMsg_PrintPages_Params* settings) { 82 PrintMsg_PrintPages_Params* settings) {
83 // Verify the input parameters. 83 // Verify the input parameters.
84 EXPECT_EQ(document_cookie_, cookie); 84 EXPECT_EQ(document_cookie_, cookie);
85 85
86 memset(settings, 0, sizeof(PrintMsg_PrintPages_Params)); 86 params->Reset();
87 settings->params.dpi = dpi_; 87 settings->params.dpi = dpi_;
88 settings->params.max_shrink = max_shrink_; 88 settings->params.max_shrink = max_shrink_;
89 settings->params.min_shrink = min_shrink_; 89 settings->params.min_shrink = min_shrink_;
90 settings->params.desired_dpi = desired_dpi_; 90 settings->params.desired_dpi = desired_dpi_;
91 settings->params.selection_only = selection_only_; 91 settings->params.selection_only = selection_only_;
92 settings->params.document_cookie = document_cookie_; 92 settings->params.document_cookie = document_cookie_;
93 settings->params.page_size = page_size_; 93 settings->params.page_size = page_size_;
94 settings->params.printable_size = printable_size_; 94 settings->params.printable_size = printable_size_;
95 settings->params.is_first_request = is_first_request_; 95 settings->params.is_first_request = is_first_request_;
96 settings->params.preview_request_id = preview_request_id_; 96 settings->params.preview_request_id = preview_request_id_;
97 printer_status_ = PRINTER_PRINTING; 97 printer_status_ = PRINTER_PRINTING;
98 } 98 }
99 99
100 void MockPrinter::UpdateSettings(int cookie, 100 void MockPrinter::UpdateSettings(int cookie,
101 PrintMsg_PrintPages_Params* params) { 101 PrintMsg_PrintPages_Params* params) {
102 EXPECT_EQ(document_cookie_, cookie); 102 EXPECT_EQ(document_cookie_, cookie);
103 103
104 memset(params, 0, sizeof(PrintMsg_PrintPages_Params)); 104 params->Reset();
105 SetPrintParams(&(params->params)); 105 SetPrintParams(&(params->params));
106 printer_status_ = PRINTER_PRINTING; 106 printer_status_ = PRINTER_PRINTING;
107 } 107 }
108 108
109 void MockPrinter::SetPrintedPagesCount(int cookie, int number_pages) { 109 void MockPrinter::SetPrintedPagesCount(int cookie, int number_pages) {
110 // Verify the input parameter and update the printer status so that the 110 // Verify the input parameter and update the printer status so that the
111 // RenderViewTest class can verify the this function finishes without errors. 111 // RenderViewTest class can verify the this function finishes without errors.
112 EXPECT_EQ(document_cookie_, cookie); 112 EXPECT_EQ(document_cookie_, cookie);
113 EXPECT_EQ(PRINTER_PRINTING, printer_status_); 113 EXPECT_EQ(PRINTER_PRINTING, printer_status_);
114 EXPECT_EQ(0, number_pages_); 114 EXPECT_EQ(0, number_pages_);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 params->desired_dpi = desired_dpi_; 226 params->desired_dpi = desired_dpi_;
227 params->selection_only = selection_only_; 227 params->selection_only = selection_only_;
228 params->document_cookie = document_cookie_; 228 params->document_cookie = document_cookie_;
229 params->page_size = page_size_; 229 params->page_size = page_size_;
230 params->printable_size = printable_size_; 230 params->printable_size = printable_size_;
231 params->margin_left = margin_left_; 231 params->margin_left = margin_left_;
232 params->margin_top = margin_top_; 232 params->margin_top = margin_top_;
233 params->is_first_request = is_first_request_; 233 params->is_first_request = is_first_request_;
234 params->preview_request_id = preview_request_id_; 234 params->preview_request_id = preview_request_id_;
235 } 235 }
OLDNEW
« no previous file with comments | « chrome/common/print_messages.h ('k') | chrome/renderer/mock_render_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698