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: 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 } 31 int32_t StopPrint(const std::string &taskId) override 32 { 33 return E_PRINT_NONE; 34 } 35 int32_t ConnectPrinter(const std::string &printerId) override 36 { 37 return E_PRINT_NONE; 38 } 39 int32_t DisconnectPrinter(const std::string &printerId) override 40 { 41 return E_PRINT_NONE; 42 } 43 int32_t StartDiscoverPrinter(const std::vector<std::string> &extensionList) override 44 { 45 return E_PRINT_NONE; 46 } 47 int32_t StopDiscoverPrinter() override 48 { 49 return E_PRINT_NONE; 50 } 51 int32_t QueryAllExtension(std::vector<PrintExtensionInfo> &extensionInfos) override 52 { 53 return E_PRINT_NONE; 54 } 55 int32_t StartPrintJob(PrintJob &jobInfo) override 56 { 57 return E_PRINT_NONE; 58 } 59 int32_t CancelPrintJob(const std::string &jobId) override 60 { 61 return E_PRINT_NONE; 62 } 63 int32_t AddPrinters(const std::vector<PrinterInfo> &printerInfos) override 64 { 65 return E_PRINT_NONE; 66 } 67 int32_t RemovePrinters(const std::vector<std::string> &printerIds) override 68 { 69 return E_PRINT_NONE; 70 } 71 int32_t UpdatePrinters(const std::vector<PrinterInfo> &printerInfos) override 72 { 73 return E_PRINT_NONE; 74 } 75 int32_t UpdatePrinterState(const std::string &printerId, uint32_t state) override 76 { 77 return E_PRINT_NONE; 78 } 79 int32_t UpdatePrintJobStateOnlyForSystemApp(const std::string &jobId, uint32_t state, uint32_t subState) override 80 { 81 return E_PRINT_NONE; 82 } 83 int32_t UpdateExtensionInfo(const std::string &extensionId) override 84 { 85 return E_PRINT_NONE; 86 } 87 int32_t RequestPreview(const PrintJob &jobinfo, std::string &previewResult) override 88 { 89 return E_PRINT_NONE; 90 } 91 int32_t QueryPrinterCapability(const std::string &printerId) override 92 { 93 return E_PRINT_NONE; 94 } 95 int32_t On(const std::string taskId, const std::string &type, const sptr<IPrintCallback> &listener) override 96 { 97 return E_PRINT_NONE; 98 } 99 int32_t Off(const std::string taskId, const std::string &type) override 100 { 101 return E_PRINT_NONE; 102 } 103 int32_t RegisterExtCallback(const std::string &extensionCID, 104 const sptr<IPrintExtensionCallback> &listener) override 105 { 106 return E_PRINT_NONE; 107 } 108 int32_t UnregisterAllExtCallback(const std::string &extensionId) override 109 { 110 return E_PRINT_NONE; 111 } 112 int32_t LoadExtSuccess(const std::string &extensionId) override 113 { 114 return E_PRINT_NONE; 115 } 116 int32_t QueryAllPrintJob(std::vector<PrintJob> &printJobs) override 117 { 118 return E_PRINT_NONE; 119 } 120 int32_t QueryPrintJobById(std::string &printJobId, PrintJob &printjob) override 121 { 122 return E_PRINT_NONE; 123 } 124 int32_t AddPrinterToCups(const std::string &printerUri, const std::string &printerName, 125 const std::string &printerMake) override 126 { 127 return E_PRINT_NONE; 128 } 129 int32_t QueryPrinterCapabilityByUri(const std::string &printerUri, const std::string &printerId, 130 PrinterCapability &printerCaps) override 131 { 132 return E_PRINT_NONE; 133 } 134 int32_t PrintByAdapter(const std::string jobName, const PrintAttributes &printAttributes, 135 std::string &taskId) override 136 { 137 return E_PRINT_NONE; 138 } 139 int32_t StartGetPrintFile(const std::string &jobId, const PrintAttributes &printAttributes, 140 const uint32_t fd) override 141 { 142 return E_PRINT_NONE; 143 } 144 int32_t NotifyPrintService(const std::string &jobId, const std::string &type) override 145 { 146 return E_PRINT_NONE; 147 } 148 int32_t StartService() override 149 { 150 return E_PRINT_NONE; 151 } 152 int32_t QueryPrinterInfoByPrinterId(const std::string &printerId, PrinterInfo &info) override 153 { 154 return E_PRINT_NONE; 155 } 156 int32_t QueryAddedPrinter(std::vector<std::string> &printerNameList) override 157 { 158 return E_PRINT_NONE; 159 } 160 int32_t QueryPrinterProperties(const std::string &printerId, const std::vector<std::string> &keyList, 161 std::vector<std::string> &valueList) override 162 { 163 return E_PRINT_NONE; 164 } 165 int32_t RegisterPrinterCallback(const std::string &type, const sptr<IPrintCallback> &listener) override 166 { 167 return E_PRINT_NONE; 168 } 169 int32_t UnregisterPrinterCallback(const std::string &type) override 170 { 171 return E_PRINT_NONE; 172 } 173 int32_t StartNativePrintJob(PrintJob &printJob) override 174 { 175 return E_PRINT_NONE; 176 } 177 int32_t NotifyPrintServiceEvent(std::string &jobId, uint32_t event) override 178 { 179 return E_PRINT_NONE; 180 } 181 int32_t GetPrinterPreference(const std::string &printerId, std::string &printerPreference) override 182 { 183 return E_PRINT_NONE; 184 } 185 int32_t SetPrinterPreference(const std::string &printerId, const std::string &printerPreference) override 186 { 187 return E_PRINT_NONE; 188 } 189 int32_t SetDefaultPrinter(const std::string &printerId, uint32_t type) override 190 { 191 return E_PRINT_NONE; 192 } 193 int32_t DeletePrinterFromCups(const std::string &printerUri, const std::string &printerName, 194 const std::string &printerMake) override 195 { 196 return E_PRINT_NONE; 197 } 198 int32_t DiscoverUsbPrinters(std::vector<PrinterInfo> &printers) override 199 { 200 return E_PRINT_NONE; 201 } 202 int32_t AddPrinterToDiscovery(const PrinterInfo& printerInfo) override 203 { 204 return E_PRINT_NONE; 205 } 206 int32_t UpdatePrinterInDiscovery(const PrinterInfo& printerInfo) override 207 { 208 return E_PRINT_NONE; 209 } 210 int32_t RemovePrinterFromDiscovery(const std::string& printerId) override 211 { 212 return E_PRINT_NONE; 213 } 214 }; 215 216 class MockPrintService final : public DummyPrintServiceStub { 217 public: 218 MOCK_METHOD3(StartPrint, int32_t(const std::vector<std::string>&, const std::vector<uint32_t>&, std::string &)); 219 MOCK_METHOD1(StopPrint, int32_t(const std::string&)); 220 MOCK_METHOD1(ConnectPrinter, int32_t(const std::string&)); 221 MOCK_METHOD1(DisconnectPrinter, int32_t(const std::string&)); 222 MOCK_METHOD1(StartDiscoverPrinter, int32_t(const std::vector<std::string>&)); 223 MOCK_METHOD0(StopDiscoverPrinter, int32_t()); 224 MOCK_METHOD1(QueryAllExtension, int32_t(std::vector<PrintExtensionInfo>&)); 225 MOCK_METHOD1(StartPrintJob, int32_t(PrintJob &)); 226 MOCK_METHOD1(CancelPrintJob, int32_t(const std::string&)); 227 MOCK_METHOD1(AddPrinters, int32_t(const std::vector<PrinterInfo>&)); 228 MOCK_METHOD1(RemovePrinters, int32_t(const std::vector<std::string>&)); 229 MOCK_METHOD1(UpdatePrinters, int32_t(const std::vector<PrinterInfo>&)); 230 MOCK_METHOD2(UpdatePrinterState, int32_t(const std::string&, uint32_t)); 231 MOCK_METHOD3(UpdatePrintJobStateOnlyForSystemApp, int32_t(const std::string&, uint32_t, uint32_t)); 232 MOCK_METHOD1(UpdateExtensionInfo, int32_t(const std::string&)); 233 MOCK_METHOD2(RequestPreview, int32_t(const PrintJob&, std::string&)); 234 MOCK_METHOD1(QueryPrinterCapability, int32_t(const std::string&)); 235 MOCK_METHOD3(On, int32_t(const std::string, const std::string&, const sptr<IPrintCallback>&)); 236 MOCK_METHOD2(Off, int32_t(const std::string, const std::string&)); 237 MOCK_METHOD2(RegisterExtCallback, int32_t(const std::string&, const sptr<IPrintExtensionCallback>&)); 238 MOCK_METHOD1(UnregisterAllExtCallback, int32_t(const std::string&)); 239 MOCK_METHOD1(LoadExtSuccess, int32_t(const std::string&)); 240 MOCK_METHOD1(QueryAllPrintJob, int32_t(std::vector<PrintJob>&)); 241 MOCK_METHOD2(QueryPrintJobById, int32_t(std::string&, PrintJob&)); 242 MOCK_METHOD3(AddPrinterToCups, int32_t(const std::string&, const std::string&, const std::string&)); 243 MOCK_METHOD3(QueryPrinterCapabilityByUri, int32_t(const std::string&, const std::string&, PrinterCapability&)); 244 MOCK_METHOD2(NotifyPrintServiceEvent, int32_t(std::string&, uint32_t)); 245 MOCK_METHOD2(SetDefaultPrinter, int32_t(const std::string&, uint32_t)); 246 MOCK_METHOD3(DeletePrinterFromCups, int32_t(const std::string&, const std::string&, const std::string&)); 247 MOCK_METHOD1(DiscoverUsbPrinters, int32_t(std::vector<PrinterInfo>&)); 248 MOCK_METHOD1(AddPrinterToDiscovery, int32_t(const PrinterInfo&)); 249 MOCK_METHOD1(UpdatePrinterInDiscovery, int32_t(const PrinterInfo&)); 250 MOCK_METHOD1(RemovePrinterFromDiscovery, int32_t(const std::string&)); 251 }; 252 } // namespace Print 253 } // namespace OHOS 254 #endif // MOCK_PRINT_SERVICE_H