mirror of
https://gitee.com/openharmony/print_print_fwk
synced 2024-11-26 18:40:40 +00:00
打印框架DT FUZZ用例整改
Signed-off-by: zheng_zhi_hao <zhengzhihao3@huawei.com>
This commit is contained in:
parent
5afad9a908
commit
5160895252
@ -1,2 +1,3 @@
|
|||||||
src:*/base/print/print_fwk/test/unittest/*
|
src:*/base/print/print_fwk/test/unittest/*
|
||||||
|
src:*/base/print/print_fwk/test/fuzztest/*
|
||||||
src:*/third_party/googletest/*
|
src:*/third_party/googletest/*
|
||||||
|
@ -21,28 +21,35 @@
|
|||||||
#include "print_log.h"
|
#include "print_log.h"
|
||||||
#include "print_service_ability.h"
|
#include "print_service_ability.h"
|
||||||
#include "print_service_ability_mock_permission.h"
|
#include "print_service_ability_mock_permission.h"
|
||||||
|
#include "print_callback.h"
|
||||||
|
#include "iprint_adapter_inner.h"
|
||||||
|
|
||||||
namespace OHOS {
|
namespace OHOS {
|
||||||
namespace Print {
|
namespace Print {
|
||||||
constexpr uint8_t MAX_STRING_LENGTH = 255;
|
constexpr uint8_t MAX_STRING_LENGTH = 20;
|
||||||
constexpr int MAX_SET_NUMBER = 100;
|
constexpr int MAX_SET_NUMBER = 128;
|
||||||
constexpr size_t U32_AT_SIZE = 4;
|
constexpr size_t U32_AT_SIZE = 4;
|
||||||
static constexpr const char *JOB_OPTIONS =
|
static constexpr const char *JOB_OPTIONS =
|
||||||
"{\"jobName\":\"xx\",\"jobNum\":1,\"mediaType\":\"stationery\",\"documentCategory\":0,\"printQuality\":\"4\","
|
"{\"jobName\":\"xx\",\"jobNum\":1,\"mediaType\":\"stationery\",\"documentCategory\":0,\"printQuality\":\"4\","
|
||||||
"\"printerName\":\"printer1\",\"printerUri\":\"ipp://192.168.0.1:111/ipp/print\","
|
"\"printerName\":\"testId\",\"printerUri\":\"ipp://192.168.0.1:111/ipp/print\","
|
||||||
"\"documentFormat\":\"application/pdf\",\"files\":[\"/data/1.pdf\"]}";
|
"\"documentFormat\":\"application/pdf\",\"files\":[\"/data/1.pdf\"]}";
|
||||||
|
static const std::string DEFAULT_PRINTERID = "testId";
|
||||||
|
|
||||||
|
void TestInitialize(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
|
{
|
||||||
|
PrintServiceAbilityMockPermission::MockPermission();
|
||||||
|
PrintServiceAbility::GetInstance()->OnStart();
|
||||||
|
auto cupsPrinter = std::make_shared<CupsPrinterInfo>();
|
||||||
|
PrintServiceAbility::GetInstance()->printSystemData_.addedPrinterMap_.Insert(DEFAULT_PRINTERID, cupsPrinter);
|
||||||
|
}
|
||||||
|
|
||||||
void TestStartService(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStartService(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->StartService();
|
PrintServiceAbility::GetInstance()->StartService();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestStartPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStartPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string fileUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string fileUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::vector<std::string> fileList;
|
std::vector<std::string> fileList;
|
||||||
fileList.push_back(fileUri);
|
fileList.push_back(fileUri);
|
||||||
@ -55,97 +62,101 @@ void TestStartPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataPr
|
|||||||
|
|
||||||
void TestStopPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStopPrint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->StopPrint(taskId);
|
PrintServiceAbility::GetInstance()->StopPrint(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestConnectPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestConnectPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
std::string printerId = size ? dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH) : DEFAULT_PRINTERID;
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
PrinterInfo printerInfo;
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
printerInfo.SetPrinterId(printerId);
|
||||||
|
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
|
printerInfo.SetOption(JOB_OPTIONS);
|
||||||
|
std::vector <PrinterInfo> printerInfos;
|
||||||
|
printerInfos.push_back(printerInfo);
|
||||||
|
PrintServiceAbility::GetInstance()->AddPrinters(printerInfos);
|
||||||
PrintServiceAbility::GetInstance()->ConnectPrinter(printerId);
|
PrintServiceAbility::GetInstance()->ConnectPrinter(printerId);
|
||||||
|
PrintServiceAbility::GetInstance()->DisconnectPrinter(printerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDisconnectPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestDisconnectPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->DisconnectPrinter(printerId);
|
PrintServiceAbility::GetInstance()->DisconnectPrinter(printerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestStartDiscoverPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStartDiscoverPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
std::vector <PrintExtensionInfo> printExtensionInfos;
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos);
|
||||||
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::vector<std::string> extensionIds;
|
std::vector <std::string> extensionIds;
|
||||||
extensionIds.push_back(extensionId);
|
extensionIds.push_back(extensionId);
|
||||||
|
for (auto &printExtensionInfo: printExtensionInfos) {
|
||||||
|
extensionIds.push_back(printExtensionInfo.GetExtensionId());
|
||||||
|
}
|
||||||
PrintServiceAbility::GetInstance()->StartDiscoverPrinter(extensionIds);
|
PrintServiceAbility::GetInstance()->StartDiscoverPrinter(extensionIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestStopDiscoverPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStopDiscoverPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->StopDiscoverPrinter();
|
PrintServiceAbility::GetInstance()->StopDiscoverPrinter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQueryAllExtension(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryAllExtension(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintExtensionInfo printExtensionInfo;
|
PrintExtensionInfo printExtensionInfo;
|
||||||
printExtensionInfo.SetExtensionId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printExtensionInfo.SetExtensionId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<PrintExtensionInfo> printExtensionInfos;
|
std::vector<PrintExtensionInfo> printExtensionInfos;
|
||||||
printExtensionInfos.push_back(printExtensionInfo);
|
printExtensionInfos.push_back(printExtensionInfo);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos);
|
PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestStartPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStartPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
PrinterInfo printerInfo;
|
||||||
|
printerInfo.SetPrinterId(DEFAULT_PRINTERID);
|
||||||
|
printerInfo.SetPrinterName(DEFAULT_PRINTERID);
|
||||||
|
std::vector <PrinterInfo> printerInfos;
|
||||||
|
PrinterCapability printerCaps;
|
||||||
|
printerCaps.SetColorMode(dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER));
|
||||||
|
printerInfos.push_back(printerInfo);
|
||||||
|
|
||||||
|
PrintServiceAbility::GetInstance()->AddPrinters(printerInfos);
|
||||||
|
PrintServiceAbility::GetInstance()->UpdatePrinters(printerInfos);
|
||||||
|
|
||||||
PrintJob testJob;
|
PrintJob testJob;
|
||||||
testJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
testJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<uint32_t> files = {1};
|
std::vector <uint32_t> files = {1};
|
||||||
testJob.SetFdList(files);
|
testJob.SetFdList(files);
|
||||||
OHOS::Print::PrintPageSize pageSize;
|
OHOS::Print::PrintPageSize pageSize;
|
||||||
pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
testJob.SetPageSize(pageSize);
|
testJob.SetPageSize(pageSize);
|
||||||
testJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
testJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
testJob.SetOption(JOB_OPTIONS);
|
testJob.SetOption(JOB_OPTIONS);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->StartPrintJob(testJob);
|
PrintServiceAbility::GetInstance()->StartPrintJob(testJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCancelPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestCancelPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->CancelPrintJob(jobId);
|
PrintServiceAbility::GetInstance()->CancelPrintJob(jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAddPrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestAddPrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrinterInfo printerInfo;
|
PrinterInfo printerInfo;
|
||||||
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetOption(JOB_OPTIONS);
|
printerInfo.SetOption(JOB_OPTIONS);
|
||||||
std::vector<PrinterInfo> printerInfos;
|
std::vector<PrinterInfo> printerInfos;
|
||||||
printerInfos.push_back(printerInfo);
|
printerInfos.push_back(printerInfo);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->AddPrinters(printerInfos);
|
PrintServiceAbility::GetInstance()->AddPrinters(printerInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRemovePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestRemovePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::vector<std::string> printerIds;
|
std::vector<std::string> printerIds;
|
||||||
printerIds.push_back(printerId);
|
printerIds.push_back(printerId);
|
||||||
@ -154,22 +165,18 @@ void TestRemovePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *da
|
|||||||
|
|
||||||
void TestUpdatePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdatePrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrinterInfo printerInfo;
|
PrinterInfo printerInfo;
|
||||||
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetOption(JOB_OPTIONS);
|
printerInfo.SetOption(JOB_OPTIONS);
|
||||||
std::vector<PrinterInfo> printerInfos;
|
std::vector<PrinterInfo> printerInfos;
|
||||||
printerInfos.push_back(printerInfo);
|
printerInfos.push_back(printerInfo);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->UpdatePrinters(printerInfos);
|
PrintServiceAbility::GetInstance()->UpdatePrinters(printerInfos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestUpdatePrinterState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdatePrinterState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
PrintServiceAbility::GetInstance()->UpdatePrinterState(printerId, state);
|
PrintServiceAbility::GetInstance()->UpdatePrinterState(printerId, state);
|
||||||
@ -177,8 +184,6 @@ void TestUpdatePrinterState(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
|
|
||||||
void TestUpdatePrintJobStateOnlyForSystemApp(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdatePrintJobStateOnlyForSystemApp(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
@ -187,15 +192,12 @@ void TestUpdatePrintJobStateOnlyForSystemApp(const uint8_t *data, size_t size, F
|
|||||||
|
|
||||||
void TestUpdateExtensionInfo(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdateExtensionInfo(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string extInfo = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extInfo = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->UpdateExtensionInfo(extInfo);
|
PrintServiceAbility::GetInstance()->UpdateExtensionInfo(extInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRequestPreview(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestRequestPreview(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintJob printJob;
|
PrintJob printJob;
|
||||||
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<uint32_t> files = {1};
|
std::vector<uint32_t> files = {1};
|
||||||
@ -206,80 +208,79 @@ void TestRequestPreview(const uint8_t *data, size_t size, FuzzedDataProvider *da
|
|||||||
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printJob.SetOption(JOB_OPTIONS);
|
printJob.SetOption(JOB_OPTIONS);
|
||||||
std::string previewResult = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string previewResult = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->RequestPreview(printJob, previewResult);
|
PrintServiceAbility::GetInstance()->RequestPreview(printJob, previewResult);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQueryPrinterCapability(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryPrinterCapability(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->QueryPrinterCapability(printerId);
|
PrintServiceAbility::GetInstance()->QueryPrinterCapability(printerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestOn(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestOn(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
PrintDocumentAdapter *printerAdapterPtr = new PrintDocumentAdapter();
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
sptr <PrintCallback> callback = new(std::nothrow) PrintCallback(printerAdapterPtr);
|
||||||
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
if (callback != nullptr) {
|
||||||
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->On(taskId, type, nullptr);
|
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
|
PrintServiceAbility::GetInstance()->On(taskId, type, callback);
|
||||||
|
} else {
|
||||||
|
delete printerAdapterPtr;
|
||||||
|
printerAdapterPtr = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestOff(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestOff(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->Off(taskId, type);
|
PrintServiceAbility::GetInstance()->Off(taskId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRegisterPrinterCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestPrinterCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
PrintDocumentAdapter *printerAdapterPtr = new PrintDocumentAdapter();
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
sptr <PrintCallback> callback = new(std::nothrow) PrintCallback(printerAdapterPtr);
|
||||||
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
if (callback != nullptr) {
|
||||||
PrintServiceAbility::GetInstance()->RegisterPrinterCallback(type, nullptr);
|
std::string type = PRINTER_DISCOVER_EVENT_TYPE;
|
||||||
|
PrintServiceAbility::GetInstance()->RegisterPrinterCallback(type, callback);
|
||||||
|
PrintServiceAbility::GetInstance()->UnregisterPrinterCallback(type);
|
||||||
|
} else {
|
||||||
|
delete printerAdapterPtr;
|
||||||
|
printerAdapterPtr = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestUnregisterPrinterCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
|
||||||
{
|
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
|
||||||
PrintServiceAbility::GetInstance()->UnregisterPrinterCallback(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestRegisterExtCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestExtCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
std::vector <PrintExtensionInfo> printExtensionInfos;
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
PrintServiceAbility::GetInstance()->QueryAllExtension(printExtensionInfos);
|
||||||
|
std::vector <std::string> extensionIds;
|
||||||
|
for (auto &printExtensionInfo: printExtensionInfos) {
|
||||||
|
extensionIds.push_back(printExtensionInfo.GetExtensionId());
|
||||||
|
}
|
||||||
|
PrintServiceAbility::GetInstance()->StartDiscoverPrinter(extensionIds);
|
||||||
|
|
||||||
|
for (auto &printExtensionInfo: printExtensionInfos) {
|
||||||
|
PrintServiceAbility::GetInstance()->RegisterExtCallback(printExtensionInfo.GetExtensionId(), nullptr);
|
||||||
|
PrintServiceAbility::GetInstance()->UnregisterAllExtCallback(printExtensionInfo.GetExtensionId());
|
||||||
|
}
|
||||||
|
|
||||||
std::string extensionCID = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extensionCID = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->RegisterExtCallback(extensionCID, nullptr);
|
PrintServiceAbility::GetInstance()->RegisterExtCallback(extensionCID, nullptr);
|
||||||
}
|
|
||||||
|
|
||||||
void TestUnregisterAllExtCallback(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
|
||||||
{
|
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string extensionCID = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
|
||||||
PrintServiceAbility::GetInstance()->UnregisterAllExtCallback(extensionCID);
|
PrintServiceAbility::GetInstance()->UnregisterAllExtCallback(extensionCID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestLoadExtSuccess(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestLoadExtSuccess(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->LoadExtSuccess(extensionId);
|
PrintServiceAbility::GetInstance()->LoadExtSuccess(extensionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQueryAllPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryAllPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintJob printJob;
|
PrintJob printJob;
|
||||||
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<uint32_t> files = {0};
|
std::vector<uint32_t> files = {0};
|
||||||
@ -290,13 +291,11 @@ void TestQueryAllPrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *
|
|||||||
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<PrintJob> printJobs;
|
std::vector<PrintJob> printJobs;
|
||||||
printJobs.push_back(printJob);
|
printJobs.push_back(printJob);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->QueryAllPrintJob(printJobs);
|
PrintServiceAbility::GetInstance()->QueryAllPrintJob(printJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQueryPrintJobById(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryPrintJobById(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintJob printJob;
|
PrintJob printJob;
|
||||||
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<uint32_t> files = {0};
|
std::vector<uint32_t> files = {0};
|
||||||
@ -306,14 +305,11 @@ void TestQueryPrintJobById(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
printJob.SetPageSize(pageSize);
|
printJob.SetPageSize(pageSize);
|
||||||
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::string printJobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printJobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->QueryPrintJobById(printJobId, printJob);
|
PrintServiceAbility::GetInstance()->QueryPrintJobById(printJobId, printJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAddPrinterToCups(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestAddPrinterToCups(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerMake = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerMake = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
@ -322,8 +318,6 @@ void TestAddPrinterToCups(const uint8_t *data, size_t size, FuzzedDataProvider *
|
|||||||
|
|
||||||
void TestQueryPrinterCapabilityByUri(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryPrinterCapabilityByUri(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerUri = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrinterCapability printerCaps;
|
PrinterCapability printerCaps;
|
||||||
@ -332,47 +326,37 @@ void TestQueryPrinterCapabilityByUri(const uint8_t *data, size_t size, FuzzedDat
|
|||||||
|
|
||||||
void TestSetHelper(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSetHelper(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->SetHelper(nullptr);
|
PrintServiceAbility::GetInstance()->SetHelper(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestPrintByAdapter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestPrintByAdapter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
std::string jobName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintAttributes printAttributes;
|
PrintAttributes printAttributes;
|
||||||
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string taskId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->PrintByAdapter(jobName, printAttributes, taskId);
|
PrintServiceAbility::GetInstance()->PrintByAdapter(jobName, printAttributes, taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestStartGetPrintFile(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStartGetPrintFile(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintAttributes printAttributes;
|
PrintAttributes printAttributes;
|
||||||
uint32_t fd = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t fd = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->StartGetPrintFile(jobId, printAttributes, fd);
|
PrintServiceAbility::GetInstance()->StartGetPrintFile(jobId, printAttributes, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQueryPrinterInfoByPrinterId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryPrinterInfoByPrinterId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrinterInfo printerInfo;
|
PrinterInfo printerInfo;
|
||||||
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetOption(JOB_OPTIONS);
|
printerInfo.SetOption(JOB_OPTIONS);
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->QueryPrinterInfoByPrinterId(printerId, printerInfo);
|
PrintServiceAbility::GetInstance()->QueryPrinterInfoByPrinterId(printerId, printerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestNotifyPrintService(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestNotifyPrintService(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string type = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->NotifyPrintService(jobId, type);
|
PrintServiceAbility::GetInstance()->NotifyPrintService(jobId, type);
|
||||||
@ -380,8 +364,6 @@ void TestNotifyPrintService(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
|
|
||||||
void TestQueryAddedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryAddedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::vector<std::string> printerNameList;
|
std::vector<std::string> printerNameList;
|
||||||
printerNameList.push_back(printerName);
|
printerNameList.push_back(printerName);
|
||||||
@ -390,8 +372,6 @@ void TestQueryAddedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
|
|
||||||
void TestQueryPrinterProperties(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestQueryPrinterProperties(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::vector<std::string> keyList;
|
std::vector<std::string> keyList;
|
||||||
@ -404,8 +384,6 @@ void TestQueryPrinterProperties(const uint8_t *data, size_t size, FuzzedDataProv
|
|||||||
|
|
||||||
void TestUpdatePrintJobState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdatePrintJobState(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
@ -414,7 +392,6 @@ void TestUpdatePrintJobState(const uint8_t *data, size_t size, FuzzedDataProvide
|
|||||||
|
|
||||||
void TestGetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestGetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->GetPrinterPreference(printerId, printerPreference);
|
PrintServiceAbility::GetInstance()->GetPrinterPreference(printerId, printerPreference);
|
||||||
@ -422,7 +399,6 @@ void TestGetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvid
|
|||||||
|
|
||||||
void TestSetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerPreference = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->SetPrinterPreference(printerId, printerPreference);
|
PrintServiceAbility::GetInstance()->SetPrinterPreference(printerId, printerPreference);
|
||||||
@ -430,7 +406,6 @@ void TestSetPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvid
|
|||||||
|
|
||||||
void TestSetDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSetDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t type = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t type = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
PrintServiceAbility::GetInstance()->SetDefaultPrinter(printerId, type);
|
PrintServiceAbility::GetInstance()->SetDefaultPrinter(printerId, type);
|
||||||
@ -438,7 +413,6 @@ void TestSetDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
|
|
||||||
void TestDeletePrinterFromCups(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestDeletePrinterFromCups(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printerMake = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerMake = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
@ -447,7 +421,6 @@ void TestDeletePrinterFromCups(const uint8_t *data, size_t size, FuzzedDataProvi
|
|||||||
|
|
||||||
void TestDiscoverUsbPrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestDiscoverUsbPrinters(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrinterInfo printerInfo;
|
PrinterInfo printerInfo;
|
||||||
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printerInfo.SetPrinterName(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
@ -460,7 +433,6 @@ void TestDiscoverUsbPrinters(const uint8_t *data, size_t size, FuzzedDataProvide
|
|||||||
|
|
||||||
void TestStartNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestStartNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintJob testJob;
|
PrintJob testJob;
|
||||||
testJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
testJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<uint32_t> files = {1};
|
std::vector<uint32_t> files = {1};
|
||||||
@ -475,7 +447,6 @@ void TestStartNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvide
|
|||||||
|
|
||||||
void TestNotifyPrintServiceEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestNotifyPrintServiceEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t event = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t event = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
PrintServiceAbility::GetInstance()->NotifyPrintServiceEvent(jobId, event);
|
PrintServiceAbility::GetInstance()->NotifyPrintServiceEvent(jobId, event);
|
||||||
@ -484,19 +455,16 @@ void TestNotifyPrintServiceEvent(const uint8_t *data, size_t size, FuzzedDataPro
|
|||||||
// below are private test
|
// below are private test
|
||||||
void TestUpdateQueuedJobList(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdateQueuedJobList(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string printJobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printJobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
auto printJob = std::make_shared<PrintJob>();
|
auto printJob = std::make_shared<PrintJob>();
|
||||||
printJob->SetJobId(printJobId);
|
printJob->SetJobId(printJobId);
|
||||||
printJob->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob->SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->UpdateQueuedJobList(printJobId, printJob);
|
PrintServiceAbility::GetInstance()->UpdateQueuedJobList(printJobId, printJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestUpdatePrintJobOptionByPrinterId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdatePrintJobOptionByPrinterId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbilityMockPermission::MockPermission();
|
|
||||||
PrintJob printJob;
|
PrintJob printJob;
|
||||||
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetJobId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
std::vector<uint32_t> files = {0};
|
std::vector<uint32_t> files = {0};
|
||||||
@ -505,20 +473,17 @@ void TestUpdatePrintJobOptionByPrinterId(const uint8_t *data, size_t size, Fuzze
|
|||||||
pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
pageSize.SetId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
printJob.SetPageSize(pageSize);
|
printJob.SetPageSize(pageSize);
|
||||||
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
printJob.SetPrinterId(dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH));
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->UpdatePrintJobOptionByPrinterId(printJob);
|
PrintServiceAbility::GetInstance()->UpdatePrintJobOptionByPrinterId(printJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDelayStartDiscovery(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestDelayStartDiscovery(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->DelayStartDiscovery(extensionId);
|
PrintServiceAbility::GetInstance()->DelayStartDiscovery(extensionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAdapterGetFileCallBack(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestAdapterGetFileCallBack(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
@ -527,7 +492,6 @@ void TestAdapterGetFileCallBack(const uint8_t *data, size_t size, FuzzedDataProv
|
|||||||
|
|
||||||
void TestAddNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestAddNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintJob printJob;
|
PrintJob printJob;
|
||||||
PrintServiceAbility::GetInstance()->AddNativePrintJob(jobId, printJob);
|
PrintServiceAbility::GetInstance()->AddNativePrintJob(jobId, printJob);
|
||||||
@ -535,28 +499,24 @@ void TestAddNativePrintJob(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
|
|
||||||
void TestIsQueuedJobListEmpty(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestIsQueuedJobListEmpty(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->IsQueuedJobListEmpty(jobId);
|
PrintServiceAbility::GetInstance()->IsQueuedJobListEmpty(jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSetPrintJobCanceled(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSetPrintJobCanceled(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintJob printJob;
|
PrintJob printJob;
|
||||||
PrintServiceAbility::GetInstance()->SetPrintJobCanceled(printJob);
|
PrintServiceAbility::GetInstance()->SetPrintJobCanceled(printJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCancelUserPrintJobs(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestCancelUserPrintJobs(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
int32_t userId = dataProvider->ConsumeIntegralInRange<int32_t>(0, MAX_SET_NUMBER);
|
int32_t userId = dataProvider->ConsumeIntegralInRange<int32_t>(0, MAX_SET_NUMBER);
|
||||||
PrintServiceAbility::GetInstance()->CancelUserPrintJobs(userId);
|
PrintServiceAbility::GetInstance()->CancelUserPrintJobs(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSendExtensionEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSendExtensionEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extensionId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string extInfo = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string extInfo = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->SendExtensionEvent(extensionId, extInfo);
|
PrintServiceAbility::GetInstance()->SendExtensionEvent(extensionId, extInfo);
|
||||||
@ -564,19 +524,16 @@ void TestSendExtensionEvent(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
|
|
||||||
void TestCallStatusBar(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestCallStatusBar(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->CallStatusBar();
|
PrintServiceAbility::GetInstance()->CallStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestUpdatePrintUserMap(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestUpdatePrintUserMap(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->UpdatePrintUserMap();
|
PrintServiceAbility::GetInstance()->UpdatePrintUserMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestnotifyAdapterJobChanged(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestNotifyAdapterJobChanged(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t state = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
uint32_t subState = dataProvider->ConsumeIntegralInRange<uint32_t>(0, MAX_SET_NUMBER);
|
||||||
@ -585,45 +542,38 @@ void TestnotifyAdapterJobChanged(const uint8_t *data, size_t size, FuzzedDataPro
|
|||||||
|
|
||||||
void TestRegisterAdapterListener(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestRegisterAdapterListener(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string jobId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->RegisterAdapterListener(jobId);
|
PrintServiceAbility::GetInstance()->RegisterAdapterListener(jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestisEprint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestisEprint(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->isEprint(printerId);
|
PrintServiceAbility::GetInstance()->isEprint(printerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestManualStart(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestManualStart(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->ManualStart();
|
PrintServiceAbility::GetInstance()->ManualStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGetPrintJobOrderId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestGetPrintJobOrderId(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->GetPrintJobOrderId();
|
PrintServiceAbility::GetInstance()->GetPrintJobOrderId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestOnStop(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestOnStop(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->OnStop();
|
PrintServiceAbility::GetInstance()->OnStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestWritePreferenceToFile(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestWritePreferenceToFile(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintServiceAbility::GetInstance()->WritePreferenceToFile();
|
PrintServiceAbility::GetInstance()->WritePreferenceToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestBuildPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestBuildPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string option = "{\
|
std::string option = "{\
|
||||||
\"cupsOptions\" : {\
|
\"cupsOptions\" : {\
|
||||||
\"supportedPageSizeArray\" : \"String\",\
|
\"supportedPageSizeArray\" : \"String\",\
|
||||||
@ -639,7 +589,6 @@ void TestBuildPrinterPreference(const uint8_t *data, size_t size, FuzzedDataProv
|
|||||||
|
|
||||||
void TestBuildPrinterPreferenceByDefault(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestBuildPrinterPreferenceByDefault(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string optJson = "{\
|
std::string optJson = "{\
|
||||||
\"defaultPageSizeId\" : \"String\",\
|
\"defaultPageSizeId\" : \"String\",\
|
||||||
\"orientation-requested-default\" : \"String\",\
|
\"orientation-requested-default\" : \"String\",\
|
||||||
@ -653,7 +602,6 @@ void TestBuildPrinterPreferenceByDefault(const uint8_t *data, size_t size, Fuzze
|
|||||||
|
|
||||||
void TestBuildPrinterPreferenceByOption(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestBuildPrinterPreferenceByOption(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string supportedOpts = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string supportedOpts = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string optAttr = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string optAttr = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
@ -664,7 +612,6 @@ void TestBuildPrinterPreferenceByOption(const uint8_t *data, size_t size, Fuzzed
|
|||||||
|
|
||||||
void TestBuildPrinterAttrComponentByJson(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestBuildPrinterAttrComponentByJson(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string key = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
std::string arrObject = "{\
|
std::string arrObject = "{\
|
||||||
\"cupsOptions\" : [\
|
\"cupsOptions\" : [\
|
||||||
@ -682,28 +629,24 @@ void TestBuildPrinterAttrComponentByJson(const uint8_t *data, size_t size, Fuzze
|
|||||||
|
|
||||||
void TestCheckIsDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestCheckIsDefaultPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->CheckIsDefaultPrinter(printerId);
|
PrintServiceAbility::GetInstance()->CheckIsDefaultPrinter(printerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCheckIsLastUsedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestCheckIsLastUsedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerName = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->CheckIsLastUsedPrinter(printerName);
|
PrintServiceAbility::GetInstance()->CheckIsLastUsedPrinter(printerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSetLastUsedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSetLastUsedPrinter(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
std::string printerId = dataProvider->ConsumeRandomLengthString(MAX_STRING_LENGTH);
|
||||||
PrintServiceAbility::GetInstance()->SetLastUsedPrinter(printerId);
|
PrintServiceAbility::GetInstance()->SetLastUsedPrinter(printerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSendPrintJobEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
void TestSendPrintJobEvent(const uint8_t *data, size_t size, FuzzedDataProvider *dataProvider)
|
||||||
{
|
{
|
||||||
PrintServiceAbility::GetInstance()->Init();
|
|
||||||
PrintJob jobInfo;
|
PrintJob jobInfo;
|
||||||
uint32_t jobStateArr[] = {PRINT_JOB_COMPLETED, PRINT_JOB_BLOCKED, PRINT_JOB_COMPLETED};
|
uint32_t jobStateArr[] = {PRINT_JOB_COMPLETED, PRINT_JOB_BLOCKED, PRINT_JOB_COMPLETED};
|
||||||
for (auto jobState : jobStateArr) {
|
for (auto jobState : jobStateArr) {
|
||||||
@ -883,7 +826,7 @@ void TestNotPublicFunction(const uint8_t *data, size_t size, FuzzedDataProvider
|
|||||||
TestSendExtensionEvent(data, size, dataProvider);
|
TestSendExtensionEvent(data, size, dataProvider);
|
||||||
TestCallStatusBar(data, size, dataProvider);
|
TestCallStatusBar(data, size, dataProvider);
|
||||||
TestUpdatePrintUserMap(data, size, dataProvider);
|
TestUpdatePrintUserMap(data, size, dataProvider);
|
||||||
TestnotifyAdapterJobChanged(data, size, dataProvider);
|
TestNotifyAdapterJobChanged(data, size, dataProvider);
|
||||||
TestRegisterAdapterListener(data, size, dataProvider);
|
TestRegisterAdapterListener(data, size, dataProvider);
|
||||||
TestisEprint(data, size, dataProvider);
|
TestisEprint(data, size, dataProvider);
|
||||||
TestWritePreferenceToFile(data, size, dataProvider);
|
TestWritePreferenceToFile(data, size, dataProvider);
|
||||||
@ -924,6 +867,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FuzzedDataProvider dataProvider(data, size);
|
FuzzedDataProvider dataProvider(data, size);
|
||||||
|
OHOS::Print::TestInitialize(data, size, &dataProvider);
|
||||||
OHOS::Print::TestStartService(data, size, &dataProvider);
|
OHOS::Print::TestStartService(data, size, &dataProvider);
|
||||||
OHOS::Print::TestStartPrint(data, size, &dataProvider);
|
OHOS::Print::TestStartPrint(data, size, &dataProvider);
|
||||||
OHOS::Print::TestStopPrint(data, size, &dataProvider);
|
OHOS::Print::TestStopPrint(data, size, &dataProvider);
|
||||||
@ -931,7 +875,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||||||
OHOS::Print::TestDisconnectPrinter(data, size, &dataProvider);
|
OHOS::Print::TestDisconnectPrinter(data, size, &dataProvider);
|
||||||
OHOS::Print::TestStartDiscoverPrinter(data, size, &dataProvider);
|
OHOS::Print::TestStartDiscoverPrinter(data, size, &dataProvider);
|
||||||
OHOS::Print::TestStopDiscoverPrinter(data, size, &dataProvider);
|
OHOS::Print::TestStopDiscoverPrinter(data, size, &dataProvider);
|
||||||
// OHOS::Print::TestQueryAllExtension(data, size, &dataProvider);
|
OHOS::Print::TestQueryAllExtension(data, size, &dataProvider);
|
||||||
OHOS::Print::TestStartPrintJob(data, size, &dataProvider);
|
OHOS::Print::TestStartPrintJob(data, size, &dataProvider);
|
||||||
OHOS::Print::TestCancelPrintJob(data, size, &dataProvider);
|
OHOS::Print::TestCancelPrintJob(data, size, &dataProvider);
|
||||||
OHOS::Print::TestAddPrinters(data, size, &dataProvider);
|
OHOS::Print::TestAddPrinters(data, size, &dataProvider);
|
||||||
@ -944,10 +888,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||||||
OHOS::Print::TestQueryPrinterCapability(data, size, &dataProvider);
|
OHOS::Print::TestQueryPrinterCapability(data, size, &dataProvider);
|
||||||
OHOS::Print::TestOn(data, size, &dataProvider);
|
OHOS::Print::TestOn(data, size, &dataProvider);
|
||||||
OHOS::Print::TestOff(data, size, &dataProvider);
|
OHOS::Print::TestOff(data, size, &dataProvider);
|
||||||
OHOS::Print::TestRegisterPrinterCallback(data, size, &dataProvider);
|
OHOS::Print::TestPrinterCallback(data, size, &dataProvider);
|
||||||
OHOS::Print::TestUnregisterPrinterCallback(data, size, &dataProvider);
|
OHOS::Print::TestExtCallback(data, size, &dataProvider);
|
||||||
OHOS::Print::TestRegisterExtCallback(data, size, &dataProvider);
|
|
||||||
OHOS::Print::TestUnregisterAllExtCallback(data, size, &dataProvider);
|
|
||||||
OHOS::Print::TestLoadExtSuccess(data, size, &dataProvider);
|
OHOS::Print::TestLoadExtSuccess(data, size, &dataProvider);
|
||||||
OHOS::Print::TestQueryAllPrintJob(data, size, &dataProvider);
|
OHOS::Print::TestQueryAllPrintJob(data, size, &dataProvider);
|
||||||
OHOS::Print::TestQueryPrintJobById(data, size, &dataProvider);
|
OHOS::Print::TestQueryPrintJobById(data, size, &dataProvider);
|
||||||
|
Loading…
Reference in New Issue
Block a user