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

Side by Side Diff: components/printing/test/print_mock_render_thread.cc

Issue 2458833005: Move printing defines to buildflag system. (Closed)
Patch Set: Merge Created 4 years, 1 month 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/page_range.h" 16 #include "printing/page_range.h"
16 #include "printing/print_job_constants.h" 17 #include "printing/print_job_constants.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 #if defined(ENABLE_PRINTING) 20 #if BUILDFLAG(ENABLE_PRINTING)
20 #include "components/printing/common/print_messages.h" 21 #include "components/printing/common/print_messages.h"
21 #endif 22 #endif
22 23
23 PrintMockRenderThread::PrintMockRenderThread() 24 PrintMockRenderThread::PrintMockRenderThread()
24 #if defined(ENABLE_PRINTING) 25 #if BUILDFLAG(ENABLE_PRINTING)
25 : printer_(new MockPrinter), 26 : printer_(new MockPrinter),
26 print_dialog_user_response_(true), 27 print_dialog_user_response_(true),
27 print_preview_cancel_page_number_(-1), 28 print_preview_cancel_page_number_(-1),
28 print_preview_pages_remaining_(0) 29 print_preview_pages_remaining_(0)
29 #endif 30 #endif
30 { 31 {
31 } 32 }
32 33
33 PrintMockRenderThread::~PrintMockRenderThread() { 34 PrintMockRenderThread::~PrintMockRenderThread() {
34 } 35 }
35 36
36 scoped_refptr<base::SingleThreadTaskRunner> 37 scoped_refptr<base::SingleThreadTaskRunner>
37 PrintMockRenderThread::GetIOTaskRunner() { 38 PrintMockRenderThread::GetIOTaskRunner() {
38 return io_task_runner_; 39 return io_task_runner_;
39 } 40 }
40 41
41 void PrintMockRenderThread::set_io_task_runner( 42 void PrintMockRenderThread::set_io_task_runner(
42 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 43 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
43 io_task_runner_ = task_runner; 44 io_task_runner_ = task_runner;
44 } 45 }
45 46
46 bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) { 47 bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) {
47 if (content::MockRenderThread::OnMessageReceived(msg)) 48 if (content::MockRenderThread::OnMessageReceived(msg))
48 return true; 49 return true;
49 50
50 // Some messages we do special handling. 51 // Some messages we do special handling.
51 bool handled = true; 52 bool handled = true;
52 IPC_BEGIN_MESSAGE_MAP(PrintMockRenderThread, msg) 53 IPC_BEGIN_MESSAGE_MAP(PrintMockRenderThread, msg)
53 #if defined(ENABLE_PRINTING) 54 #if BUILDFLAG(ENABLE_PRINTING)
54 IPC_MESSAGE_HANDLER(PrintHostMsg_GetDefaultPrintSettings, 55 IPC_MESSAGE_HANDLER(PrintHostMsg_GetDefaultPrintSettings,
55 OnGetDefaultPrintSettings) 56 OnGetDefaultPrintSettings)
56 IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptedPrint, OnScriptedPrint) 57 IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
57 IPC_MESSAGE_HANDLER(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings) 58 IPC_MESSAGE_HANDLER(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings)
58 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, 59 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount,
59 OnDidGetPrintedPagesCount) 60 OnDidGetPrintedPagesCount)
60 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) 61 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage)
61 #if defined(ENABLE_PRINT_PREVIEW) 62 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
62 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, 63 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount,
63 OnDidGetPreviewPageCount) 64 OnDidGetPreviewPageCount)
64 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage) 65 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage)
65 IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel) 66 IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
66 #endif 67 #endif
67 #endif // defined(ENABLE_PRINTING) 68 #endif // BUILDFLAG(ENABLE_PRINTING)
68 IPC_MESSAGE_UNHANDLED(handled = false) 69 IPC_MESSAGE_UNHANDLED(handled = false)
69 IPC_END_MESSAGE_MAP() 70 IPC_END_MESSAGE_MAP()
70 return handled; 71 return handled;
71 } 72 }
72 73
73 #if defined(ENABLE_PRINTING) 74 #if BUILDFLAG(ENABLE_PRINTING)
74 75
75 void PrintMockRenderThread::OnGetDefaultPrintSettings( 76 void PrintMockRenderThread::OnGetDefaultPrintSettings(
76 PrintMsg_Print_Params* params) { 77 PrintMsg_Print_Params* params) {
77 printer_->GetDefaultPrintSettings(params); 78 printer_->GetDefaultPrintSettings(params);
78 } 79 }
79 80
80 void PrintMockRenderThread::OnScriptedPrint( 81 void PrintMockRenderThread::OnScriptedPrint(
81 const PrintHostMsg_ScriptedPrint_Params& params, 82 const PrintHostMsg_ScriptedPrint_Params& params,
82 PrintMsg_PrintPages_Params* settings) { 83 PrintMsg_PrintPages_Params* settings) {
83 if (print_dialog_user_response_) { 84 if (print_dialog_user_response_) {
84 printer_->ScriptedPrint(params.cookie, params.expected_pages_count, 85 printer_->ScriptedPrint(params.cookie, params.expected_pages_count,
85 params.has_selection, settings); 86 params.has_selection, settings);
86 } 87 }
87 } 88 }
88 89
89 void PrintMockRenderThread::OnDidGetPrintedPagesCount(int cookie, 90 void PrintMockRenderThread::OnDidGetPrintedPagesCount(int cookie,
90 int number_pages) { 91 int number_pages) {
91 printer_->SetPrintedPagesCount(cookie, number_pages); 92 printer_->SetPrintedPagesCount(cookie, number_pages);
92 } 93 }
93 94
94 void PrintMockRenderThread::OnDidPrintPage( 95 void PrintMockRenderThread::OnDidPrintPage(
95 const PrintHostMsg_DidPrintPage_Params& params) { 96 const PrintHostMsg_DidPrintPage_Params& params) {
96 printer_->PrintPage(params); 97 printer_->PrintPage(params);
97 } 98 }
98 99
99 #if defined(ENABLE_PRINT_PREVIEW) 100 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
100 void PrintMockRenderThread::OnDidGetPreviewPageCount( 101 void PrintMockRenderThread::OnDidGetPreviewPageCount(
101 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { 102 const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
102 print_preview_pages_remaining_ = params.page_count; 103 print_preview_pages_remaining_ = params.page_count;
103 } 104 }
104 105
105 void PrintMockRenderThread::OnDidPreviewPage( 106 void PrintMockRenderThread::OnDidPreviewPage(
106 const PrintHostMsg_DidPreviewPage_Params& params) { 107 const PrintHostMsg_DidPreviewPage_Params& params) {
107 DCHECK_GE(params.page_number, printing::FIRST_PAGE_INDEX); 108 DCHECK_GE(params.page_number, printing::FIRST_PAGE_INDEX);
108 print_preview_pages_remaining_--; 109 print_preview_pages_remaining_--;
109 } 110 }
110 111
111 void PrintMockRenderThread::OnCheckForCancel(int32_t preview_ui_id, 112 void PrintMockRenderThread::OnCheckForCancel(int32_t preview_ui_id,
112 int preview_request_id, 113 int preview_request_id,
113 bool* cancel) { 114 bool* cancel) {
114 *cancel = 115 *cancel =
115 (print_preview_pages_remaining_ == print_preview_cancel_page_number_); 116 (print_preview_pages_remaining_ == print_preview_cancel_page_number_);
116 } 117 }
117 #endif // defined(ENABLE_PRINT_PREVIEW) 118 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
118 119
119 void PrintMockRenderThread::OnUpdatePrintSettings( 120 void PrintMockRenderThread::OnUpdatePrintSettings(
120 int document_cookie, 121 int document_cookie,
121 const base::DictionaryValue& job_settings, 122 const base::DictionaryValue& job_settings,
122 PrintMsg_PrintPages_Params* params, 123 PrintMsg_PrintPages_Params* params,
123 bool* canceled) { 124 bool* canceled) {
124 if (canceled) 125 if (canceled)
125 *canceled = false; 126 *canceled = false;
126 // Check and make sure the required settings are all there. 127 // Check and make sure the required settings are all there.
127 // We don't actually care about the values. 128 // We don't actually care about the values.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 print_dialog_user_response_ = response; 179 print_dialog_user_response_ = response;
179 } 180 }
180 181
181 void PrintMockRenderThread::set_print_preview_cancel_page_number(int page) { 182 void PrintMockRenderThread::set_print_preview_cancel_page_number(int page) {
182 print_preview_cancel_page_number_ = page; 183 print_preview_cancel_page_number_ = page;
183 } 184 }
184 185
185 int PrintMockRenderThread::print_preview_pages_remaining() const { 186 int PrintMockRenderThread::print_preview_pages_remaining() const {
186 return print_preview_pages_remaining_; 187 return print_preview_pages_remaining_;
187 } 188 }
188 #endif // defined(ENABLE_PRINTING) 189 #endif // BUILDFLAG(ENABLE_PRINTING)
OLDNEW
« no previous file with comments | « components/printing/test/print_mock_render_thread.h ('k') | components/printing/test/print_test_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698