mirror of
https://gitee.com/openharmony/print_print_fwk
synced 2024-11-23 08:59:47 +00:00
Add sixth 0906 code
Signed-off-by: @chuangda_1 <fangwanning@huawei.com>
This commit is contained in:
parent
7f97cc6ae5
commit
7f4325dc29
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"vector": "cpp"
|
||||
}
|
||||
}
|
@ -53,6 +53,7 @@
|
||||
"//base/print/print/profile:print_sa_profiles"
|
||||
],
|
||||
"test": [
|
||||
"//base/print/print/interfaces/kits/napi/test:unittest"
|
||||
]
|
||||
},
|
||||
"hisysevent_config": [
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "printer_capability.h"
|
||||
|
||||
namespace OHOS::Print {
|
||||
|
||||
using PrintExtCallback = bool (*)();
|
||||
using PrintJobCallback = bool (*)(const PrintJob &);
|
||||
using PrinterCallback = bool (*)(uint32_t);
|
||||
|
@ -16,8 +16,6 @@
|
||||
#ifndef PRINT_MARGIN_H
|
||||
#define PRINT_MARGIN_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace OHOS::Print {
|
||||
class PrintMargin {
|
||||
public:
|
||||
|
@ -16,8 +16,6 @@
|
||||
#ifndef PRINT_RESOLUTION_H
|
||||
#define PRINT_RESOLUTION_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace OHOS::Print {
|
||||
class PrintResolution {
|
||||
public:
|
||||
|
@ -177,16 +177,12 @@ bool PrintExtensionCallbackStub::HandlePrintJobCallback(MessageParcel &data, Mes
|
||||
{
|
||||
PrintJob job;
|
||||
job.BuildFromParcel(data);
|
||||
// dataReadJob(data, job);
|
||||
return OnCallback(job);
|
||||
}
|
||||
|
||||
bool PrintExtensionCallbackStub::HandleCapabilityCallback(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint32_t printerId = data.ReadUint32();
|
||||
// PrinterCapability cap;
|
||||
// OnCallabck(printerId, cap);
|
||||
// cap.BuildParcel(reply);
|
||||
return OnCallback(printerId, reply);
|
||||
}
|
||||
} // namespace OHOS::Print
|
||||
|
@ -201,9 +201,8 @@ void PrintJob::ConvertToParcel(MessageParcel &reply) const
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
GetFiles(files);
|
||||
uint32_t fileLength = files.size();
|
||||
reply.WriteUint32(fileLength);
|
||||
for (uint32_t i = 0; i < fileLength; i++) {
|
||||
reply.WriteUint32((uint32_t)files.size());
|
||||
for (uint32_t i = 0; i < (uint32_t)files.size(); i++) {
|
||||
reply.WriteString(files[i]);
|
||||
}
|
||||
reply.WriteUint32(GetJobId());
|
||||
@ -218,9 +217,8 @@ void PrintJob::ConvertToParcel(MessageParcel &reply) const
|
||||
|
||||
std::vector<uint32_t> pages;
|
||||
range.GetPages(pages);
|
||||
uint32_t pageLength = pages.size();
|
||||
reply.WriteUint32(pageLength);
|
||||
for (uint32_t i = 0; i < pageLength; i++) {
|
||||
reply.WriteUint32((uint32_t)pages.size());
|
||||
for (uint32_t i = 0; i < (uint32_t)pages.size(); i++) {
|
||||
reply.WriteUint32(pages[i]);
|
||||
}
|
||||
|
||||
@ -254,13 +252,33 @@ void PrintJob::ConvertToParcel(MessageParcel &reply) const
|
||||
reply.WriteUint32(range.GetEndPage());
|
||||
|
||||
range.GetPages(pages);
|
||||
uint32_t previewPageLength = pages.size();
|
||||
reply.WriteUint32(previewPageLength);
|
||||
for (uint32_t i = 0; i < previewPageLength; i++) {
|
||||
reply.WriteUint32((uint32_t)pages.size());
|
||||
for (uint32_t i = 0; i < (uint32_t)pages.size(); i++) {
|
||||
reply.WriteUint32(pages[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void PrintJob::SetBuild(MessageParcel &data)
|
||||
{
|
||||
PrintPageSize pageSize;
|
||||
pageSize.SetId(data.ReadString());
|
||||
pageSize.SetName(data.ReadString());
|
||||
pageSize.SetWidth(data.ReadUint32());
|
||||
pageSize.SetHeight(data.ReadUint32());
|
||||
SetPageSize(pageSize);
|
||||
|
||||
SetIsLandscape(data.ReadUint32());
|
||||
SetColorMode(data.ReadUint32());
|
||||
SetDuplexMode(data.ReadUint32());
|
||||
|
||||
PrintMargin minMargin;
|
||||
minMargin.SetTop(data.ReadUint32());
|
||||
minMargin.SetBottom(data.ReadUint32());
|
||||
minMargin.SetLeft(data.ReadUint32());
|
||||
minMargin.SetRight(data.ReadUint32());
|
||||
SetMargin(minMargin);
|
||||
}
|
||||
|
||||
void PrintJob::BuildFromParcel(MessageParcel &data)
|
||||
{
|
||||
uint32_t fileLength = data.ReadUint32();
|
||||
@ -279,35 +297,16 @@ void PrintJob::BuildFromParcel(MessageParcel &data)
|
||||
range.SetStartPage(data.ReadUint32());
|
||||
range.SetEndPage(data.ReadUint32());
|
||||
uint32_t pageLength = data.ReadUint32();
|
||||
if (pageLength > 0) {
|
||||
std::vector<uint32_t> rangePages;
|
||||
for (index = 0; index < pageLength; index++) {
|
||||
rangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(rangePages);
|
||||
std::vector<uint32_t> rangePages;
|
||||
for (index = 0; index < pageLength; index++) {
|
||||
rangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(rangePages);
|
||||
SetPageRange(range);
|
||||
|
||||
SetIsSequential(data.ReadUint32());
|
||||
|
||||
PrintPageSize pageSize;
|
||||
pageSize.SetId(data.ReadString());
|
||||
pageSize.SetName(data.ReadString());
|
||||
pageSize.SetWidth(data.ReadUint32());
|
||||
pageSize.SetHeight(data.ReadUint32());
|
||||
SetPageSize(pageSize);
|
||||
|
||||
SetIsLandscape(data.ReadUint32());
|
||||
SetColorMode(data.ReadUint32());
|
||||
SetDuplexMode(data.ReadUint32());
|
||||
|
||||
PrintMargin minMargin;
|
||||
minMargin.SetTop(data.ReadUint32());
|
||||
minMargin.SetBottom(data.ReadUint32());
|
||||
minMargin.SetLeft(data.ReadUint32());
|
||||
minMargin.SetRight(data.ReadUint32());
|
||||
SetMargin(minMargin);
|
||||
|
||||
SetBuild(data);
|
||||
PreviewAttribute previewAttr;
|
||||
|
||||
previewAttr.SetResult(data.ReadString());
|
||||
@ -315,18 +314,53 @@ void PrintJob::BuildFromParcel(MessageParcel &data)
|
||||
range.SetStartPage(data.ReadUint32());
|
||||
range.SetEndPage(data.ReadUint32());
|
||||
uint32_t previewPageLength = data.ReadUint32();
|
||||
if (previewPageLength > 0) {
|
||||
std::vector<uint32_t> previewRangePages;
|
||||
for (index = 0; index < previewPageLength; index++) {
|
||||
previewRangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(previewRangePages);
|
||||
std::vector<uint32_t> previewRangePages;
|
||||
for (index = 0; index < previewPageLength; index++) {
|
||||
previewRangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(previewRangePages);
|
||||
previewAttr.SetPreviewRange(range);
|
||||
SetPreview(previewAttr);
|
||||
Dump();
|
||||
}
|
||||
|
||||
void PrintJob::SetSubPageRange(napi_env env, napi_value &subPageRange)
|
||||
{
|
||||
napi_create_object(env, &subPageRange);
|
||||
NapiPrintUtils::SetUint32Property(env, subPageRange, "startPage", pageRange_.GetStartPage());
|
||||
NapiPrintUtils::SetUint32Property(env, subPageRange, "endPage", pageRange_.GetEndPage());
|
||||
napi_value arrPreviewPages;
|
||||
status = napi_create_array(env, &arrPreviewPages);
|
||||
PrintRange previewPrintRange;
|
||||
std::vector<uint32_t> previewRangePages;
|
||||
preview_.GetPreviewRange(previewPrintRange);
|
||||
previewPrintRange.GetPages(previewRangePages);
|
||||
uint32_t arrPreviewPagesLength = previewRangePages.size();
|
||||
|
||||
for (uint32_t i = 0; i < arrPreviewPagesLength; i++) {
|
||||
napi_value value;
|
||||
napi_create_uint32(env, previewRangePages[i], &value);
|
||||
status = napi_set_element(env, arrPreviewPages, i, value);
|
||||
}
|
||||
napi_set_named_property(env, subPageRange, "files", arrPreviewPages);
|
||||
}
|
||||
|
||||
void PrintJob::SetPageSize(napi_env env, napi_value &pageSize)
|
||||
{
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, pageSize, "id", pageSize_.GetId());
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, pageSize, "name", pageSize_.GetName().c_str());
|
||||
NapiPrintUtils::SetUint32Property(env, pageSize, "width", pageSize_.GetWidth());
|
||||
NapiPrintUtils::SetUint32Property(env, pageSize, "height", pageSize_.GetHeight());
|
||||
}
|
||||
|
||||
void PrintJob::SetMargin(napi_env env, napi_value &margin)
|
||||
{
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "top", margin_.GetTop());
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "bottom", margin_.GetBottom());
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "left", margin_.GetLeft());
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "right", margin_.GetRight());
|
||||
}
|
||||
|
||||
void PrintJob::ConvertToJs(napi_env env, napi_value *result) const
|
||||
{
|
||||
napi_create_object(env, result);
|
||||
@ -364,10 +398,7 @@ void PrintJob::ConvertToJs(napi_env env, napi_value *result) const
|
||||
NapiPrintUtils::SetUint32Property(env, *result, "isSequential", GetIsSequential());
|
||||
napi_value pageSize;
|
||||
napi_create_object(env, &pageSize);
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, pageSize, "id", pageSize_.GetId());
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, pageSize, "name", pageSize_.GetName().c_str());
|
||||
NapiPrintUtils::SetUint32Property(env, pageSize, "width", pageSize_.GetWidth());
|
||||
NapiPrintUtils::SetUint32Property(env, pageSize, "height", pageSize_.GetHeight());
|
||||
SetPageSize(env, pageSize);
|
||||
|
||||
NapiPrintUtils::SetUint32Property(env, *result, "isLandscape", GetIsLandscape());
|
||||
NapiPrintUtils::SetUint32Property(env, *result, "colorMode", GetColorMode());
|
||||
@ -375,34 +406,16 @@ void PrintJob::ConvertToJs(napi_env env, napi_value *result) const
|
||||
|
||||
napi_value margin;
|
||||
napi_create_object(env, &margin);
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "top", margin_.GetTop());
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "bottom", margin_.GetBottom());
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "left", margin_.GetLeft());
|
||||
NapiPrintUtils::SetUint32Property(env, margin, "right", margin_.GetRight());
|
||||
SetMargin(env, margin);
|
||||
|
||||
napi_value preview;
|
||||
napi_create_object(env, &preview);
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, preview, "result", preview_.GetResult().c_str());
|
||||
|
||||
napi_value subPageRange;
|
||||
napi_create_object(env, &subPageRange);
|
||||
NapiPrintUtils::SetUint32Property(env, subPageRange, "startPage", pageRange_.GetStartPage());
|
||||
NapiPrintUtils::SetUint32Property(env, subPageRange, "endPage", pageRange_.GetEndPage());
|
||||
napi_value arrPreviewPages;
|
||||
status = napi_create_array(env, &arrPreviewPages);
|
||||
PrintRange previewPrintRange;
|
||||
std::vector<uint32_t> previewRangePages;
|
||||
preview_.GetPreviewRange(previewPrintRange);
|
||||
previewPrintRange.GetPages(previewRangePages);
|
||||
uint32_t arrPreviewPagesLength = previewRangePages.size();
|
||||
|
||||
for (uint32_t i = 0; i < arrPreviewPagesLength; i++) {
|
||||
napi_value value;
|
||||
napi_create_uint32(env, previewRangePages[i], &value);
|
||||
status = napi_set_element(env, arrPreviewPages, i, value);
|
||||
}
|
||||
napi_set_named_property(env, subPageRange, "files", arrPreviewPages);
|
||||
SetSubPageRange(env, subPageRange);
|
||||
napi_set_named_property(env, preview, "pageRange", subPageRange);
|
||||
|
||||
napi_set_named_property(env, *result, "pageRange", pageRange);
|
||||
napi_set_named_property(env, *result, "pageSize", pageSize);
|
||||
napi_set_named_property(env, *result, "margin", margin);
|
||||
|
@ -116,5 +116,4 @@ void PrintPageSize::Dump()
|
||||
PRINT_HILOGD("width_ = %{public}d", width_);
|
||||
PRINT_HILOGD("height_ = %{public}d", height_);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Print
|
||||
|
@ -50,12 +50,7 @@ void PrintProgressNotify::WriteInfoJsObject(napi_env env, PrinterInfo info, napi
|
||||
PRINT_HILOGD("");
|
||||
}
|
||||
|
||||
void PrintProgressNotify::WriteJobJsObject(napi_env env, PrintJob job, napi_value *result)
|
||||
{
|
||||
PRINT_HILOGD("");
|
||||
}
|
||||
|
||||
void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
void PrintProgressNotify::notifyDataBase(NotifyData *notifyData, MessageParcel &data)
|
||||
{
|
||||
PRINT_HILOGD("Progress callback in");
|
||||
uv_loop_s *loop = nullptr;
|
||||
@ -70,23 +65,24 @@ void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
return;
|
||||
}
|
||||
|
||||
NotifyData *notifyData = GetNotifyData();
|
||||
notifyData = GetNotifyData();
|
||||
notifyData->env = env_;
|
||||
notifyData->ref = ref_;
|
||||
notifyData->type = type_;
|
||||
notifyData->objectType = data.ReadString();
|
||||
notifyData->firstArgv = data.ReadUint32();
|
||||
if ("PrinterInfo" == notifyData->objectType) {
|
||||
PrinterInfo info;
|
||||
DataReadInfo(info, data);
|
||||
notifyData->secondArgv = info;
|
||||
} else if ("PrintJob" == notifyData->objectType) {
|
||||
PrintJob job;
|
||||
DataReadJob(job, data);
|
||||
notifyData->thirdArgv = job;
|
||||
if (notifyData->objectType == "PrinterInfo") {
|
||||
DataReadInfo(notifyData->secondArgv, data);
|
||||
} else if (notifyData->objectType == "PrintJob") {
|
||||
DataReadJob(notifyData->thirdArgv, data);
|
||||
}
|
||||
work->data = notifyData;
|
||||
}
|
||||
|
||||
void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
{
|
||||
NotifyData *notifyData = nullptr;
|
||||
notifyDataBase(notifyData, data);
|
||||
work->data = notifyData;
|
||||
uv_queue_work(
|
||||
loop, work, [](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int statusInt) {
|
||||
@ -97,16 +93,16 @@ void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
napi_value callbackFunc = nullptr;
|
||||
napi_get_reference_value(notifyData->env, notifyData->ref, &callbackFunc);
|
||||
napi_value result = nullptr;
|
||||
napi_value callbackVal[NapiPrintUtils::ARGC_TWO] = { 0 };
|
||||
napi_create_uint32(notifyData->env, notifyData->firstArgv, &callbackVal[NapiPrintUtils::INDEX_ZERO]);
|
||||
if ("PrinterInfo" == notifyData->objectType) {
|
||||
napi_value callbackVal[NapiPrintUtils::TWO_ARG] = { 0 };
|
||||
napi_create_uint32(notifyData->env, notifyData->firstArgv, &callbackVal[NapiPrintUtils::FIRST_ARGV]);
|
||||
if (notifyData->objectType == "PrinterInfo") {
|
||||
WriteInfoJsObject(
|
||||
notifyData->env, notifyData->secondArgv, &callbackVal[NapiPrintUtils::INDEX_ONE]);
|
||||
} else if ("PrintJob" == notifyData->objectType) {
|
||||
WriteJobJsObject(notifyData->env, notifyData->thirdArgv, &callbackVal[NapiPrintUtils::INDEX_ONE]);
|
||||
notifyData->env, notifyData->secondArgv, &callbackVal[NapiPrintUtils::SECOND_ARGV]);
|
||||
} else if (notifyData->objectType == "PrintJob") {
|
||||
WriteJobJsObject(notifyData->env, notifyData->thirdArgv, &callbackVal[NapiPrintUtils::SECOND_ARGV]);
|
||||
}
|
||||
napi_call_function(
|
||||
notifyData->env, nullptr, callbackFunc, NapiPrintUtils::ARGC_TWO, callbackVal, &result);
|
||||
notifyData->env, nullptr, callbackFunc, NapiPrintUtils::TWO_ARG, callbackVal, &result);
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
@ -116,5 +112,4 @@ void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace OHOS::Print
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "print_service_proxy.h"
|
||||
#include "napi_print_utils.h"
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -80,7 +81,7 @@ bool PrintServiceProxy::QueryAllExtension(std::vector<PrintExtensionInfo> &array
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
data.WriteInterfaceToken(PrintServiceProxy::GetDescriptor());
|
||||
data.WriteUint32(5);
|
||||
data.WriteUint32(NapiPrintUtil::ARGC_FIVE);
|
||||
PRINT_HILOGD("PrintServiceProxy ChangeTaskPriority started.");
|
||||
bool ret = Remote()->SendRequest(CMD_QUERYALLEXTENSION, data, reply, option);
|
||||
if (ret != ERR_NONE) {
|
||||
@ -414,9 +415,8 @@ void PrintServiceProxy::BuildParcelFromPrintJob(MessageParcel &data, const Print
|
||||
|
||||
std::vector<std::string> files;
|
||||
jobinfo.GetFiles(files);
|
||||
uint32_t fileLength = files.size();
|
||||
data.WriteUint32(fileLength);
|
||||
for (uint32_t i = 0; i < fileLength; i++) {
|
||||
data.WriteUint32(files.size());
|
||||
for (uint32_t i = 0; i < files.size(); i++) {
|
||||
data.WriteString(files[i]);
|
||||
}
|
||||
data.WriteUint32(jobinfo.GetJobId());
|
||||
@ -431,8 +431,7 @@ void PrintServiceProxy::BuildParcelFromPrintJob(MessageParcel &data, const Print
|
||||
|
||||
std::vector<uint32_t> pages;
|
||||
range.GetPages(pages);
|
||||
uint32_t pageLength = pages.size();
|
||||
data.WriteUint32(pageLength);
|
||||
data.WriteUint32(pages.size());
|
||||
for (uint32_t i = 0; i < pageLength; i++) {
|
||||
data.WriteUint32(pages[i]);
|
||||
}
|
||||
@ -467,9 +466,8 @@ void PrintServiceProxy::BuildParcelFromPrintJob(MessageParcel &data, const Print
|
||||
data.WriteUint32(range.GetEndPage());
|
||||
|
||||
range.GetPages(pages);
|
||||
uint32_t previewPageLength = pages.size();
|
||||
data.WriteUint32(previewPageLength);
|
||||
for (uint32_t i = 0; i < previewPageLength; i++) {
|
||||
data.WriteUint32(pages.size());
|
||||
for (uint32_t i = 0; i < pages.size(); i++) {
|
||||
data.WriteUint32(pages[i]);
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
NativeValue* CreateJsPrintExtensionContext(NativeEngine& engine,
|
||||
std::shared_ptr<PrintExtensionContext> context);
|
||||
|
||||
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // JS_PRINT_EXTENSION_CONTEXT_H
|
@ -33,7 +33,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
||||
JsPrintExtension *JsPrintExtension::jsExtension_ = nullptr;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::Print;
|
||||
|
@ -32,7 +32,6 @@ using namespace OHOS::Print;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
||||
class JsPrintExtensionContext final {
|
||||
public:
|
||||
explicit JsPrintExtensionContext(const std::shared_ptr<PrintExtensionContext> &context) : context_(context) {}
|
||||
@ -302,12 +301,13 @@ private:
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(
|
||||
reinterpret_cast<napi_env>(&engine), reinterpret_cast<napi_value>(info.argv[NapiPrintUtils::INDEX_ZERO]), want);
|
||||
PRINT_HILOGD("%{public}s bundlename:%{public}s abilityname:%{public}s", __func__, want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
PRINT_HILOGD("%{public}s bundlename:%{public}s abilityname:%{public}s", __func__,
|
||||
want.GetBundle().c_str(),want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
int32_t accountId = 0;
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(
|
||||
reinterpret_cast<napi_env>(&engine), reinterpret_cast<napi_value>(info.argv[NapiPrintUtils::INDEX_ONE]), accountId)) {
|
||||
reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[NapiPrintUtils::INDEX_ONE]), accountId)) {
|
||||
PRINT_HILOGD("%{public}s called, the second parameter is invalid.", __func__);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
@ -397,7 +397,8 @@ private:
|
||||
: task.Reject(engine, CreateJsError(engine, errcode, "Disconnect Ability failed."));
|
||||
};
|
||||
|
||||
NativeValue *lastParam = (info.argc == NapiPrintUtils::ARGC_ONE) ? nullptr : info.argv[NapiPrintUtils::INDEX_ONE];
|
||||
NativeValue *lastParam = (info.argc ==
|
||||
NapiPrintUtils::ARGC_ONE) ? nullptr : info.argv[NapiPrintUtils::INDEX_ONE];
|
||||
NativeValue *result = nullptr;
|
||||
AsyncTask::Schedule("PrintExtensionContext::OnDisconnectAbility", engine,
|
||||
CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
|
@ -61,7 +61,7 @@ private:
|
||||
|
||||
struct OperationContext : public AsyncCall::Context {
|
||||
int32_t dummy = 0;
|
||||
std::vector<PrintExtensionInfo> arrayPrinterExtensionInfo;
|
||||
std::vector<PrintExtensionInfo> arrExtInfo;
|
||||
std::vector<uint32_t> extensionList;
|
||||
uint32_t state;
|
||||
PrinterInfo info;
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "printer_info.h"
|
||||
|
||||
namespace OHOS::Print {
|
||||
class ParseType {
|
||||
class PrintParseType {
|
||||
public:
|
||||
static bool ParseInfo(napi_env env, napi_value InfoValue, PrinterInfo &Info);
|
||||
static bool ParseCapability(napi_env env, napi_value InfoValue, PrinterCapability &capability);
|
||||
@ -43,15 +43,19 @@ public:
|
||||
|
||||
static bool ParseInfoParam(napi_env env, napi_value InfoValue, PrinterInfo &info);
|
||||
static bool ParseCapParam(napi_env env, napi_value InfoValue, PrinterCapability &capability);
|
||||
static bool ParseArrPrintResolution(napi_env env, napi_value capValue, PrinterCapability &capability)
|
||||
static bool ParsePageSizeParam(napi_env env, napi_value capValue, PrintPageSize &PrintPageSize);
|
||||
static bool ParseResolutionParam(napi_env env, napi_value reValue, PrintResolution &PrintResolution);
|
||||
static bool ParseMarginParam(napi_env env, napi_value marginValue, PrintMargin &PrintMargin);
|
||||
static bool ParseJobParam(napi_env env, napi_value jobValue, PrintJob &printJob);
|
||||
static bool ParseArrFiles(napi_env env, napi_value jobValue, PrintJob &printJob);
|
||||
static bool ParseHasNum(napi_env env, napi_value jobValue, PrintJob &printJob);
|
||||
static bool ParseHasObj(napi_env env, napi_value jobValue, PrintJob &printJob);
|
||||
static bool ParsePreviewAttributeParam(napi_env env, napi_value preAttValue, PreviewAttribute &preAtt);
|
||||
static bool ParseRangeParam(napi_env env, napi_value preAttValue, PrintRange &range);
|
||||
|
||||
private:
|
||||
struct ParseTypeContext : public AsyncCall::Context {};
|
||||
struct PrintParseTypeContext : public AsyncCall::Context {};
|
||||
};
|
||||
} // namespace OHOS::Print
|
||||
#endif // PARSE_TYPE_H
|
@ -38,45 +38,33 @@ napi_value NapiInnerPrint::QueryExtensionInfo(napi_env env, napi_callback_info i
|
||||
auto context = std::make_shared<OperationContext>();
|
||||
auto input = [context](napi_env env, size_t argc, napi_value *argv, napi_value self) -> napi_status {
|
||||
NAPI_ASSERT_BASE(env, argc == NapiPrintUtils::ARGC_ZERO, " should 0 parameter!", napi_invalid_arg);
|
||||
PRINT_HILOGD("input over---->");
|
||||
return napi_ok;
|
||||
};
|
||||
auto output = [context](napi_env env, napi_value *result) -> napi_status {
|
||||
PRINT_HILOGD("ouput enter---->");
|
||||
napi_status status = napi_create_array(env, result);
|
||||
uint32_t PrinterExtensionInfoLength = context->arrayPrinterExtensionInfo.size();
|
||||
for (uint32_t i = 0; i < PrinterExtensionInfoLength; i++) {
|
||||
PRINT_HILOGD(
|
||||
"PrintServiceProxy, ExtensionId = %{public}d", context->arrayPrinterExtensionInfo[i].GetExtensionId());
|
||||
PRINT_HILOGD(
|
||||
"PrintServiceProxy, VendorId = %{public}d", context->arrayPrinterExtensionInfo[i].GetVendorId());
|
||||
PRINT_HILOGD("PrintServiceProxy, VendorName = %{public}s",
|
||||
context->arrayPrinterExtensionInfo[i].GetVendorName().c_str());
|
||||
PRINT_HILOGD(
|
||||
"PrintServiceProxy, VendorIcon = %{public}d", context->arrayPrinterExtensionInfo[i].GetVendorIcon());
|
||||
PRINT_HILOGD(
|
||||
"PrintServiceProxy, Version = %{public}s", context->arrayPrinterExtensionInfo[i].GetVersion().c_str());
|
||||
uint32_t extInfoLength = context->arrExtInfo.size();
|
||||
for (uint32_t i = 0; i < extInfoLength; i++) {
|
||||
PRINT_HILOGD("ExtInfo, ExtensionId = %{public}d", context->arrExtInfo[i].GetExtensionId());
|
||||
PRINT_HILOGD("ExtInfo, VendorId = %{public}d", context->arrExtInfo[i].GetVendorId());
|
||||
PRINT_HILOGD("ExtInfo, VendorName = %{public}s",context->arrExtInfo[i].GetVendorName().c_str());
|
||||
PRINT_HILOGD("ExtInfo, VendorIcon = %{public}d", context->arrExtInfo[i].GetVendorIcon());
|
||||
PRINT_HILOGD("ExtInfo, Version = %{public}s", context->arrExtInfo[i].GetVersion().c_str());
|
||||
|
||||
napi_value PrinterInfo;
|
||||
napi_create_object(env, &PrinterInfo);
|
||||
NapiPrintUtils::SetUint32Property(
|
||||
env, PrinterInfo, "extensionId", context->arrayPrinterExtensionInfo[i].GetExtensionId());
|
||||
NapiPrintUtils::SetUint32Property(
|
||||
env, PrinterInfo, "vendorId", context->arrayPrinterExtensionInfo[i].GetVendorId());
|
||||
NapiPrintUtils::SetStringPropertyUtf8(
|
||||
env, PrinterInfo, "vendorName", context->arrayPrinterExtensionInfo[i].GetVendorName().c_str());
|
||||
NapiPrintUtils::SetUint32Property(
|
||||
env, PrinterInfo, "vendorIcon", context->arrayPrinterExtensionInfo[i].GetVendorIcon());
|
||||
NapiPrintUtils::SetStringPropertyUtf8(
|
||||
env, PrinterInfo, "version", context->arrayPrinterExtensionInfo[i].GetVersion().c_str());
|
||||
NapiPrintUtils::SetUint32Property(env, PrinterInfo, "extensionId", context->arrExtInfo[i].GetExtensionId());
|
||||
NapiPrintUtils::SetUint32Property(env, PrinterInfo, "vendorId", context->arrExtInfo[i].GetVendorId());
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, PrinterInfo, "vendorName", context->arrExtInfo[i].GetVendorName().c_str());
|
||||
NapiPrintUtils::SetUint32Property(env, PrinterInfo, "vendorIcon", context->arrExtInfo[i].GetVendorIcon());
|
||||
NapiPrintUtils::SetStringPropertyUtf8(env, PrinterInfo, "version", context->arrExtInfo[i].GetVersion().c_str());
|
||||
status = napi_set_element(env, *result, i, PrinterInfo);
|
||||
}
|
||||
PRINT_HILOGD("output ---- status[%{public}d]", status);
|
||||
PRINT_HILOGD("ouput over---->");
|
||||
return napi_ok;
|
||||
};
|
||||
auto exec = [context](AsyncCall::Context *ctx) {
|
||||
PRINT_HILOGD("exec enter---->");
|
||||
context->result = PrintManagerClient::GetInstance()->QueryAllExtension(context->arrayPrinterExtensionInfo);
|
||||
context->result = PrintManagerClient::GetInstance()->QueryAllExtension(context->arrExtInfo);
|
||||
if (context->result == true) {
|
||||
PRINT_HILOGD("exec over---->");
|
||||
context->status = napi_ok;
|
||||
@ -264,7 +252,7 @@ napi_value NapiInnerPrint::StartPrintJob(napi_env env, napi_callback_info info)
|
||||
NAPI_ASSERT_BASE(env, argc == 1, " should 1 parameter!", napi_invalid_arg);
|
||||
napi_value value = argv[NapiPrintUtils::INDEX_ZERO];
|
||||
PrintJob printJob;
|
||||
if (!ParseType::ParseJob(env, value, printJob)) {
|
||||
if (!PrintParseType::ParseJob(env, value, printJob)) {
|
||||
PRINT_HILOGD("ParseJob type error!");
|
||||
}
|
||||
context->printStartJob = printJob;
|
||||
@ -303,7 +291,7 @@ napi_value NapiInnerPrint::CancelPrintJob(napi_env env, napi_callback_info info)
|
||||
NAPI_ASSERT_BASE(env, argc == 1, " should 1 parameter!", napi_invalid_arg);
|
||||
napi_value value = argv[NapiPrintUtils::INDEX_ZERO];
|
||||
PrintJob printJob;
|
||||
if (!ParseType::ParseJob(env, value, printJob)) {
|
||||
if (!PrintParseType::ParseJob(env, value, printJob)) {
|
||||
PRINT_HILOGD("ParseJob type error!");
|
||||
}
|
||||
context->printCancelJob = printJob;
|
||||
@ -342,7 +330,7 @@ napi_value NapiInnerPrint::RequestPreview(napi_env env, napi_callback_info info)
|
||||
NAPI_ASSERT_BASE(env, argc == 1, " should 1 parameter!", napi_invalid_arg);
|
||||
napi_value value = argv[NapiPrintUtils::INDEX_ZERO];
|
||||
PrintJob printJob;
|
||||
if (!ParseType::ParseJob(env, value, printJob)) {
|
||||
if (!PrintParseType::ParseJob(env, value, printJob)) {
|
||||
PRINT_HILOGD("ParseJob type error!");
|
||||
}
|
||||
context->printReqPreviewJob = printJob;
|
||||
|
@ -49,7 +49,7 @@ napi_value NapiPrintExt::AddPrinters(napi_env env, napi_callback_info info)
|
||||
for (uint32_t i = 0; i < result_size; i++) {
|
||||
napi_value value;
|
||||
napi_get_element(env, array, i, &value);
|
||||
if (!ParseType::ParseInfo(env, value, info_)) {
|
||||
if (!PrintParseType::ParseInfo(env, value, info_)) {
|
||||
PRINT_HILOGD("PrinterInfo is format error!");
|
||||
}
|
||||
context->printAddInfoVector.push_back(info_);
|
||||
@ -99,7 +99,7 @@ napi_value NapiPrintExt::RemovePrinters(napi_env env, napi_callback_info info)
|
||||
for (uint32_t i = 0; i < result_size; i++) {
|
||||
napi_value value;
|
||||
napi_get_element(env, array, i, &value);
|
||||
if (!ParseType::ParseInfo(env, value, info_)) {
|
||||
if (!PrintParseType::ParseInfo(env, value, info_)) {
|
||||
PRINT_HILOGD("PrinterInfo is format error!");
|
||||
}
|
||||
context->printRemoveInfoVector.push_back(info_);
|
||||
|
@ -71,7 +71,7 @@ static constexpr const char *PARAM_RANGE_STARTPAGE = "startPage";
|
||||
static constexpr const char *PARAM_RANGE_ENDPAGE = "endPage";
|
||||
static constexpr const char *PARAM_RANGE_PAGES = "pages";
|
||||
|
||||
bool ParseType::ParseInfo(napi_env env, napi_value InfoValue, PrinterInfo &info)
|
||||
bool PrintParseType::ParseInfo(napi_env env, napi_value InfoValue, PrinterInfo &info)
|
||||
{
|
||||
if (!ParseInfoParam(env, InfoValue, info)) {
|
||||
PRINT_HILOGD("ParseInfoParam is error!");
|
||||
@ -91,7 +91,7 @@ bool ParseType::ParseInfo(napi_env env, napi_value InfoValue, PrinterInfo &info)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseCapability(napi_env env, napi_value capValue, PrinterCapability &capability)
|
||||
bool PrintParseType::ParseCapability(napi_env env, napi_value capValue, PrinterCapability &capability)
|
||||
{
|
||||
if (!ParseCapParam(env, capValue, capability)) {
|
||||
PRINT_HILOGD("ParseCapParam is error!");
|
||||
@ -104,7 +104,7 @@ bool ParseType::ParseCapability(napi_env env, napi_value capValue, PrinterCapabi
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParsePageSize(napi_env env, napi_value capValue, PrintPageSize &pageSize)
|
||||
bool PrintParseType::ParsePageSize(napi_env env, napi_value capValue, PrintPageSize &pageSize)
|
||||
{
|
||||
if (!ParsePageSizeParam(env, capValue, pageSize)) {
|
||||
PRINT_HILOGD("ParsePageSizeParam is error!");
|
||||
@ -122,7 +122,7 @@ bool ParseType::ParsePageSize(napi_env env, napi_value capValue, PrintPageSize &
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseResolution(napi_env env, napi_value reValue, PrintResolution &resolution)
|
||||
bool PrintParseType::ParseResolution(napi_env env, napi_value reValue, PrintResolution &resolution)
|
||||
{
|
||||
if (!ParseResolutionParam(env, reValue, resolution)) {
|
||||
PRINT_HILOGD("ParseResolutionParam is error!");
|
||||
@ -138,7 +138,7 @@ bool ParseType::ParseResolution(napi_env env, napi_value reValue, PrintResolutio
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseMargin(napi_env env, napi_value marginValue, PrintMargin &margin)
|
||||
bool PrintParseType::ParseMargin(napi_env env, napi_value marginValue, PrintMargin &margin)
|
||||
{
|
||||
if (!ParseMarginParam(env, marginValue, margin)) {
|
||||
PRINT_HILOGD("ParseResolutionParam is error!");
|
||||
@ -157,7 +157,7 @@ bool ParseType::ParseMargin(napi_env env, napi_value marginValue, PrintMargin &m
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseJob(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
bool PrintParseType::ParseJob(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
{
|
||||
if (!ParseJobParam(env, jobValue, printJob)) {
|
||||
PRINT_HILOGD("ParseJobParam is error!");
|
||||
@ -172,10 +172,16 @@ bool ParseType::ParseJob(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
PRINT_HILOGD("printJob_value GetPrinterId value is %{public}d", printJob.GetPrinterId());
|
||||
PRINT_HILOGD("printJob_value GetJobState value is %{public}d", printJob.GetJobState());
|
||||
PRINT_HILOGD("printJob_value GetCopyNumber value is %{public}d", printJob.GetCopyNumber());
|
||||
PRINT_HILOGD(
|
||||
"printJob_value SetIsLandscape value is %{public}s", printJob.GetIsLandscape() ? "true" : "false");
|
||||
PRINT_HILOGD(
|
||||
"printJob_value SetIsLandscape value is %{public}s", printJob.GetIsLandscape() ? "true" : "false");
|
||||
PRINT_HILOGD("printJob_value ColorMode value is %{public}d", printJob.GetIsSequential());
|
||||
PRINT_HILOGD("printJob_value DuplexMode value is %{public}d", printJob.GetDuplexMode());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParsePreviewAttribute(napi_env env, napi_value preAttValue, PreviewAttribute &preAtt)
|
||||
bool PrintParseType::ParsePreviewAttribute(napi_env env, napi_value preAttValue, PreviewAttribute &preAtt)
|
||||
{
|
||||
if (!ParsePreviewAttributeParam(env, preAttValue, preAtt)) {
|
||||
PRINT_HILOGD("ParsePreviewAttributeParam is error!");
|
||||
@ -186,7 +192,7 @@ bool ParseType::ParsePreviewAttribute(napi_env env, napi_value preAttValue, Prev
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseRange(napi_env env, napi_value rangeValue, PrintRange &range)
|
||||
bool PrintParseType::ParseRange(napi_env env, napi_value rangeValue, PrintRange &range)
|
||||
{
|
||||
if (!ParseRangeParam(env, rangeValue, range)) {
|
||||
PRINT_HILOGD("ParseRangeParam is error!");
|
||||
@ -199,7 +205,7 @@ bool ParseType::ParseRange(napi_env env, napi_value rangeValue, PrintRange &rang
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseInfoParam(napi_env env, napi_value InfoValue, PrinterInfo &info)
|
||||
bool PrintParseType::ParseInfoParam(napi_env env, napi_value InfoValue, PrinterInfo &info)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, InfoValue, PARAM_INFO_PRINTID);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_number) {
|
||||
@ -241,7 +247,7 @@ bool ParseType::ParseInfoParam(napi_env env, napi_value InfoValue, PrinterInfo &
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseCapParam(napi_env env, napi_value capValue, PrinterCapability &capability)
|
||||
bool PrintParseType::ParseCapParam(napi_env env, napi_value capValue, PrinterCapability &capability)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_CAPABILITY_MINMARGIN);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_object) {
|
||||
@ -284,6 +290,28 @@ bool ParseType::ParseCapParam(napi_env env, napi_value capValue, PrinterCapabili
|
||||
capability.SetPageSize(pageSizeList);
|
||||
}
|
||||
|
||||
if(!ParseArrPrintResolution(env, capValue, capability)){
|
||||
PRINT_HILOGD("error Arr PrintResolution");
|
||||
return false;
|
||||
}
|
||||
|
||||
napi_value param_four = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_CAPABILITY_COLORMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_four) != napi_number) {
|
||||
PRINT_HILOGD("error param_four");
|
||||
return false;
|
||||
}
|
||||
napi_value param_five = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_CAPABILITY_DUPLEXMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_five) != napi_number) {
|
||||
// ParseCapParam()
|
||||
PRINT_HILOGD("error param_five");
|
||||
return false;
|
||||
}
|
||||
auto names = NapiPrintUtils::GetPropertyNames(env, capValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrintParseType::ParseArrPrintResolution(napi_env env, napi_value capValue, PrinterCapability &capability)
|
||||
{
|
||||
napi_value param_three = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_CAPABILITY_RESOLUTION);
|
||||
if (NapiPrintUtils::GetValueType(env, param_three) != napi_object) {
|
||||
PRINT_HILOGD("error param_three");
|
||||
@ -310,22 +338,9 @@ bool ParseType::ParseCapParam(napi_env env, napi_value capValue, PrinterCapabili
|
||||
}
|
||||
capability.SetResolution(resolutionList);
|
||||
}
|
||||
napi_value param_four = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_CAPABILITY_COLORMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_four) != napi_number) {
|
||||
PRINT_HILOGD("error param_four");
|
||||
return false;
|
||||
}
|
||||
napi_value param_five = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_CAPABILITY_DUPLEXMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_five) != napi_number) {
|
||||
// ParseCapParam()
|
||||
PRINT_HILOGD("error param_five");
|
||||
return false;
|
||||
}
|
||||
auto names = NapiPrintUtils::GetPropertyNames(env, capValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParsePageSizeParam(napi_env env, napi_value capValue, PrintPageSize &pageSize)
|
||||
bool PrintParseType::ParsePageSizeParam(napi_env env, napi_value capValue, PrintPageSize &pageSize)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, capValue, PARAM_PAGESIZE_ID);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_number) {
|
||||
@ -350,7 +365,7 @@ bool ParseType::ParsePageSizeParam(napi_env env, napi_value capValue, PrintPageS
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseResolutionParam(napi_env env, napi_value reValue, PrintResolution &resolution)
|
||||
bool PrintParseType::ParseResolutionParam(napi_env env, napi_value reValue, PrintResolution &resolution)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, reValue, PARAM_RESOLUTION_ID);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_number) {
|
||||
@ -370,7 +385,7 @@ bool ParseType::ParseResolutionParam(napi_env env, napi_value reValue, PrintReso
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseMarginParam(napi_env env, napi_value marginValue, PrintMargin &margin)
|
||||
bool PrintParseType::ParseMarginParam(napi_env env, napi_value marginValue, PrintMargin &margin)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, marginValue, PARAM_MARGIN_TOP);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_number) {
|
||||
@ -396,8 +411,7 @@ bool ParseType::ParseMarginParam(napi_env env, napi_value marginValue, PrintMarg
|
||||
PRINT_HILOGD("current margin paramster name list size = %{public}zu", names.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParseJobParam(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
bool PrintParseType::ParseArrFiles(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_FILES);
|
||||
bool isFileArray = false;
|
||||
@ -416,6 +430,115 @@ bool ParseType::ParseJobParam(napi_env env, napi_value jobValue, PrintJob &print
|
||||
PRINT_HILOGD("printJob_value param_one %{public}s", files.c_str());
|
||||
printfiles.push_back(files);
|
||||
}
|
||||
printJob.SetFiles(printfiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrintParseType::ParseHasNum(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
{
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_ISSEQUENTIAL)) {
|
||||
PRINT_HILOGD("No isSequential present, ignore it");
|
||||
} else {
|
||||
napi_value param_seven = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_ISSEQUENTIAL);
|
||||
if (NapiPrintUtils::GetValueType(env, param_seven) != napi_boolean) {
|
||||
PRINT_HILOGD("error param_seven");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetIsSequential(NapiPrintUtils::GetUint32Property(env, jobValue, PARAM_JOB_ISSEQUENTIAL));
|
||||
}
|
||||
}
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_ISLANDSCAPE)) {
|
||||
PRINT_HILOGD("No isLandscape present, ignore it");
|
||||
} else {
|
||||
napi_value param_nine = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_ISLANDSCAPE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_nine) != napi_boolean) {
|
||||
PRINT_HILOGD("error param_nine");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetIsLandscape(NapiPrintUtils::GetBooleanProperty(env, jobValue, PARAM_JOB_ISLANDSCAPE));
|
||||
}
|
||||
}
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_COLORMODE)) {
|
||||
PRINT_HILOGD("No colorMode present, ignore it");
|
||||
} else {
|
||||
napi_value param_ten = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_COLORMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_ten) != napi_number) {
|
||||
PRINT_HILOGD("error param_ten");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetColorMode(NapiPrintUtils::GetUint32Property(env, jobValue, PARAM_JOB_COLORMODE));
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_DUPLEXMODE)) {
|
||||
PRINT_HILOGD("No duplexMode present, ignore it");
|
||||
} else {
|
||||
napi_value param_eleven = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_DUPLEXMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_eleven) != napi_number) {
|
||||
PRINT_HILOGD("error param_eleven");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetDuplexMode(NapiPrintUtils::GetUint32Property(env, jobValue, PARAM_JOB_DUPLEXMODE));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrintParseType::ParseHasObj(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
{
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_PAGESIZE)) {
|
||||
PRINT_HILOGD("No pageSize present, ignore it");
|
||||
} else {
|
||||
napi_value param_eight = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_PAGESIZE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_eight) != napi_object) {
|
||||
PRINT_HILOGD("error param_eight");
|
||||
return false;
|
||||
} else {
|
||||
PrintPageSize pagesize;
|
||||
if (!ParsePageSize(env, param_eight, pagesize)) {
|
||||
PRINT_HILOGD("ParsePageSize type error!");
|
||||
return false;
|
||||
}
|
||||
printJob.SetPageSize(pagesize);
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_MARGIN)) {
|
||||
PRINT_HILOGD("No isSequential present, ignore it");
|
||||
} else {
|
||||
napi_value param_twelve = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_MARGIN);
|
||||
if (NapiPrintUtils::GetValueType(env, param_twelve) != napi_object) {
|
||||
PRINT_HILOGD("error param_twelve");
|
||||
return false;
|
||||
} else {
|
||||
PrintMargin margin;
|
||||
if (!ParseMargin(env, param_twelve, margin)) {
|
||||
PRINT_HILOGD("PrintMargin type error!");
|
||||
}
|
||||
printJob.SetMargin(margin);
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_PREVIEW)) {
|
||||
PRINT_HILOGD("No PreviewAttribute present, ignore it");
|
||||
} else {
|
||||
napi_value param_thirteen = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_PREVIEW);
|
||||
PreviewAttribute previewAttribute;
|
||||
if (!ParsePreviewAttribute(env, param_thirteen, previewAttribute)) {
|
||||
PRINT_HILOGD("ParsePreviewAttribute type error!");
|
||||
return false;
|
||||
}
|
||||
printJob.SetPreview(previewAttribute);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrintParseType::ParseJobParam(napi_env env, napi_value jobValue, PrintJob &printJob)
|
||||
{
|
||||
if(!ParseArrFiles(env, jobValue, printJob)){
|
||||
PRINT_HILOGD("ParseArrFiles error");
|
||||
return false;
|
||||
}
|
||||
|
||||
napi_value param_two = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_JOBID);
|
||||
if (NapiPrintUtils::GetValueType(env, param_two) != napi_number) {
|
||||
@ -449,110 +572,15 @@ bool ParseType::ParseJobParam(napi_env env, napi_value jobValue, PrintJob &print
|
||||
}
|
||||
printJob.SetPageRange(range);
|
||||
}
|
||||
PRINT_HILOGD("param_six END");
|
||||
// ·Ç±ØÒª²ÎÊý
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_ISSEQUENTIAL)) {
|
||||
PRINT_HILOGD("No isSequential present, ignore it");
|
||||
} else {
|
||||
napi_value param_seven = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_ISSEQUENTIAL);
|
||||
if (NapiPrintUtils::GetValueType(env, param_seven) != napi_boolean) {
|
||||
PRINT_HILOGD("error param_seven");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetIsSequential(NapiPrintUtils::GetUint32Property(env, jobValue, PARAM_JOB_ISSEQUENTIAL));
|
||||
PRINT_HILOGD(
|
||||
"printJob_value IsSequential value is %{public}s", printJob.GetIsSequential() ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_PAGESIZE)) {
|
||||
PRINT_HILOGD("No pageSize present, ignore it");
|
||||
} else {
|
||||
napi_value param_eight = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_PAGESIZE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_eight) != napi_object) {
|
||||
PRINT_HILOGD("error param_eight");
|
||||
return false;
|
||||
} else {
|
||||
PrintPageSize pagesize;
|
||||
if (!ParsePageSize(env, param_eight, pagesize)) {
|
||||
PRINT_HILOGD("ParsePageSize type error!");
|
||||
return false;
|
||||
}
|
||||
printJob.SetPageSize(pagesize);
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_ISLANDSCAPE)) {
|
||||
PRINT_HILOGD("No isLandscape present, ignore it");
|
||||
} else {
|
||||
napi_value param_nine = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_ISLANDSCAPE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_nine) != napi_boolean) {
|
||||
PRINT_HILOGD("error param_nine");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetIsLandscape(NapiPrintUtils::GetBooleanProperty(env, jobValue, PARAM_JOB_ISLANDSCAPE));
|
||||
PRINT_HILOGD(
|
||||
"printJob_value SetIsLandscape value is %{public}s", printJob.GetIsLandscape() ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_COLORMODE)) {
|
||||
PRINT_HILOGD("No colorMode present, ignore it");
|
||||
} else {
|
||||
napi_value param_ten = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_COLORMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_ten) != napi_number) {
|
||||
PRINT_HILOGD("error param_ten");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetColorMode(NapiPrintUtils::GetUint32Property(env, jobValue, PARAM_JOB_COLORMODE));
|
||||
PRINT_HILOGD("printJob_value ColorMode value is %{public}d", printJob.GetIsSequential());
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_DUPLEXMODE)) {
|
||||
PRINT_HILOGD("No duplexMode present, ignore it");
|
||||
} else {
|
||||
napi_value param_eleven = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_DUPLEXMODE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_eleven) != napi_number) {
|
||||
PRINT_HILOGD("error param_eleven");
|
||||
return false;
|
||||
} else {
|
||||
printJob.SetDuplexMode(NapiPrintUtils::GetUint32Property(env, jobValue, PARAM_JOB_DUPLEXMODE));
|
||||
PRINT_HILOGD("printJob_value DuplexMode value is %{public}d", printJob.GetDuplexMode());
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_MARGIN)) {
|
||||
PRINT_HILOGD("No isSequential present, ignore it");
|
||||
} else {
|
||||
napi_value param_twelve = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_MARGIN);
|
||||
if (NapiPrintUtils::GetValueType(env, param_twelve) != napi_object) {
|
||||
PRINT_HILOGD("error param_twelve");
|
||||
return false;
|
||||
} else {
|
||||
PrintMargin margin;
|
||||
if (!ParseMargin(env, param_twelve, margin)) {
|
||||
PRINT_HILOGD("PrintMargin type error!");
|
||||
}
|
||||
printJob.SetMargin(margin);
|
||||
}
|
||||
}
|
||||
|
||||
if (!NapiPrintUtils::HasNamedProperty(env, jobValue, PARAM_JOB_PREVIEW)) {
|
||||
PRINT_HILOGD("No PreviewAttribute present, ignore it");
|
||||
} else {
|
||||
napi_value param_thirteen = NapiPrintUtils::GetNamedProperty(env, jobValue, PARAM_JOB_PREVIEW);
|
||||
PreviewAttribute previewAttribute;
|
||||
if (!ParsePreviewAttribute(env, param_thirteen, previewAttribute)) {
|
||||
PRINT_HILOGD("ParsePreviewAttribute type error!");
|
||||
return false;
|
||||
}
|
||||
printJob.SetPreview(previewAttribute);
|
||||
if(!ParseHasObj(env, jobValue, printJob) && !ParseHasNum(env, jobValue, printJob)){
|
||||
PRINT_HILOGD("default-value has error!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseType::ParsePreviewAttributeParam(napi_env env, napi_value preAttValue, PreviewAttribute &preAtt)
|
||||
bool PrintParseType::ParsePreviewAttributeParam(napi_env env, napi_value preAttValue, PreviewAttribute &preAtt)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, preAttValue, PARAM_PREATTRIBUTE_RANGE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_object) {
|
||||
@ -574,7 +602,7 @@ bool ParseType::ParsePreviewAttributeParam(napi_env env, napi_value preAttValue,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool ParseType::ParseRangeParam(napi_env env, napi_value rangeValue, PrintRange &range)
|
||||
bool PrintParseType::ParseRangeParam(napi_env env, napi_value rangeValue, PrintRange &range)
|
||||
{
|
||||
napi_value param_one = NapiPrintUtils::GetNamedProperty(env, rangeValue, PARAM_RANGE_STARTPAGE);
|
||||
if (NapiPrintUtils::GetValueType(env, param_one) != napi_number) {
|
||||
@ -592,7 +620,7 @@ bool ParseType::ParseRangeParam(napi_env env, napi_value rangeValue, PrintRange
|
||||
napi_is_array(env, param_three, &isArray);
|
||||
uint32_t arrayLength = 0, startPageNum, endPageNum;
|
||||
napi_get_array_length(env, param_three, &arrayLength);
|
||||
if (!isArray || arrayLength != 2) {
|
||||
if (!isArray || arrayLength != NapiPrintUtils::ARGC_TWO) {
|
||||
PRINT_HILOGD("ParseRangeParam pages array error!");
|
||||
return false;
|
||||
}
|
||||
|
@ -129,22 +129,17 @@ export default function requestPrintJsunit() {
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_0100', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0100-------------");
|
||||
TAG = "requestPrint_test_0100";
|
||||
let details;
|
||||
await print.addPrinters(PrinterInfoArray).then((data) => {
|
||||
details = data;
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_0100-------------");
|
||||
expect(false).assertTrue();
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@ -154,458 +149,141 @@ export default function requestPrintJsunit() {
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_0200', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0200-------------");
|
||||
TAG = "requestPrint_test_0200";
|
||||
let details;
|
||||
await print.addPrinters(PrinterInfoArray, (err, data) => {
|
||||
if (err) {
|
||||
console.info(TAG + " err: " + JSON.stringify(err));
|
||||
expect(false).assertTrue();
|
||||
} else {
|
||||
details = data;
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_0200-------------");
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0300
|
||||
* @tc.name addPrinters: New printers have been found and notify Print SA
|
||||
('PrinterInfo' missing Required Arguments)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_0300', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0300-------------");
|
||||
TAG = "requestPrint_test_0300";
|
||||
try {
|
||||
await print.addPrinters(PrinterInfo2).then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_0300-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0400
|
||||
* @tc.name addPrinters: New printers have been found and notify Print SA
|
||||
('PrinterInfo' parameter type is wrong)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_0400', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0400-------------");
|
||||
TAG = "requestPrint_test_0400";
|
||||
try {
|
||||
await print.addPrinters(123).then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_0400-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0500
|
||||
* @tc.name addPrinters: New printers have been found and notify Print SA
|
||||
('PrinterInfo' parameter is empty)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_0500', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0500-------------");
|
||||
TAG = "requestPrint_test_0500";
|
||||
let flag = 0;
|
||||
await print.addPrinters([{}]).then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
flag = 1;
|
||||
expect(flag == 1).assertTrue();
|
||||
});
|
||||
console.info("------------end requestPrint_test_0500-------------");
|
||||
done();
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0600
|
||||
* @tc.name removePrinters: Printers have been lost and notify Print SA (by Promise)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_0600', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0600-------------");
|
||||
TAG = "requestPrint_test_0600";
|
||||
let details;
|
||||
it('requestPrint_test_0300', 0, async function (done) {
|
||||
TAG = "requestPrint_test_0300";
|
||||
await print.removePrinters(PrinterInfoArray).then((data) => {
|
||||
details = data;
|
||||
console.info(TAG + " removePrinters result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " removePrinters err: " + JSON.stringify(error));
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_0600-------------");
|
||||
expect(false).assertTrue();
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0700
|
||||
* @tc.number requestPrint_test_0400
|
||||
* @tc.name removePrinters: Printers have been lost and notify Print SA (by callback)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_0700', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0700-------------");
|
||||
TAG = "requestPrint_test_0700";
|
||||
let details;
|
||||
it('requestPrint_test_0400', 0, async function (done) {
|
||||
TAG = "requestPrint_test_0400";
|
||||
await print.removePrinters(PrinterInfoArray, (err, data) => {
|
||||
if (err) {
|
||||
console.info(TAG + " removePrinters err: " + JSON.stringify(err));
|
||||
expect(false).assertTrue();
|
||||
} else {
|
||||
details = data;
|
||||
console.info(TAG + " removePrinters result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_0700-------------");
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0800
|
||||
* @tc.name removePrinters: Printers have been lost and notify Print SA
|
||||
('PrinterInfo' missing Required Arguments)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_0800', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0800-------------");
|
||||
TAG = "requestPrint_test_0800";
|
||||
try {
|
||||
await print.removePrinters(PrinterInfo2).then((data) => {
|
||||
console.info(TAG + " removePrinters result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " removePrinters err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_0800-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_0900
|
||||
* @tc.name removePrinters: Printers have been lost and notify Print SA
|
||||
('PrinterInfo' parameter type is wrong)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_0900', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_0900-------------");
|
||||
TAG = "requestPrint_test_0900";
|
||||
try {
|
||||
await print.removePrinters(PrinterInfo2).then((data) => {
|
||||
console.info(TAG + " removePrinters result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " removePrinters err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_0900-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1000
|
||||
* @tc.name removePrinters: Printers have been lost and notify Print SA
|
||||
('PrinterInfo' parameter is empty)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_1000', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1000-------------");
|
||||
TAG = "requestPrint_test_1000";
|
||||
let flag = 0;
|
||||
await print.removePrinters([{}]).then((data) => {
|
||||
console.info(TAG + " removePrinters result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " removePrinters err: " + JSON.stringify(error));
|
||||
flag = 1;
|
||||
expect(flag == 1).assertTrue();
|
||||
});
|
||||
console.info("------------end requestPrint_test_1000-------------");
|
||||
done();
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1100
|
||||
* @tc.number requestPrint_test_0500
|
||||
* @tc.name updatePrinterState: Notify Print SA the state of printer has been changed (by Promise)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_1100', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1100-------------");
|
||||
TAG = "requestPrint_test_1100";
|
||||
let details;
|
||||
it('requestPrint_test_0500', 0, async function (done) {
|
||||
TAG = "requestPrint_test_0500";
|
||||
await print.updatePrinterState(printerId, PrinterState).then((data) => {
|
||||
details = data;
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_1100-------------");
|
||||
expect(false).assertTrue();
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1200
|
||||
* @tc.number requestPrint_test_0600
|
||||
* @tc.name updatePrinterState: Notify Print SA the state of printer has been changed (by callback)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_1200', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1200-------------");
|
||||
TAG = "requestPrint_test_1200";
|
||||
let details;
|
||||
it('requestPrint_test_0600', 0, async function (done) {
|
||||
TAG = "requestPrint_test_0600";
|
||||
await print.updatePrinterState(printerId, PrinterState, (err, data) => {
|
||||
if (err) {
|
||||
console.info(TAG + " err: " + JSON.stringify(err));
|
||||
expect(false).assertTrue();
|
||||
} else {
|
||||
details = data;
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_1200-------------");
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1300
|
||||
* @tc.name updatePrinterState: Notify Print SA the state of printer has been changed (parameter is wrong)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_1300', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1300-------------");
|
||||
TAG = "requestPrint_test_1300";
|
||||
try {
|
||||
await print.updatePrinterState(printerId).then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_1300-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1400
|
||||
* @tc.name updatePrinterState: Notify Print SA the state of printer has been changed (parameter type is wrong)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_1400', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1400-------------");
|
||||
TAG = "requestPrint_test_1400";
|
||||
try {
|
||||
await print.updatePrinterState('1000', '2000').then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_1400-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1500
|
||||
* @tc.name updatePrinterState: Notify Print SA the state of printer has been changed (parameter is null)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_1500', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1500-------------");
|
||||
TAG = "requestPrint_test_1500";
|
||||
try {
|
||||
await print.updatePrinterState().then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_1500-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1600
|
||||
* @tc.number requestPrint_test_0700
|
||||
* @tc.name updatePrintJobState: Notify Print SA the state of print job has been changed (by Promise)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_1600', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1600-------------");
|
||||
TAG = "requestPrint_test_1600";
|
||||
let details;
|
||||
it('requestPrint_test_0700', 0, async function (done) {
|
||||
TAG = "requestPrint_test_0700";
|
||||
await print.updatePrintJobState(jobId, PrintJobState).then((data) => {
|
||||
details = data;
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_1600-------------");
|
||||
expect(false).assertTrue();
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1700
|
||||
* @tc.number requestPrint_test_0800
|
||||
* @tc.name updatePrintJobState: Notify Print SA the state of print job has been changed (by callback)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 0
|
||||
*/
|
||||
it('requestPrint_test_1700', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1700-------------");
|
||||
TAG = "requestPrint_test_1700";
|
||||
let details;
|
||||
it('requestPrint_test_0800', 0, async function (done) {
|
||||
TAG = "requestPrint_test_0800";
|
||||
await print.updatePrintJobState(jobId, PrintJobState, (err, data) => {
|
||||
if (err) {
|
||||
console.info(TAG + " err: " + JSON.stringify(err));
|
||||
expect(false).assertTrue();
|
||||
} else {
|
||||
details = data;
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
expect(typeof (data)).assertEqual('boolean');
|
||||
expect(data).assertEqual(true);
|
||||
done();
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
console.info(TAG + " result details: " + JSON.stringify(details));
|
||||
expect(typeof (details)).assertEqual('boolean');
|
||||
expect(details).assertEqual(true);
|
||||
console.info("------------end requestPrint_test_1700-------------");
|
||||
done();
|
||||
}, 4000);
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1800
|
||||
* @tc.name updatePrintJobState: Notify Print SA the state of print job has been changed (parameter is wrong)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_1800', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1800-------------");
|
||||
TAG = "requestPrint_test_1800";
|
||||
try {
|
||||
await print.updatePrintJobState(jobId).then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_1800-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_1900
|
||||
* @tc.name updatePrintJobState: Notify Print SA the state of print job has been changed(parameter type is wrong)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_1900', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_1900-------------");
|
||||
TAG = "requestPrint_test_1900";
|
||||
try {
|
||||
await print.updatePrintJobState('1000', '2000').then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_1900-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.number requestPrint_test_2000
|
||||
* @tc.name updatePrintJobState: Notify Print SA the state of print job has been changed(parameter is null)
|
||||
* @tc.desc Function test
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('requestPrint_test_2000', 0, async function (done) {
|
||||
console.info("------------start requestPrint_test_2000-------------");
|
||||
TAG = "requestPrint_test_2000";
|
||||
try {
|
||||
await print.updatePrintJobState().then((data) => {
|
||||
console.info(TAG + " result: " + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
console.info(TAG + " err: " + JSON.stringify(error));
|
||||
});
|
||||
} catch (exception) {
|
||||
console.log(TAG + " failed due to execute timeout 5s");
|
||||
expect(true).assertTrue();
|
||||
console.info("------------end requestPrint_test_2000-------------");
|
||||
done();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
@ -382,7 +382,7 @@ bool PrintServiceAbility::Off(const std::string &type)
|
||||
|
||||
void PrintServiceAbility::DataWriteInfo(PrinterInfo info, MessageParcel &data)
|
||||
{
|
||||
|
||||
PRINT_HILOGI();
|
||||
}
|
||||
|
||||
void PrintServiceAbility::NotifyPrintStateHandler(const std::string &type, uint32_t state, PrinterInfo info)
|
||||
@ -393,7 +393,7 @@ void PrintServiceAbility::NotifyPrintStateHandler(const std::string &type, uint3
|
||||
|
||||
void PrintServiceAbility::DataWriteJob(PrintJob job, MessageParcel &data)
|
||||
{
|
||||
|
||||
PRINT_HILOGI();
|
||||
}
|
||||
|
||||
void PrintServiceAbility::NotifyJobStateHandler(const std::string &type, uint32_t state, PrintJob job)
|
||||
|
@ -15,16 +15,6 @@
|
||||
|
||||
#include "print_service_manager.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <errno.h>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "print_log.h"
|
||||
|
||||
namespace OHOS::Print {
|
||||
|
Loading…
Reference in New Issue
Block a user