• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef MOCK_PRINT_SERVICE_H
16 #define MOCK_PRINT_SERVICE_H
17 
18 #include <gmock/gmock.h>
19 #include "print_constant.h"
20 #include "print_service_stub.h"
21 
22 namespace OHOS {
23 namespace Print {
24 class DummyPrintServiceStub : public PrintServiceStub {
25 public:
StartPrint(const std::vector<std::string> & fileList,const std::vector<uint32_t> & fdList,std::string & taskId)26     int32_t StartPrint(const std::vector<std::string> &fileList,
27         const std::vector<uint32_t> &fdList, std::string &taskId) override
28     {
29             return E_PRINT_NONE;
30     }
StartPrint(const std::vector<std::string> & fileList,const std::vector<uint32_t> & fdList,std::string & taskId,const sptr<IRemoteObject> & token)31     int32_t StartPrint(const std::vector<std::string> &fileList,
32         const std::vector<uint32_t> &fdList, std::string &taskId, const sptr<IRemoteObject> &token) override
33     {
34             return E_PRINT_NONE;
35     }
StopPrint(const std::string & taskId)36     int32_t StopPrint(const std::string &taskId) override
37     {
38         return E_PRINT_NONE;
39     }
ConnectPrinter(const std::string & printerId)40     int32_t ConnectPrinter(const std::string &printerId) override
41     {
42         return E_PRINT_NONE;
43     }
DisconnectPrinter(const std::string & printerId)44     int32_t DisconnectPrinter(const std::string &printerId) override
45     {
46         return E_PRINT_NONE;
47     }
StartDiscoverPrinter(const std::vector<std::string> & extensionList)48     int32_t StartDiscoverPrinter(const std::vector<std::string> &extensionList) override
49     {
50         return E_PRINT_NONE;
51     }
StopDiscoverPrinter()52     int32_t StopDiscoverPrinter() override
53     {
54         return E_PRINT_NONE;
55     }
QueryAllExtension(std::vector<PrintExtensionInfo> & extensionInfos)56     int32_t QueryAllExtension(std::vector<PrintExtensionInfo> &extensionInfos) override
57     {
58         return E_PRINT_NONE;
59     }
StartPrintJob(const PrintJob & jobInfo)60     int32_t StartPrintJob(const PrintJob &jobInfo) override
61     {
62         return E_PRINT_NONE;
63     }
CancelPrintJob(const std::string & jobId)64     int32_t CancelPrintJob(const std::string &jobId) override
65     {
66         return E_PRINT_NONE;
67     }
AddPrinters(const std::vector<PrinterInfo> & printerInfos)68     int32_t AddPrinters(const std::vector<PrinterInfo> &printerInfos) override
69     {
70         return E_PRINT_NONE;
71     }
RemovePrinters(const std::vector<std::string> & printerIds)72     int32_t RemovePrinters(const std::vector<std::string> &printerIds) override
73     {
74         return E_PRINT_NONE;
75     }
UpdatePrinters(const std::vector<PrinterInfo> & printerInfos)76     int32_t UpdatePrinters(const std::vector<PrinterInfo> &printerInfos) override
77     {
78         return E_PRINT_NONE;
79     }
UpdatePrinterState(const std::string & printerId,uint32_t state)80     int32_t UpdatePrinterState(const std::string &printerId, uint32_t state) override
81     {
82         return E_PRINT_NONE;
83     }
UpdatePrintJobState(const std::string & jobId,uint32_t state,uint32_t subState)84     int32_t UpdatePrintJobState(const std::string &jobId, uint32_t state, uint32_t subState) override
85     {
86         return E_PRINT_NONE;
87     }
UpdateExtensionInfo(const std::string & extensionId)88     int32_t UpdateExtensionInfo(const std::string &extensionId) override
89     {
90         return E_PRINT_NONE;
91     }
RequestPreview(const PrintJob & jobinfo,std::string & previewResult)92     int32_t RequestPreview(const PrintJob &jobinfo, std::string &previewResult) override
93     {
94         return E_PRINT_NONE;
95     }
QueryPrinterCapability(const std::string & printerId)96     int32_t QueryPrinterCapability(const std::string &printerId) override
97     {
98         return E_PRINT_NONE;
99     }
On(const std::string taskId,const std::string & type,const sptr<IPrintCallback> & listener)100     int32_t On(const std::string taskId, const std::string &type, const sptr<IPrintCallback> &listener) override
101     {
102         return E_PRINT_NONE;
103     }
Off(const std::string taskId,const std::string & type)104     int32_t Off(const std::string taskId, const std::string &type) override
105     {
106         return E_PRINT_NONE;
107     }
RegisterExtCallback(const std::string & extensionCID,const sptr<IPrintExtensionCallback> & listener)108     int32_t RegisterExtCallback(const std::string &extensionCID,
109         const sptr<IPrintExtensionCallback> &listener) override
110     {
111         return E_PRINT_NONE;
112     }
UnregisterAllExtCallback(const std::string & extensionId)113     int32_t UnregisterAllExtCallback(const std::string &extensionId) override
114     {
115         return E_PRINT_NONE;
116     }
LoadExtSuccess(const std::string & extensionId)117     int32_t LoadExtSuccess(const std::string &extensionId) override
118     {
119         return E_PRINT_NONE;
120     }
QueryAllPrintJob(std::vector<PrintJob> & printJobs)121     int32_t QueryAllPrintJob(std::vector<PrintJob> &printJobs) override
122     {
123         return E_PRINT_NONE;
124     }
QueryPrintJobById(std::string & printJobId,PrintJob & printjob)125     int32_t QueryPrintJobById(std::string &printJobId, PrintJob &printjob) override
126     {
127         return E_PRINT_NONE;
128     }
AddPrinterToCups(const std::string & printerUri,const std::string & printerName)129     int32_t AddPrinterToCups(const std::string &printerUri, const std::string &printerName) override
130     {
131         return E_PRINT_NONE;
132     }
QueryPrinterCapabilityByUri(const std::string & printerUri,PrinterCapability & printerCaps)133     int32_t QueryPrinterCapabilityByUri(const std::string &printerUri, PrinterCapability &printerCaps) override
134     {
135         return E_PRINT_NONE;
136     }
137 };
138 
139 class MockPrintService final : public DummyPrintServiceStub {
140 public:
141     MOCK_METHOD3(StartPrint, int32_t(const std::vector<std::string>&, const std::vector<uint32_t>&, std::string &));
142     MOCK_METHOD4(StartPrint, int32_t(const std::vector<std::string>&, const std::vector<uint32_t>&,
143         std::string &, const sptr<IRemoteObject> &));
144     MOCK_METHOD1(StopPrint, int32_t(const std::string&));
145     MOCK_METHOD1(ConnectPrinter, int32_t(const std::string&));
146     MOCK_METHOD1(DisconnectPrinter, int32_t(const std::string&));
147     MOCK_METHOD1(StartDiscoverPrinter, int32_t(const std::vector<std::string>&));
148     MOCK_METHOD0(StopDiscoverPrinter, int32_t());
149     MOCK_METHOD1(QueryAllExtension, int32_t(std::vector<PrintExtensionInfo>&));
150     MOCK_METHOD1(StartPrintJob, int32_t(const PrintJob &));
151     MOCK_METHOD1(CancelPrintJob, int32_t(const std::string&));
152     MOCK_METHOD1(AddPrinters, int32_t(const std::vector<PrinterInfo>&));
153     MOCK_METHOD1(RemovePrinters, int32_t(const std::vector<std::string>&));
154     MOCK_METHOD1(UpdatePrinters, int32_t(const std::vector<PrinterInfo>&));
155     MOCK_METHOD2(UpdatePrinterState, int32_t(const std::string&, uint32_t));
156     MOCK_METHOD3(UpdatePrintJobState, int32_t(const std::string&, uint32_t, uint32_t));
157     MOCK_METHOD1(UpdateExtensionInfo, int32_t(const std::string&));
158     MOCK_METHOD2(RequestPreview, int32_t(const PrintJob&, std::string&));
159     MOCK_METHOD1(QueryPrinterCapability, int32_t(const std::string&));
160     MOCK_METHOD3(On, int32_t(const std::string, const std::string&, const sptr<IPrintCallback>&));
161     MOCK_METHOD2(Off, int32_t(const std::string, const std::string&));
162     MOCK_METHOD2(RegisterExtCallback, int32_t(const std::string&, const sptr<IPrintExtensionCallback>&));
163     MOCK_METHOD1(UnregisterAllExtCallback, int32_t(const std::string&));
164     MOCK_METHOD1(LoadExtSuccess, int32_t(const std::string&));
165     MOCK_METHOD1(QueryAllPrintJob, int32_t(std::vector<PrintJob>&));
166     MOCK_METHOD2(QueryPrintJobById, int32_t(std::string&, PrintJob&));
167     MOCK_METHOD2(AddPrinterToCups, int32_t(const std::string&, const std::string&));
168     MOCK_METHOD2(QueryPrinterCapabilityByUri, int32_t(const std::string&, PrinterCapability&));
169 };
170 } // namespace Print
171 } // namespace OHOS
172 #endif // MOCK_PRINT_SERVICE_H