mirror of
https://gitee.com/openharmony/print_print_fwk
synced 2024-11-23 00:50:01 +00:00
commit
6fe17cc557
@ -192,5 +192,80 @@ HWTEST_F(PrintCallbackStubTest, PrintCallbackStubTest_0006, TestSize.Level1)
|
||||
EXPECT_EQ(callback->OnRemoteRequest(code, data, reply, option), E_PRINT_NONE);
|
||||
EXPECT_TRUE(reply.ReadBool());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintServiceProxyTest_0008
|
||||
* @tc.desc: Verify the capability function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCallbackStubTest, PrintCallbackStubTest_0008, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
uint32_t code = static_cast<uint32_t>(PRINT_CALLBACK_PRINT_JOB_ADAPTER);
|
||||
|
||||
std::string jobId = "job:1234";
|
||||
auto oldAttrs = PrintAttributes::Unmarshalling(data);
|
||||
auto newAttrs = PrintAttributes::Unmarshalling(data);
|
||||
if (oldAttrs == nullptr || newAttrs == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
EXPECT_TRUE(data.WriteInterfaceToken(IPrintCallback::GetDescriptor()));
|
||||
auto callback = std::make_shared<MockPrintCallbackStub>();
|
||||
EXPECT_NE(callback, nullptr);
|
||||
EXPECT_EQ(callback->OnRemoteRequest(code, data, reply, option), E_PRINT_NONE);
|
||||
EXPECT_TRUE(reply.ReadBool());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintServiceProxyTest_0009
|
||||
* @tc.desc: Verify the capability function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCallbackStubTest, PrintCallbackStubTest_0009, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
uint32_t code = static_cast<uint32_t>(PRINT_CALLBACK_PRINT_JOB_CHANGED_ADAPTER);
|
||||
|
||||
auto testState = static_cast<uint32_t>(PRINT_JOB_RUNNING);
|
||||
auto testSubState = static_cast<uint32_t>(PRINTER_ADDED);
|
||||
std::string jobId = "job:1234";
|
||||
|
||||
EXPECT_TRUE(data.WriteInterfaceToken(IPrintCallback::GetDescriptor()));
|
||||
EXPECT_TRUE(data.WriteUint32(testState));
|
||||
EXPECT_TRUE(data.WriteUint32(testSubState));
|
||||
auto callback = std::make_shared<MockPrintCallbackStub>();
|
||||
EXPECT_NE(callback, nullptr);
|
||||
EXPECT_EQ(callback->OnRemoteRequest(code, data, reply, option), E_PRINT_NONE);
|
||||
EXPECT_TRUE(reply.ReadBool());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintCallbackStubTest_0010
|
||||
* @tc.desc: Verify the capability function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCallbackStubTest, PrintCallbackStubTest_0010, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
uint32_t code = static_cast<uint32_t>(PRINT_CALLBACK_PRINT_GET_FILE_ADAPTER);
|
||||
|
||||
auto testState = static_cast<uint32_t>(PRINT_JOB_RUNNING);
|
||||
EXPECT_TRUE(data.WriteInterfaceToken(IPrintCallback::GetDescriptor()));
|
||||
EXPECT_TRUE(data.WriteUint32(testState));
|
||||
auto callback = std::make_shared<MockPrintCallbackStub>();
|
||||
EXPECT_NE(callback, nullptr);
|
||||
EXPECT_EQ(callback->OnRemoteRequest(code, data, reply, option), E_PRINT_NONE);
|
||||
EXPECT_TRUE(reply.ReadBool());
|
||||
}
|
||||
} // namespace Print
|
||||
} // namespace OHOS
|
||||
|
@ -1652,5 +1652,113 @@ HWTEST_F(PrintCupsClientTest, PrintCupsClientTest_0078, TestSize.Level1)
|
||||
jobParams = printCupsClient.BuildJobParameters(testJob);
|
||||
EXPECT_EQ(jobParams, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintCupsClientTest_0079
|
||||
* @tc.desc: HandleFiles
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCupsClientTest, PrintCupsClientTest_0079, TestSize.Level1)
|
||||
{
|
||||
OHOS::Print::PrintCupsClient printCupsClient;
|
||||
http_t *http = nullptr;
|
||||
PrintJob testJob;
|
||||
JobParameters *jobParams = printCupsClient.BuildJobParameters(testJob);
|
||||
int32_t numFiles = 1;
|
||||
int32_t jobId = 1;
|
||||
EXPECT_EQ(printCupsClient.HandleFiles(jobParams, numFiles, http, jobId), false);
|
||||
jobParams = nullptr;
|
||||
EXPECT_EQ(printCupsClient.HandleFiles(jobParams, numFiles, http, jobId), false);
|
||||
delete http;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintCupsClientTest_0080
|
||||
* @tc.desc: HandleJobState
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCupsClientTest, PrintCupsClientTest_0080, TestSize.Level1)
|
||||
{
|
||||
OHOS::Print::PrintCupsClient printCupsClient;
|
||||
http_t *http = nullptr;
|
||||
JobStatus *prevousJobStatus = new (std::nothrow) JobStatus{{'\0'}, (ipp_jstate_t)0, {'\0'}};
|
||||
JobStatus *jobStatus = new (std::nothrow) JobStatus{{'\0'}, (ipp_jstate_t)0, {'\0'}};
|
||||
PrintJob testJob;
|
||||
testJob.SetJobId(GetDefaultJobId());
|
||||
std::vector<uint32_t> files = {1};
|
||||
testJob.SetFdList(files);
|
||||
OHOS::Print::PrintPageSize pageSize;
|
||||
pageSize.SetId("pgid-1234");
|
||||
testJob.SetPageSize(pageSize);
|
||||
testJob.SetPrinterId("printid-1234");
|
||||
testJob.SetOption(JOB_OPTIONS);
|
||||
JobParameters *jobParams = printCupsClient.BuildJobParameters(testJob);
|
||||
JobMonitorParam *param = new (std::nothrow) JobMonitorParam{jobParams->serviceAbility,
|
||||
jobParams->serviceJobId,
|
||||
1,
|
||||
"ipp://192.168.186.1:631/ipp/print",
|
||||
"DIRECT-PixLab_V1-0105"};
|
||||
|
||||
printCupsClient.HandleJobState(http, param, jobStatus, prevousJobStatus);
|
||||
EXPECT_NE(prevousJobStatus, nullptr);
|
||||
printCupsClient.QueryJobStateAgain(http, param, jobStatus);
|
||||
printCupsClient.HandleJobState(http, param, jobStatus, prevousJobStatus);
|
||||
EXPECT_NE(prevousJobStatus, nullptr);
|
||||
delete prevousJobStatus;
|
||||
delete jobStatus;
|
||||
delete param;
|
||||
delete http;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintCupsClientTest_0081
|
||||
* @tc.desc: MonitorJobState
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCupsClientTest, PrintCupsClientTest_0081, TestSize.Level1)
|
||||
{
|
||||
OHOS::Print::PrintCupsClient printCupsClient;
|
||||
CallbackFunc callback = [this](){};
|
||||
PrintJob testJob;
|
||||
testJob.SetJobId(GetDefaultJobId());
|
||||
std::vector<uint32_t> files = {1};
|
||||
testJob.SetFdList(files);
|
||||
OHOS::Print::PrintPageSize pageSize;
|
||||
pageSize.SetId("pgid-1234");
|
||||
testJob.SetPageSize(pageSize);
|
||||
testJob.SetPrinterId("printid-1234");
|
||||
testJob.SetOption(JOB_OPTIONS);
|
||||
JobParameters *jobParams = printCupsClient.BuildJobParameters(testJob);
|
||||
JobMonitorParam *param = new (std::nothrow) JobMonitorParam{jobParams->serviceAbility,
|
||||
jobParams->serviceJobId,
|
||||
1,
|
||||
"ipp://192.168.186.1:631/ipp/print",
|
||||
"DIRECT-PixLab_V1-0105"};
|
||||
|
||||
printCupsClient.MonitorJobState(param, callback);
|
||||
EXPECT_NE(param, nullptr);
|
||||
param = nullptr;
|
||||
printCupsClient.MonitorJobState(param, callback);
|
||||
delete param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintCupsClientTest_0082
|
||||
* @tc.desc: ResumePrinter
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintCupsClientTest, PrintCupsClientTest_0082, TestSize.Level1)
|
||||
{
|
||||
OHOS::Print::PrintCupsClient printCupsClient;
|
||||
std::string printerName = "testPrinterName";
|
||||
EXPECT_EQ(printCupsClient.ResumePrinter(printerName), E_PRINT_SERVER_FAILURE);
|
||||
printCupsClient.printAbility_ = nullptr;
|
||||
EXPECT_EQ(printCupsClient.ResumePrinter(printerName), E_PRINT_SERVER_FAILURE);
|
||||
}
|
||||
|
||||
} // namespace Print
|
||||
} // namespace OHOS
|
@ -2164,4 +2164,15 @@ HWTEST_F(PrintServiceAbilityTest, PrintServiceAbilityTest_0137, TestSize.Level1)
|
||||
info.SetOption(infoJson.dump());
|
||||
EXPECT_EQ(service->UpdatePrinterInSystem(info), E_PRINT_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
HWTEST_F(PrintServiceAbilityTest, PrintServiceAbilityTest_0138, TestSize.Level1)
|
||||
{
|
||||
auto service = std::make_shared<PrintServiceAbility>(PRINT_SERVICE_ID, true);
|
||||
PrinterInfo info;
|
||||
info.SetPrinterId(DEFAULT_EXT_PRINTER_ID);
|
||||
std::string type = "testType";
|
||||
EXPECT_EQ(service->CheckUserIdInEventType(type), false);
|
||||
type = PRINTER_CHANGE_EVENT_TYPE;
|
||||
EXPECT_EQ(service->CheckUserIdInEventType(type), false);
|
||||
}
|
||||
} // namespace OHOS::Print
|
||||
|
@ -152,6 +152,49 @@ HWTEST_F(PrintHttpServerManagerTest, PrintHttpServerManagerTest_004, TestSize.Le
|
||||
printHttpServerManager.StopServer(printerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintHttpServerManagerTest_005
|
||||
* @tc.desc: Verify the AllocatePort function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintHttpServerManagerTest, PrintHttpServerManagerTest_005, TestSize.Level1)
|
||||
{
|
||||
OHOS::Print::PrintHttpServerManager printHttpServerManager;
|
||||
std::string printerName = "HUAWEI PixLab V1-0105";
|
||||
std::shared_ptr<httplib::Server> newServer = std::make_shared<httplib::Server>();
|
||||
EXPECT_NE(newServer, nullptr);
|
||||
std::shared_ptr<PrintHttpRequestProcess> newProcess = std::make_shared<PrintHttpRequestProcess>();
|
||||
EXPECT_NE(newProcess, nullptr);
|
||||
int32_t port = 0;
|
||||
printHttpServerManager.printHttpServerMap[printerName] = newServer;
|
||||
EXPECT_EQ(printHttpServerManager.AllocatePort(newServer, port), true);
|
||||
printHttpServerManager.printHttpPortMap[printerName] = 60000;
|
||||
printHttpServerManager.printHttpProcessMap[printerName] = newProcess;
|
||||
EXPECT_EQ(printHttpServerManager.AllocatePort(newServer, port), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PrintHttpServerManagerTest_006
|
||||
* @tc.desc: Verify the DealUsbDevDetch function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(PrintHttpServerManagerTest, PrintHttpServerManagerTest_006, TestSize.Level1)
|
||||
{
|
||||
OHOS::Print::PrintHttpServerManager printHttpServerManager;
|
||||
std::string printerName = "HUAWEI PixLab V1-0105";
|
||||
std::shared_ptr<httplib::Server> newServer = std::make_shared<httplib::Server>();
|
||||
EXPECT_NE(newServer, nullptr);
|
||||
std::shared_ptr<PrintHttpRequestProcess> newProcess = std::make_shared<PrintHttpRequestProcess>();
|
||||
EXPECT_NE(newProcess, nullptr);
|
||||
printHttpServerManager.printHttpServerMap[printerName] = newServer;
|
||||
printHttpServerManager.printHttpPortMap[printerName] = 60000;
|
||||
printHttpServerManager.printHttpProcessMap[printerName] = newProcess;
|
||||
std::string devStr = "";
|
||||
printHttpServerManager.DealUsbDevDetach(devStr);
|
||||
}
|
||||
|
||||
} // namespace Print
|
||||
} // namespace OHOS
|
||||
#endif // IPPOVERUSB_ENABLE
|
Loading…
Reference in New Issue
Block a user