146debc2cSopenharmony_ci/* 246debc2cSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 346debc2cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 446debc2cSopenharmony_ci * you may not use this file except in compliance with the License. 546debc2cSopenharmony_ci * You may obtain a copy of the License at 646debc2cSopenharmony_ci * 746debc2cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 846debc2cSopenharmony_ci * 946debc2cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1046debc2cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1146debc2cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1246debc2cSopenharmony_ci * See the License for the specific language governing permissions and 1346debc2cSopenharmony_ci * limitations under the License. 1446debc2cSopenharmony_ci */ 1546debc2cSopenharmony_ci#define private public 1646debc2cSopenharmony_ci#define protected public 1746debc2cSopenharmony_ci#include "printserviceability_fuzzer.h" 1846debc2cSopenharmony_ci#include "fuzzer/FuzzedDataProvider.h" 1946debc2cSopenharmony_ci#include "print_constant.h" 2046debc2cSopenharmony_ci#include "printer_capability.h" 2146debc2cSopenharmony_ci#include "print_log.h" 2246debc2cSopenharmony_ci#include "print_service_ability.h" 2346debc2cSopenharmony_ci#include "print_service_ability_mock_permission.h" 2446debc2cSopenharmony_ci#include "print_callback.h" 2546debc2cSopenharmony_ci#include "iprint_adapter_inner.h" 2646debc2cSopenharmony_ci 2746debc2cSopenharmony_cinamespace OHOS { 2846debc2cSopenharmony_cinamespace Print { 2946debc2cSopenharmony_ciconstexpr uint8_t MAX_STRING_LENGTH = 20; 3046debc2cSopenharmony_ciconstexpr int MAX_SET_NUMBER = 128; 3146debc2cSopenharmony_ciconstexpr size_t U32_AT_SIZE = 4; 3246debc2cSopenharmony_cistatic constexpr const char *JOB_OPTIONS = 3346debc2cSopenharmony_ci "{\"jobName\":\"xx\",\"jobNum\":1,\"mediaType\":\"stationery\",\"documentCategory\":0,\"printQuality\":\"4\"," 3446debc2cSopenharmony_ci "\"printerName\":\"testId\",\"printerUri\":\"ipp://192.168.0.1:111/ipp/print\"," 3546debc2cSopenharmony_ci "\"documentFormat\":\"application/pdf\",\"files\":[\"/data/1.pdf\"]}"; 3646debc2cSopenharmony_cistatic const std::string DEFAULT_PRINTERID = "testId"; 3746debc2cSopenharmony_ci 3846debc2cSopenharmony_civoid TestStartPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 3946debc2cSopenharmony_ci{ 4046debc2cSopenharmony_ci PrintServiceAbilityMockPermission::MockPermission(); 4146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->OnStart(); 4246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ManualStart(); 4346debc2cSopenharmony_ci auto cupsPrinter = std::make_shared<CupsPrinterInfo>(); 4446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->printSystemData_.addedPrinterMap_.Insert(DEFAULT_PRINTERID, cupsPrinter); 4546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartService(); 4646debc2cSopenharmony_ci std::string fileUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 4746debc2cSopenharmony_ci std::vector<std::string> fileList; 4846debc2cSopenharmony_ci fileList.push_back(fileUri); 4946debc2cSopenharmony_ci uint32_t fd = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 5046debc2cSopenharmony_ci std::vector<uint32_t> fdList; 5146debc2cSopenharmony_ci fdList.push_back(fd); 5246debc2cSopenharmony_ci std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 5346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartPrint(fileList, fdList, taskId); 5446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->OnStop(); 5546debc2cSopenharmony_ci} 5646debc2cSopenharmony_ci 5746debc2cSopenharmony_civoid TestStopPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 5846debc2cSopenharmony_ci{ 5946debc2cSopenharmony_ci std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 6046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StopPrint(taskId); 6146debc2cSopenharmony_ci} 6246debc2cSopenharmony_ci 6346debc2cSopenharmony_civoid TestConnectPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 6446debc2cSopenharmony_ci{ 6546debc2cSopenharmony_ci std::string printerId = size ? dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH) : DEFAULT_PRINTERID; 6646debc2cSopenharmony_ci PrinterInfo printerInfo; 6746debc2cSopenharmony_ci printerInfo.SetPrinterId(printerId); 6846debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 6946debc2cSopenharmony_ci printerInfo.SetOption(JOB_OPTIONS); 7046debc2cSopenharmony_ci std::vector <PrinterInfo> printerInfos; 7146debc2cSopenharmony_ci printerInfos.push_back(printerInfo); 7246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->AddPrinters(printerInfos); 7346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ConnectPrinter(printerId); 7446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DisconnectPrinter(printerId); 7546debc2cSopenharmony_ci} 7646debc2cSopenharmony_ci 7746debc2cSopenharmony_civoid TestDisconnectPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 7846debc2cSopenharmony_ci{ 7946debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 8046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DisconnectPrinter(printerId); 8146debc2cSopenharmony_ci} 8246debc2cSopenharmony_ci 8346debc2cSopenharmony_civoid TestStartDiscoverPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 8446debc2cSopenharmony_ci{ 8546debc2cSopenharmony_ci std::vector <PrintExtensionInfo> printExtensionInfos; 8646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos); 8746debc2cSopenharmony_ci std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 8846debc2cSopenharmony_ci std::vector <std::string> extensionIds; 8946debc2cSopenharmony_ci extensionIds.push_back(extensionId); 9046debc2cSopenharmony_ci for (auto &printExtensionInfo: printExtensionInfos) { 9146debc2cSopenharmony_ci extensionIds.push_back(printExtensionInfo.GetExtensionId()); 9246debc2cSopenharmony_ci } 9346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartDiscoverPrinter(extensionIds); 9446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StopDiscoverPrinter(); 9546debc2cSopenharmony_ci} 9646debc2cSopenharmony_ci 9746debc2cSopenharmony_civoid TestQueryAllExtension(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 9846debc2cSopenharmony_ci{ 9946debc2cSopenharmony_ci PrintExtensionInfo printExtensionInfo; 10046debc2cSopenharmony_ci printExtensionInfo.SetExtensionId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 10146debc2cSopenharmony_ci std::vector<PrintExtensionInfo> printExtensionInfos; 10246debc2cSopenharmony_ci printExtensionInfos.push_back(printExtensionInfo); 10346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos); 10446debc2cSopenharmony_ci} 10546debc2cSopenharmony_ci 10646debc2cSopenharmony_civoid TestStartPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 10746debc2cSopenharmony_ci{ 10846debc2cSopenharmony_ci PrinterInfo printerInfo; 10946debc2cSopenharmony_ci printerInfo.SetPrinterId(DEFAULT_PRINTERID); 11046debc2cSopenharmony_ci printerInfo.SetPrinterName(DEFAULT_PRINTERID); 11146debc2cSopenharmony_ci std::vector <PrinterInfo> printerInfos; 11246debc2cSopenharmony_ci PrinterCapability printerCaps; 11346debc2cSopenharmony_ci printerCaps.SetColorMode(dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER)); 11446debc2cSopenharmony_ci printerInfos.push_back(printerInfo); 11546debc2cSopenharmony_ci 11646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->AddPrinters(printerInfos); 11746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrinters(printerInfos); 11846debc2cSopenharmony_ci 11946debc2cSopenharmony_ci PrintJob testJob; 12046debc2cSopenharmony_ci testJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 12146debc2cSopenharmony_ci std::vector <uint32_t> files = {1}; 12246debc2cSopenharmony_ci testJob.SetFdList(files); 12346debc2cSopenharmony_ci OHOS::Print::PrintPageSize pageSize; 12446debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 12546debc2cSopenharmony_ci testJob.SetPageSize(pageSize); 12646debc2cSopenharmony_ci testJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 12746debc2cSopenharmony_ci testJob.SetOption(JOB_OPTIONS); 12846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartPrintJob(testJob); 12946debc2cSopenharmony_ci} 13046debc2cSopenharmony_ci 13146debc2cSopenharmony_civoid TestCancelPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 13246debc2cSopenharmony_ci{ 13346debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 13446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CancelPrintJob(jobId); 13546debc2cSopenharmony_ci} 13646debc2cSopenharmony_ci 13746debc2cSopenharmony_civoid TestAddPrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 13846debc2cSopenharmony_ci{ 13946debc2cSopenharmony_ci PrinterInfo printerInfo; 14046debc2cSopenharmony_ci printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 14146debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 14246debc2cSopenharmony_ci printerInfo.SetOption(JOB_OPTIONS); 14346debc2cSopenharmony_ci std::vector<PrinterInfo> printerInfos; 14446debc2cSopenharmony_ci printerInfos.push_back(printerInfo); 14546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->AddPrinters(printerInfos); 14646debc2cSopenharmony_ci} 14746debc2cSopenharmony_ci 14846debc2cSopenharmony_civoid TestRemovePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 14946debc2cSopenharmony_ci{ 15046debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 15146debc2cSopenharmony_ci std::vector<std::string> printerIds; 15246debc2cSopenharmony_ci printerIds.push_back(printerId); 15346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->RemovePrinters(printerIds); 15446debc2cSopenharmony_ci} 15546debc2cSopenharmony_ci 15646debc2cSopenharmony_civoid TestUpdatePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 15746debc2cSopenharmony_ci{ 15846debc2cSopenharmony_ci PrinterInfo printerInfo; 15946debc2cSopenharmony_ci printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 16046debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 16146debc2cSopenharmony_ci printerInfo.SetOption(JOB_OPTIONS); 16246debc2cSopenharmony_ci std::vector<PrinterInfo> printerInfos; 16346debc2cSopenharmony_ci printerInfos.push_back(printerInfo); 16446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrinters(printerInfos); 16546debc2cSopenharmony_ci return; 16646debc2cSopenharmony_ci} 16746debc2cSopenharmony_ci 16846debc2cSopenharmony_civoid TestUpdatePrinterState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 16946debc2cSopenharmony_ci{ 17046debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 17146debc2cSopenharmony_ci uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 17246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrinterState(printerId, state); 17346debc2cSopenharmony_ci} 17446debc2cSopenharmony_ci 17546debc2cSopenharmony_civoid TestUpdatePrintJobStateOnlyForSystemApp(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 17646debc2cSopenharmony_ci{ 17746debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 17846debc2cSopenharmony_ci uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 17946debc2cSopenharmony_ci uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 18046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrintJobStateOnlyForSystemApp(jobId, state, subState); 18146debc2cSopenharmony_ci} 18246debc2cSopenharmony_ci 18346debc2cSopenharmony_civoid TestUpdateExtensionInfo(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 18446debc2cSopenharmony_ci{ 18546debc2cSopenharmony_ci std::string extInfo = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 18646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdateExtensionInfo(extInfo); 18746debc2cSopenharmony_ci} 18846debc2cSopenharmony_ci 18946debc2cSopenharmony_civoid TestRequestPreview(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 19046debc2cSopenharmony_ci{ 19146debc2cSopenharmony_ci PrintJob printJob; 19246debc2cSopenharmony_ci printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 19346debc2cSopenharmony_ci std::vector<uint32_t> files = {1}; 19446debc2cSopenharmony_ci printJob.SetFdList(files); 19546debc2cSopenharmony_ci OHOS::Print::PrintPageSize pageSize; 19646debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 19746debc2cSopenharmony_ci printJob.SetPageSize(pageSize); 19846debc2cSopenharmony_ci printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 19946debc2cSopenharmony_ci printJob.SetOption(JOB_OPTIONS); 20046debc2cSopenharmony_ci std::string previewResult = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 20146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->RequestPreview(printJob, previewResult); 20246debc2cSopenharmony_ci} 20346debc2cSopenharmony_ci 20446debc2cSopenharmony_civoid TestQueryPrinterCapability(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 20546debc2cSopenharmony_ci{ 20646debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 20746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryPrinterCapability(printerId); 20846debc2cSopenharmony_ci} 20946debc2cSopenharmony_ci 21046debc2cSopenharmony_civoid TestOn(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 21146debc2cSopenharmony_ci{ 21246debc2cSopenharmony_ci PrintDocumentAdapter *printerAdapterPtr = new PrintDocumentAdapter(); 21346debc2cSopenharmony_ci sptr <PrintCallback> callback = new(std::nothrow) PrintCallback(printerAdapterPtr); 21446debc2cSopenharmony_ci if (callback != nullptr) { 21546debc2cSopenharmony_ci std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 21646debc2cSopenharmony_ci std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 21746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->On(taskId, type, callback); 21846debc2cSopenharmony_ci } else { 21946debc2cSopenharmony_ci delete printerAdapterPtr; 22046debc2cSopenharmony_ci printerAdapterPtr = nullptr; 22146debc2cSopenharmony_ci } 22246debc2cSopenharmony_ci} 22346debc2cSopenharmony_ci 22446debc2cSopenharmony_civoid TestOff(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 22546debc2cSopenharmony_ci{ 22646debc2cSopenharmony_ci std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 22746debc2cSopenharmony_ci std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 22846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->Off(taskId, type); 22946debc2cSopenharmony_ci} 23046debc2cSopenharmony_ci 23146debc2cSopenharmony_civoid TestCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 23246debc2cSopenharmony_ci{ 23346debc2cSopenharmony_ci PrintDocumentAdapter *printerAdapterPtr = new PrintDocumentAdapter(); 23446debc2cSopenharmony_ci sptr <PrintCallback> callback = new(std::nothrow) PrintCallback(printerAdapterPtr); 23546debc2cSopenharmony_ci if (callback != nullptr) { 23646debc2cSopenharmony_ci std::string type = PRINTER_DISCOVER_EVENT_TYPE; 23746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->RegisterPrinterCallback(type, callback); 23846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UnregisterPrinterCallback(type); 23946debc2cSopenharmony_ci } else { 24046debc2cSopenharmony_ci delete printerAdapterPtr; 24146debc2cSopenharmony_ci printerAdapterPtr = nullptr; 24246debc2cSopenharmony_ci } 24346debc2cSopenharmony_ci std::vector <PrintExtensionInfo> printExtensionInfos; 24446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos); 24546debc2cSopenharmony_ci std::vector <std::string> extensionIds; 24646debc2cSopenharmony_ci for (auto &printExtensionInfo: printExtensionInfos) { 24746debc2cSopenharmony_ci extensionIds.push_back(printExtensionInfo.GetExtensionId()); 24846debc2cSopenharmony_ci } 24946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartDiscoverPrinter(extensionIds); 25046debc2cSopenharmony_ci 25146debc2cSopenharmony_ci for (auto &printExtensionInfo: printExtensionInfos) { 25246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->RegisterExtCallback(printExtensionInfo.GetExtensionId(), nullptr); 25346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UnregisterAllExtCallback(printExtensionInfo.GetExtensionId()); 25446debc2cSopenharmony_ci } 25546debc2cSopenharmony_ci 25646debc2cSopenharmony_ci std::string extensionCID = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 25746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->RegisterExtCallback(extensionCID, nullptr); 25846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UnregisterAllExtCallback(extensionCID); 25946debc2cSopenharmony_ci} 26046debc2cSopenharmony_ci 26146debc2cSopenharmony_civoid TestLoadExtSuccess(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 26246debc2cSopenharmony_ci{ 26346debc2cSopenharmony_ci std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 26446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->LoadExtSuccess(extensionId); 26546debc2cSopenharmony_ci} 26646debc2cSopenharmony_ci 26746debc2cSopenharmony_civoid TestQueryAllPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 26846debc2cSopenharmony_ci{ 26946debc2cSopenharmony_ci PrintJob printJob; 27046debc2cSopenharmony_ci printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 27146debc2cSopenharmony_ci std::vector<uint32_t> files = {0}; 27246debc2cSopenharmony_ci printJob.SetFdList(files); 27346debc2cSopenharmony_ci OHOS::Print::PrintPageSize pageSize; 27446debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 27546debc2cSopenharmony_ci printJob.SetPageSize(pageSize); 27646debc2cSopenharmony_ci printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 27746debc2cSopenharmony_ci std::vector<PrintJob> printJobs; 27846debc2cSopenharmony_ci printJobs.push_back(printJob); 27946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryAllPrintJob(printJobs); 28046debc2cSopenharmony_ci} 28146debc2cSopenharmony_ci 28246debc2cSopenharmony_civoid TestQueryPrintJobById(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 28346debc2cSopenharmony_ci{ 28446debc2cSopenharmony_ci PrintJob printJob; 28546debc2cSopenharmony_ci printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 28646debc2cSopenharmony_ci std::vector<uint32_t> files = {0}; 28746debc2cSopenharmony_ci printJob.SetFdList(files); 28846debc2cSopenharmony_ci OHOS::Print::PrintPageSize pageSize; 28946debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 29046debc2cSopenharmony_ci printJob.SetPageSize(pageSize); 29146debc2cSopenharmony_ci printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 29246debc2cSopenharmony_ci std::string printJobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 29346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryPrintJobById(printJobId, printJob); 29446debc2cSopenharmony_ci} 29546debc2cSopenharmony_ci 29646debc2cSopenharmony_civoid TestAddPrinterToCups(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 29746debc2cSopenharmony_ci{ 29846debc2cSopenharmony_ci std::string printerUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 29946debc2cSopenharmony_ci std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 30046debc2cSopenharmony_ci std::string printerMake = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 30146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->AddPrinterToCups(printerUri, printerName, printerMake); 30246debc2cSopenharmony_ci} 30346debc2cSopenharmony_ci 30446debc2cSopenharmony_civoid TestQueryPrinterCapabilityByUri(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 30546debc2cSopenharmony_ci{ 30646debc2cSopenharmony_ci std::string printerUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 30746debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 30846debc2cSopenharmony_ci PrinterCapability printerCaps; 30946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SetHelper(nullptr); 31046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryPrinterCapabilityByUri(printerUri, printerId, printerCaps); 31146debc2cSopenharmony_ci} 31246debc2cSopenharmony_ci 31346debc2cSopenharmony_civoid TestPrintByAdapter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 31446debc2cSopenharmony_ci{ 31546debc2cSopenharmony_ci std::string jobName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 31646debc2cSopenharmony_ci PrintAttributes printAttributes; 31746debc2cSopenharmony_ci std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 31846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->PrintByAdapter(jobName, printAttributes, taskId); 31946debc2cSopenharmony_ci} 32046debc2cSopenharmony_ci 32146debc2cSopenharmony_civoid TestStartGetPrintFile(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 32246debc2cSopenharmony_ci{ 32346debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 32446debc2cSopenharmony_ci PrintAttributes printAttributes; 32546debc2cSopenharmony_ci uint32_t fd = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 32646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartGetPrintFile(jobId, printAttributes, fd); 32746debc2cSopenharmony_ci} 32846debc2cSopenharmony_ci 32946debc2cSopenharmony_civoid TestQueryPrinterInfoByPrinterId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 33046debc2cSopenharmony_ci{ 33146debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 33246debc2cSopenharmony_ci PrinterInfo printerInfo; 33346debc2cSopenharmony_ci printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 33446debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 33546debc2cSopenharmony_ci printerInfo.SetOption(JOB_OPTIONS); 33646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryPrinterInfoByPrinterId(printerId, printerInfo); 33746debc2cSopenharmony_ci} 33846debc2cSopenharmony_ci 33946debc2cSopenharmony_civoid TestNotifyPrintService(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 34046debc2cSopenharmony_ci{ 34146debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 34246debc2cSopenharmony_ci std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 34346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->NotifyPrintService(jobId, type); 34446debc2cSopenharmony_ci} 34546debc2cSopenharmony_ci 34646debc2cSopenharmony_civoid TestQueryAddedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 34746debc2cSopenharmony_ci{ 34846debc2cSopenharmony_ci std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 34946debc2cSopenharmony_ci std::vector<std::string> printerNameList; 35046debc2cSopenharmony_ci printerNameList.push_back(printerName); 35146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryAddedPrinter(printerNameList); 35246debc2cSopenharmony_ci} 35346debc2cSopenharmony_ci 35446debc2cSopenharmony_civoid TestQueryPrinterProperties(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 35546debc2cSopenharmony_ci{ 35646debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 35746debc2cSopenharmony_ci std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 35846debc2cSopenharmony_ci std::vector<std::string> keyList; 35946debc2cSopenharmony_ci keyList.push_back(key); 36046debc2cSopenharmony_ci std::string value = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 36146debc2cSopenharmony_ci std::vector<std::string> valueList; 36246debc2cSopenharmony_ci valueList.push_back(value); 36346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->QueryPrinterProperties(printerId, keyList, valueList); 36446debc2cSopenharmony_ci} 36546debc2cSopenharmony_ci 36646debc2cSopenharmony_civoid TestUpdatePrintJobState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 36746debc2cSopenharmony_ci{ 36846debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 36946debc2cSopenharmony_ci uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 37046debc2cSopenharmony_ci uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 37146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrintJobState(jobId, state, subState); 37246debc2cSopenharmony_ci} 37346debc2cSopenharmony_ci 37446debc2cSopenharmony_civoid TestGetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 37546debc2cSopenharmony_ci{ 37646debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 37746debc2cSopenharmony_ci std::string printerPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 37846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->GetPrinterPreference(printerId, printerPreference); 37946debc2cSopenharmony_ci} 38046debc2cSopenharmony_ci 38146debc2cSopenharmony_civoid TestSetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 38246debc2cSopenharmony_ci{ 38346debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 38446debc2cSopenharmony_ci std::string printerPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 38546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SetPrinterPreference(printerId, printerPreference); 38646debc2cSopenharmony_ci} 38746debc2cSopenharmony_ci 38846debc2cSopenharmony_civoid TestSetDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 38946debc2cSopenharmony_ci{ 39046debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 39146debc2cSopenharmony_ci uint32_t type = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 39246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SetDefaultPrinter(printerId, type); 39346debc2cSopenharmony_ci} 39446debc2cSopenharmony_ci 39546debc2cSopenharmony_civoid TestDeletePrinterFromCups(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 39646debc2cSopenharmony_ci{ 39746debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 39846debc2cSopenharmony_ci std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 39946debc2cSopenharmony_ci std::string printerMake = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 40046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DeletePrinterFromCups(printerId, printerName, printerMake); 40146debc2cSopenharmony_ci} 40246debc2cSopenharmony_ci 40346debc2cSopenharmony_civoid TestDiscoverUsbPrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 40446debc2cSopenharmony_ci{ 40546debc2cSopenharmony_ci PrinterInfo printerInfo; 40646debc2cSopenharmony_ci printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 40746debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 40846debc2cSopenharmony_ci printerInfo.SetDescription(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 40946debc2cSopenharmony_ci printerInfo.SetPrinterState(dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER)); 41046debc2cSopenharmony_ci std::vector<PrinterInfo> printers; 41146debc2cSopenharmony_ci printers.push_back(printerInfo); 41246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DiscoverUsbPrinters(printers); 41346debc2cSopenharmony_ci} 41446debc2cSopenharmony_ci 41546debc2cSopenharmony_civoid TestStartNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 41646debc2cSopenharmony_ci{ 41746debc2cSopenharmony_ci PrintJob testJob; 41846debc2cSopenharmony_ci testJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 41946debc2cSopenharmony_ci std::vector<uint32_t> files = {1}; 42046debc2cSopenharmony_ci testJob.SetFdList(files); 42146debc2cSopenharmony_ci OHOS::Print::PrintPageSize pageSize; 42246debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 42346debc2cSopenharmony_ci testJob.SetPageSize(pageSize); 42446debc2cSopenharmony_ci testJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 42546debc2cSopenharmony_ci testJob.SetOption(JOB_OPTIONS); 42646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartNativePrintJob(testJob); 42746debc2cSopenharmony_ci} 42846debc2cSopenharmony_ci 42946debc2cSopenharmony_civoid TestNotifyPrintServiceEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 43046debc2cSopenharmony_ci{ 43146debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 43246debc2cSopenharmony_ci uint32_t event = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 43346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->NotifyPrintServiceEvent(jobId, event); 43446debc2cSopenharmony_ci} 43546debc2cSopenharmony_ci 43646debc2cSopenharmony_ci// below are private test 43746debc2cSopenharmony_civoid TestUpdateQueuedJobList(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 43846debc2cSopenharmony_ci{ 43946debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 44046debc2cSopenharmony_ci std::string printJobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 44146debc2cSopenharmony_ci auto printJob = std::make_shared<PrintJob>(); 44246debc2cSopenharmony_ci printJob->SetJobId(printJobId); 44346debc2cSopenharmony_ci printJob->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 44446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdateQueuedJobList(printJobId, printJob); 44546debc2cSopenharmony_ci} 44646debc2cSopenharmony_ci 44746debc2cSopenharmony_civoid TestUpdatePrintJobOptionByPrinterId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 44846debc2cSopenharmony_ci{ 44946debc2cSopenharmony_ci PrintJob printJob; 45046debc2cSopenharmony_ci printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 45146debc2cSopenharmony_ci std::vector<uint32_t> files = {0}; 45246debc2cSopenharmony_ci printJob.SetFdList(files); 45346debc2cSopenharmony_ci OHOS::Print::PrintPageSize pageSize; 45446debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 45546debc2cSopenharmony_ci printJob.SetPageSize(pageSize); 45646debc2cSopenharmony_ci printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 45746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrintJobOptionByPrinterId(printJob); 45846debc2cSopenharmony_ci} 45946debc2cSopenharmony_ci 46046debc2cSopenharmony_civoid TestDelayStartDiscovery(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 46146debc2cSopenharmony_ci{ 46246debc2cSopenharmony_ci std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 46346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DelayStartDiscovery(extensionId); 46446debc2cSopenharmony_ci} 46546debc2cSopenharmony_ci 46646debc2cSopenharmony_civoid TestAdapterGetFileCallBack(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 46746debc2cSopenharmony_ci{ 46846debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 46946debc2cSopenharmony_ci uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 47046debc2cSopenharmony_ci uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 47146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->AdapterGetFileCallBack(jobId, state, subState); 47246debc2cSopenharmony_ci} 47346debc2cSopenharmony_ci 47446debc2cSopenharmony_civoid TestAddNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 47546debc2cSopenharmony_ci{ 47646debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 47746debc2cSopenharmony_ci PrintJob printJob; 47846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->AddNativePrintJob(jobId, printJob); 47946debc2cSopenharmony_ci} 48046debc2cSopenharmony_ci 48146debc2cSopenharmony_civoid TestIsQueuedJobListEmpty(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 48246debc2cSopenharmony_ci{ 48346debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 48446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->IsQueuedJobListEmpty(jobId); 48546debc2cSopenharmony_ci} 48646debc2cSopenharmony_ci 48746debc2cSopenharmony_civoid TestSetPrintJobCanceled(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 48846debc2cSopenharmony_ci{ 48946debc2cSopenharmony_ci PrintJob printJob; 49046debc2cSopenharmony_ci std::string printerid = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 49146debc2cSopenharmony_ci printJob.SetPrinterId(printerid); 49246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SetPrintJobCanceled(printJob); 49346debc2cSopenharmony_ci} 49446debc2cSopenharmony_ci 49546debc2cSopenharmony_civoid TestCancelUserPrintJobs(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 49646debc2cSopenharmony_ci{ 49746debc2cSopenharmony_ci int32_t userId = dataProvider->ConsumeIntegralInRange<int32_t>(0, MAX_SET_NUMBER); 49846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CancelUserPrintJobs(userId); 49946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CallStatusBar(); 50046debc2cSopenharmony_ci} 50146debc2cSopenharmony_ci 50246debc2cSopenharmony_civoid TestSendExtensionEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 50346debc2cSopenharmony_ci{ 50446debc2cSopenharmony_ci std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 50546debc2cSopenharmony_ci std::string extInfo = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 50646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SendExtensionEvent(extensionId, extInfo); 50746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrintUserMap(); 50846debc2cSopenharmony_ci} 50946debc2cSopenharmony_ci 51046debc2cSopenharmony_civoid TestNotifyAdapterJobChanged(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 51146debc2cSopenharmony_ci{ 51246debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 51346debc2cSopenharmony_ci uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 51446debc2cSopenharmony_ci uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 51546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->notifyAdapterJobChanged(jobId, state, subState); 51646debc2cSopenharmony_ci} 51746debc2cSopenharmony_ci 51846debc2cSopenharmony_civoid TestRegisterAdapterListener(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 51946debc2cSopenharmony_ci{ 52046debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 52146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->RegisterAdapterListener(jobId); 52246debc2cSopenharmony_ci} 52346debc2cSopenharmony_ci 52446debc2cSopenharmony_civoid TestisEprint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 52546debc2cSopenharmony_ci{ 52646debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 52746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->isEprint(printerId); 52846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->GetPrintJobOrderId(); 52946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->WritePreferenceToFile(); 53046debc2cSopenharmony_ci} 53146debc2cSopenharmony_ci 53246debc2cSopenharmony_civoid TestBuildPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 53346debc2cSopenharmony_ci{ 53446debc2cSopenharmony_ci std::string option = "{\ 53546debc2cSopenharmony_ci \"cupsOptions\" : {\ 53646debc2cSopenharmony_ci \"supportedPageSizeArray\" : \"String\",\ 53746debc2cSopenharmony_ci \"orientation-requested-supported\" : \"String\",\ 53846debc2cSopenharmony_ci \"print-quality-supported\" : \"String\"\ 53946debc2cSopenharmony_ci }\ 54046debc2cSopenharmony_ci }"; 54146debc2cSopenharmony_ci PrinterCapability cap; 54246debc2cSopenharmony_ci cap.SetOption(option); 54346debc2cSopenharmony_ci PrinterPreference printPreference; 54446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->BuildPrinterPreference(cap, printPreference); 54546debc2cSopenharmony_ci std::string optionRandom = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 54646debc2cSopenharmony_ci cap.SetOption(optionRandom); 54746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->BuildPrinterPreference(cap, printPreference); 54846debc2cSopenharmony_ci} 54946debc2cSopenharmony_ci 55046debc2cSopenharmony_civoid TestBuildPrinterPreferenceByDefault(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 55146debc2cSopenharmony_ci{ 55246debc2cSopenharmony_ci std::string optJson = "{\ 55346debc2cSopenharmony_ci \"defaultPageSizeId\" : \"String\",\ 55446debc2cSopenharmony_ci \"orientation-requested-default\" : \"String\",\ 55546debc2cSopenharmony_ci \"sides-default\" : \"String\",\ 55646debc2cSopenharmony_ci \"print-quality-default\" : \"String\"\ 55746debc2cSopenharmony_ci }"; 55846debc2cSopenharmony_ci nlohmann::json capOpt = nlohmann::json::parse(optJson); 55946debc2cSopenharmony_ci PreferenceSetting printerDefaultAttr; 56046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->BuildPrinterPreferenceByDefault(capOpt, printerDefaultAttr); 56146debc2cSopenharmony_ci printerDefaultAttr.pagesizeId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 56246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->BuildPrinterPreferenceByDefault(capOpt, printerDefaultAttr); 56346debc2cSopenharmony_ci} 56446debc2cSopenharmony_ci 56546debc2cSopenharmony_civoid TestBuildPrinterPreferenceByOption(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 56646debc2cSopenharmony_ci{ 56746debc2cSopenharmony_ci std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 56846debc2cSopenharmony_ci std::string supportedOpts = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 56946debc2cSopenharmony_ci std::string optAttr = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 57046debc2cSopenharmony_ci std::vector<std::string> optAttrs; 57146debc2cSopenharmony_ci optAttrs.push_back(optAttr); 57246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->BuildPrinterPreferenceByOption(key, supportedOpts, optAttrs); 57346debc2cSopenharmony_ci} 57446debc2cSopenharmony_ci 57546debc2cSopenharmony_civoid TestBuildPrinterAttrComponentByJson(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 57646debc2cSopenharmony_ci{ 57746debc2cSopenharmony_ci std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 57846debc2cSopenharmony_ci std::string arrObject = "{\ 57946debc2cSopenharmony_ci \"cupsOptions\" : [\ 58046debc2cSopenharmony_ci \"supportedPageSizeArray\", \ 58146debc2cSopenharmony_ci \"orientation-requested-supported\", \ 58246debc2cSopenharmony_ci \"print-quality-supported\"\ 58346debc2cSopenharmony_ci ]\ 58446debc2cSopenharmony_ci }"; 58546debc2cSopenharmony_ci nlohmann::json jsonArrObject = nlohmann::json::parse(arrObject); 58646debc2cSopenharmony_ci std::string printerAttr = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 58746debc2cSopenharmony_ci std::vector<std::string> printerAttrs; 58846debc2cSopenharmony_ci printerAttrs.push_back(printerAttr); 58946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->BuildPrinterAttrComponentByJson(key, jsonArrObject, printerAttrs); 59046debc2cSopenharmony_ci} 59146debc2cSopenharmony_ci 59246debc2cSopenharmony_civoid TestCheckIsDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 59346debc2cSopenharmony_ci{ 59446debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 59546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CheckIsDefaultPrinter(printerId); 59646debc2cSopenharmony_ci} 59746debc2cSopenharmony_ci 59846debc2cSopenharmony_civoid TestCheckIsLastUsedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 59946debc2cSopenharmony_ci{ 60046debc2cSopenharmony_ci std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 60146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CheckIsLastUsedPrinter(printerName); 60246debc2cSopenharmony_ci} 60346debc2cSopenharmony_ci 60446debc2cSopenharmony_civoid TestSetLastUsedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 60546debc2cSopenharmony_ci{ 60646debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 60746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SetLastUsedPrinter(printerId); 60846debc2cSopenharmony_ci} 60946debc2cSopenharmony_ci 61046debc2cSopenharmony_civoid TestSendPrintJobEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 61146debc2cSopenharmony_ci{ 61246debc2cSopenharmony_ci PrintJob jobInfo; 61346debc2cSopenharmony_ci uint32_t jobStateArr[] = {PRINT_JOB_COMPLETED, PRINT_JOB_BLOCKED, PRINT_JOB_COMPLETED}; 61446debc2cSopenharmony_ci for (auto jobState : jobStateArr) { 61546debc2cSopenharmony_ci jobInfo.SetJobState(jobState); 61646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SendPrintJobEvent(jobInfo); 61746debc2cSopenharmony_ci } 61846debc2cSopenharmony_ci uint32_t jobState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 61946debc2cSopenharmony_ci jobInfo.SetJobState(jobState); 62046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SendPrintJobEvent(jobInfo); 62146debc2cSopenharmony_ci} 62246debc2cSopenharmony_ci 62346debc2cSopenharmony_civoid TestStartPrintJobCB(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 62446debc2cSopenharmony_ci{ 62546debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 62646debc2cSopenharmony_ci auto printJob = std::make_shared<PrintJob>(); 62746debc2cSopenharmony_ci printJob->SetJobId(jobId); 62846debc2cSopenharmony_ci printJob->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 62946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->StartPrintJobCB(jobId, printJob); 63046debc2cSopenharmony_ci} 63146debc2cSopenharmony_ci 63246debc2cSopenharmony_civoid TestCheckPrinterUriDifferent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 63346debc2cSopenharmony_ci{ 63446debc2cSopenharmony_ci auto printerInfo = std::make_shared<PrinterInfo>(); 63546debc2cSopenharmony_ci printerInfo->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 63646debc2cSopenharmony_ci printerInfo->SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 63746debc2cSopenharmony_ci printerInfo->SetDescription(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 63846debc2cSopenharmony_ci printerInfo->SetPrinterState(dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER)); 63946debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CheckPrinterUriDifferent(printerInfo); 64046debc2cSopenharmony_ci} 64146debc2cSopenharmony_ci 64246debc2cSopenharmony_civoid TestUpdatePrinterCapability(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 64346debc2cSopenharmony_ci{ 64446debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 64546debc2cSopenharmony_ci PrinterInfo printerInfo; 64646debc2cSopenharmony_ci printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 64746debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 64846debc2cSopenharmony_ci printerInfo.SetDescription(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 64946debc2cSopenharmony_ci printerInfo.SetPrinterState(dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER)); 65046debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->UpdatePrinterCapability(printerId, printerInfo); 65146debc2cSopenharmony_ci} 65246debc2cSopenharmony_ci 65346debc2cSopenharmony_civoid TestReportCompletedPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 65446debc2cSopenharmony_ci{ 65546debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 65646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ReportCompletedPrint(printerId); 65746debc2cSopenharmony_ci} 65846debc2cSopenharmony_ci 65946debc2cSopenharmony_civoid TestReportHisysEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 66046debc2cSopenharmony_ci{ 66146debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 66246debc2cSopenharmony_ci auto printJob = std::make_shared<PrintJob>(); 66346debc2cSopenharmony_ci printJob->SetJobId(jobId); 66446debc2cSopenharmony_ci printJob->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 66546debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 66646debc2cSopenharmony_ci uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 66746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ReportHisysEvent(printJob, printerId, subState); 66846debc2cSopenharmony_ci} 66946debc2cSopenharmony_ci 67046debc2cSopenharmony_civoid TestNotifyAppJobQueueChanged(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 67146debc2cSopenharmony_ci{ 67246debc2cSopenharmony_ci std::string applyResult = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 67346debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->NotifyAppJobQueueChanged(applyResult); 67446debc2cSopenharmony_ci} 67546debc2cSopenharmony_ci 67646debc2cSopenharmony_civoid TestSendPrinterChangeEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 67746debc2cSopenharmony_ci{ 67846debc2cSopenharmony_ci int event = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER); 67946debc2cSopenharmony_ci PrinterInfo printerInfo; 68046debc2cSopenharmony_ci printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 68146debc2cSopenharmony_ci printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 68246debc2cSopenharmony_ci printerInfo.SetDescription(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 68346debc2cSopenharmony_ci printerInfo.SetPrinterState(dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER)); 68446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->SendPrinterChangeEvent(event, printerInfo); 68546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DestroyExtension(); 68646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ReduceAppCount(); 68746debc2cSopenharmony_ci} 68846debc2cSopenharmony_ci 68946debc2cSopenharmony_civoid TestCheckJobQueueBlocked(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 69046debc2cSopenharmony_ci{ 69146debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 69246debc2cSopenharmony_ci PrintJob printJob; 69346debc2cSopenharmony_ci printJob.SetJobId(jobId); 69446debc2cSopenharmony_ci printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 69546debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->CheckJobQueueBlocked(printJob); 69646debc2cSopenharmony_ci} 69746debc2cSopenharmony_ci 69846debc2cSopenharmony_civoid TestGetListeningState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 69946debc2cSopenharmony_ci{ 70046debc2cSopenharmony_ci uint32_t subState = dataProvider->ConsumeIntegralInRange<int32_t>(0, MAX_SET_NUMBER); 70146debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->GetListeningState(subState); 70246debc2cSopenharmony_ci} 70346debc2cSopenharmony_ci 70446debc2cSopenharmony_civoid TestChangeDefaultPrinterForDelete(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 70546debc2cSopenharmony_ci{ 70646debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 70746debc2cSopenharmony_ci auto userData = std::make_shared<PrintUserData>(); 70846debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ChangeDefaultPrinterForDelete(userData, printerId); 70946debc2cSopenharmony_ci} 71046debc2cSopenharmony_ci 71146debc2cSopenharmony_civoid TestGetUserDataByUserId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 71246debc2cSopenharmony_ci{ 71346debc2cSopenharmony_ci int32_t userId = dataProvider->ConsumeIntegralInRange<int32_t>(0, MAX_SET_NUMBER); 71446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->GetUserDataByUserId(userId); 71546debc2cSopenharmony_ci} 71646debc2cSopenharmony_ci 71746debc2cSopenharmony_civoid TestDetermineUserJobStatus(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 71846debc2cSopenharmony_ci{ 71946debc2cSopenharmony_ci std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 72046debc2cSopenharmony_ci auto printJob = std::make_shared<PrintJob>(); 72146debc2cSopenharmony_ci printJob->SetJobId(jobId); 72246debc2cSopenharmony_ci printJob->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 72346debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 72446debc2cSopenharmony_ci std::map<std::string, std::shared_ptr<PrintJob>> jobList; 72546debc2cSopenharmony_ci jobList[jobId] = printJob; 72646debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->DetermineUserJobStatus(jobList); 72746debc2cSopenharmony_ci} 72846debc2cSopenharmony_ci 72946debc2cSopenharmony_civoid TestNotifyCurrentUserChanged(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 73046debc2cSopenharmony_ci{ 73146debc2cSopenharmony_ci int32_t userId = dataProvider->ConsumeIntegralInRange<int32_t>(0, MAX_SET_NUMBER); 73246debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->NotifyCurrentUserChanged(userId); 73346debc2cSopenharmony_ci} 73446debc2cSopenharmony_ci 73546debc2cSopenharmony_civoid TestWriteEprinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 73646debc2cSopenharmony_ci{ 73746debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 73846debc2cSopenharmony_ci PrinterCapability printerCaps; 73946debc2cSopenharmony_ci PrintPageSize pageSize; 74046debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 74146debc2cSopenharmony_ci std::vector<PrintPageSize> pageSizeList; 74246debc2cSopenharmony_ci pageSizeList.push_back(pageSize); 74346debc2cSopenharmony_ci printerCaps.SetSupportedPageSize(pageSizeList); 74446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->WriteEprinterPreference(printerId, printerCaps); 74546debc2cSopenharmony_ci} 74646debc2cSopenharmony_ci 74746debc2cSopenharmony_civoid TestWritePrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 74846debc2cSopenharmony_ci{ 74946debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 75046debc2cSopenharmony_ci PrinterCapability printerCaps; 75146debc2cSopenharmony_ci PrintPageSize pageSize; 75246debc2cSopenharmony_ci pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 75346debc2cSopenharmony_ci std::vector<PrintPageSize> pageSizeList; 75446debc2cSopenharmony_ci pageSizeList.push_back(pageSize); 75546debc2cSopenharmony_ci printerCaps.SetSupportedPageSize(pageSizeList); 75646debc2cSopenharmony_ci printerCaps.SetOption(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH)); 75746debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->WritePrinterPreference(printerId, printerCaps); 75846debc2cSopenharmony_ci} 75946debc2cSopenharmony_ci 76046debc2cSopenharmony_civoid TestReadPreferenceFromFile(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 76146debc2cSopenharmony_ci{ 76246debc2cSopenharmony_ci std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 76346debc2cSopenharmony_ci std::string printPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH); 76446debc2cSopenharmony_ci PrintServiceAbility::GetInstance()->ReadPreferenceFromFile(printerId, printPreference); 76546debc2cSopenharmony_ci} 76646debc2cSopenharmony_ci 76746debc2cSopenharmony_civoid TestMoreFunction(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 76846debc2cSopenharmony_ci{ 76946debc2cSopenharmony_ci TestChangeDefaultPrinterForDelete(data, size, dataProvider); 77046debc2cSopenharmony_ci TestGetUserDataByUserId(data, size, dataProvider); 77146debc2cSopenharmony_ci TestDetermineUserJobStatus(data, size, dataProvider); 77246debc2cSopenharmony_ci TestNotifyCurrentUserChanged(data, size, dataProvider); 77346debc2cSopenharmony_ci TestWriteEprinterPreference(data, size, dataProvider); 77446debc2cSopenharmony_ci TestWritePrinterPreference(data, size, dataProvider); 77546debc2cSopenharmony_ci TestReadPreferenceFromFile(data, size, dataProvider); 77646debc2cSopenharmony_ci} 77746debc2cSopenharmony_ci 77846debc2cSopenharmony_civoid TestNotPublicFunction(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider) 77946debc2cSopenharmony_ci{ 78046debc2cSopenharmony_ci TestDiscoverUsbPrinters(data, size, dataProvider); 78146debc2cSopenharmony_ci TestStartNativePrintJob(data, size, dataProvider); 78246debc2cSopenharmony_ci TestNotifyPrintServiceEvent(data, size, dataProvider); 78346debc2cSopenharmony_ci TestUpdateQueuedJobList(data, size, dataProvider); 78446debc2cSopenharmony_ci TestUpdatePrintJobOptionByPrinterId(data, size, dataProvider); 78546debc2cSopenharmony_ci TestDelayStartDiscovery(data, size, dataProvider); 78646debc2cSopenharmony_ci TestAdapterGetFileCallBack(data, size, dataProvider); 78746debc2cSopenharmony_ci TestAddNativePrintJob(data, size, dataProvider); 78846debc2cSopenharmony_ci TestIsQueuedJobListEmpty(data, size, dataProvider); 78946debc2cSopenharmony_ci TestSetPrintJobCanceled(data, size, dataProvider); 79046debc2cSopenharmony_ci TestCancelUserPrintJobs(data, size, dataProvider); 79146debc2cSopenharmony_ci TestSendExtensionEvent(data, size, dataProvider); 79246debc2cSopenharmony_ci TestNotifyAdapterJobChanged(data, size, dataProvider); 79346debc2cSopenharmony_ci TestRegisterAdapterListener(data, size, dataProvider); 79446debc2cSopenharmony_ci TestisEprint(data, size, dataProvider); 79546debc2cSopenharmony_ci TestBuildPrinterPreferenceByOption(data, size, dataProvider); 79646debc2cSopenharmony_ci TestBuildPrinterPreference(data, size, dataProvider); 79746debc2cSopenharmony_ci TestBuildPrinterPreferenceByDefault(data, size, dataProvider); 79846debc2cSopenharmony_ci TestBuildPrinterPreferenceByOption(data, size, dataProvider); 79946debc2cSopenharmony_ci TestBuildPrinterAttrComponentByJson(data, size, dataProvider); 80046debc2cSopenharmony_ci TestCheckIsDefaultPrinter(data, size, dataProvider); 80146debc2cSopenharmony_ci TestCheckIsLastUsedPrinter(data, size, dataProvider); 80246debc2cSopenharmony_ci TestSetLastUsedPrinter(data, size, dataProvider); 80346debc2cSopenharmony_ci TestSendPrintJobEvent(data, size, dataProvider); 80446debc2cSopenharmony_ci TestStartPrintJobCB(data, size, dataProvider); 80546debc2cSopenharmony_ci TestCheckPrinterUriDifferent(data, size, dataProvider); 80646debc2cSopenharmony_ci TestUpdatePrinterCapability(data, size, dataProvider); 80746debc2cSopenharmony_ci TestReportCompletedPrint(data, size, dataProvider); 80846debc2cSopenharmony_ci TestReportHisysEvent(data, size, dataProvider); 80946debc2cSopenharmony_ci TestNotifyAppJobQueueChanged(data, size, dataProvider); 81046debc2cSopenharmony_ci TestSendPrinterChangeEvent(data, size, dataProvider); 81146debc2cSopenharmony_ci TestCheckJobQueueBlocked(data, size, dataProvider); 81246debc2cSopenharmony_ci TestGetListeningState(data, size, dataProvider); 81346debc2cSopenharmony_ci TestMoreFunction(data, size, dataProvider); 81446debc2cSopenharmony_ci} 81546debc2cSopenharmony_ci 81646debc2cSopenharmony_ci} // namespace Print 81746debc2cSopenharmony_ci} // namespace OHOS 81846debc2cSopenharmony_ci 81946debc2cSopenharmony_ci/* Fuzzer entry point */ 82046debc2cSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 82146debc2cSopenharmony_ci{ 82246debc2cSopenharmony_ci /* Run your code on data */ 82346debc2cSopenharmony_ci if (data == nullptr) { 82446debc2cSopenharmony_ci return 0; 82546debc2cSopenharmony_ci } 82646debc2cSopenharmony_ci 82746debc2cSopenharmony_ci if (size < OHOS::Print::U32_AT_SIZE) { 82846debc2cSopenharmony_ci } 82946debc2cSopenharmony_ci 83046debc2cSopenharmony_ci FuzzedDataProvider dataProvider(data, size); 83146debc2cSopenharmony_ci OHOS::Print::TestStartPrint(data, size, &dataProvider); 83246debc2cSopenharmony_ci OHOS::Print::TestStopPrint(data, size, &dataProvider); 83346debc2cSopenharmony_ci OHOS::Print::TestConnectPrinter(data, size, &dataProvider); 83446debc2cSopenharmony_ci OHOS::Print::TestDisconnectPrinter(data, size, &dataProvider); 83546debc2cSopenharmony_ci OHOS::Print::TestStartDiscoverPrinter(data, size, &dataProvider); 83646debc2cSopenharmony_ci OHOS::Print::TestQueryAllExtension(data, size, &dataProvider); 83746debc2cSopenharmony_ci OHOS::Print::TestStartPrintJob(data, size, &dataProvider); 83846debc2cSopenharmony_ci OHOS::Print::TestCancelPrintJob(data, size, &dataProvider); 83946debc2cSopenharmony_ci OHOS::Print::TestAddPrinters(data, size, &dataProvider); 84046debc2cSopenharmony_ci OHOS::Print::TestRemovePrinters(data, size, &dataProvider); 84146debc2cSopenharmony_ci OHOS::Print::TestUpdatePrinters(data, size, &dataProvider); 84246debc2cSopenharmony_ci OHOS::Print::TestUpdatePrinterState(data, size, &dataProvider); 84346debc2cSopenharmony_ci OHOS::Print::TestUpdatePrintJobStateOnlyForSystemApp(data, size, &dataProvider); 84446debc2cSopenharmony_ci OHOS::Print::TestUpdateExtensionInfo(data, size, &dataProvider); 84546debc2cSopenharmony_ci OHOS::Print::TestRequestPreview(data, size, &dataProvider); 84646debc2cSopenharmony_ci OHOS::Print::TestQueryPrinterCapability(data, size, &dataProvider); 84746debc2cSopenharmony_ci OHOS::Print::TestOn(data, size, &dataProvider); 84846debc2cSopenharmony_ci OHOS::Print::TestOff(data, size, &dataProvider); 84946debc2cSopenharmony_ci OHOS::Print::TestCallback(data, size, &dataProvider); 85046debc2cSopenharmony_ci OHOS::Print::TestLoadExtSuccess(data, size, &dataProvider); 85146debc2cSopenharmony_ci OHOS::Print::TestQueryAllPrintJob(data, size, &dataProvider); 85246debc2cSopenharmony_ci OHOS::Print::TestQueryPrintJobById(data, size, &dataProvider); 85346debc2cSopenharmony_ci OHOS::Print::TestAddPrinterToCups(data, size, &dataProvider); 85446debc2cSopenharmony_ci OHOS::Print::TestQueryPrinterCapabilityByUri(data, size, &dataProvider); 85546debc2cSopenharmony_ci OHOS::Print::TestPrintByAdapter(data, size, &dataProvider); 85646debc2cSopenharmony_ci OHOS::Print::TestStartGetPrintFile(data, size, &dataProvider); 85746debc2cSopenharmony_ci OHOS::Print::TestNotifyPrintService(data, size, &dataProvider); 85846debc2cSopenharmony_ci OHOS::Print::TestQueryPrinterInfoByPrinterId(data, size, &dataProvider); 85946debc2cSopenharmony_ci OHOS::Print::TestQueryAddedPrinter(data, size, &dataProvider); 86046debc2cSopenharmony_ci OHOS::Print::TestQueryPrinterProperties(data, size, &dataProvider); 86146debc2cSopenharmony_ci OHOS::Print::TestUpdatePrintJobState(data, size, &dataProvider); 86246debc2cSopenharmony_ci OHOS::Print::TestGetPrinterPreference(data, size, &dataProvider); 86346debc2cSopenharmony_ci OHOS::Print::TestSetPrinterPreference(data, size, &dataProvider); 86446debc2cSopenharmony_ci OHOS::Print::TestSetDefaultPrinter(data, size, &dataProvider); 86546debc2cSopenharmony_ci OHOS::Print::TestDeletePrinterFromCups(data, size, &dataProvider); 86646debc2cSopenharmony_ci OHOS::Print::TestNotPublicFunction(data, size, &dataProvider); 86746debc2cSopenharmony_ci return 0; 86846debc2cSopenharmony_ci} 869