From cd77f0f752b3fc74da7dba13fa50ee9b858b6036 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 25 Apr 2022 14:37:38 +0800 Subject: [PATCH 1/9] test1 Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 88 +++++++++--------- ext/pin_auth/src/lite/pin_auth_ui.cpp | 6 +- ext/pin_auth/src/pin_auth.cpp | 18 ++-- ext/pin_auth/src/standard/pin_auth_ui.cpp | 6 +- .../native_cpp/src/device_manager_impl.cpp | 8 +- .../src/ipc/lite/ipc_client_manager.cpp | 8 +- .../src/ipc/lite/ipc_client_server_proxy.cpp | 10 +-- .../src/ipc/lite/ipc_client_stub.cpp | 2 +- .../src/ipc/lite/ipc_cmd_parser.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 8 +- .../authentication/auth_message_processor.cpp | 8 +- .../src/authentication/auth_request_state.cpp | 18 ++-- .../authentication/auth_response_state.cpp | 12 +-- .../src/authentication/dm_auth_manager.cpp | 22 ++--- .../src/config/mini/pin_auth.cpp | 12 +-- .../dependency/hichain/hichain_connector.cpp | 38 ++++---- .../dependency/softbus/softbus_connector.cpp | 14 +-- .../dependency/softbus/softbus_session.cpp | 6 +- .../src/device_manager_service.cpp | 20 ++--- .../src/ipc/lite/ipc_cmd_parser.cpp | 4 +- .../src/ipc/lite/ipc_server_listener.cpp | 6 +- .../src/ipc/lite/ipc_server_listenermgr.cpp | 6 +- .../src/ipc/lite/ipc_server_stub.cpp | 6 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 24 ++--- .../src/ipc/standard/ipc_server_listener.cpp | 2 +- .../src/ipc/standard/ipc_server_stub.cpp | 2 +- .../UTTest_auth_message_processor.cpp | 2 +- test/unittest/UTTest_auth_request_state.cpp | 38 ++++---- test/unittest/UTTest_auth_response_state.cpp | 24 ++--- test/unittest/UTTest_device_manager_impl.cpp | 90 +++++++++---------- .../UTTest_device_manager_service.cpp | 40 ++++----- test/unittest/UTTest_dm_auth_manager.cpp | 10 +-- test/unittest/UTTest_hichain_connector.cpp | 14 +-- test/unittest/UTTest_ipc_client_manager.cpp | 54 +++++------ test/unittest/UTTest_ipc_client_proxy.cpp | 38 ++++---- test/unittest/UTTest_ipc_client_stub.cpp | 8 +- .../UTTest_ipc_server_client_proxy.cpp | 12 +-- test/unittest/UTTest_ipc_server_listener.cpp | 8 +- test/unittest/UTTest_pin_auth.cpp | 30 +++---- test/unittest/UTTest_softbus_connector.cpp | 12 +-- test/unittest/UTTest_softbus_session.cpp | 10 +-- test/unittest/auth_request_state.cpp | 18 ++-- test/unittest/auth_response_state.cpp | 12 +-- test/unittest/device_manager_impl_test.cpp | 6 +- test/unittest/mock/device_auth.cpp | 4 +- utils/src/dm_hash.cpp | 8 +- utils/src/dm_random.cpp | 2 +- 47 files changed, 394 insertions(+), 402 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index a2124ae27..81da8d186 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -43,54 +43,46 @@ const int32_t DISCOVER_STATUS_LEN = 20; const int32_t COMMON_CALLBACK_MAX_SIZE = 200; enum { - DM_OK = 0, - DM_FAILED = 1000, - DM_TIME_OUT, - DM_NOT_INIT, - DM_INT_MULTIPLE, - DM_INIT_FAILED, - DM_UNINIT_FAILED, - DM_POINT_NULL, - DM_INPUT_PARA_EMPTY, - DM_NO_PERMISSION, - DM_INVALID_VALUE, - DM_FLATTEN_OBJECT, - DM_MALLOC_ERROR, - DM_COPY_FAILED, - DM_WRITE_FAILED, - DM_DISCOVERY_FAILED, - DM_MAKE_SHARED_FAIL, - DM_SERVICE_NOT_READY, - DM_DEVICE_ALREADY_TRUSTED, - ERR_DM_KEY_ALREADY_EXISTS, - ERR_DM_INPUT_PARA_INVALID, - ERR_DM_SUBSCRIBE_DP_EVENTS, - ERR_DM_UNSUBSCRIBE_DP_EVENTS, - DM_IPC_FAILED = 2000, - DM_IPC_TRANSACTION_FAILED, - DM_IPC_FLATTEN_OBJECT, - DM_IPC_COPY_FAILED, - DM_IPC_SEND_REQUEST_FAILED, - DM_IPC_NOT_REGISTER_FUNC, - DM_IPC_RESPOND_ERROR, - DM_IPC_WRITE_TOKEN_ERROR, - DM_DISCOVERY_REPEATED, - DM_AUTH_NOT_SUPPORT, - DM_AUTH_BUSINESS_BUSY, - DM_AUTH_INPUT_FAILED, - DM_AUTH_STATE_FAILED, - DM_AUTH_DEVICE_AUTHED, - DM_AUTH_OPEN_SESSION_FAILED, - DM_AUTH_PEER_REJECT, - DM_AUTH_NOT_AUTH, - DM_AUTH_DONT_AUTH, - DM_AUTH_NOT_START, - DM_SOFTBUS_FAILED = 3000, - DM_SOFTBUS_CREATE_SESSION_SERVER_FAILED, - DM_HICHAIN_FAILED = 4000, - DM_HICHAIN_GROUP_CREATE_FAILED, - DM_HICHAIN_MEMBER_ADD_FAILED, - DM_HICHAIN_CREATE_CHANNEL_FAILED, + DM_OK = -20000, + ERR_DM_FAILED = -20001, + ERR_DM_TIME_OUT = -20002, + ERR_DM_NOT_INIT + ERR_DM_NOT_INIT = -20003, + ERR_DM_INIT_REPEATE = -20004, + ERR_DM_INIT_FAILED = -20005, + ERR_DM_UNINIT_FAILED = -20006, + DM_POINT_NULL = -20007, + DM_INPUT_PARA_EMPTY = -20008, + DM_NO_PERMISSION = -20009, + DM_INVALID_VALUE = -20010, + DM_FLATTEN_OBJECT = -20011, + DM_MALLOC_ERROR = -20012, + DM_COPY_FAILED = -20013, + DM_WRITE_FAILED = -20014, + DM_DISCOVERY_FAILED = -20015, + DM_MAKE_SHARED_FAIL = -20016, + DM_SERVICE_NOT_READY = -20017, + ERR_DM_KEY_ALREADY_EXISTS = -20018, + ERR_DM_INPUT_PARA_INVALID = -20019, + ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20020, + DM_IPC_FAILED = -20021, + DM_IPC_TRANSACTION_FAILED = -20022, + DM_IPC_FLATTEN_OBJECT = -20023, + DM_IPC_COPY_FAILED = -20024, + DM_IPC_SEND_REQUEST_FAILED = -20025, + DM_IPC_NOT_REGISTER_FUNC = -20026, + DM_IPC_RESPOND_ERROR = -20027, + DM_IPC_WRITE_TOKEN_ERROR = -20028, + DM_DISCOVERY_REPEATED = -20029, + DM_AUTH_NOT_SUPPORT = -20030, + DM_AUTH_BUSINESS_BUSY = -20031, + DM_AUTH_INPUT_FAILED = -20032, + DM_AUTH_OPEN_SESSION_FAILED = -20033, + DM_AUTH_PEER_REJECT = -20034, + DM_AUTH_NOT_AUTH = -20035, + DM_AUTH_DONT_AUTH = -20036, + DM_AUTH_NOT_START = -20037, + DM_HICHAIN_GROUP_CREATE_FAILED = -20038, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/ext/pin_auth/src/lite/pin_auth_ui.cpp b/ext/pin_auth/src/lite/pin_auth_ui.cpp index f12a74e46..205d32762 100644 --- a/ext/pin_auth/src/lite/pin_auth_ui.cpp +++ b/ext/pin_auth/src/lite/pin_auth_ui.cpp @@ -39,7 +39,7 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a std::shared_ptr dmAbilityManager_ = std::make_shared(); if (dmAbilityManager_ == nullptr) { LOGE("PinAuthUi::dmAbilityManager is null"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("InputPinDialog end"); return StartFaUiService(dmAbilityManager_); @@ -50,7 +50,7 @@ int32_t ClosePage(const int32_t &pageId, std::shared_ptr authMana LOGI("ClosePage hap start"); if (authManager == nullptr) { LOGE("PinAuthUi::authManager is null"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("ClosePage hap end"); authManager->CancelDisplay(); @@ -62,7 +62,7 @@ int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityM AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { LOGE("PinAuthUi::StartFaUiService timeout"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index da2d88653..bc0b09bc5 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -40,11 +40,11 @@ int32_t PinAuth::ShowAuthInfo(std::string &authToken, std::shared_ptrShowPinDialog(jsonObject[PIN_CODE_KEY], authManager); } @@ -54,11 +54,11 @@ int32_t PinAuth::StartAuth(std::string &authToken, std::shared_ptrInputPinDialog(jsonObject[PIN_CODE_KEY], authManager); } @@ -71,22 +71,22 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string return DM_OK; } LOGE("Peer rejection"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authParamJson = nlohmann::json::parse(authParam, nullptr, false); if (authParamJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authTokenJson = nlohmann::json::parse(authToken, nullptr, false); if (authTokenJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } if (!authParamJson.contains(PIN_CODE_KEY) || !authParamJson.contains(PIN_TOKEN) || !authTokenJson.contains(PIN_CODE_KEY) || !authTokenJson.contains(PIN_TOKEN)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t code = authTokenJson[PIN_CODE_KEY]; std::string pinToken = authTokenJson[PIN_TOKEN]; @@ -97,7 +97,7 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) { return DM_AUTH_INPUT_FAILED; } else { - return DM_FAILED; + return ERR_DM_FAILED; } } diff --git a/ext/pin_auth/src/standard/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp index 65851bcb9..6e349747a 100644 --- a/ext/pin_auth/src/standard/pin_auth_ui.cpp +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -33,7 +33,7 @@ int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr au LOGI("ShowPinDialog start"); if (authManager == nullptr) { LOGE("ShowPinDialog authManager is null"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = code; @@ -63,7 +63,7 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a LOGI("InputPinDialog start"); if (authManager == nullptr) { LOGE("ShowPinDialog InputPinDialog is null"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = code; @@ -102,7 +102,7 @@ int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityM AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { LOGE("PinAuthUi::StartFaService timeout"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 39106aea2..d186da0c3 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -55,19 +55,19 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh int32_t retryNum = 0; while (retryNum < SERVICE_INIT_TRY_MAX_NUM) { ret = ipcClientProxy_->Init(pkgName); - if (ret != DM_NOT_INIT) { + if (ret != ERR_DM_NOT_INIT) { break; } usleep(SLEEP_TIME_MS); retryNum++; if (retryNum == SERVICE_INIT_TRY_MAX_NUM) { LOGE("InitDeviceManager error: wait for device manager service starting timeout."); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - return DM_INIT_FAILED; + return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); @@ -86,7 +86,7 @@ int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName) int32_t ret = ipcClientProxy_->UnInit(pkgName); if (ret != DM_OK) { LOGE("UnInitDeviceManager error: proxy unInit failed ret: %d", ret); - return DM_UNINIT_FAILED; + return ERR_DM_UNINIT_FAILED; } DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp index 3b89b67f4..1c19f249c 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp @@ -30,11 +30,11 @@ int32_t IpcClientManager::Init(const std::string &pkgName) } if (serverProxy_.Init() != DM_OK) { LOGE("server proxy init failed."); - return DM_INIT_FAILED; + return ERR_DM_INIT_FAILED; } if (IpcClientStub::GetInstance().Init() != DM_OK) { LOGE("ipcclientstub init failed."); - return DM_INIT_FAILED; + return ERR_DM_INIT_FAILED; } std::shared_ptr req = std::make_shared(); @@ -59,13 +59,13 @@ int32_t IpcClientManager::UnInit(const std::string &pkgName) { LOGI("UnInitDeviceManager in, pkgName %s", pkgName.c_str()); if (!IsInit(pkgName)) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); if (req == nullptr) { LOGE("req is null"); - return DM_FAILED; + return ERR_DM_FAILED; } req->SetPkgName(pkgName); int32_t ret = serverProxy_.SendCmd(UNREGISTER_DEVICE_MANAGER_LISTENER, req, rsp); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp index 191c57986..2c5fa9e28 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp @@ -82,7 +82,7 @@ int IpcClientServerProxy::RegisterServerDeathCb(void) g_deathCbId = INVALID_CB_ID; if (RegisterDeathCallback(nullptr, g_svcIdentity, DmDeathCallback, nullptr, &g_deathCbId) != EC_SUCCESS) { LOGE("reg death callback failed"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -94,7 +94,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r IpcIo request; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, request, data, MAX_DM_IPC_LEN) != DM_OK) { - return DM_FAILED; + return ERR_DM_FAILED; } { std::lock_guard autoLock(lock_); @@ -102,7 +102,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r if (serviceProxy_ != nullptr && serviceProxy_->Invoke(serviceProxy_, cmdCode, &request, &cmdCode, SendCmdResultCb) != 0) { LOGE("serviceProxy_ invoke failed."); - return DM_FAILED; + return ERR_DM_FAILED; } } LOGI("IpcClientServerProxy::SendCmd:%d, end", cmdCode); @@ -119,11 +119,11 @@ int32_t IpcClientServerProxy::Init(void) serviceProxy_ = GetServerProxy(); if (serviceProxy_ == nullptr) { LOGE("get ipc client proxy failed"); - return DM_FAILED; + return ERR_DM_FAILED; } if (RegisterServerDeathCb() != DM_OK) { LOGE("register server death cb failed"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("ServerProxyInit ok"); return DM_OK; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp index d692823ea..34551578f 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp @@ -49,7 +49,7 @@ int32_t IpcClientStub::Init() } if (RegisterIpcCallback(ClientIpcInterfaceMsgHandle, 0, IPC_WAIT_FOREVER, &clientIdentity_, nullptr) != 0) { LOGE("register ipc cb failed"); - return DM_FAILED; + return ERR_DM_FAILED; } bInit = true; return DM_OK; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index 35643d54c..d09959e04 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -50,7 +50,7 @@ ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, IpcIo &reply, std::shared { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(IpcIoPopInt32(&reply)); return DM_OK; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index 3cb76e362..f0aa8e798 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -59,7 +59,7 @@ ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &reply, std { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -111,7 +111,7 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt LOGE("GetTrustedDeviceList read node info failed!"); if (pRsp == nullptr) { LOGE("pRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED); return DM_IPC_TRANSACTION_FAILED; @@ -231,7 +231,7 @@ ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, MessageParcel &reply, std::shared_ptr { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -269,7 +269,7 @@ ON_IPC_READ_RESPONSE(AUTHENTICATE_DEVICE, MessageParcel &reply, std::shared_ptr< { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; diff --git a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp index 486aa989e..f946d11f9 100644 --- a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp +++ b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp @@ -158,11 +158,11 @@ int32_t AuthMessageProcessor::ParseMessage(const std::string &message) nlohmann::json jsonObject = nlohmann::json::parse(message, nullptr, false); if (jsonObject.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } if (!jsonObject.contains(TAG_TYPE)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t sliceNum = 0; int32_t msgType = jsonObject[TAG_TYPE]; @@ -176,7 +176,7 @@ int32_t AuthMessageProcessor::ParseMessage(const std::string &message) if (!jsonObject.contains(TAG_INDEX) || !jsonObject.contains(TAG_DEVICE_ID) || !jsonObject.contains(TAG_SLICE_NUM)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } authResponseContext_->deviceId = jsonObject[TAG_DEVICE_ID]; authResponseContext_->authType = jsonObject[TAG_AUTH_TYPE]; @@ -240,7 +240,7 @@ int32_t AuthMessageProcessor::ParseAuthRequestMessage() authResponseContext_->groupId = jsonObject[TAG_GROUP_ID]; authResponseContext_->groupName = jsonObject[TAG_GROUP_NAME]; authResponseContext_->requestId = jsonObject[TAG_REQUEST_ID]; - return DM_FAILED; + return ERR_DM_FAILED; } authSplitJsonList_.clear(); return DM_OK; diff --git a/services/devicemanagerservice/src/authentication/auth_request_state.cpp b/services/devicemanagerservice/src/authentication/auth_request_state.cpp index ae2d967bd..716367185 100644 --- a/services/devicemanagerservice/src/authentication/auth_request_state.cpp +++ b/services/devicemanagerservice/src/authentication/auth_request_state.cpp @@ -48,7 +48,7 @@ int32_t AuthRequestState::TransitionTo(std::shared_ptr state) std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthRequestState(state); @@ -68,7 +68,7 @@ int32_t AuthRequestInitState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->EstablishAuthChannel(context_->deviceId); return DM_OK; @@ -84,7 +84,7 @@ int32_t AuthRequestNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartNegotiate(context_->sessionId); return DM_OK; @@ -100,7 +100,7 @@ int32_t AuthRequestNegotiateDoneState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->SendAuthRequest(context_->sessionId); return DM_OK; @@ -116,7 +116,7 @@ int32_t AuthRequestReplyState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartRespAuthProcess(); return DM_OK; @@ -133,7 +133,7 @@ int32_t AuthRequestInputState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowStartAuthDialog(); return DM_OK; @@ -150,7 +150,7 @@ int32_t AuthRequestJoinState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AddMember(context_->deviceId); return DM_OK; @@ -166,7 +166,7 @@ int32_t AuthRequestNetworkState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->JoinNetwork(); return DM_OK; @@ -182,7 +182,7 @@ int32_t AuthRequestFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/services/devicemanagerservice/src/authentication/auth_response_state.cpp b/services/devicemanagerservice/src/authentication/auth_response_state.cpp index c2725a515..50e566b00 100644 --- a/services/devicemanagerservice/src/authentication/auth_response_state.cpp +++ b/services/devicemanagerservice/src/authentication/auth_response_state.cpp @@ -49,7 +49,7 @@ int32_t AuthResponseState::TransitionTo(std::shared_ptr state std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthResponseState(state); @@ -80,7 +80,7 @@ int32_t AuthResponseNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->RespNegotiate(context_->sessionId); return DM_OK; @@ -97,7 +97,7 @@ int32_t AuthResponseConfirmState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowConfigDialog(); return DM_OK; @@ -114,7 +114,7 @@ int32_t AuthResponseGroupState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->CreateGroup(); return DM_OK; @@ -130,7 +130,7 @@ int32_t AuthResponseShowState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowAuthInfoDialog(); return DM_OK; @@ -146,7 +146,7 @@ int32_t AuthResponseFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 86d31b3e7..09a7b3632 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -142,13 +142,13 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st { if (pkgName.empty()) { LOGE(" DmAuthManager::UnAuthenticateDevice failed pkgName is null"); - return DM_FAILED; + return ERR_DM_FAILED; } std::string deviceUdid; int32_t ret = SoftbusConnector::GetUdidByNetworkId(deviceId.c_str(), deviceUdid); if (ret != DM_OK) { LOGE("UnAuthenticateDevice GetNodeKeyInfo failed"); - return DM_FAILED; + return ERR_DM_FAILED; } std::string groupId = ""; @@ -161,7 +161,7 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st hiChainConnector_->DeleteGroup(groupId); } else { LOGE("DmAuthManager::UnAuthenticateDevice groupList.size = 0"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -177,7 +177,7 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end() || timerMap_.find(INPUT_TIMEOUT_TASK) == timerMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); - return DM_FAILED; + return ERR_DM_FAILED; } timerMap_[INPUT_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); ptr = authenticationMap_[authResponseContext_->authType]; @@ -381,13 +381,13 @@ int32_t DmAuthManager::HandleAuthenticateTimeout() authResponseContext_ = std::make_shared(); } authResponseContext_->state = authRequestState_->GetStateType(); - authRequestContext_->reason = DM_TIME_OUT; + authRequestContext_->reason = ERR_DM_TIME_OUT; authRequestState_->TransitionTo(std::make_shared()); } if (authResponseState_ != nullptr && authResponseState_->GetStateType() != AuthState::AUTH_RESPONSE_FINISH) { authResponseContext_->state = authResponseState_->GetStateType(); - authResponseContext_->reply = DM_TIME_OUT; + authResponseContext_->reply = ERR_DM_TIME_OUT; authResponseState_->TransitionTo(std::make_shared()); } LOGI("DmAuthManager::HandleAuthenticateTimeout start complete"); @@ -544,7 +544,7 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) nlohmann::json jsonObj = nlohmann::json::parse(authResponseContext_->authToken, nullptr, false); if (jsonObj.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("DmAuthManager::AddMember start %s", authResponseContext_->authToken.c_str()); @@ -560,13 +560,13 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) joinStartTimer->Start(ADD_TIMEOUT, TimeOut, this); int32_t ret = hiChainConnector_->AddMember(deviceId, connectInfo); if (ret != 0) { - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("DmAuthManager::authRequestContext CancelDisplay start"); std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); - return DM_FAILED; + return ERR_DM_FAILED; } ptr = authenticationMap_[authResponseContext_->authType]; ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); @@ -585,7 +585,7 @@ int32_t DmAuthManager::JoinNetwork() { LOGI("DmAuthManager JoinNetwork start"); if (timerMap_.find(AUTHENTICATE_TIMEOUT_TASK) == timerMap_.end()) { - return DM_FAILED; + return ERR_DM_FAILED; } timerMap_[AUTHENTICATE_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; @@ -719,7 +719,7 @@ int32_t DmAuthManager::GetPinCode() nlohmann::json jsonObj = nlohmann::json::parse(authResponseContext_->authToken, nullptr, false); if (jsonObj.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } return jsonObj[PIN_CODE_KEY]; } diff --git a/services/devicemanagerservice/src/config/mini/pin_auth.cpp b/services/devicemanagerservice/src/config/mini/pin_auth.cpp index ccecb1911..ac09ac523 100644 --- a/services/devicemanagerservice/src/config/mini/pin_auth.cpp +++ b/services/devicemanagerservice/src/config/mini/pin_auth.cpp @@ -38,7 +38,7 @@ int32_t PinAuth::CloseAuthInfo(const int32_t &pageId, std::shared_ptrCancelDisplay(); @@ -65,21 +65,21 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string return DM_OK; } LOGE("Peer rejection"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authParamJson = nlohmann::json::parse(authParam, nullptr, false); if (authParamJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authTokenJson = nlohmann::json::parse(authToken, nullptr, false); if (authTokenJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } if (!authParamJson.contains(PIN_CODE_KEY) || !authTokenJson.contains(PIN_CODE_KEY)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t code = authTokenJson[PIN_CODE_KEY]; int32_t inputPinCode = authParamJson[PIN_CODE_KEY]; @@ -88,7 +88,7 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) { return DM_AUTH_INPUT_FAILED; } else { - return DM_FAILED; + return ERR_DM_FAILED; } } } // namespace DistributedHardware diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index f1bb3a441..6cc700d36 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -116,7 +116,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->createGroup(userId, requestId, DM_PKG_NAME.c_str(), jsonObj.dump().c_str()); @@ -147,7 +147,7 @@ int32_t HiChainConnector::GetGroupInfo(const std::string &queryParams, std::vect int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->getGroupInfo(userId, DM_PKG_NAME.c_str(), queryParams.c_str(), &groupVec, &num); if (ret != 0) { @@ -224,7 +224,7 @@ int32_t HiChainConnector::AddMember(const std::string &deviceId, const std::stri nlohmann::json jsonObject = nlohmann::json::parse(connectInfo, nullptr, false); if (jsonObject.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); @@ -245,7 +245,7 @@ int32_t HiChainConnector::AddMember(const std::string &deviceId, const std::stri int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->addMemberToGroup(userId, requestId, DM_PKG_NAME.c_str(), tmpStr.c_str()); LOGI("HiChainConnector::AddMember completed"); @@ -281,7 +281,7 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); - hiChainConnectorCallback_->OnMemberJoin(requestId, DM_FAILED); + hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); @@ -303,7 +303,7 @@ char *HiChainConnector::onRequest(int64_t requestId, int operationCode, const ch } nlohmann::json jsonObj; int32_t pinCode = hiChainConnectorCallback_->GetPinCode(); - if (pinCode == DM_FAILED) { + if (pinCode == ERR_DM_FAILED) { jsonObj[FIELD_CONFIRMATION] = REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = REQUEST_ACCEPTED; @@ -345,32 +345,32 @@ int32_t HiChainConnector::GetRelatedGroups(const std::string &deviceId, std::vec int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->getRelatedGroups(userId, DM_PKG_NAME.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { LOGE("HiChainConnector::GetRelatedGroups failed , ret: %d.", ret); - return DM_FAILED; + return ERR_DM_FAILED; } if (returnGroups == nullptr) { LOGE("HiChainConnector::GetRelatedGroups failed , returnGroups is nullptr"); - return DM_FAILED; + return ERR_DM_FAILED; } if (groupNum == 0) { LOGE("HiChainConnector::GetRelatedGroups group failed, groupNum is 0."); - return DM_FAILED; + return ERR_DM_FAILED; } std::string relatedGroups = std::string(returnGroups); nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups); if (jsonObject.is_discarded()) { LOGE("returnGroups parse error"); - return DM_FAILED; + return ERR_DM_FAILED; } std::vector groupInfos = jsonObject.get>(); if (groupInfos.empty()) { LOGE("HiChainConnector::GetRelatedGroups group failed, groupInfos is empty."); - return DM_FAILED; + return ERR_DM_FAILED; } groupList = groupInfos; return DM_OK; @@ -380,7 +380,7 @@ int32_t HiChainConnector::GetSyncGroupList(std::vector &groupList, st { if (groupList.empty()) { LOGE("groupList is empty."); - return DM_FAILED; + return ERR_DM_FAILED; } for (auto group : groupList) { if (IsGroupInfoInvalid(group)) { @@ -446,7 +446,7 @@ int32_t HiChainConnector::DelMemberFromGroup(const std::string &groupId, const s int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->deleteMemberFromGroup(userId, requestId, DM_PKG_NAME.c_str(), deleteParams.c_str()); @@ -466,13 +466,13 @@ int32_t HiChainConnector::DeleteGroup(std::string &groupId) int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->deleteGroup(userId, requestId, DM_PKG_NAME.c_str(), disbandParams.c_str()); if (ret != 0) { LOGE("HiChainConnector::DeleteGroup failed , ret: %d.", ret); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -486,7 +486,7 @@ int32_t HiChainConnector::DeleteGroup(const int32_t userId, std::string &groupId int32_t ret = deviceGroupManager_->deleteGroup(userId, requestId, DM_PKG_NAME.c_str(), disbandParams.c_str()); if (ret != 0) { LOGE("HiChainConnector::DeleteGroup failed , ret: %d.", ret); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -497,7 +497,7 @@ int32_t HiChainConnector::DeleteTimeOutGroup(const char* deviceId) int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } std::vector peerGroupInfoList; GetRelatedGroups(deviceId, peerGroupInfoList); @@ -509,7 +509,7 @@ int32_t HiChainConnector::DeleteTimeOutGroup(const char* deviceId) return DM_OK; } } - return DM_FAILED; + return ERR_DM_FAILED; } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index e3e858672..52bdc2ef1 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -188,7 +188,7 @@ int32_t SoftbusConnector::GetTrustedDeviceList(std::vector &device int32_t ret = GetAllNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeInfo, &infoNum); if (ret != 0) { LOGE("GetAllNodeDeviceInfo failed with ret %d", ret); - return DM_FAILED; + return ERR_DM_FAILED; } DmDeviceInfo *info = (DmDeviceInfo *)malloc(sizeof(DmDeviceInfo) * (infoNum)); if (info == nullptr) { @@ -215,7 +215,7 @@ int32_t SoftbusConnector::GetLocalDeviceInfo(DmDeviceInfo &deviceInfo) int32_t ret = GetLocalNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeBasicInfo); if (ret != 0) { LOGE("GetLocalNodeDeviceInfo failed with ret %d", ret); - return DM_FAILED; + return ERR_DM_FAILED; } CovertNodeBasicInfoToDmDevice(nodeBasicInfo, deviceInfo); LOGI("SoftbusConnector::GetLocalDeviceInfo success"); @@ -262,7 +262,7 @@ int32_t SoftbusConnector::GetUdidByNetworkId(const char *networkId, std::string GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId, NodeDeviceInfoKey::NODE_KEY_UDID, mUdid, sizeof(mUdid)); if (ret != DM_OK) { LOGE("GetUdidByNetworkId GetNodeKeyInfo failed"); - return DM_FAILED; + return ERR_DM_FAILED; } udid = (char *)mUdid; LOGI("SoftbusConnector::GetUdidByNetworkId completed"); @@ -277,7 +277,7 @@ int32_t SoftbusConnector::GetUuidByNetworkId(const char *networkId, std::string GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId, NodeDeviceInfoKey::NODE_KEY_UUID, mUuid, sizeof(mUuid)); if (ret != DM_OK) { LOGE("GetUuidByNetworkId GetNodeKeyInfo failed"); - return DM_FAILED; + return ERR_DM_FAILED; } uuid = (char *)mUuid; LOGI("SoftbusConnector::GetUuidByNetworkId completed"); @@ -342,12 +342,12 @@ int32_t SoftbusConnector::GetConnectionIpAddress(const std::string &deviceId, st auto iter = discoveryDeviceInfoMap_.find(deviceId); if (iter == discoveryDeviceInfoMap_.end()) { LOGE("deviceInfo not found by deviceId %s", GetAnonyString(deviceId).c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } DeviceInfo *deviceInfo = iter->second.get(); if (deviceInfo->addrNum <= 0 || deviceInfo->addrNum >= CONNECTION_ADDR_MAX) { LOGE("deviceInfo address num not valid, addrNum %d", deviceInfo->addrNum); - return DM_FAILED; + return ERR_DM_FAILED; } for (uint32_t i = 0; i < deviceInfo->addrNum; ++i) { // currently, only support CONNECT_ADDR_WLAN @@ -360,7 +360,7 @@ int32_t SoftbusConnector::GetConnectionIpAddress(const std::string &deviceId, st return DM_OK; } LOGE("failed to get ipAddress for deviceId %s", GetAnonyString(deviceId).c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } ConnectionAddr *SoftbusConnector::GetConnectAddrByType(DeviceInfo *deviceInfo, ConnectionAddrType type) diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp index d0022cdab..99605d7df 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp @@ -90,7 +90,7 @@ int32_t SoftbusSession::GetPeerDeviceId(int32_t sessionId, std::string &peerDevI if (ret == 0) { peerDevId = peerDeviceId; LOGI("GetPeerDeviceId success for session:%d, peerDeviceId:%s", sessionId, GetAnonyString(peerDevId).c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } LOGE("GetPeerDeviceId failed for session:%d", sessionId); peerDevId = ""; @@ -103,7 +103,7 @@ int32_t SoftbusSession::SendData(int32_t sessionId, std::string &message) nlohmann::json jsonObject = nlohmann::json::parse(message, nullptr, false); if (jsonObject.is_discarded()) { LOGE("extrasJson error"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t msgType = jsonObject[TAG_TYPE]; LOGI("AuthMessageProcessor::ParseAuthRequestMessage msgType = %d", msgType); @@ -113,7 +113,7 @@ int32_t SoftbusSession::SendData(int32_t sessionId, std::string &message) int32_t ret = SendBytes(sessionId, message.c_str(), strlen(message.c_str())); if (ret != DM_OK) { LOGE("SendData Start failed"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("SendData Start success"); return DM_OK; diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index ede24825c..afe8ea597 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -51,7 +51,7 @@ int32_t DeviceManagerService::Init() { if (intFlag_) { LOGE("Init failed, singleton cannot be initialized multiple times"); - return DM_INT_MULTIPLE; + return ERR_DM_INIT_REPEATE; } if (!PermissionManager::GetInstance().CheckPermission()) { @@ -139,7 +139,7 @@ int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, c } if (!intFlag_) { LOGE("GetTrustedDeviceList failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("GetTrustedDeviceList failed, pkgName is empty"); @@ -156,7 +156,7 @@ int32_t DeviceManagerService::GetLocalDeviceInfo(DmDeviceInfo &info) } if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } return deviceInfoMgr_->GetLocalDeviceInfo(info); } @@ -166,7 +166,7 @@ int32_t DeviceManagerService::GetUdidByNetworkId(const std::string &pkgName, con { if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { @@ -182,7 +182,7 @@ int32_t DeviceManagerService::GetUuidByNetworkId(const std::string &pkgName, con { if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { @@ -202,7 +202,7 @@ int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, c } if (!intFlag_) { LOGE("StartDeviceDiscovery failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); @@ -219,7 +219,7 @@ int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, ui } if (!intFlag_) { LOGE("StopDeviceDiscovery failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("StopDeviceDiscovery failed, pkgName is empty"); @@ -237,7 +237,7 @@ int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int } if (!intFlag_) { LOGE("AuthenticateDevice failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("AuthenticateDevice failed, pkgName is empty"); @@ -258,7 +258,7 @@ int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, c } if (!intFlag_) { LOGE("UnAuthenticateDevice failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("UnAuthenticateDevice failed, pkgName is empty"); @@ -279,7 +279,7 @@ int32_t DeviceManagerService::VerifyAuthentication(const std::string &authParam) } if (!intFlag_) { LOGE("VerifyAuthentication failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } return authMgr_->VerifyAuthentication(authParam); } diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp index 595f3326c..afcd8feb1 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp @@ -46,7 +46,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply, std::shared_ptrSetErrCode(IpcIoPopInt32(&reply)); return DM_OK; @@ -71,7 +71,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, IpcIo &reply, std::shared_ptr { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(IpcIoPopInt32(&reply)); return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp index 5f29386cd..53b01a1f3 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp @@ -38,7 +38,7 @@ int32_t IpcServerListener::GetIdentityByPkgName(std::string &name, SvcIdentity * CommonSvcId svcId; if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(name, &svcId) != DM_OK) { LOGE("get identity failed."); - return DM_FAILED; + return ERR_DM_FAILED; } CommonSvcToIdentity(&svcId, svc); return DM_OK; @@ -50,14 +50,14 @@ int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr SvcIdentity svc; if (GetIdentityByPkgName(pkgName, &svc) != DM_OK) { LOGE("OnDeviceFound callback get listener failed."); - return DM_FAILED; + return ERR_DM_FAILED; } IpcIo io; uint8_t data[MAX_DM_IPC_LEN] = {0}; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, io, data, MAX_DM_IPC_LEN) != DM_OK) { LOGE("SetRequest failed cmdCode:%d", cmdCode); - return DM_FAILED; + return ERR_DM_FAILED; } if (::SendRequest(nullptr, svc, cmdCode, &io, nullptr, LITEIPC_FLAG_ONEWAY, nullptr) != DM_OK) { diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp index f8537b0e2..43b1920a9 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp @@ -26,7 +26,7 @@ int32_t IpcServerListenermgr::RegisterListener(std::string &pkgName, const Commo { if (pkgName == "" || svcId == nullptr) { LOGE("invalid param"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("new listener register:%s", pkgName.c_str()); std::lock_guard autoLock(lock_); @@ -38,13 +38,13 @@ int32_t IpcServerListenermgr::GetListenerByPkgName(std::string &pkgName, CommonS { if (pkgName == "" || svcId == nullptr) { LOGE("invalid param"); - return DM_FAILED; + return ERR_DM_FAILED; } std::lock_guard autoLock(lock_); std::map::iterator iter = dmListenerMap_.find(pkgName); if (iter == dmListenerMap_.end()) { LOGE("listener not found for pkg:%s", pkgName.c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } *svcId = iter->second; return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 23203801c..38202c476 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -61,7 +61,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi LOGE("not found client by package name."); free(arg); arg = nullptr; - return DM_FAILED; + return ERR_DM_FAILED; } IpcServerListenermgr::GetInstance().UnregisterListener(pkgName); free(arg); @@ -128,12 +128,12 @@ int32_t UnRegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) std::string pkgName = (const char *)IpcIoPopString(req, &len); if (pkgName == "" || len == 0) { LOGE("get para failed"); - return DM_FAILED; + return ERR_DM_FAILED; } CommonSvcId svcId; if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(pkgName, &svcId) != DM_OK) { LOGE("not found listener by package name."); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = IpcServerListenermgr::GetInstance().UnregisterListener(pkgName); if (ret == DM_OK) { diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 0c29b7873..94a9fc11e 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -34,7 +34,7 @@ namespace DistributedHardware { ON_IPC_SET_REQUEST(SERVER_DEVICE_STATE_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -60,7 +60,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &reply, std::shar { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -69,7 +69,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &reply, std::shar ON_IPC_SET_REQUEST(SERVER_DEVICE_FOUND, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -95,7 +95,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, MessageParcel &reply, std::shared_ptr< { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -104,7 +104,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, MessageParcel &reply, std::shared_ptr< ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); @@ -129,7 +129,7 @@ ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_p { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -138,7 +138,7 @@ ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_p ON_IPC_SET_REQUEST(SERVER_AUTH_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -174,7 +174,7 @@ ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT, MessageParcel &reply, std::shared_ptrSetErrCode(reply.ReadInt32()); return DM_OK; @@ -183,7 +183,7 @@ ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT, MessageParcel &reply, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -215,7 +215,7 @@ ON_IPC_READ_RESPONSE(SERVER_VERIFY_AUTH_RESULT, MessageParcel &reply, std::share { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -224,7 +224,7 @@ ON_IPC_READ_RESPONSE(SERVER_VERIFY_AUTH_RESULT, MessageParcel &reply, std::share ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -246,7 +246,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, MessageParcel &reply, std::shared_ { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp index 81dcc2399..518480c4c 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp @@ -42,7 +42,7 @@ int32_t IpcServerListener::SendAll(int32_t cmdCode, std::shared_ptr req, sptr listener = iface_cast(remote); if (listener == nullptr) { LOGI("cannot get listener for package:%s.", pkgName.c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } listener->SendCmd(cmdCode, req, rsp); } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index e95e98fc5..ee1ddeeab 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -128,7 +128,7 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< if (!DeviceManagerService::GetInstance().IsServiceInitialized()) { LOGE("Device manager service has not been initialized or initialized failed."); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } LOGI("Register device manager listener for pakage name: %s", pkgName.c_str()); diff --git a/test/unittest/UTTest_auth_message_processor.cpp b/test/unittest/UTTest_auth_message_processor.cpp index df185bac1..13a2b8100 100644 --- a/test/unittest/UTTest_auth_message_processor.cpp +++ b/test/unittest/UTTest_auth_message_processor.cpp @@ -285,7 +285,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_001, testing::ext::Te jsonThumbnail[TAG_REQUEST_ID] = authResponseContext->requestId; authMessageProcessor->authSplitJsonList_.push_back(jsonThumbnail); int32_t ret = authMessageProcessor->ParseAuthRequestMessage(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_auth_request_state.cpp b/test/unittest/UTTest_auth_request_state.cpp index 8b22a6c9f..aaeeb64b2 100644 --- a/test/unittest/UTTest_auth_request_state.cpp +++ b/test/unittest/UTTest_auth_request_state.cpp @@ -155,7 +155,7 @@ HWTEST_F(AuthRequestStateTest, SetAuthManager_002, testing::ext::TestSize.Level0 * @tc.name: AuthRequestNegotiateState::TransitionTo_001 * @tc.desc: 1 set authManager to null * 2 call AuthRequestInitState::TransitionTo with authManager = null - * 4 check ret is DM_FAILED + * 4 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -167,7 +167,7 @@ HWTEST_F(AuthRequestStateTest, TransitionTo_001, testing::ext::TestSize.Level0) authManager = nullptr; authRequestState->authManager_ = authManager; int32_t ret = authRequestState->TransitionTo(std::make_shared()); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -219,7 +219,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_001, testing::ext::TestSize.Level0) * @tc.name: AuthRequestInitState::Enter_001 * @tc.desc: 1 set authManager to null * 2 call AuthRequestInitState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -231,14 +231,14 @@ HWTEST_F(AuthRequestStateTest, Enter_001, testing::ext::TestSize.Level0) authManager = nullptr; authRequestState->SetAuthManager(authManager); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: AuthRequestInitState::Enter_002 * @tc.desc: 1 set authManager not null * 2 call AuthRequestInitState::Enter with authManager != null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -276,7 +276,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_002, testing::ext::TestSize.Level0) * @tc.name: AuthRequestNegotiateState::Enter_001 * @tc.desc: 1 set authManager to null * 2 call AuthRequestNegotiateState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -287,7 +287,7 @@ HWTEST_F(AuthRequestStateTest, Enter_003, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -337,7 +337,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_003, testing::ext::TestSize.Level0) * @tc.name: AuthRequestNegotiateDoneState::Enter_005 * @tc.desc: 1 set authManager to null * 2 call AuthRequestNegotiateDoneState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -348,7 +348,7 @@ HWTEST_F(AuthRequestStateTest, Enter_005, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -399,7 +399,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_004, testing::ext::TestSize.Level0) * @tc.name: AuthRequestReplyState::Enter_007 * @tc.desc: 1 set authManager to null * 2 call AuthRequestReplyState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -410,7 +410,7 @@ HWTEST_F(AuthRequestStateTest, Enter_007, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -462,7 +462,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_005, testing::ext::TestSize.Level0) * @tc.name: AuthRequestInputState::Enter_009 * @tc.desc: 1 set authManager to null * 2 call AuthRequestInputState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -473,7 +473,7 @@ HWTEST_F(AuthRequestStateTest, Enter_009, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -513,7 +513,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_006, testing::ext::TestSize.Level0) * @tc.name: AuthRequestJoinState::Enter_011 * @tc.desc: 1 set authManager to null * 2 call AuthRequestJoinState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -524,7 +524,7 @@ HWTEST_F(AuthRequestStateTest, Enter_011, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -578,7 +578,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_007, testing::ext::TestSize.Level0) * @tc.name: AuthRequestNetworkState::Enter_013 * @tc.desc: 1 set authManager to null * 2 call AuthRequestNetworkState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -589,7 +589,7 @@ HWTEST_F(AuthRequestStateTest, Enter_013, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -638,7 +638,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_008, testing::ext::TestSize.Level0) * @tc.name: AuthRequestFinishState::Enter_015 * @tc.desc: 1 set authManager to null * 2 call AuthRequestFinishState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -649,7 +649,7 @@ HWTEST_F(AuthRequestStateTest, Enter_015, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_auth_response_state.cpp b/test/unittest/UTTest_auth_response_state.cpp index fc28c4821..d2e6682f8 100644 --- a/test/unittest/UTTest_auth_response_state.cpp +++ b/test/unittest/UTTest_auth_response_state.cpp @@ -115,7 +115,7 @@ HWTEST_F(AuthResponseStateTest, SetAuthManager_002, testing::ext::TestSize.Level * @tc.name: AuthResponseInitState::TransitionTo_001 * @tc.desc: 1 set authManager to null * 2 call AuthResponseInitState::TransitionTo with authManager = null - * 4 check ret is DM_FAILED + * 4 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -127,7 +127,7 @@ HWTEST_F(AuthResponseStateTest, TransitionTo_001, testing::ext::TestSize.Level0) authManager = nullptr; authResponseState->authManager_ = authManager; int32_t ret = authResponseState->TransitionTo(std::make_shared()); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -200,7 +200,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_002, testing::ext::TestSize.Level0) * @tc.name: AuthResponseNegotiateState::Enter_002 * @tc.desc: 1 set authManager to null * 2 call AuthResponseNegotiateState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -212,7 +212,7 @@ HWTEST_F(AuthResponseStateTest, Enter_002, testing::ext::TestSize.Level0) authManager = nullptr; authResponseState->SetAuthManager(authManager); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -265,7 +265,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_003, testing::ext::TestSize.Level0) * @tc.name: AuthResponseConfirmState::Enter_004 * @tc.desc: 1 set authManager to null * 2 call AuthResponseConfirmState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -276,7 +276,7 @@ HWTEST_F(AuthResponseStateTest, Enter_004, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -316,7 +316,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_004, testing::ext::TestSize.Level0) * @tc.name: AuthResponseGroupState::Enter_006 * @tc.desc: 1 set authManager to null * 2 call AuthResponseGroupState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -327,7 +327,7 @@ HWTEST_F(AuthResponseStateTest, Enter_006, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -368,7 +368,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_005, testing::ext::TestSize.Level0) * @tc.name: AuthResponseShowState::Enter_008 * @tc.desc: 1 set authManager to null * 2 call AuthResponseShowState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -379,7 +379,7 @@ HWTEST_F(AuthResponseStateTest, Enter_008, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -419,7 +419,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_006, testing::ext::TestSize.Level0) * @tc.name: AuthResponseFinishState::Enter_010 * @tc.desc: 1 set authManager to null * 2 call AuthResponseFinishState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -430,7 +430,7 @@ HWTEST_F(AuthResponseStateTest, Enter_010, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_device_manager_impl.cpp b/test/unittest/UTTest_device_manager_impl.cpp index d17c7b27a..ac888171b 100644 --- a/test/unittest/UTTest_device_manager_impl.cpp +++ b/test/unittest/UTTest_device_manager_impl.cpp @@ -91,7 +91,7 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_002, testing::ext::TestSize.Le std::string packName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(); - // 2. MOCK IpcClientProxy Init return DM_FAILED + // 2. MOCK IpcClientProxy Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_OK)); @@ -106,9 +106,9 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_002, testing::ext::TestSize.Le * @tc.name: InitDeviceManager_003 * @tc.desc: 1. set packName not null * set dmInitCallback not null - * 2. MOCK IpcClientProxy Init return DM_INIT_FAILED + * 2. MOCK IpcClientProxy Init return ERR_DM_INIT_FAILED * 3. call DeviceManagerImpl::InitDeviceManager with parameter - * 4. check ret is DM_INIT_FAILED + * 4. check ret is ERR_DM_INIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -119,14 +119,14 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_003, testing::ext::TestSize.Le std::string packName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(); - // 2. MOCK IpcClientProxy Init return DM_FAILED + // 2. MOCK IpcClientProxy Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_INIT_FAILED)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); // 3. call DeviceManagerImpl::InitDeviceManager with parameter int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, callback); - // 4. check ret is DM_INIT_FAILED - ASSERT_EQ(ret, DM_INIT_FAILED); + // 4. check ret is ERR_DM_INIT_FAILED + ASSERT_EQ(ret, ERR_DM_INIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -187,9 +187,9 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_001, testing::ext::TestSize. /** * @tc.name: UnInitDeviceManager_002 * @tc.desc: 1. set packName not null - * 2. MOCK IpcClientProxy UnInit return DM_UNINIT_FAILED + * 2. MOCK IpcClientProxy UnInit return ERR_DM_UNINIT_FAILED * 3. call DeviceManagerImpl::UnInitDeviceManager with parameter - * 4. check ret is DM_UNINIT_FAILED + * 4. check ret is ERR_DM_UNINIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -201,10 +201,10 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_002, testing::ext::TestSize. // 2. call DeviceManagerImpl::InitDeviceManager with parameter std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_UNINIT_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_UNINIT_FAILED)); int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_UNINIT_FAILED - ASSERT_EQ(ret, DM_UNINIT_FAILED); + // 3. check ret is ERR_DM_UNINIT_FAILED + ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -235,9 +235,9 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_003, testing::ext::TestSize. /** * @tc.name: UnInitDeviceManager_004 * @tc.desc: 1. set packName not null - * 2. MOCK IpcClientProxy UnInit return DM_INIT_FAILED + * 2. MOCK IpcClientProxy UnInit return ERR_DM_INIT_FAILED * 3. call DeviceManagerImpl::UnInitDeviceManager with parameter - * 4. check ret is DM_UNINIT_FAILED + * 4. check ret is ERR_DM_UNINIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -249,19 +249,19 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_004, testing::ext::TestSize. // 2. call DeviceManagerImpl::InitDeviceManager with parameter std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_INIT_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_UNINIT_FAILED - ASSERT_EQ(ret, DM_UNINIT_FAILED); + // 3. check ret is ERR_DM_UNINIT_FAILED + ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } /** * @tc.name: UnInitDeviceManager_005 * @tc.desc: 1. set packName not null - * 2. MOCK IpcClientProxy UnInit return DM_INIT_FAILED + * 2. MOCK IpcClientProxy UnInit return ERR_DM_INIT_FAILED * 3. call DeviceManagerImpl::UnInitDeviceManager with parameter - * 4. check ret is DM_UNINIT_FAILED + * 4. check ret is ERR_DM_UNINIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -273,10 +273,10 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_005, testing::ext::TestSize. // 2. call DeviceManagerImpl::InitDeviceManager with parameter std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_INIT_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_UNINIT_FAILED - ASSERT_EQ(ret, DM_UNINIT_FAILED); + // 3. check ret is ERR_DM_UNINIT_FAILED + ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -867,11 +867,11 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_003, testing::ext::TestSize DmSubscribeInfo subscribeInfo; std::string extra = "test"; std::shared_ptr callback = std::make_shared(); ; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -917,7 +917,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_004, testing::ext::TestSize * @tc.desc: 1. set packName not null * set subscribeInfo null * set callback not null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -933,11 +933,11 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_005, testing::ext::TestSize DmSubscribeInfo subscribeInfo; // set callback not null std::shared_ptr callback = std::make_shared(); - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); // 4. check ret is DEVICEMANAGER_IPC_FAILED @@ -971,7 +971,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_001, testing::ext::TestSize. * @tc.name: StopDeviceDiscovery_002 * @tc.desc: 1. set packName not null * set subscribeId is 0 - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter * 3. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -984,11 +984,11 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_002, testing::ext::TestSize. std::string packName = "com.ohos.test"; // set subscribeInfo is 0 uint16_t subscribeId = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1120,7 +1120,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_001, testing::ext::TestSize.L * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1138,11 +1138,11 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_002, testing::ext::TestSize.L std::string extra = ""; // set callback null std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1295,7 +1295,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_001, testing::ext::TestSize * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1443,7 +1443,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_001, testing::ext::TestSize.Level0) * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1460,7 +1460,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_002, testing::ext::TestSize.Level0) std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); // 4. check ret is DM_OK @@ -1590,7 +1590,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_001, testing::ext::TestSize.Lev * @tc.name: SetUserOperation_002 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1603,11 +1603,11 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_002, testing::ext::TestSize.Lev std::string packName = "com.ohos.test"; // set authParam null int32_t action = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1729,7 +1729,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_001, testing::ext::TestSize.L * @tc.name: GetUdidByNetworkId_002 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1743,11 +1743,11 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_002, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string udid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1872,7 +1872,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_001, testing::ext::TestSize.L * @tc.name: GetUuidByNetworkId_002 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1886,11 +1886,11 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_002, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string uuid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index b684f9546..da72c1777 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -42,7 +42,7 @@ void DeviceManagerServiceTest::TearDownTestCase() namespace { /** * @tc.name: StartDeviceDiscovery_001 - * @tc.desc: Set StartDeviceDiscovery's flag bit intFlag_ to False and return DM_NOT_INIT + * @tc.desc: Set StartDeviceDiscovery's flag bit intFlag_ to False and return ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -53,7 +53,7 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_001, testing::ext::TestS DmSubscribeInfo subscribeInfo; std::string extra = "test"; int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -92,7 +92,7 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_003, testing::ext::TestS /** * @tc.name: StopDeviceDiscovery_001 - * @tc.desc: Set StopDeviceDiscovery's flag bit intFlag_ to false and return DM_NOT_INIT + * @tc.desc: Set StopDeviceDiscovery's flag bit intFlag_ to false and return ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -102,7 +102,7 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_001, testing::ext::TestSi std::string pkgName = "com.ohos.test"; uint16_t subscribeId = 1; int ret = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -122,7 +122,7 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_002, testing::ext::TestSi /** * @tc.name: GetLocalDeviceInfo_001 - * @tc.desc: Set the flag bit of GetLocalDeviceInfo to intFlag_ to false; The return value is DM_NOT_INIT + * @tc.desc: Set the flag bit of GetLocalDeviceInfo to intFlag_ to false; The return value is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -131,7 +131,7 @@ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_001, testing::ext::TestSiz DeviceManagerService::GetInstance().intFlag_ = false; DmDeviceInfo info; int ret = DeviceManagerService::GetInstance().GetLocalDeviceInfo(info); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -150,7 +150,7 @@ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_002, testing::ext::TestSiz /** * @tc.name: Init_001 - * @tc.desc: The OnDeviceFound function does the worong case and return DM_INT_MULTIPLE + * @tc.desc: The OnDeviceFound function does the worong case and return ERR_DM_INIT_REPEATE * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -158,7 +158,7 @@ HWTEST_F(DeviceManagerServiceTest, Init_001, testing::ext::TestSize.Level0) { DeviceManagerService::GetInstance().intFlag_ = true; int ret = DeviceManagerService::GetInstance().Init(); - EXPECT_EQ(ret, DM_INT_MULTIPLE); + EXPECT_EQ(ret, ERR_DM_INIT_REPEATE); } /** @@ -177,7 +177,7 @@ HWTEST_F(DeviceManagerServiceTest, Init_002, testing::ext::TestSize.Level0) /** * @tc.name: GetTrustedDeviceList_001 - * @tc.desc: Set the intFlag of GetTrustedDeviceList to false. The return value is DM_NOT_INIT + * @tc.desc: Set the intFlag of GetTrustedDeviceList to false. The return value is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -189,7 +189,7 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_001, testing::ext::TestS std::string extra = "jdddd"; std::vector deviceList; int ret = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -210,7 +210,7 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_002, testing::ext::TestS /** * @tc.name: AuthenticateDevice_001 - * @tc.desc: 将GAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为DM_NOT_INIT + * @tc.desc: 将GAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -222,7 +222,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_001, testing::ext::TestSiz int32_t authType = 0; std::string deviceId = "2345"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -277,7 +277,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_004, testing::ext::TestSiz /** * @tc.name: UnAuthenticateDevice_001 - * @tc.desc: 将UnAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为DM_NOT_INIT + * @tc.desc: 将UnAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -287,7 +287,7 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_001, testing::ext::TestS std::string pkgName = "com.ohos.test"; std::string deviceId = "12345"; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -324,7 +324,7 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_003, testing::ext::TestS /** * @tc.name: VerifyAuthentication_001 * @tc.desc: Set intFlag for VerifyAuthentication to false and set authParam = "jdjjjj",The return value is - * DM_NOT_INIT + * ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -333,7 +333,7 @@ HWTEST_F(DeviceManagerServiceTest, VerifyAuthentication_001, testing::ext::TestS DeviceManagerService::GetInstance().intFlag_ = false; std::string authParam = "jdjjjj"; int ret = DeviceManagerService::GetInstance().VerifyAuthentication(authParam); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -356,7 +356,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_001, testing::ext::TestSiz /** * @tc.name: GetUdidByNetworkId_002 * @tc.desc: Make not init for GetUdidByNetworkId,The return value is - * DM_NOT_INIT + * ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -367,7 +367,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_002, testing::ext::TestSiz std::string netWorkId = ""; std::string udid = ""; int ret = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -407,7 +407,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_001, testing::ext::TestSiz /** * @tc.name: GetUuidByNetworkId_002 * @tc.desc: Make not init for GetUuidByNetworkId,The return value is - * DM_NOT_INIT + * ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -418,7 +418,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_002, testing::ext::TestSiz std::string netWorkId = ""; std::string uuid = ""; int ret = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, netWorkId, uuid); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** diff --git a/test/unittest/UTTest_dm_auth_manager.cpp b/test/unittest/UTTest_dm_auth_manager.cpp index 4250b6f27..20c8af727 100644 --- a/test/unittest/UTTest_dm_auth_manager.cpp +++ b/test/unittest/UTTest_dm_auth_manager.cpp @@ -57,12 +57,12 @@ HWTEST_F(DmAuthManagerTest, UnAuthenticateDevice_001, testing::ext::TestSize.Lev std::string pkgName = ""; std::string deviceId = "222"; int32_t ret = authManager->UnAuthenticateDevice(pkgName, deviceId); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::HandleAuthenticateTimeout_001 - * @tc.desc: authResponseContext_= nullptr; Call handleauthenticatemeout to check whether the return value is DM_FAILED + * @tc.desc: authResponseContext_= nullptr; Call handleauthenticatemeout to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -121,7 +121,7 @@ HWTEST_F(DmAuthManagerTest, EstablishAuthChannel_001, testing::ext::TestSize.Lev /** * @tc.name: DmAuthManager::StartAuthProcess_001 - * @tc.desc: Whether the return value of calling startauthprocess is DM_FAILED + * @tc.desc: Whether the return value of calling startauthprocess is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -211,7 +211,7 @@ HWTEST_F(DmAuthManagerTest, AddMember_001, testing::ext::TestSize.Level0) authManager->hiChainConnector_->RegisterHiChainCallback(authManager); authManager->SetAuthResponseState(authResponseState); int32_t ret = authManager->AddMember(deviceId); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -265,7 +265,7 @@ HWTEST_F(DmAuthManagerTest, GetPinCode_001, testing::ext::TestSize.Level0) std::make_shared(softbusConnector, listener, hiChainConnector_); authManager->authResponseContext_ = std::make_shared(); int32_t ret = authManager->GetPinCode(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_hichain_connector.cpp b/test/unittest/UTTest_hichain_connector.cpp index 13e041125..5a677df88 100644 --- a/test/unittest/UTTest_hichain_connector.cpp +++ b/test/unittest/UTTest_hichain_connector.cpp @@ -254,7 +254,7 @@ HWTEST_F(HichainConnectorTest, AddMember_002, testing::ext::TestSize.Level0) std::string connectInfo; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->AddMember(deviceId, connectInfo); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** @@ -336,7 +336,7 @@ HWTEST_F(HichainConnectorTest, DeleteGroup_001, testing::ext::TestSize.Level0) /** * @tc.name: GetRelatedGroups_001 - * @tc.desc: set DeviceId 123 groupList null and return DM_FAILED + * @tc.desc: set DeviceId 123 groupList null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -346,12 +346,12 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_001, testing::ext::TestSize.Leve std::vector groupList; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetRelatedGroups(DeviceId, groupList); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: GetRelatedGroups_002 - * @tc.desc: set DeviceId = 12345,groupList null and return DM_FAILED + * @tc.desc: set DeviceId = 12345,groupList null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -361,7 +361,7 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_002, testing::ext::TestSize.Leve std::vector groupList; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetRelatedGroups(DeviceId, groupList); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** @@ -381,7 +381,7 @@ HWTEST_F(HichainConnectorTest, SyncGroups_001, testing::ext::TestSize.Level0) /** * @tc.name: GetSyncGroupList_001 - * @tc.desc: set groupList null,and return DM_FAILED + * @tc.desc: set groupList null,and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -391,7 +391,7 @@ HWTEST_F(HichainConnectorTest, GetSyncGroupList_001, testing::ext::TestSize.Leve std::vector syncGroupList; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetSyncGroupList(groupList, syncGroupList); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index a7d99cc0d..2f3a99343 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -81,7 +81,7 @@ HWTEST_F(IpcClientManagerTest, OnRemoteDied_001, testing::ext::TestSize.Level0) * @tc.desc: 1. new a dmInterface * 2. set IpcClientManager dmInterface_ not null * 3. call ClientInit - * 4. check ret is not DM_FAILED + * 4. check ret is not ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -96,8 +96,8 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0) instance->dmInterface_ = dmInterface; // 3. call ClientInit int ret = instance->ClientInit(); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -105,7 +105,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0) * @tc.desc: 1. new a dmInterface * 2. set IpcClientManager dmInterface_ not null * 3. call ClientInit - * 4. check ret is not DM_FAILED + * 4. check ret is not ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -114,8 +114,8 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); // 3. call ClientInit int ret = instance->ClientInit(); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -124,7 +124,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) * 2. set a pkgName not null * 3. add listener and pkgName in dmListener_ Map * 4. call Init with pkgName - * 5. check ret is not DM_FAILED + * 5. check ret is not ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -139,16 +139,16 @@ HWTEST_F(IpcClientManagerTest, Init_001, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 4. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 5. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 5. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** * @tc.name: Init_002 * @tc.desc: 1. set pkcName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED * 3. call Init with pkgName - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -156,17 +156,17 @@ HWTEST_F(IpcClientManagerTest, Init_002, testing::ext::TestSize.Level0) { // 1. set pkcName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -272,11 +272,11 @@ HWTEST_F(IpcClientManagerTest, UnInit1, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is DM_FAILED + * 6. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -284,11 +284,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -297,8 +297,8 @@ HWTEST_F(IpcClientManagerTest, UnInit_002, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 6. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -425,11 +425,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_001, testing::ext::TestSize.Level0) /** * @tc.name: SendRequest_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is DM_FAILED + * 6. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -440,11 +440,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_002, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -453,8 +453,8 @@ HWTEST_F(IpcClientManagerTest, SendRequest_002, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 6. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_ipc_client_proxy.cpp b/test/unittest/UTTest_ipc_client_proxy.cpp index 46cb27eeb..bff54151c 100644 --- a/test/unittest/UTTest_ipc_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_proxy.cpp @@ -68,9 +68,9 @@ HWTEST_F(IpcClientProxyTest, Init_001, testing::ext::TestSize.Level0) /** * @tc.name: Init_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_FAILED + * 2. Mock IpcClient Init return ERR_DM_FAILED * 3. call IpcClientProxy Init - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -78,15 +78,15 @@ HWTEST_F(IpcClientProxyTest, Init_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_FAILED + // 2. Mock IpcClient Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_FAILED)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -186,9 +186,9 @@ HWTEST_F(IpcClientProxyTest, UnInit_001, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_FAILED + * 2. Mock IpcClient Init return ERR_DM_FAILED * 3. call IpcClientProxy UnInit - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -196,15 +196,15 @@ HWTEST_F(IpcClientProxyTest, UnInit_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_FAILED + // 2. Mock IpcClient Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -358,9 +358,9 @@ HWTEST_F(IpcClientProxyTest, SendRequest_003, testing::ext::TestSize.Level0) * @tc.name: SendRequest_004 * @tc.desc: 1. set req not nullptr * set rsp not nullptr - * 2. Mock IpcClient SendRequest return DM_FAILED + * 2. Mock IpcClient SendRequest return ERR_DM_FAILED * 3. call IpcClientProxy SendRequest - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -370,16 +370,16 @@ HWTEST_F(IpcClientProxyTest, SendRequest_004, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); // set rsp not nullptr std::shared_ptr rsp = std::make_shared(); - // 2. Mock IpcClient SendRequest return DM_FAILED + // 2. Mock IpcClient SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call IpcClientProxy SendRequest std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -398,7 +398,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest5, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); // set rsp not nullptr std::shared_ptr rsp = std::make_shared(); - // 2. Mock IpcClient SendRequest return DM_FAILED + // 2. Mock IpcClient SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index 8e2805551..70a692dde 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -56,7 +56,7 @@ namespace { * set MessageParcel not null * 2. set set code is 999 * 3. call IpcClientStub OnRemoteRequest with parameter - * 4. check result is DM_FAILED + * 4. check result is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -74,10 +74,10 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_001, testing::ext::TestSize.Level0) // 3. call IpcClientStub OnRemoteRequest with parameter int32_t result = instance->OnRemoteRequest(code, data, reply, option); if (result != DM_OK) { - result = DM_FAILED; + result = ERR_DM_FAILED; } - // 4. check result is DM_FAILED - ASSERT_EQ(result, DM_FAILED); + // 4. check result is ERR_DM_FAILED + ASSERT_EQ(result, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_ipc_server_client_proxy.cpp b/test/unittest/UTTest_ipc_server_client_proxy.cpp index 4817cdf41..e7d0c214b 100644 --- a/test/unittest/UTTest_ipc_server_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_server_client_proxy.cpp @@ -105,8 +105,8 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_002, testing::ext::TestSize.Level0) int ret = 0; std::shared_ptr ipcServerListener = std::make_shared(); ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -145,8 +145,8 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_003, testing::ext::TestSize.Level0) int ret = 0; std::shared_ptr ipcServerListener = std::make_shared(); ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -185,8 +185,8 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_004, testing::ext::TestSize.Level0) int ret = 0; std::shared_ptr ipcServerListener = std::make_shared(); ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_server_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index d9077971d..54f89567e 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -109,8 +109,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_002, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -142,8 +142,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_003, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_pin_auth.cpp b/test/unittest/UTTest_pin_auth.cpp index cb1d0cecf..52ad52741 100644 --- a/test/unittest/UTTest_pin_auth.cpp +++ b/test/unittest/UTTest_pin_auth.cpp @@ -49,7 +49,7 @@ std::shared_ptr authManager = std::make_shared(softbusConnector, listener, hiChainConnector); /** * @tc.name: DmAuthManager::ShowAuthInfo_001 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -58,12 +58,12 @@ HWTEST_F(PinAuthTest, ShowAuthInfo_001, testing::ext::TestSize.Level0) std::shared_ptr pinAuth = std::make_shared(); std::string authToken = "123456"; int32_t ret = pinAuth->ShowAuthInfo(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::ShowAuthInfo_002 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -74,7 +74,7 @@ HWTEST_F(PinAuthTest, ShowAuthInfo_002, testing::ext::TestSize.Level0) jsonObject[PIN_TOKEN] = 123456; std::string authToken = jsonObject.dump(); int32_t ret = pinAuth->ShowAuthInfo(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -110,7 +110,7 @@ HWTEST_F(PinAuthTest, ShowAuthInfo_004, testing::ext::TestSize.Level0) } /** * @tc.name: DmAuthManager::StartAuth_001 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -119,12 +119,12 @@ HWTEST_F(PinAuthTest, StartAuth_001, testing::ext::TestSize.Level0) std::shared_ptr pinAuth = std::make_shared(); std::string authToken = ""; int32_t ret = pinAuth->StartAuth(authToken, nullptr); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::StartAuth_002 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -133,12 +133,12 @@ HWTEST_F(PinAuthTest, StartAuth_002, testing::ext::TestSize.Level0) std::shared_ptr pinAuth = std::make_shared(); std::string authToken = ""; int32_t ret = pinAuth->StartAuth(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::StartAuth_003 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -149,7 +149,7 @@ HWTEST_F(PinAuthTest, StartAuth_003, testing::ext::TestSize.Level0) jsonObject[PIN_TOKEN] = 123456; std::string authToken = jsonObject.dump(); int32_t ret = pinAuth->StartAuth(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -170,7 +170,7 @@ HWTEST_F(PinAuthTest, StartAuth_004, testing::ext::TestSize.Level0) /** * @tc.name: DmAuthManager::VerifyAuthentication_001 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -180,7 +180,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_001, testing::ext::TestSize.Level0) std::string authToken; std::string authParam = "1"; int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -195,7 +195,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_002, testing::ext::TestSize.Level0) std::string authToken; std::string authParam = "0"; int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::VerifyAuthentication_003 @@ -241,7 +241,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_004, testing::ext::TestSize.Level0) /** * @tc.name: DmAuthManager::VerifyAuthentication_005 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -259,7 +259,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_005, testing::ext::TestSize.Level0) pinAuth->VerifyAuthentication(authToken, authParam); pinAuth->VerifyAuthentication(authToken, authParam); int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } } } // namespace DistributedHardware diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index b0c57e43b..ccd4fdd62 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -395,7 +395,7 @@ HWTEST_F(SoftbusConnectorTest, HaveDeviceInMap_002, testing::ext::TestSize.Level /** * @tc.name: GetConnectionIpAddress_001 - * @tc.desc: set deviceId null,and return DM_FAILED + * @tc.desc: set deviceId null,and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -404,12 +404,12 @@ HWTEST_F(SoftbusConnectorTest, GetConnectionIpAddress_001, testing::ext::TestSiz std::string deviceId; std::string ipAddress = "123456"; int ret = softbusConnector->GetConnectionIpAddress(deviceId, ipAddress); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: GetConnectionIpAddress_002 - * @tc.desc: set some corrort para,and return DM_FAILED + * @tc.desc: set some corrort para,and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -418,11 +418,11 @@ HWTEST_F(SoftbusConnectorTest, GetConnectionIpAddress_002, testing::ext::TestSiz std::string deviceId = "213456"; std::string ipAddress = "123456"; int ret = softbusConnector->GetConnectionIpAddress(deviceId, ipAddress); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: GetConnectionIpAddress_003 - * @tc.desc: set deviceInfo.addrNum = -1;go to second master and return DM_FAILED + * @tc.desc: set deviceInfo.addrNum = -1;go to second master and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -433,7 +433,7 @@ HWTEST_F(SoftbusConnectorTest, GetConnectionIpAddress_003, testing::ext::TestSiz std::string ipAddress; std::string deviceId = "3338848"; int ret = softbusConnector->GetConnectionIpAddress(deviceId, ipAddress); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_softbus_session.cpp b/test/unittest/UTTest_softbus_session.cpp index c1bcda157..ce94dc051 100644 --- a/test/unittest/UTTest_softbus_session.cpp +++ b/test/unittest/UTTest_softbus_session.cpp @@ -72,7 +72,7 @@ HWTEST_F(SoftbusSessionTest, OpenAuthSession_002, testing::ext::TestSize.Level0) /** * @tc.name: SendData_001 - * @tc.desc: set message null and return DM_FAILED + * @tc.desc: set message null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -81,12 +81,12 @@ HWTEST_F(SoftbusSessionTest, SendData_001, testing::ext::TestSize.Level0) std::string message = ""; int32_t sessionId = -1; int ret = softbusSession->SendData(sessionId, message); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: SendData_002 - * @tc.desc: set sessionId = 0 ,go to the SendBytes'smaster and return DM_FAILED + * @tc.desc: set sessionId = 0 ,go to the SendBytes'smaster and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -100,7 +100,7 @@ HWTEST_F(SoftbusSessionTest, SendData_002, testing::ext::TestSize.Level0) int32_t sessionId = 0; softbusSession->RegisterSessionCallback(std::shared_ptr(discoveryMgr)); int ret = softbusSession->SendData(sessionId, message); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** @@ -170,7 +170,7 @@ HWTEST_F(SoftbusSessionTest, RegisterSessionCallback_001, testing::ext::TestSize /** * @tc.name: UnRegisterSessionCallback_001 - * @tc.desc: set info to null and return DM_FAILED + * @tc.desc: set info to null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/auth_request_state.cpp b/test/unittest/auth_request_state.cpp index ae2d967bd..716367185 100644 --- a/test/unittest/auth_request_state.cpp +++ b/test/unittest/auth_request_state.cpp @@ -48,7 +48,7 @@ int32_t AuthRequestState::TransitionTo(std::shared_ptr state) std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthRequestState(state); @@ -68,7 +68,7 @@ int32_t AuthRequestInitState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->EstablishAuthChannel(context_->deviceId); return DM_OK; @@ -84,7 +84,7 @@ int32_t AuthRequestNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartNegotiate(context_->sessionId); return DM_OK; @@ -100,7 +100,7 @@ int32_t AuthRequestNegotiateDoneState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->SendAuthRequest(context_->sessionId); return DM_OK; @@ -116,7 +116,7 @@ int32_t AuthRequestReplyState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartRespAuthProcess(); return DM_OK; @@ -133,7 +133,7 @@ int32_t AuthRequestInputState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowStartAuthDialog(); return DM_OK; @@ -150,7 +150,7 @@ int32_t AuthRequestJoinState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AddMember(context_->deviceId); return DM_OK; @@ -166,7 +166,7 @@ int32_t AuthRequestNetworkState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->JoinNetwork(); return DM_OK; @@ -182,7 +182,7 @@ int32_t AuthRequestFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/test/unittest/auth_response_state.cpp b/test/unittest/auth_response_state.cpp index c2725a515..50e566b00 100644 --- a/test/unittest/auth_response_state.cpp +++ b/test/unittest/auth_response_state.cpp @@ -49,7 +49,7 @@ int32_t AuthResponseState::TransitionTo(std::shared_ptr state std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthResponseState(state); @@ -80,7 +80,7 @@ int32_t AuthResponseNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->RespNegotiate(context_->sessionId); return DM_OK; @@ -97,7 +97,7 @@ int32_t AuthResponseConfirmState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowConfigDialog(); return DM_OK; @@ -114,7 +114,7 @@ int32_t AuthResponseGroupState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->CreateGroup(); return DM_OK; @@ -130,7 +130,7 @@ int32_t AuthResponseShowState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowAuthInfoDialog(); return DM_OK; @@ -146,7 +146,7 @@ int32_t AuthResponseFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/test/unittest/device_manager_impl_test.cpp b/test/unittest/device_manager_impl_test.cpp index ead031314..2a1857e48 100644 --- a/test/unittest/device_manager_impl_test.cpp +++ b/test/unittest/device_manager_impl_test.cpp @@ -68,7 +68,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Leve DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(testing::Return(DM_FAILED)); + .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); ASSERT_EQ(ret, DM_IPC_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; @@ -109,7 +109,7 @@ HWTEST_F(DeviceManagerImplTest, VerifyAuthentication2, testing::ext::TestSize.Le DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(testing::Return(DM_FAILED)); + .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().VerifyAuthentication(packName, authPara, callback); ASSERT_EQ(ret, DM_IPC_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; @@ -166,7 +166,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery3, testing::ext::TestSize.Le DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(testing::Return(DM_FAILED)); + .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, test_callback_); ASSERT_EQ(ret, DM_IPC_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; diff --git a/test/unittest/mock/device_auth.cpp b/test/unittest/mock/device_auth.cpp index c3076a3d4..9a1583110 100644 --- a/test/unittest/mock/device_auth.cpp +++ b/test/unittest/mock/device_auth.cpp @@ -19,7 +19,7 @@ int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disbandParams) { if (disbandParams == 0) { - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; @@ -37,7 +37,7 @@ int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char ** int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createParams) { if (requestId == 0) { - return DM_FAILED; + return ERR_DM_FAILED; } (void)appId; (void)createParams; diff --git a/utils/src/dm_hash.cpp b/utils/src/dm_hash.cpp index 3ee316848..2477af45b 100644 --- a/utils/src/dm_hash.cpp +++ b/utils/src/dm_hash.cpp @@ -40,28 +40,28 @@ int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32]) ret = mbedtls_md_setup(&ctx, info, 0); if (ret != 0) { LOGE("mbedtls_md_setup is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = mbedtls_md_starts(&ctx); if (ret != 0) { LOGE("mbedtls_md_starts is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = mbedtls_md_update(&ctx, udid, udidDataLen); if (ret != 0) { LOGE("mbedtls_md_update is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = mbedtls_md_finish(&ctx, outudidData); if (ret != 0) { LOGE("mbedtls_md_finish is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = DM_OK; diff --git a/utils/src/dm_random.cpp b/utils/src/dm_random.cpp index 01daea9df..21dff422e 100644 --- a/utils/src/dm_random.cpp +++ b/utils/src/dm_random.cpp @@ -55,7 +55,7 @@ int32_t GetRandomData(uint8_t *randStr, uint32_t len) { mbedtls_entropy_context *entropy = nullptr; mbedtls_ctr_drbg_context *ctrDrbg = nullptr; - int32_t ret = DM_FAILED; + int32_t ret = ERR_DM_FAILED; do { if (randStr == nullptr || len == 0) { break; -- Gitee From 1cc68f3e93122eea566650a3c0abef4c04a4d646 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 25 Apr 2022 14:46:56 +0800 Subject: [PATCH 2/9] 121 Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 5 +-- .../native_cpp/src/ipc/ipc_client_proxy.cpp | 6 +-- .../ipc/standard/ipc_client_server_proxy.cpp | 2 +- .../src/authentication/dm_auth_manager.cpp | 4 +- .../dependency/hichain/hichain_connector.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 2 +- .../ipc/standard/ipc_server_client_proxy.cpp | 2 +- .../src/ipc/standard/ipc_server_listener.cpp | 2 +- .../src/ipc/standard/ipc_server_stub.cpp | 4 +- test/unittest/UTTest_device_manager_impl.cpp | 44 +++++++++---------- test/unittest/UTTest_ipc_client_proxy.cpp | 26 +++++------ .../UTTest_ipc_client_server_proxy.cpp | 2 +- .../UTTest_ipc_server_client_proxy.cpp | 2 +- test/unittest/UTTest_ipc_server_listener.cpp | 18 ++++---- test/unittest/UTTest_ipc_server_stub.cpp | 20 ++++----- test/unittest/UTTest_pin_auth_ui.cpp | 4 +- utils/src/dm_hash.cpp | 4 +- utils/src/ipc/standard/ipc_cmd_register.cpp | 4 +- 18 files changed, 76 insertions(+), 77 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 81da8d186..88141d02f 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -46,12 +46,11 @@ enum { DM_OK = -20000, ERR_DM_FAILED = -20001, ERR_DM_TIME_OUT = -20002, - ERR_DM_NOT_INIT ERR_DM_NOT_INIT = -20003, ERR_DM_INIT_REPEATE = -20004, ERR_DM_INIT_FAILED = -20005, ERR_DM_UNINIT_FAILED = -20006, - DM_POINT_NULL = -20007, + ERR_DM_POINT_NULL = -20007, DM_INPUT_PARA_EMPTY = -20008, DM_NO_PERMISSION = -20009, DM_INVALID_VALUE = -20010, @@ -82,7 +81,7 @@ enum { DM_AUTH_NOT_AUTH = -20035, DM_AUTH_DONT_AUTH = -20036, DM_AUTH_NOT_START = -20037, - DM_HICHAIN_GROUP_CREATE_FAILED = -20038, + ERR_DM_HICHAIN_CREATE_GROUP = -20038, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp index 3dc488a68..4e82edf76 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp @@ -23,7 +23,7 @@ namespace DistributedHardware { int32_t IpcClientProxy::Init(const std::string &pkgName) { if (ipcClientManager_ == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return ipcClientManager_->Init(pkgName); } @@ -31,7 +31,7 @@ int32_t IpcClientProxy::Init(const std::string &pkgName) int32_t IpcClientProxy::UnInit(const std::string &pkgName) { if (ipcClientManager_ == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return ipcClientManager_->UnInit(pkgName); } @@ -40,7 +40,7 @@ int32_t IpcClientProxy::SendRequest(int32_t cmdCode, std::shared_ptr req { if (req == nullptr || rsp == nullptr || ipcClientManager_ == nullptr) { LOGE("req,rsp or ipc client is null"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return ipcClientManager_->SendRequest(cmdCode, req, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp index 6093b9e04..91e96352b 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp @@ -27,7 +27,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r sptr remote = Remote(); if (remote == nullptr) { LOGE("remote service null"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } MessageParcel data; diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 09a7b3632..53611a4a3 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -333,7 +333,7 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId return; } if (groupId == "{}") { - authResponseContext_->reply = DM_HICHAIN_GROUP_CREATE_FAILED; + authResponseContext_->reply = ERR_DM_HICHAIN_CREATE_GROUP; authMessageProcessor_->SetResponseContext(authResponseContext_); std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_AUTH); softbusConnector_->GetSoftbusSession()->SendData(authResponseContext_->sessionId, message); @@ -768,7 +768,7 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) { if (dmAbilityMgr_ == nullptr) { LOGE("dmAbilityMgr_ is nullptr"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } if (authResponseContext_ == nullptr) { diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 6cc700d36..38167e434 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -122,7 +122,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou int32_t ret = deviceGroupManager_->createGroup(userId, requestId, DM_PKG_NAME.c_str(), jsonObj.dump().c_str()); if (ret != 0) { LOGE("Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); - return DM_HICHAIN_GROUP_CREATE_FAILED; + return ERR_DM_HICHAIN_CREATE_GROUP; } return DM_OK; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 94a9fc11e..c46b5fed3 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -312,7 +312,7 @@ ON_IPC_CMD(START_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply) std::string pkgName = data.ReadString(); std::string extra = data.ReadString(); DmSubscribeInfo *subscribeInfo = (DmSubscribeInfo *)data.ReadRawData(sizeof(DmSubscribeInfo)); - int32_t result = DM_POINT_NULL; + int32_t result = ERR_DM_POINT_NULL; if (subscribeInfo != nullptr) { LOGI("pkgName:%s, subscribeId: %d", pkgName.c_str(), subscribeInfo->subscribeId); diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp index c61e42284..7e7caab10 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp @@ -28,7 +28,7 @@ int32_t IpcServerClientProxy::SendCmd(int32_t cmdCode, std::shared_ptr r sptr remote = Remote(); if (remote == nullptr) { LOGE("remote service null"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } MessageParcel data; MessageParcel reply; diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp index 518480c4c..5589b2974 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp @@ -27,7 +27,7 @@ int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr sptr listener = IpcServerStub::GetInstance().GetDmListener(pkgName); if (listener == nullptr) { LOGI("cannot get listener for package:%s.", pkgName.c_str()); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return listener->SendCmd(cmdCode, req, rsp); } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index ee1ddeeab..35ba4fa68 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -123,7 +123,7 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< { if (pkgName.empty() || listener == nullptr) { LOGE("RegisterDeviceManagerListener error: input parameter invalid."); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } if (!DeviceManagerService::GetInstance().IsServiceInitialized()) { @@ -156,7 +156,7 @@ int32_t IpcServerStub::UnRegisterDeviceManagerListener(std::string &pkgName) { if (pkgName.empty()) { LOGE("Error: parameter invalid"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } LOGI("In, pkgName: %s", pkgName.c_str()); std::lock_guard autoLock(listenerLock_); diff --git a/test/unittest/UTTest_device_manager_impl.cpp b/test/unittest/UTTest_device_manager_impl.cpp index ac888171b..6171b1ecf 100644 --- a/test/unittest/UTTest_device_manager_impl.cpp +++ b/test/unittest/UTTest_device_manager_impl.cpp @@ -1058,7 +1058,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. * @tc.name: StopDeviceDiscovery_005 * @tc.desc: 1. set packName not null * set subscribeId is 0 - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1071,11 +1071,11 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_005, testing::ext::TestSize. std::string packName = "com.ohos.test"; // set subscribeInfo is 0 uint16_t subscribeId = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1233,7 +1233,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1252,11 +1252,11 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_005, testing::ext::TestSize.L std::string extra = ""; // set callback null std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1386,7 +1386,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1400,11 +1400,11 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_005, testing::ext::TestSize // set dmDeviceInfo null std::string deviceId = "1"; std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1539,7 +1539,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1552,11 +1552,11 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_005, testing::ext::TestSize.Level0) std::string packName = "com.ohos.helloworld"; // set dmDeviceInfo null DmAuthParam dmFaParam; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1677,7 +1677,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev * @tc.name: SetUserOperation_005 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1690,11 +1690,11 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_005, testing::ext::TestSize.Lev std::string packName = "com.ohos.test"; // set authParam null int32_t action = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1819,7 +1819,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L * @tc.name: GetUdidByNetworkId_005 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1833,11 +1833,11 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_005, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string udid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1962,7 +1962,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L * @tc.name: GetUuidByNetworkId_005 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_IPC_SEND_REQUEST_FAILED * deviceTypeId @@ -1976,11 +1976,11 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string uuid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED @@ -1992,7 +1992,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L * @tc.name: RegisterDeviceManagerFaCallback_001 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter * 4. check ret is DM_INVALID_VALUE * deviceTypeId diff --git a/test/unittest/UTTest_ipc_client_proxy.cpp b/test/unittest/UTTest_ipc_client_proxy.cpp index bff54151c..858121708 100644 --- a/test/unittest/UTTest_ipc_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_proxy.cpp @@ -48,7 +48,7 @@ namespace { * @tc.desc: 1. set pkgName not null * 2. set IpcClientProxy ipcClientManager nullptr * 3. call IpcClientProxy Init - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -61,8 +61,8 @@ HWTEST_F(IpcClientProxyTest, Init_001, testing::ext::TestSize.Level0) std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); // 3. call IpcClientProxy int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -166,7 +166,7 @@ HWTEST_F(IpcClientProxyTest, Init_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set pkgName not null * 2. set IpcClientProxy ipcClientManager nullptr * 3. call IpcClientProxy UnInit - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -179,8 +179,8 @@ HWTEST_F(IpcClientProxyTest, UnInit_001, testing::ext::TestSize.Level0) std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); // 3. call IpcClientProxy int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -301,7 +301,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest_001, testing::ext::TestSize.Level0) std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); // 3. check ret is DEVICEMANAGER_NULLPTR - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -310,7 +310,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest_001, testing::ext::TestSize.Level0) * set rsp nullptr * set IpcClientProxy ipcClientManager not null * 2. call IpcClientProxy SendRequest - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -325,8 +325,8 @@ HWTEST_F(IpcClientProxyTest, SendRequest_002, testing::ext::TestSize.Level0) // 2. call IpcClientProxy SendRequest std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -335,7 +335,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest_002, testing::ext::TestSize.Level0) * set rsp not nullptr * set IpcClientProxy ipcClientManager null * 2. call IpcClientProxy SendRequest - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -350,8 +350,8 @@ HWTEST_F(IpcClientProxyTest, SendRequest_003, testing::ext::TestSize.Level0) // 2. call IpcClientProxy SendRequest std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** diff --git a/test/unittest/UTTest_ipc_client_server_proxy.cpp b/test/unittest/UTTest_ipc_client_server_proxy.cpp index 941eb7790..a1b688600 100644 --- a/test/unittest/UTTest_ipc_client_server_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_server_proxy.cpp @@ -63,7 +63,7 @@ HWTEST_F(IpcClientServerProxyTest, SendCmd_001, testing::ext::TestSize.Level0) auto instance = new IpcClientServerProxy(remoteObject); int ret = instance->SendCmd(cmdCode, nullptr, nullptr); // 4. check ret is DEVICEMANAGER_NULLPTR - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_server_client_proxy.cpp b/test/unittest/UTTest_ipc_server_client_proxy.cpp index e7d0c214b..e62548568 100644 --- a/test/unittest/UTTest_ipc_server_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_server_client_proxy.cpp @@ -66,7 +66,7 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_001, testing::ext::TestSize.Level0) auto instance = new IpcServerClientProxy(remoteObject); int ret = instance->SendCmd(cmdCode, nullptr, nullptr); // 4. check ret is DEVICEMANAGER_NULLPTR - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** diff --git a/test/unittest/UTTest_ipc_server_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index 54f89567e..c0c7104f3 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -56,7 +56,7 @@ namespace { * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -76,8 +76,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_001, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -154,7 +154,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_003, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -175,8 +175,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_004, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -187,7 +187,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_004, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -208,8 +208,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_005, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index cb0385a5f..a4686000d 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -219,7 +219,7 @@ HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_001, testing::ext::Tes int ret = 0; sptr listener = nullptr; ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -251,7 +251,7 @@ HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_003, testing::ext::Tes int ret = 0; sptr listener = sptr(new IpcClientStub()); ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -305,7 +305,7 @@ HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_005, testing::ext::Tes /** * @tc.name: UnRegisterDeviceManagerListener_001 * @tc.desc: 1. Call IpcServerStub UnRegisterDeviceManagerListener - * 2. check ret is DM_POINT_NULL + * 2. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -314,7 +314,7 @@ HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_001, testing::ext::T std::string pkgName = ""; int ret = 0; ret = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName); - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -496,7 +496,7 @@ HWTEST_F(IpcServerStubTest, GetDmListener_003, testing::ext::TestSize.Level0) * @tc.name: GetDmListener_004 * @tc.desc: 1. Set pkgName is com.ohos.test * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -508,8 +508,8 @@ HWTEST_F(IpcServerStubTest, GetDmListener_004, testing::ext::TestSize.Level0) sptr listener = sptr(new IpcClientStub()); // 2. Call IpcServerStub RegisterDeviceManagerListener with param result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(result, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(result, ERR_DM_POINT_NULL); sptr ret = nullptr; // 2. Call IpcServerStub UnRegisterDeviceManagerListener ret = IpcServerStub::GetInstance().GetDmListener(pkgName); @@ -521,7 +521,7 @@ HWTEST_F(IpcServerStubTest, GetDmListener_004, testing::ext::TestSize.Level0) * @tc.name: GetDmListener_005 * @tc.desc: 1. Set pkgName is com.ohos.test * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -533,8 +533,8 @@ HWTEST_F(IpcServerStubTest, GetDmListener_005, testing::ext::TestSize.Level0) sptr listener = nullptr; // 2. Call IpcServerStub RegisterDeviceManagerListener with param result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(result, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(result, ERR_DM_POINT_NULL); sptr ret = nullptr; // 2. Call IpcServerStub UnRegisterDeviceManagerListener ret = IpcServerStub::GetInstance().GetDmListener(pkgName); diff --git a/test/unittest/UTTest_pin_auth_ui.cpp b/test/unittest/UTTest_pin_auth_ui.cpp index 7961e55c4..448854f0d 100644 --- a/test/unittest/UTTest_pin_auth_ui.cpp +++ b/test/unittest/UTTest_pin_auth_ui.cpp @@ -51,7 +51,7 @@ std::shared_ptr authManager = std::make_shared(softbusConnector, listener, hiChainConnector); /** * @tc.name: PinAuthUi::ShowPinDialog_001 - * @tc.desc: Call ShowPinDialog to check whether the return value is DM_POINT_NULL + * @tc.desc: Call ShowPinDialog to check whether the return value is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -79,7 +79,7 @@ HWTEST_F(PinAuthUiTest, ShowPinDialog_002, testing::ext::TestSize.Level0) /** * @tc.name: PinAuthUi::ShowPinDialog_001 - * @tc.desc: Call InputPinDialog to check whether the return value is DM_POINT_NULL + * @tc.desc: Call InputPinDialog to check whether the return value is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/utils/src/dm_hash.cpp b/utils/src/dm_hash.cpp index 2477af45b..4e12dc526 100644 --- a/utils/src/dm_hash.cpp +++ b/utils/src/dm_hash.cpp @@ -24,7 +24,7 @@ int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32]) LOGI("GetUdidHash"); if (udid == nullptr || *udid < 0) { LOGE("udid is nullptr or dataLen: %d", udidDataLen); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } mbedtls_md_context_t ctx; const mbedtls_md_info_t *info; @@ -33,7 +33,7 @@ int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32]) info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); if (info == nullptr) { LOGE("info is nullptr"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } int32_t ret = DM_OK; do { diff --git a/utils/src/ipc/standard/ipc_cmd_register.cpp b/utils/src/ipc/standard/ipc_cmd_register.cpp index 9ecd6f083..54f8c8919 100644 --- a/utils/src/ipc/standard/ipc_cmd_register.cpp +++ b/utils/src/ipc/standard/ipc_cmd_register.cpp @@ -51,7 +51,7 @@ int32_t IpcCmdRegister::ReadResponse(int32_t cmdCode, MessageParcel &reply, std: return DM_IPC_NOT_REGISTER_FUNC; } if (readResponseMapIter->second == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return (readResponseMapIter->second)(reply, pBaseRsp); } @@ -64,7 +64,7 @@ int32_t IpcCmdRegister::OnIpcCmd(int32_t cmdCode, MessageParcel &data, MessagePa return DM_IPC_NOT_REGISTER_FUNC; } if (onIpcCmdMapIter->second == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return (onIpcCmdMapIter->second)(data, reply); } -- Gitee From e66e2d73f530bf682e4130b97721f63f1fd9cf14 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 25 Apr 2022 15:41:19 +0800 Subject: [PATCH 3/9] 123 Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 59 +++--- ext/profile/src/device_profile_adapter.cpp | 4 +- ext/profile/src/profile_connector.cpp | 4 +- .../native_cpp/src/device_manager_impl.cpp | 38 ++-- .../src/ipc/lite/ipc_client_stub.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 8 +- .../src/mini/device_manager_impl.cpp | 34 ++-- .../src/authentication/dm_auth_manager.cpp | 4 +- .../dependency/hichain/hichain_connector.cpp | 2 +- .../dependency/softbus/softbus_connector.cpp | 2 +- .../src/device_manager_service.cpp | 26 +-- .../src/dispatch/command_dispatch.cpp | 2 +- .../src/ipc/lite/ipc_server_stub.cpp | 10 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 36 ++-- .../src/ipc/standard/ipc_server_stub.cpp | 2 +- test/unittest/UTTest_device_manager_impl.cpp | 188 +++++++++--------- .../UTTest_device_manager_service.cpp | 44 ++-- .../UTTest_device_profile_adapter.cpp | 8 +- .../UTTest_dm_device_info_manager.cpp | 6 +- test/unittest/UTTest_hichain_connector.cpp | 6 +- test/unittest/UTTest_ipc_cmd_register.cpp | 12 +- .../UTTest_multiple_user_connector.cpp | 6 +- test/unittest/UTTest_profile_connector.cpp | 12 +- test/unittest/device_manager_impl_test.cpp | 8 +- utils/src/ipc/standard/ipc_cmd_register.cpp | 2 +- 25 files changed, 262 insertions(+), 263 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 88141d02f..fdc2fa55b 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -51,37 +51,36 @@ enum { ERR_DM_INIT_FAILED = -20005, ERR_DM_UNINIT_FAILED = -20006, ERR_DM_POINT_NULL = -20007, - DM_INPUT_PARA_EMPTY = -20008, + ERR_DM_INPUT_PARAMETER_EMPTY = -20008, DM_NO_PERMISSION = -20009, - DM_INVALID_VALUE = -20010, - DM_FLATTEN_OBJECT = -20011, - DM_MALLOC_ERROR = -20012, - DM_COPY_FAILED = -20013, - DM_WRITE_FAILED = -20014, - DM_DISCOVERY_FAILED = -20015, - DM_MAKE_SHARED_FAIL = -20016, - DM_SERVICE_NOT_READY = -20017, - ERR_DM_KEY_ALREADY_EXISTS = -20018, - ERR_DM_INPUT_PARA_INVALID = -20019, - ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20020, - DM_IPC_FAILED = -20021, - DM_IPC_TRANSACTION_FAILED = -20022, - DM_IPC_FLATTEN_OBJECT = -20023, - DM_IPC_COPY_FAILED = -20024, - DM_IPC_SEND_REQUEST_FAILED = -20025, - DM_IPC_NOT_REGISTER_FUNC = -20026, - DM_IPC_RESPOND_ERROR = -20027, - DM_IPC_WRITE_TOKEN_ERROR = -20028, - DM_DISCOVERY_REPEATED = -20029, - DM_AUTH_NOT_SUPPORT = -20030, - DM_AUTH_BUSINESS_BUSY = -20031, - DM_AUTH_INPUT_FAILED = -20032, - DM_AUTH_OPEN_SESSION_FAILED = -20033, - DM_AUTH_PEER_REJECT = -20034, - DM_AUTH_NOT_AUTH = -20035, - DM_AUTH_DONT_AUTH = -20036, - DM_AUTH_NOT_START = -20037, - ERR_DM_HICHAIN_CREATE_GROUP = -20038, + DM_FLATTEN_OBJECT = -20010, + ERR_DM_MALLOC_FAILED = -20011, + ERR_DM_STRCOPY_FAILED = -20012, + ERR_DM_WRITE_FAILED = -20013, + DM_DISCOVERY_FAILED = -20014, + DM_MAKE_SHARED_FAIL = -20015, + DM_SERVICE_NOT_READY = -20016, + ERR_DM_KEY_ALREADY_EXISTS = -20017, + //ERR_DM_INPUT_PARAMETER_EMPTY = -20018, + ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20019, + DM_IPC_FAILED = -20020, + DM_IPC_TRANSACTION_FAILED = -20021, + DM_IPC_FLATTEN_OBJECT = -20022, + DM_IPC_COPY_FAILED = -20023, + DM_IPC_SEND_REQUEST_FAILED = -20024, + DM_IPC_NOT_REGISTER_FUNC = -20025, + DM_IPC_RESPOND_ERROR = -20026, + DM_IPC_WRITE_TOKEN_ERROR = -20027, + DM_DISCOVERY_REPEATED = -20028, + DM_AUTH_NOT_SUPPORT = -20029, + DM_AUTH_BUSINESS_BUSY = -20030, + DM_AUTH_INPUT_FAILED = -20031, + DM_AUTH_OPEN_SESSION_FAILED = -20032, + DM_AUTH_PEER_REJECT = -20033, + DM_AUTH_NOT_AUTH = -20034, + DM_AUTH_DONT_AUTH = -20035, + DM_AUTH_NOT_START = -20036, + ERR_DM_HICHAIN_CREATE_GROUP = -20037, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp index b4f6425ac..98180cd60 100755 --- a/ext/profile/src/device_profile_adapter.cpp +++ b/ext/profile/src/device_profile_adapter.cpp @@ -36,7 +36,7 @@ int32_t DeviceProfileAdapter::RegisterProfileListener(const std::string &pkgName { if (pkgName.empty() || deviceId.empty() || callback == nullptr) { LOGE("Not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("register profile listener with pkgName: %s", pkgName.c_str()); std::lock_guard mutexLock(deviceProfileAdapterMutex_); @@ -54,7 +54,7 @@ int32_t DeviceProfileAdapter::UnRegisterProfileListener(const std::string &pkgNa { if (pkgName.empty()) { LOGE("not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("unregister profile listener with pkgName: %s", pkgName.c_str()); std::lock_guard mutexLock(deviceProfileAdapterMutex_); diff --git a/ext/profile/src/profile_connector.cpp b/ext/profile/src/profile_connector.cpp index 0b28bfe41..c24c361ea 100755 --- a/ext/profile/src/profile_connector.cpp +++ b/ext/profile/src/profile_connector.cpp @@ -37,7 +37,7 @@ int32_t ProfileConnector::RegisterProfileCallback(const std::string &pkgName, co { if (pkgName.empty() || deviceId.empty() || callback == nullptr) { LOGE("Not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("register profile callback with pkgName: %s", pkgName.c_str()); @@ -62,7 +62,7 @@ int32_t ProfileConnector::UnRegisterProfileCallback(const std::string &pkgName) { if (pkgName.empty()) { LOGE("Not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("unregister profile callback with pkgName: %s", pkgName.c_str()); diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index d186da0c3..5f11f1f55 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -48,7 +48,7 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || dmInitCallback == nullptr) { LOGE("InitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } int32_t ret = DM_OK; @@ -80,7 +80,7 @@ int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName) LOGI("DeviceManager::UnInitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnInitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } int32_t ret = ipcClientProxy_->UnInit(pkgName); @@ -100,7 +100,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons LOGI("DeviceManager::GetTrustedDeviceList start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetTrustedDeviceList error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -153,7 +153,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, LOGI("DeviceManager::RegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("RegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); @@ -169,7 +169,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName LOGI("DeviceManager::UnRegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); @@ -185,7 +185,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("StartDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("DeviceManager StartDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -217,7 +217,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 LOGI("DeviceManager::StopDeviceDiscovery start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("StopDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("StopDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -249,7 +249,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("AuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::string strDeviceId = deviceInfo.deviceId; @@ -281,14 +281,14 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons if (deviceId.empty()) { LOGE("UnAuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DmDeviceInfo deviceInfo; int32_t ret = strcpy_s(deviceInfo.deviceId, DM_MAX_DEVICE_ID_LEN, deviceId.c_str()); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: copy deviceId failed"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); @@ -315,7 +315,7 @@ int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(const std::string &pk LOGI("DeviceManager::RegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("RegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, callback); LOGI("DeviceManager::RegisterDevStateCallback completed, pkgName: %s", pkgName.c_str()); @@ -327,7 +327,7 @@ int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(const std::string & LOGI("DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); LOGI("DeviceManager::UnRegisterDevStateCallback completed, pkgName: %s", pkgName.c_str()); @@ -340,7 +340,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons LOGI("DeviceManager::VerifyAuthentication start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterVerifyAuthenticationCallback(pkgName, authPara, callback); @@ -370,7 +370,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d LOGI("DeviceManager::GetFaParam start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -391,7 +391,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t LOGI("DeviceManager::SetUserOperation start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -416,7 +416,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -441,7 +441,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -465,7 +465,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, { if (pkgName.empty()) { LOGE("RegisterDevStateCallback failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -488,7 +488,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName { if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp index 34551578f..58e22c84c 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp @@ -30,7 +30,7 @@ static int32_t ClientIpcInterfaceMsgHandle(const IpcContext *ctx, void *ipcMsg, (void)arg; if (ipcMsg == nullptr || io == nullptr) { LOGE("invalid param"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } uint32_t code = 0; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index f0aa8e798..1fafaeb6a 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -353,7 +353,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, } if (!data.WriteInt32(action)) { LOGE("write action failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -378,7 +378,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -403,7 +403,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -508,7 +508,7 @@ ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, MessageParcel &data, MessageParcel &reply) DeviceManagerNotify::GetInstance().OnFaCall(packagename, paramJson); if (!reply.WriteInt32(DM_OK)) { LOGE("write return failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp index b8b944453..23c5eec19 100644 --- a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp @@ -44,7 +44,7 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || dmInitCallback == nullptr) { LOGE("InitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } CommandDispatch::GetInstance().AddPkgName(pkgName); @@ -58,7 +58,7 @@ int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName) LOGI("DeviceManager::UnInitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("InitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } CommandDispatch::GetInstance().DeletePkgName(pkgName); @@ -73,7 +73,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons LOGI("DeviceManager::GetTrustedDeviceList start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetTrustedDeviceList error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -101,7 +101,7 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi LOGI("DeviceManager::GetLocalDeviceInfo start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetLocalDeviceInfo error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -128,7 +128,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, LOGI("DeviceManager::RegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("RegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); @@ -141,7 +141,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName LOGI("DeviceManager::UnRegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); @@ -154,7 +154,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("StartDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("DeviceManager StartDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -182,7 +182,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 LOGI("DeviceManager::StopDeviceDiscovery start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("StopDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("StopDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -212,7 +212,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("AuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::string strDeviceId = deviceInfo.deviceId; @@ -243,7 +243,7 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons LOGI("DeviceManager::UnAuthenticateDevice start , pkgName: %s, deviceId: %s", pkgName.c_str(), deviceId.c_str()); if (deviceId.empty()) { LOGE("UnAuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DmDeviceInfo deviceInfo; @@ -273,7 +273,7 @@ int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(const std::string &pa LOGI("DeviceManager::RegisterDeviceManagerFaCallback start, pkgName: %s", packageName.c_str()); if (packageName.empty() || callback == nullptr) { LOGE("RegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(packageName, callback); @@ -286,7 +286,7 @@ int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(const std::string & LOGI("DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); @@ -299,7 +299,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons LOGI("DeviceManager::VerifyAuthentication start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterVerifyAuthenticationCallback(pkgName, authPara, callback); @@ -328,7 +328,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d LOGI("DeviceManager::GetFaParam start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetFaParam failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -350,7 +350,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -376,7 +376,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("GetUdidByNetworkId failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -403,7 +403,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("GetUuidByNetworkId failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 53611a4a3..70f6cdf63 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -97,8 +97,8 @@ int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t au } if (extra.empty()) { LOGE("AuthenticateDevice failed, extra is empty"); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_INPUT_PARA_EMPTY); - return DM_INPUT_PARA_EMPTY; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_INPUT_PARAMETER_EMPTY); + return ERR_DM_INPUT_PARAMETER_EMPTY; } authMessageProcessor_ = std::make_shared(shared_from_this()); diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 38167e434..2d1777520 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -96,7 +96,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou { if (deviceGroupManager_ == nullptr) { LOGE("HiChainConnector::CreateGroup group manager is null, requestId %lld.", requestId); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } GroupInfo groupInfo; if (IsGroupCreated(groupName, groupInfo)) { diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 52bdc2ef1..2fc889936 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -193,7 +193,7 @@ int32_t SoftbusConnector::GetTrustedDeviceList(std::vector &device DmDeviceInfo *info = (DmDeviceInfo *)malloc(sizeof(DmDeviceInfo) * (infoNum)); if (info == nullptr) { FreeNodeInfo(nodeInfo); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } DmDeviceInfo **pInfoList = &info; for (int32_t i = 0; i < infoNum; ++i) { diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index afe8ea597..87e7f2010 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -143,7 +143,7 @@ int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, c } if (pkgName.empty()) { LOGE("GetTrustedDeviceList failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return deviceInfoMgr_->GetTrustedDeviceList(pkgName, extra, deviceList); } @@ -171,7 +171,7 @@ int32_t DeviceManagerService::GetUdidByNetworkId(const std::string &pkgName, con if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } SoftbusConnector::GetUdidByNetworkId(netWorkId.c_str(), udid); return DM_OK; @@ -187,7 +187,7 @@ int32_t DeviceManagerService::GetUuidByNetworkId(const std::string &pkgName, con if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } SoftbusConnector::GetUuidByNetworkId(netWorkId.c_str(), uuid); return DM_OK; @@ -206,7 +206,7 @@ int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, c } if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); } @@ -223,7 +223,7 @@ int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, ui } if (pkgName.empty()) { LOGE("StopDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return discoveryMgr_->StopDeviceDiscovery(pkgName, subscribeId); } @@ -241,11 +241,11 @@ int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int } if (pkgName.empty()) { LOGE("AuthenticateDevice failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceId.empty()) { LOGE("AuthenticateDevice failed, deviceId is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return authMgr_->AuthenticateDevice(pkgName, authType, deviceId, extra); } @@ -262,11 +262,11 @@ int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, c } if (pkgName.empty()) { LOGE("UnAuthenticateDevice failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceId.empty()) { LOGE("UnAuthenticateDevice failed, deviceId is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return authMgr_->UnAuthenticateDevice(pkgName, deviceId); } @@ -288,7 +288,7 @@ int32_t DeviceManagerService::GetFaParam(std::string &pkgName, DmAuthParam &auth { if (pkgName.empty()) { LOGE("GetFaParam failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (authMgr_ != nullptr) { authMgr_->GetAuthenticationParam(authParam); @@ -300,7 +300,7 @@ int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t act { if (pkgName.empty()) { LOGE("SetUserOperation failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (authMgr_ != nullptr) { authMgr_->OnUserOperation(action); @@ -312,7 +312,7 @@ int32_t DeviceManagerService::RegisterDevStateCallback(const std::string &pkgNam { if (pkgName.empty()) { LOGE("RegisterDevStateCallback failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceStateMgr_ != nullptr) { deviceStateMgr_->RegisterDevStateCallback(pkgName, extra); @@ -324,7 +324,7 @@ int32_t DeviceManagerService::UnRegisterDevStateCallback(const std::string &pkgN { if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceStateMgr_!= nullptr) { deviceStateMgr_->UnRegisterDevStateCallback(pkgName, extra); diff --git a/services/devicemanagerservice/src/dispatch/command_dispatch.cpp b/services/devicemanagerservice/src/dispatch/command_dispatch.cpp index 79d2ded4a..9820d72de 100644 --- a/services/devicemanagerservice/src/dispatch/command_dispatch.cpp +++ b/services/devicemanagerservice/src/dispatch/command_dispatch.cpp @@ -42,7 +42,7 @@ int32_t CommandDispatch::MessageSendCmd(int32_t cmdCode, const std::shared_ptr MALLOC_MAX_LEN) { LOGE("malloc length invalid!"); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } char *pkgName = new char[len+1]; if (pkgName == nullptr) { LOGE("malloc failed!"); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } if (strcpy_s(pkgName, len + 1, (const char *)name) != DM_OK) { LOGE("strcpy_s failed!"); delete[] pkgName; - return DM_COPY_FAILED; + return ERR_DM_STRCOPY_FAILED; } uint32_t cbId = 0; RegisterDeathCallback(NULL, sid, DeathCb, pkgName, &cbId); diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index c46b5fed3..9256e470c 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -263,7 +263,7 @@ ON_IPC_CMD(GET_TRUST_DEVICE_LIST, MessageParcel &data, MessageParcel &reply) DmDeviceInfo deviceInfo; if (!reply.WriteInt32(infoNum)) { LOGE("write infoNum failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } if (!deviceList.empty()) { for (; !deviceList.empty();) { @@ -272,13 +272,13 @@ ON_IPC_CMD(GET_TRUST_DEVICE_LIST, MessageParcel &data, MessageParcel &reply) if (!reply.WriteRawData(&deviceInfo, sizeof(DmDeviceInfo))) { LOGE("write subscribeInfo failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } } } if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } LOGI("GET_TRUST_DEVICE_LIST ok pkgName:%s, extra:%s", pkgName.c_str(), extra.c_str()); return DM_OK; @@ -291,7 +291,7 @@ ON_IPC_CMD(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParcel int32_t result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -302,7 +302,7 @@ ON_IPC_CMD(UNREGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParce int32_t result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -320,7 +320,7 @@ ON_IPC_CMD(START_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply) } if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -333,7 +333,7 @@ ON_IPC_CMD(STOP_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply) int32_t result = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -349,7 +349,7 @@ ON_IPC_CMD(AUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply) LOGE("AuthenticateDevice"); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } LOGE("AuthenticateDevice %d", result); return DM_OK; @@ -364,7 +364,7 @@ ON_IPC_CMD(UNAUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply) result = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -376,7 +376,7 @@ ON_IPC_CMD(VERIFY_AUTHENTICATION, MessageParcel &data, MessageParcel &reply) int32_t result = DeviceManagerService::GetInstance().VerifyAuthentication(authPara); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -393,7 +393,7 @@ ON_IPC_CMD(GET_LOCAL_DEVICE_INFO, MessageParcel &data, MessageParcel &reply) if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } LOGI("localDeviceInfo: %s", localDeviceInfo.deviceId); return DM_OK; @@ -408,11 +408,11 @@ ON_IPC_CMD(GET_UDID_BY_NETWORK, MessageParcel &data, MessageParcel &reply) if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } if (!reply.WriteString(udid)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -426,11 +426,11 @@ ON_IPC_CMD(GET_UUID_BY_NETWORK, MessageParcel &data, MessageParcel &reply) if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } if (!reply.WriteString(uuid)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -475,7 +475,7 @@ ON_IPC_CMD(SERVER_USER_AUTH_OPERATION, MessageParcel &data, MessageParcel &reply int result = DeviceManagerService::GetInstance().SetUserOperation(packageName, action); if (!reply.WriteInt32(action)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return result; } @@ -487,7 +487,7 @@ ON_IPC_CMD(REGISTER_DEV_STATE_CALLBACK, MessageParcel &data, MessageParcel &repl int result = DeviceManagerService::GetInstance().RegisterDevStateCallback(packageName, extra); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return result; } @@ -499,7 +499,7 @@ ON_IPC_CMD(UNREGISTER_DEV_STATE_CALLBACK, MessageParcel &data, MessageParcel &re int result = DeviceManagerService::GetInstance().UnRegisterDevStateCallback(packageName, extra); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return result; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index 35ba4fa68..8b4f25a17 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -147,7 +147,7 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< appRecipient_[pkgName] = appRecipient; } catch (const std::bad_alloc &e) { LOGE("new AppDeathRecipient failed"); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } return DM_OK; } diff --git a/test/unittest/UTTest_device_manager_impl.cpp b/test/unittest/UTTest_device_manager_impl.cpp index 6171b1ecf..f1b924989 100644 --- a/test/unittest/UTTest_device_manager_impl.cpp +++ b/test/unittest/UTTest_device_manager_impl.cpp @@ -59,7 +59,7 @@ namespace { /** * @tc.name: InitDeviceManager_001 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName = null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -70,8 +70,8 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_001, testing::ext::TestSize.Le std::string packName = ""; std::shared_ptr dmInitCallback = nullptr; int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, dmInitCallback); - // 2. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -133,7 +133,7 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_003, testing::ext::TestSize.Le /** * @tc.name: InitDeviceManager_004 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName not null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -144,14 +144,14 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_004, testing::ext::TestSize.Le std::string packName = "com.ohos.test"; std::shared_ptr callback = nullptr; int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, callback); - // 2. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: InitDeviceManager_005 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName not null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -162,14 +162,14 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_005, testing::ext::TestSize.Le std::string packName = ""; std::shared_ptr callback = std::make_shared();; int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, callback); - // 2. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnInitDeviceManager_001 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName not null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -180,8 +180,8 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_001, testing::ext::TestSize. std::string packName = ""; // 2. call DeviceManagerImpl::InitDeviceManager with parameter int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -286,7 +286,7 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_005, testing::ext::TestSize. * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -301,8 +301,8 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_001, testing::ext::TestSize std::vector deviceList; // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -407,7 +407,7 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_004, testing::ext::TestSize * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -422,8 +422,8 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_005, testing::ext::TestSize std::vector deviceList; // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } @@ -433,7 +433,7 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_005, testing::ext::TestSize * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -552,7 +552,7 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_004, testing::ext::TestSize.L * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -597,8 +597,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_001, testing::ext::Test std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -632,7 +632,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_002, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -647,8 +647,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_003, testing::ext::Test std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -673,7 +673,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_004, testing::ext::Test // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra, callback); // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -682,7 +682,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_004, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -697,15 +697,15 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_005, testing::ext::Test std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_001 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -716,15 +716,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_001, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_002 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -735,15 +735,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_002, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_003 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -754,15 +754,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_003, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_004 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -773,15 +773,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_004, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_005 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -792,8 +792,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_005, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -802,7 +802,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_005, testing::ext::Te * set subscribeInfo null * set callback null * 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -818,8 +818,8 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_001, testing::ext::TestSize std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -828,7 +828,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_001, testing::ext::TestSize * set subscribeInfo null * set callback null * 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -844,8 +844,8 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_002, testing::ext::TestSize std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -950,7 +950,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_005, testing::ext::TestSize * @tc.desc: 1. set packName null * set subscribeId is 0 * 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -963,8 +963,8 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_001, testing::ext::TestSize. uint16_t subscribeId = 0; // 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1110,7 +1110,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_001, testing::ext::TestSize.L // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); // 3. check ret is DEVICEMANAGER_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1285,7 +1285,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_001, testing::ext::TestSize // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); // 3. check ret is DEVICEMANAGER_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1310,7 +1310,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_002, testing::ext::TestSize // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); // 3. check ret is DEVICEMANAGER_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1420,7 +1420,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_005, testing::ext::TestSize * set extra = null * set callback = nullptr * 2. call DeviceManagerImpl::AuthenticateDevice with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1432,8 +1432,8 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_001, testing::ext::TestSize.Level0) DmAuthParam dmFaParam; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1569,7 +1569,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set packName null * set action null * 2. call DeviceManagerImpl::SetUserOperation with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1582,8 +1582,8 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_001, testing::ext::TestSize.Lev int32_t action = 0; // 2. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1707,7 +1707,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_005, testing::ext::TestSize.Lev * @tc.desc: 1. set packName null * set action null * 2. call DeviceManagerImpl::SetUserOperation with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1721,8 +1721,8 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_001, testing::ext::TestSize.L std::string udid = "222"; // 2. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1850,7 +1850,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_005, testing::ext::TestSize.L * @tc.desc: 1. set packName null * set action null * 2. call DeviceManagerImpl::SetUserOperation with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1864,8 +1864,8 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_001, testing::ext::TestSize.L std::string uuid = "222"; // 2. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1994,7 +1994,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_INVALID_VALUE + * 4. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2007,8 +2007,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_001, testing::ex std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2038,7 +2038,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_002, testing::ex * @tc.desc: 1. set packName not null * set callback not null * 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2051,8 +2051,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_003, testing::ex std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2060,7 +2060,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_003, testing::ex * @tc.desc: 1. set packName not null * set callback not null * 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2073,8 +2073,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_004, testing::ex std::shared_ptr callback = std::make_shared(); // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2082,7 +2082,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_004, testing::ex * @tc.desc: 1. set packName not null * set callback not null * 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2095,15 +2095,15 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_005, testing::ex std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDeviceManagerFaCallback_001 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2114,8 +2114,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDeviceManagerFaCallback_001, testing:: std::string packName = ""; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDeviceManagerFaCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2257,7 +2257,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDeviceManagerFaCallback_005, testing:: * set extra null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2270,8 +2270,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_006, testing::ext::Test std::string extra= "test"; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra); - // 3. check ret is DM_INVALID_VALUE; - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY; + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2280,7 +2280,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_006, testing::ext::Test * set extra null * set callback not null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2294,7 +2294,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_007, testing::ext::Test // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2385,7 +2385,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_010, testing::ext::Test * @tc.name: UnRegisterDevStateCallback_006 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2398,15 +2398,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_006, testing::ext::Te std::string extra= ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_007 * @tc.desc: 1. set packName not null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2419,8 +2419,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_007, testing::ext::Te std::string extra= "test"; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index da72c1777..ce880b062 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -58,7 +58,7 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_001, testing::ext::TestS /** * @tc.name: StartDeviceDiscovery_002 - * @tc.desc: Empty pkgName of StartDeviceDiscovery and return DM_INPUT_PARA_EMPTY + * @tc.desc: Empty pkgName of StartDeviceDiscovery and return ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -69,7 +69,7 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_002, testing::ext::TestS std::string extra = "test"; DeviceManagerService::GetInstance().Init(); int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -107,7 +107,7 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_001, testing::ext::TestSi /** * @tc.name:StopDeviceDiscovery_002 - * @tc.desc: StopDeviceDiscovery is initialized, pkgName is null, and its return value is DM_INPUT_PARA_EMPTY + * @tc.desc: StopDeviceDiscovery is initialized, pkgName is null, and its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -117,7 +117,7 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_002, testing::ext::TestSi uint16_t subscribeId = 1; DeviceManagerService::GetInstance().Init(); int ret = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -194,7 +194,7 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_001, testing::ext::TestS /** * @tc.name: GetTrustedDeviceList_002 - * @tc.desc:Set the intFlag of GetTrustedDeviceList to true and pkgName = null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc:Set the intFlag of GetTrustedDeviceList to true and pkgName = null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -205,7 +205,7 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_002, testing::ext::TestS std::string extra = "jdddd"; std::vector deviceList; int ret = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -227,7 +227,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_001, testing::ext::TestSiz /** * @tc.name: AuthenticateDevice_002 - * @tc.desc: Set intFlag for GAuthenticateDevice to True and pkgName to null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc: Set intFlag for GAuthenticateDevice to True and pkgName to null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -239,12 +239,12 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_002, testing::ext::TestSiz int32_t authType = 0; std::string deviceId = " 2345"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: AuthenticateDevice_003 - * @tc.desc: Set intFlag for GAuthenticateDevice to True and deviceId to null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc: Set intFlag for GAuthenticateDevice to True and deviceId to null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -256,7 +256,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_003, testing::ext::TestSiz int32_t authType = 0; std::string deviceId; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: AuthenticateDevice_004 @@ -292,7 +292,7 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_001, testing::ext::TestS /** * @tc.name: UnAuthenticateDevice_002 - * @tc.desc: Set intFlag for UnAuthenticateDevice to True and pkgName to null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc: Set intFlag for UnAuthenticateDevice to True and pkgName to null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -302,13 +302,13 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_002, testing::ext::TestS std::string pkgName; std::string deviceId = "12345"; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnAuthenticateDevice_003 * @tc.desc: Set intFlag for UnAuthenticateDevice to true and pkgName to com.ohos.test; set deviceId null ,The return - * value is DM_INPUT_PARA_EMPTY + * value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -318,7 +318,7 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_003, testing::ext::TestS std::string pkgName = "com.ohos.test"; std::string deviceId; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -373,7 +373,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_002, testing::ext::TestSiz /** * @tc.name: GetUdidByNetworkId_003 * @tc.desc: Make pkgName empty for GetUdidByNetworkId,The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -384,7 +384,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_003, testing::ext::TestSiz std::string netWorkId = ""; std::string udid = ""; int ret = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -424,7 +424,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_002, testing::ext::TestSiz /** * @tc.name: GetUuidByNetworkId_003 * @tc.desc: Make pkgName empty for GetUuidByNetworkId,The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -435,7 +435,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_003, testing::ext::TestSiz std::string netWorkId = ""; std::string uuid = ""; int ret = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, netWorkId, uuid); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -456,7 +456,7 @@ HWTEST_F(DeviceManagerServiceTest, GetFaParam_001, testing::ext::TestSize.Level0 /** * @tc.name: GetFaParam_002 * @tc.desc: Make pkgName empty for GetFaParam, The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -465,7 +465,7 @@ HWTEST_F(DeviceManagerServiceTest, GetFaParam_002, testing::ext::TestSize.Level0 std::string pkgName = ""; DmAuthParam authParam; int ret = DeviceManagerService::GetInstance().GetFaParam(pkgName, authParam); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -486,7 +486,7 @@ HWTEST_F(DeviceManagerServiceTest, SetUserOperation_001, testing::ext::TestSize. /** * @tc.name: SetUserOperation_002 * @tc.desc: Make pkgName empty for SetUserOperation,The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -495,7 +495,7 @@ HWTEST_F(DeviceManagerServiceTest, SetUserOperation_002, testing::ext::TestSize. std::string pkgName = ""; int32_t action = 0; int ret = DeviceManagerService::GetInstance().SetUserOperation(pkgName, action); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** diff --git a/test/unittest/UTTest_device_profile_adapter.cpp b/test/unittest/UTTest_device_profile_adapter.cpp index 7147b4d42..c07d38685 100644 --- a/test/unittest/UTTest_device_profile_adapter.cpp +++ b/test/unittest/UTTest_device_profile_adapter.cpp @@ -48,7 +48,7 @@ std::shared_ptr deviceStateMgr = std::make_shared dmDeviceStateManager = std::make_shared discoveryMgr = /** * @tc.name: CreateGroup_001 - * @tc.desc: Set the deviceGroupManager_ pointer to CreateGroup to NULlptr and return DM_INVALID_VALUE + * @tc.desc: Set the deviceGroupManager_ pointer to CreateGroup to NULlptr and return ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -59,7 +59,7 @@ HWTEST_F(HichainConnectorTest, CreateGroup_001, testing::ext::TestSize.Level0) std::string groupName = "dfggg"; hiChainConnector->deviceGroupManager_ = nullptr; int ret = hiChainConnector->CreateGroup(requestId, groupName); - EXPECT_EQ(ret, DM_INVALID_VALUE); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -73,7 +73,7 @@ HWTEST_F(HichainConnectorTest, CreateGroup_002, testing::ext::TestSize.Level0) int64_t requestId = 123456; std::string groupName = "uuiioo"; int ret = hiChainConnector->CreateGroup(requestId, groupName); - EXPECT_EQ(ret, DM_INVALID_VALUE); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index 04e6a0b14..543d5ef66 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -75,8 +75,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_001, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -759,7 +759,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, return DM_IPC_TRANSACTION_FAILED; } if (!data.WriteInt32(action)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -782,7 +782,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq return DM_IPC_TRANSACTION_FAILED; } if (!data.WriteString(extra)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -805,7 +805,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR return DM_IPC_TRANSACTION_FAILED; } if (!data.WriteString(extra)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -908,7 +908,7 @@ ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, MessageParcel &data, MessageParcel &reply) std::string paramJson = data.ReadString(); DeviceManagerNotify::GetInstance().OnFaCall(packagename, paramJson); if (!reply.WriteInt32(DM_OK)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } diff --git a/test/unittest/UTTest_multiple_user_connector.cpp b/test/unittest/UTTest_multiple_user_connector.cpp index 7ac5fe35b..5e917427e 100644 --- a/test/unittest/UTTest_multiple_user_connector.cpp +++ b/test/unittest/UTTest_multiple_user_connector.cpp @@ -37,7 +37,7 @@ namespace { * @tc.name: OnDecisionFilterResult_001 * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is DM_INPUT_PARA_EMPTY + * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -52,7 +52,7 @@ HWTEST_F(MultipleUserConnectorTest, GetCurrentAccountUserID_001, testing::ext::T * @tc.name: SetSwitchOldUserId_001 * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is DM_INPUT_PARA_EMPTY + * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -69,7 +69,7 @@ HWTEST_F(MultipleUserConnectorTest, SetSwitchOldUserId_001, testing::ext::TestSi * @tc.name: GetSwitchOldUserId_001 * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is DM_INPUT_PARA_EMPTY + * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/UTTest_profile_connector.cpp b/test/unittest/UTTest_profile_connector.cpp index 5b5fd53ab..954577f14 100644 --- a/test/unittest/UTTest_profile_connector.cpp +++ b/test/unittest/UTTest_profile_connector.cpp @@ -48,7 +48,7 @@ std::shared_ptr deviceStateMgr = std::make_shared callback = nullptr; int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Level0) @@ -97,7 +97,7 @@ HWTEST_F(DeviceManagerImplTest, VerifyAuthentication1, testing::ext::TestSize.Le std::string authPara = ""; std::shared_ptr callback = nullptr; int32_t ret = DeviceManager::GetInstance().VerifyAuthentication(packName, authPara, callback); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, VerifyAuthentication2, testing::ext::TestSize.Level0) @@ -137,7 +137,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery1, testing::ext::TestSize.Le std::string extra = ""; std::shared_ptr callback = nullptr; int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery2, testing::ext::TestSize.Level0) diff --git a/utils/src/ipc/standard/ipc_cmd_register.cpp b/utils/src/ipc/standard/ipc_cmd_register.cpp index 54f8c8919..f3c1701dd 100644 --- a/utils/src/ipc/standard/ipc_cmd_register.cpp +++ b/utils/src/ipc/standard/ipc_cmd_register.cpp @@ -28,7 +28,7 @@ int32_t IpcCmdRegister::SetRequest(int32_t cmdCode, std::shared_ptr pBas int32_t ret = DM_OK; if (cmdCode < 0 || cmdCode >= UNREGISTER_DEV_STATE_CALLBACK || pBaseReq == nullptr) { LOGE("IpcCmdRegister::SetRequest cmdCode param invalid!"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (setIpcRequestFuncMap_.count(cmdCode) == 0) { -- Gitee From 1da6a743d6035700258f2d18258e4ed4071c3f0e Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 25 Apr 2022 20:20:02 +0800 Subject: [PATCH 4/9] test0425 Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 51 ++-- ext/pin_auth/src/pin_auth.cpp | 2 +- .../native_cpp/src/device_manager_impl.cpp | 34 +-- .../src/ipc/lite/ipc_client_manager.cpp | 2 +- .../src/ipc/lite/ipc_cmd_parser.cpp | 4 +- .../src/ipc/standard/ipc_client_manager.cpp | 10 +- .../ipc/standard/ipc_client_server_proxy.cpp | 6 +- .../src/ipc/standard/ipc_client_stub.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 50 ++-- .../src/mini/device_manager_impl.cpp | 2 +- .../src/authentication/dm_auth_manager.cpp | 26 +- .../src/config/mini/pin_auth.cpp | 2 +- .../dependency/softbus/softbus_connector.cpp | 2 +- .../src/device_manager_service.cpp | 16 +- .../src/discovery/dm_discovery_manager.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 6 +- .../ipc/standard/ipc_server_client_proxy.cpp | 4 +- .../src/ipc/standard/ipc_server_stub.cpp | 6 +- test/unittest/UTTest_device_manager_impl.cpp | 256 +++++++++--------- .../UTTest_device_manager_service.cpp | 10 +- test/unittest/UTTest_dm_discovery_manager.cpp | 8 +- test/unittest/UTTest_ipc_client_manager.cpp | 70 ++--- test/unittest/UTTest_ipc_client_proxy.cpp | 48 ++-- test/unittest/UTTest_ipc_client_stub.cpp | 6 +- test/unittest/UTTest_ipc_cmd_register.cpp | 92 +++---- test/unittest/UTTest_ipc_server_listener.cpp | 2 +- test/unittest/UTTest_pin_auth.cpp | 4 +- test/unittest/UTTest_softbus_connector.cpp | 10 +- test/unittest/device_manager_impl_test.cpp | 6 +- utils/src/ipc/lite/ipc_cmd_register.cpp | 8 +- utils/src/ipc/standard/ipc_cmd_register.cpp | 6 +- 31 files changed, 375 insertions(+), 378 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index fdc2fa55b..a0a138faa 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -47,40 +47,37 @@ enum { ERR_DM_FAILED = -20001, ERR_DM_TIME_OUT = -20002, ERR_DM_NOT_INIT = -20003, - ERR_DM_INIT_REPEATE = -20004, + ERR_DM_INIT_REPEATED = -20004, ERR_DM_INIT_FAILED = -20005, ERR_DM_UNINIT_FAILED = -20006, ERR_DM_POINT_NULL = -20007, ERR_DM_INPUT_PARAMETER_EMPTY = -20008, - DM_NO_PERMISSION = -20009, - DM_FLATTEN_OBJECT = -20010, + DM_NO_PERMISSION = -20009,///111 + DM_FLATTEN_OBJECT = -20010,///11111 ERR_DM_MALLOC_FAILED = -20011, ERR_DM_STRCOPY_FAILED = -20012, ERR_DM_WRITE_FAILED = -20013, - DM_DISCOVERY_FAILED = -20014, - DM_MAKE_SHARED_FAIL = -20015, - DM_SERVICE_NOT_READY = -20016, - ERR_DM_KEY_ALREADY_EXISTS = -20017, - //ERR_DM_INPUT_PARAMETER_EMPTY = -20018, - ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20019, - DM_IPC_FAILED = -20020, - DM_IPC_TRANSACTION_FAILED = -20021, - DM_IPC_FLATTEN_OBJECT = -20022, - DM_IPC_COPY_FAILED = -20023, - DM_IPC_SEND_REQUEST_FAILED = -20024, - DM_IPC_NOT_REGISTER_FUNC = -20025, - DM_IPC_RESPOND_ERROR = -20026, - DM_IPC_WRITE_TOKEN_ERROR = -20027, - DM_DISCOVERY_REPEATED = -20028, - DM_AUTH_NOT_SUPPORT = -20029, - DM_AUTH_BUSINESS_BUSY = -20030, - DM_AUTH_INPUT_FAILED = -20031, - DM_AUTH_OPEN_SESSION_FAILED = -20032, - DM_AUTH_PEER_REJECT = -20033, - DM_AUTH_NOT_AUTH = -20034, - DM_AUTH_DONT_AUTH = -20035, - DM_AUTH_NOT_START = -20036, - ERR_DM_HICHAIN_CREATE_GROUP = -20037, + ERR_DM_DISCOVERY = -20014, + ERR_DM_KEY_ALREADY_EXISTS = -20015, + ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20016, + FAILED_DM_IPC = -20017, + FAILED_DM_IPC_COMMUNICATION = -20018, + FAILED_DM_IPC_WRITE = -20019, + FAILED_DM_IPC_COPY = -20020, + FAILED_DM_IPC_SEND_REQUEST = -20021, + ERR_DM_IPC_REGISTER_FUNC = -20022, + ERR_DM_IPC_RESPOND = -20023, + ERR_DM_IPC_WRITE_TOKEN = -20024, + ERR_DM_DISCOVERY_REPEATED = -20025, + ERR_DM_AUTH_BUSINESS_BUSY = -20026, + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20027, + FAILED_DM_AUTH_OPEN_SESSION = -20028, + + DM_AUTH_PEER_REJECT = -20033,/// + DM_AUTH_NOT_AUTH = -20034,/// + DM_AUTH_DONT_AUTH = -20035,/// + DM_AUTH_NOT_START = -20036,//// + ERR_DM_HICHAIN_CREATE_GROUP = -20037,//// }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index bc0b09bc5..34a2182ad 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -95,7 +95,7 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string if (code == inputPinCode && pinToken == inputPinToken) { return DM_OK; } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) { - return DM_AUTH_INPUT_FAILED; + return ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; } else { return ERR_DM_FAILED; } diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 5f11f1f55..5ad7bdacd 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -110,13 +110,13 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(GET_TRUST_DEVICE_LIST, req, rsp); if (ret != DM_OK) { LOGE("GetTrustedDeviceList error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetTrustedDeviceList error: failed ret: %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } deviceList = rsp->GetDeviceVec(); @@ -133,13 +133,13 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi int32_t ret = ipcClientProxy_->SendRequest(GET_LOCAL_DEVICE_INFO, req, rsp); if (ret != DM_OK) { LOGE("GetLocalDeviceInfo error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } info = rsp->GetLocalDeviceInfo(); @@ -199,7 +199,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(START_DEVICE_DISCOVER, req, rsp); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -228,7 +228,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 int32_t ret = ipcClientProxy_->SendRequest(STOP_DEVICE_DISCOVER, req, rsp); if (ret != DM_OK) { LOGE("StopDeviceDiscovery error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -263,13 +263,13 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Failed with ret %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; @@ -297,12 +297,12 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = ipcClientProxy_->SendRequest(UNAUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); @@ -353,7 +353,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(VERIFY_AUTHENTICATION, req, rsp); if (ret != DM_OK) { LOGE("VerifyAuthentication error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -379,7 +379,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d if (ipcClientProxy_->SendRequest(SERVER_GET_DMFA_INFO, req, rsp) != DM_OK) { LOGI("DeviceManagerImpl::GetFaParam start 2"); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } dmFaParam = rsp->GetDmAuthParam(); LOGI("GetFaParam completed, pkgName: %s", pkgName.c_str()); @@ -400,7 +400,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t req->SetOperation(action); if (ipcClientProxy_->SendRequest(SERVER_USER_AUTH_OPERATION, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -425,7 +425,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const req->SetNetWorkId(netWorkId); if (ipcClientProxy_->SendRequest(GET_UDID_BY_NETWORK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -450,7 +450,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const req->SetNetWorkId(netWorkId); if (ipcClientProxy_->SendRequest(GET_UUID_BY_NETWORK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -474,7 +474,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, req->SetExtra(extra); if (ipcClientProxy_->SendRequest(REGISTER_DEV_STATE_CALLBACK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -497,7 +497,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName req->SetExtra(extra); if (ipcClientProxy_->SendRequest(UNREGISTER_DEV_STATE_CALLBACK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp index 1c19f249c..4834f1a8b 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp @@ -82,7 +82,7 @@ int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr r { std::string pkgName = req->GetPkgName(); if (!IsInit(pkgName)) { - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } return serverProxy_.SendCmd(cmdCode, req, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index d09959e04..c8398d463 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -96,8 +96,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptrSetErrCode(DM_IPC_TRANSACTION_FAILED); - return DM_IPC_TRANSACTION_FAILED; + pRsp->SetErrCode(FAILED_DM_IPC_COMMUNICATION); + return FAILED_DM_IPC_COMMUNICATION; } for (int32_t i = 0; i < deviceNum; ++i) { deviceInfoVec.emplace_back(*pDmDeviceinfo); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp index d7b674e4d..383c4b57c 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp @@ -46,13 +46,13 @@ int32_t IpcClientManager::ClientInit() auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (samgr == nullptr) { LOGE("Get SystemAbilityManager Failed"); - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } auto object = samgr->CheckSystemAbility(DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); if (object == nullptr) { LOGE("Get DeviceManager SystemAbility Failed"); - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } if (dmRecipient_ == nullptr) { @@ -103,7 +103,7 @@ int32_t IpcClientManager::UnInit(const std::string &pkgName) LOGI("in, pkgName %s", pkgName.c_str()); if (dmInterface_ == nullptr) { LOGE("DeviceManager not Init"); - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } std::lock_guard autoLock(lock_); @@ -131,8 +131,8 @@ int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr r LOGI("IpcClientManager::SendRequest in"); std::string pkgName = req->GetPkgName(); if (!IsInit(pkgName)) { - LOGE("IpcClientManager::SendRequest DM_SERVICE_NOT_READY"); - return DM_SERVICE_NOT_READY; + LOGE("IpcClientManager::SendRequest ERR_DM_NOT_INIT"); + return ERR_DM_NOT_INIT; } LOGI("IpcClientManager::SendRequest cmdCode: %d", cmdCode); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp index 91e96352b..69b0459c6 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp @@ -35,14 +35,14 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { LOGE("WriteInterfaceToken fail!"); - return DM_IPC_WRITE_TOKEN_ERROR; + return ERR_DM_IPC_WRITE_TOKEN; } if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } if (remote->SendRequest((uint32_t)cmdCode, data, reply, option) != DM_OK) { LOGE("SendRequest fail, cmd:%d", cmdCode); - return DM_IPC_SEND_REQUEST_FAILED; + return FAILED_DM_IPC_SEND_REQUEST; } return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp index da1049da2..2b5a90e4e 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp @@ -48,7 +48,7 @@ int32_t IpcClientStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { LOGE("set request cmd failed"); - return DM_IPC_FAILED; + return FAILED_DM_IPC; } LOGI("cmdCode = %d, flags= %d.", cmdCode, option.GetFlags()); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index 1fafaeb6a..83c4b3e7b 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -46,11 +46,11 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteRemoteObject(listener)) { LOGE("write listener failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } return DM_OK; } @@ -70,7 +70,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { LOGE("write papam failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } return DM_OK; } @@ -88,11 +88,11 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { LOGE("write pkg failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } return DM_OK; } @@ -113,8 +113,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt LOGE("pRsp is null"); return ERR_DM_FAILED; } - pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED); - return DM_IPC_TRANSACTION_FAILED; + pRsp->SetErrCode(FAILED_DM_IPC_COMMUNICATION); + return FAILED_DM_IPC_COMMUNICATION; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -196,11 +196,11 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Mess const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) { LOGE("write subscribe info failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -218,11 +218,11 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa uint16_t subscribeId = pReq->GetSubscribeId(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteInt16((int16_t)subscribeId)) { LOGE("write subscribeId failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -248,19 +248,19 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { LOGE("write extra failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteInt32(authType)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -283,11 +283,11 @@ ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Mess std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { LOGE("write extra failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -303,7 +303,7 @@ ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr pBaseReq, Mess std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string authPara = pReq->GetAuthPara(); if (!data.WriteString(authPara)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -320,7 +320,7 @@ ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr pBaseReq, Messa std::string packagename = pReq->GetPkgName(); if (!data.WriteString(packagename)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -349,7 +349,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteInt32(action)) { LOGE("write action failed"); @@ -374,7 +374,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteString(extra)) { LOGE("write extra failed"); @@ -399,7 +399,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteString(extra)) { LOGE("write extra failed"); @@ -423,7 +423,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); + reply.WriteInt32(FAILED_DM_IPC_COPY); return DM_OK; } switch (deviceState) { @@ -455,8 +455,8 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); - return DM_IPC_COPY_FAILED; + reply.WriteInt32(FAILED_DM_IPC_COPY); + return FAILED_DM_IPC_COPY; } DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); reply.WriteInt32(DM_OK); diff --git a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp index 23c5eec19..f23a628ed 100644 --- a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp @@ -114,7 +114,7 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi if (rsp->GetErrCode() != DM_OK) { LOGE("GetLocalDeviceInfo error: failed ret: %d", rsp->GetErrCode()); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } info = rsp->GetLocalDeviceInfo(); diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 70f6cdf63..98ea8d09c 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -80,20 +80,20 @@ int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t au std::shared_ptr authentication = authenticationMap_[authType]; if (authentication == nullptr) { LOGE("DmAuthManager::AuthenticateDevice authType %d not support.", authType); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_NOT_SUPPORT); - return DM_AUTH_NOT_SUPPORT; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_FAILED); + return ERR_DM_FAILED; } if (authRequestState_ != nullptr || authResponseState_ != nullptr) { LOGE("DmAuthManager::AuthenticateDevice %s is request authentication.", pkgName.c_str()); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_BUSINESS_BUSY); - return DM_AUTH_BUSINESS_BUSY; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_AUTH_BUSINESS_BUSY); + return ERR_DM_AUTH_BUSINESS_BUSY; } if (!softbusConnector_->HaveDeviceInMap(deviceId)) { LOGE("AuthenticateDevice failed, the discoveryDeviceInfoMap_ not have this device"); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_INPUT_FAILED); - return DM_AUTH_INPUT_FAILED; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_AUTH_INPUT_PARAMETER_EMPTY); + return ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; } if (extra.empty()) { LOGE("AuthenticateDevice failed, extra is empty"); @@ -186,12 +186,12 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) case DM_OK: authRequestState_->TransitionTo(std::make_shared()); break; - case DM_AUTH_INPUT_FAILED: + case ERR_DM_AUTH_INPUT_PARAMETER_EMPTY: listener_->OnVerifyAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, - DM_AUTH_INPUT_FAILED, ""); + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY, ""); break; default: - authRequestContext_->reason = DM_AUTH_INPUT_FAILED; + authRequestContext_->reason = ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; authResponseContext_->state = authRequestState_->GetStateType(); authRequestState_->TransitionTo(std::make_shared()); break; @@ -220,7 +220,7 @@ void DmAuthManager::OnSessionOpened(int32_t sessionId, int32_t sessionSide, int3 std::shared_ptr authMessageProcessor = std::make_shared(shared_from_this()); std::shared_ptr authResponseContext = std::make_shared(); - authResponseContext->reply = DM_AUTH_BUSINESS_BUSY; + authResponseContext->reply = ERR_DM_AUTH_BUSINESS_BUSY; authMessageProcessor->SetResponseContext(authResponseContext); std::string message = authMessageProcessor->CreateSimpleMessage(MSG_TYPE_REQ_AUTH_TERMINATE); softbusConnector_->GetSoftbusSession()->SendData(sessionId, message); @@ -364,7 +364,7 @@ void DmAuthManager::OnMemberJoin(int64_t requestId, int32_t status) if (status != DM_OK || authResponseContext_->requestId != requestId) { if (authRequestState_ != nullptr) { authResponseContext_->state = AuthState::AUTH_REQUEST_JOIN; - authRequestContext_->reason = DM_AUTH_INPUT_FAILED; + authRequestContext_->reason = ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; authRequestState_->TransitionTo(std::make_shared()); return; } @@ -401,7 +401,7 @@ int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) LOGE("OpenAuthSession failed, stop the authentication"); authResponseContext_ = std::make_shared(); authResponseContext_->state = AuthState::AUTH_REQUEST_NEGOTIATE; - authRequestContext_->reason = DM_AUTH_OPEN_SESSION_FAILED; + authRequestContext_->reason = FAILED_DM_AUTH_OPEN_SESSION; authRequestState_->TransitionTo(std::make_shared()); } return DM_OK; @@ -440,7 +440,7 @@ void DmAuthManager::RespNegotiate(const int32_t &sessionId) std::shared_ptr authentication = authenticationMap_[authResponseContext_->authType]; if (authentication == nullptr) { LOGE("DmAuthManager::AuthenticateDevice authType %d not support.", authResponseContext_->authType); - authResponseContext_->reply = DM_AUTH_NOT_SUPPORT; + authResponseContext_->reply = ERR_DM_FAILED; } std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_NEGOTIATE); diff --git a/services/devicemanagerservice/src/config/mini/pin_auth.cpp b/services/devicemanagerservice/src/config/mini/pin_auth.cpp index ac09ac523..e38953ac2 100644 --- a/services/devicemanagerservice/src/config/mini/pin_auth.cpp +++ b/services/devicemanagerservice/src/config/mini/pin_auth.cpp @@ -86,7 +86,7 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string if (code == inputPinCode) { return DM_OK; } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) { - return DM_AUTH_INPUT_FAILED; + return ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; } else { return ERR_DM_FAILED; } diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 2fc889936..cf61c15bc 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -237,7 +237,7 @@ int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo) int32_t ret = ::StartDiscovery(DM_PKG_NAME.c_str(), &subscribeInfo, &softbusDiscoveryCallback_); if (ret != 0) { LOGE("StartDiscovery failed with ret %d.", ret); - return DM_DISCOVERY_FAILED; + return ERR_DM_DISCOVERY; } return DM_OK; } diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index 87e7f2010..f24747d8d 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -51,7 +51,7 @@ int32_t DeviceManagerService::Init() { if (intFlag_) { LOGE("Init failed, singleton cannot be initialized multiple times"); - return ERR_DM_INIT_REPEATE; + return ERR_DM_INIT_REPEATED; } if (!PermissionManager::GetInstance().CheckPermission()) { @@ -63,35 +63,35 @@ int32_t DeviceManagerService::Init() softbusConnector_ = std::make_shared(); if (softbusConnector_ == nullptr) { LOGE("Init failed, softbusConnector_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (listener_ == nullptr) { listener_ = std::make_shared(); if (softbusConnector_ == nullptr) { LOGE("Init failed, listener_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (hiChainConnector_ == nullptr) { hiChainConnector_ = std::make_shared(); if (hiChainConnector_ == nullptr) { LOGE("Init failed, hiChainConnector_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (deviceInfoMgr_ == nullptr) { deviceInfoMgr_ = std::make_shared(softbusConnector_); if (deviceInfoMgr_ == nullptr) { LOGE("Init failed, deviceInfoMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (deviceStateMgr_ == nullptr) { deviceStateMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_); if (deviceStateMgr_ == nullptr) { LOGE("Init failed, deviceStateMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } deviceStateMgr_->RegisterSoftbusStateCallback(); } @@ -99,14 +99,14 @@ int32_t DeviceManagerService::Init() discoveryMgr_ = std::make_shared(softbusConnector_, listener_); if (discoveryMgr_ == nullptr) { LOGE("Init failed, discoveryMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (authMgr_ == nullptr) { authMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_); if (authMgr_ == nullptr) { LOGE("Init failed, authMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } softbusConnector_->GetSoftbusSession()->RegisterSessionCallback(authMgr_); hiChainConnector_->RegisterHiChainCallback(authMgr_); diff --git a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp index bc8f80ad3..22ce91657 100644 --- a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp +++ b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp @@ -60,7 +60,7 @@ int32_t DmDiscoveryManager::StartDeviceDiscovery(const std::string &pkgName, con if (!discoveryQueue_.empty()) { if (pkgName == discoveryQueue_.front()) { LOGE("DmDiscoveryManager::StartDeviceDiscovery repeated, pkgName:%s", pkgName.c_str()); - return DM_DISCOVERY_REPEATED; + return ERR_DM_DISCOVERY_REPEATED; } else { LOGI("DmDiscoveryManager::StartDeviceDiscovery stop preview discovery first, the preview pkgName is %s", discoveryQueue_.front().c_str()); diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 9256e470c..3d1442245 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -450,19 +450,19 @@ ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply) !reply.WriteInt32(authParam.business) || !reply.WriteInt32(authParam.pincode) || !reply.WriteInt32(appIconLen) || !reply.WriteInt32(appThumbnailLen)) { LOGE("write reply failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (appIconLen > 0 && authParam.imageinfo.GetAppIcon() != nullptr) { if (!reply.WriteRawData(authParam.imageinfo.GetAppIcon(), appIconLen)) { LOGE("write appIcon failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } } if (appThumbnailLen > 0 && authParam.imageinfo.GetAppThumbnail() != nullptr) { if (!reply.WriteRawData(authParam.imageinfo.GetAppThumbnail(), appThumbnailLen)) { LOGE("write appThumbnail failed"); - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } } return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp index 7e7caab10..290d4bbf8 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp @@ -34,11 +34,11 @@ int32_t IpcServerClientProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageParcel reply; MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { - return DM_IPC_FAILED; + return FAILED_DM_IPC; } if (remote->SendRequest((uint32_t)cmdCode, data, reply, option) != DM_OK) { LOGE("SendRequest fail, cmd:%d", cmdCode); - return DM_IPC_FAILED; + return FAILED_DM_IPC; } return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index 8b4f25a17..af91dd99f 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -88,7 +88,7 @@ int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa } int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply); - if (ret == DM_IPC_NOT_REGISTER_FUNC) { + if (ret == ERR_DM_REGISTER_FUNC) { LOGW("unsupported code: %d", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -103,11 +103,11 @@ int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { LOGE("set request cmd failed"); - return DM_IPC_FAILED; + return FAILED_DM_IPC; } int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - if (ret == DM_IPC_NOT_REGISTER_FUNC) { + if (ret == ERR_DM_REGISTER_FUNC) { LOGW("unsupported code: %d", cmdCode); return IPCObjectStub::OnRemoteRequest(cmdCode, data, reply, option); } diff --git a/test/unittest/UTTest_device_manager_impl.cpp b/test/unittest/UTTest_device_manager_impl.cpp index f1b924989..faa415536 100644 --- a/test/unittest/UTTest_device_manager_impl.cpp +++ b/test/unittest/UTTest_device_manager_impl.cpp @@ -310,9 +310,9 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_001, testing::ext::TestSize * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + * 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -325,15 +325,15 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_002, testing::ext::TestSize std::string extra = ""; // set deviceList null std::vector deviceList; - // 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + // 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_SEND_REQUEST_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC_SEND_REQUEST)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -374,9 +374,9 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_003, testing::ext::TestSize * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -389,15 +389,15 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_004, testing::ext::TestSize std::string extra = "test"; // set deviceList null std::vector deviceList; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -444,14 +444,14 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + // 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1).WillOnce(testing::Return(DM_OK)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST ASSERT_EQ(ret, DM_OK); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -461,9 +461,9 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.L * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + * 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -474,15 +474,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_002, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + // 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_SEND_REQUEST_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC_SEND_REQUEST)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -521,9 +521,9 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_003, testing::ext::TestSize.L * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -534,15 +534,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_004, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -563,15 +563,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_005, testing::ext::TestSize.L std::string packName = ""; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -874,8 +874,8 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_003, testing::ext::TestSize .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -919,7 +919,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_004, testing::ext::TestSize * set callback not null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -941,7 +941,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_005, testing::ext::TestSize // 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); // 4. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -973,7 +973,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_001, testing::ext::TestSize. * set subscribeId is 0 * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -991,8 +991,8 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_002, testing::ext::TestSize. .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1029,9 +1029,9 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_003, testing::ext::TestSize. * @tc.name: StopDeviceDiscovery_004 * @tc.desc: 1. set packName not null * set subscribeId is 0 - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1042,15 +1042,15 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. std::string packName = "com.ohos.test"; // set subscribeInfo is 0 uint16_t subscribeId = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1060,7 +1060,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. * set subscribeId is 0 * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1078,8 +1078,8 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_005, testing::ext::TestSize. .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1122,7 +1122,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_001, testing::ext::TestSize.L * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1145,8 +1145,8 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_002, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1195,9 +1195,9 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_003, testing::ext::TestSize.L * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1214,15 +1214,15 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L std::string extra = ""; // set callback null std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1235,7 +1235,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1259,8 +1259,8 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_005, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1297,7 +1297,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_001, testing::ext::TestSize * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1353,9 +1353,9 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_003, testing::ext::TestSize * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1367,15 +1367,15 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize // set dmDeviceInfo null std::string deviceId = "1"; std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1388,7 +1388,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1407,8 +1407,8 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_005, testing::ext::TestSize .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1445,7 +1445,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_001, testing::ext::TestSize.Level0) * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1464,7 +1464,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_002, testing::ext::TestSize.Level0) // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); // 4. check ret is DM_OK - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1507,9 +1507,9 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_003, testing::ext::TestSize.Level0) * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1520,15 +1520,15 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) std::string packName = "com.ohos.helloworld"; // set dmDeviceInfo null DmAuthParam dmFaParam; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1541,7 +1541,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1559,8 +1559,8 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_005, testing::ext::TestSize.Level0) .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1592,7 +1592,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_001, testing::ext::TestSize.Lev * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1610,8 +1610,8 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_002, testing::ext::TestSize.Lev .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1648,9 +1648,9 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_003, testing::ext::TestSize.Lev * @tc.name: SetUserOperation_004 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1661,15 +1661,15 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev std::string packName = "com.ohos.test"; // set authParam null int32_t action = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1679,7 +1679,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1697,8 +1697,8 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_005, testing::ext::TestSize.Lev .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1731,7 +1731,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_001, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1750,8 +1750,8 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_002, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1789,9 +1789,9 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_003, testing::ext::TestSize.L * @tc.name: GetUdidByNetworkId_004 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1803,15 +1803,15 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string udid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1821,7 +1821,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1840,8 +1840,8 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_005, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1874,7 +1874,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_001, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1893,8 +1893,8 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_002, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1932,9 +1932,9 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_003, testing::ext::TestSize.L * @tc.name: GetUuidByNetworkId_004 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1946,15 +1946,15 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string uuid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1964,7 +1964,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1983,8 +1983,8 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2303,7 +2303,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_007, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2317,11 +2317,11 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_008, testing::ext::Test std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2331,7 +2331,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_008, testing::ext::Test * set extra not null * set callback not null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2345,11 +2345,11 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_009, testing::ext::Test std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2429,7 +2429,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_007, testing::ext::Te * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2443,11 +2443,11 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_008, testing::ext::Te std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2457,7 +2457,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_008, testing::ext::Te * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is FAILED_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2471,11 +2471,11 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_009, testing::ext::Te std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index ce880b062..9a00a986a 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -75,7 +75,7 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_002, testing::ext::TestS /** * @tc.name: StartDeviceDiscovery_003 * @tc.desc: Call StartDeviceDiscovery twice with pkgName not null and flag bit not false and return - * DM_DISCOVERY_REPEATED + * ERR_DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -87,7 +87,7 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_003, testing::ext::TestS int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); pkgName = "1com.ohos.test1"; ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_DISCOVERY_FAILED); + EXPECT_EQ(ret, ERR_DM_DISCOVERY); } /** @@ -150,7 +150,7 @@ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_002, testing::ext::TestSiz /** * @tc.name: Init_001 - * @tc.desc: The OnDeviceFound function does the worong case and return ERR_DM_INIT_REPEATE + * @tc.desc: The OnDeviceFound function does the worong case and return ERR_DM_INIT_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -158,7 +158,7 @@ HWTEST_F(DeviceManagerServiceTest, Init_001, testing::ext::TestSize.Level0) { DeviceManagerService::GetInstance().intFlag_ = true; int ret = DeviceManagerService::GetInstance().Init(); - EXPECT_EQ(ret, ERR_DM_INIT_REPEATE); + EXPECT_EQ(ret, ERR_DM_INIT_REPEATED); } /** @@ -272,7 +272,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_004, testing::ext::TestSiz int32_t authType = 0; std::string deviceId = "123456"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_AUTH_NOT_SUPPORT); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_dm_discovery_manager.cpp b/test/unittest/UTTest_dm_discovery_manager.cpp index 686c1f36a..e0af96cdb 100644 --- a/test/unittest/UTTest_dm_discovery_manager.cpp +++ b/test/unittest/UTTest_dm_discovery_manager.cpp @@ -76,7 +76,7 @@ HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_002, testing::ext::TestSize. /** * @tc.name:StartDeviceDiscovery_001 * @tc.desc: keeping pkgame unchanged, call StartDeviceDiscovery twice - * so that its discoveryQueue is not empty and return DM_DISCOVERY_REPEATED + * so that its discoveryQueue is not empty and return ERR_DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -87,13 +87,13 @@ HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_001, testing::ext::TestSiz const std::string extra; discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); int32_t ret = discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_DISCOVERY_REPEATED); + EXPECT_EQ(ret, ERR_DM_DISCOVERY_REPEATED); } /** * @tc.name:StartDeviceDiscovery_002 * @tc.desc: pkgame changed, call StartDeviceDiscovery twice - * so that its discoveryQueue is not empty and return DM_DISCOVERY_REPEATED + * so that its discoveryQueue is not empty and return ERR_DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -105,7 +105,7 @@ HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_002, testing::ext::TestSiz discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); pkgName = "com.ohos.helloworld.new"; int32_t ret = discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); - ASSERT_EQ(ret, DM_DISCOVERY_FAILED); + ASSERT_EQ(ret, ERR_DM_DISCOVERY); } /** diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index 2f3a99343..57e77cd9a 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -214,7 +214,7 @@ HWTEST_F(IpcClientManagerTest, Init_004, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); // 4. check ret is DEVICEMANAGER_OK @@ -224,9 +224,9 @@ HWTEST_F(IpcClientManagerTest, Init_004, testing::ext::TestSize.Level0) /** * @tc.name: Init_005 * @tc.desc: 1. set pkcName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + * 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC * 3. call Init with pkgName - * 4. check ret is DM_IPC_FAILED + * 4. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -240,11 +240,11 @@ HWTEST_F(IpcClientManagerTest, Init_005, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 4. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 4. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -265,8 +265,8 @@ HWTEST_F(IpcClientManagerTest, UnInit1, testing::ext::TestSize.Level0) instance->dmInterface_ = nullptr; // 2. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 3. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 3. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -336,11 +336,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_003, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is DM_SERVICE_NOT_READY + * 6. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -348,11 +348,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -361,18 +361,18 @@ HWTEST_F(IpcClientManagerTest, UnInit_004, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 6. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: UnInit_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + * 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is DM_IPC_FAILED + * 6. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -380,11 +380,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + // 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -393,8 +393,8 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 6. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -402,7 +402,7 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set pkgName null * 2. set IpcClientManager dmInterface_null * 3. call SendRequest with parameter - * 4. check ret is DM_SERVICE_NOT_READY + * 4. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -418,8 +418,8 @@ HWTEST_F(IpcClientManagerTest, SendRequest_001, testing::ext::TestSize.Level0) instance->dmInterface_ = nullptr; // 3. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -495,11 +495,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_003, testing::ext::TestSize.Level0) /** * @tc.name: SendRequest_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is DM_SERVICE_NOT_READY + * 6. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -510,11 +510,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_004, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -523,18 +523,18 @@ HWTEST_F(IpcClientManagerTest, SendRequest_004, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 6. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: SendRequest_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + * 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is DM_IPC_FAILED + * 6. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -545,11 +545,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + // 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -558,8 +558,8 @@ HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 6. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** diff --git a/test/unittest/UTTest_ipc_client_proxy.cpp b/test/unittest/UTTest_ipc_client_proxy.cpp index 858121708..904af13b3 100644 --- a/test/unittest/UTTest_ipc_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_proxy.cpp @@ -116,9 +116,9 @@ HWTEST_F(IpcClientProxyTest, Init_003, testing::ext::TestSize.Level0) /** * @tc.name: Init_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_SERVICE_NOT_READY + * 2. Mock IpcClient Init return ERR_DM_NOT_INIT * 3. call IpcClientProxy Init - * 4. check ret is DM_SERVICE_NOT_READY + * 4. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -126,23 +126,23 @@ HWTEST_F(IpcClientProxyTest, Init_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_SERVICE_NOT_READY + // 2. Mock IpcClient Init return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: Init_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_IPC_FAILED + * 2. Mock IpcClient Init return FAILED_DM_IPC * 3. call IpcClientProxy Init - * 4. check ret is DM_IPC_FAILED + * 4. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -150,15 +150,15 @@ HWTEST_F(IpcClientProxyTest, Init_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_IPC_FAILED + // 2. Mock IpcClient Init return FAILED_DM_IPC std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 4. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -234,9 +234,9 @@ HWTEST_F(IpcClientProxyTest, UnInit_003, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient UnInit return DM_SERVICE_NOT_READY + * 2. Mock IpcClient UnInit return ERR_DM_NOT_INIT * 3. call IpcClientProxy UnInit - * 4. check ret is DM_SERVICE_NOT_READY + * 4. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -244,23 +244,23 @@ HWTEST_F(IpcClientProxyTest, UnInit_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_SERVICE_NOT_READY + // 2. Mock IpcClient Init return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: UnInit_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient UnInit return DM_IPC_FAILED + * 2. Mock IpcClient UnInit return FAILED_DM_IPC * 3. call IpcClientProxy UnInit - * 4. check ret is DM_IPC_FAILED + * 4. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -268,15 +268,15 @@ HWTEST_F(IpcClientProxyTest, UnInit_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_IPC_FAILED + // 2. Mock IpcClient Init return FAILED_DM_IPC std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 4. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index 70a692dde..2996709f6 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -114,7 +114,7 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) * set req is nullptr * set rsp is nullptr * 2. call IpcClientStub SendCmd with parameter - * 3. check result is DM_IPC_FAILED + * 3. check result is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -129,8 +129,8 @@ HWTEST_F(IpcClientStubTest, SendCmd_001, testing::ext::TestSize.Level0) sptr instance = new IpcClientStub(); // 2. call IpcClientStub SendCmd with parameter int ret = instance->SendCmd(cmdCode, req, rsp); - // 3. check result is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 3. check result is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index 543d5ef66..1d3a51182 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -60,7 +60,7 @@ namespace { * set MessageParcel data null * set IpcReq null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_NOT_REGISTER_FUNC + * 3. check ret is ERR_DM_REGISTER_FUNC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -85,7 +85,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_001, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is FAILED_DM_IPC_COMMUNICATION * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -100,8 +100,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is FAILED_DM_IPC_COMMUNICATION + ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); } /** @@ -110,7 +110,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with pkgName not null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is FAILED_DM_IPC_COMMUNICATION * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -127,8 +127,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is FAILED_DM_IPC_COMMUNICATION + ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); } /** @@ -137,7 +137,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is FAILED_DM_IPC_COMMUNICATION * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -156,8 +156,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is FAILED_DM_IPC_COMMUNICATION + ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); } /** @@ -166,7 +166,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is FAILED_DM_IPC_COMMUNICATION * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -185,8 +185,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is FAILED_DM_IPC_COMMUNICATION + ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); } /** @@ -194,7 +194,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set cmdCode 9999 * set MessageParcel reply null * 2. call IpcCmdRegister ReadResponse with parameter - * 3. check ret is DM_IPC_NOT_REGISTER_FUNC + * 3. check ret is ERR_DM_REGISTER_FUNC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -209,8 +209,8 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_001, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister ReadResponse with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); - // 3. check ret is DM_IPC_NOT_REGISTER_FUNC - ASSERT_EQ(ret, DM_IPC_NOT_REGISTER_FUNC); + // 3. check ret is ERR_DM_REGISTER_FUNC + ASSERT_EQ(ret, ERR_DM_REGISTER_FUNC); } /** @@ -294,7 +294,7 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_004, testing::ext::TestSize.Level0) * set MessageParcel reply null * set IpcRsp null * 2. call IpcCmdRegister ReadResponse with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is FAILED_DM_IPC_COMMUNICATION * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -313,8 +313,8 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp);; - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is FAILED_DM_IPC_COMMUNICATION + ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); } /** @@ -338,8 +338,8 @@ HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_001, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister ReadResponse with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - // 3. check ret is DM_IPC_NOT_REGISTER_FUNC - ASSERT_EQ(ret, DM_IPC_NOT_REGISTER_FUNC); + // 3. check ret is ERR_DM_REGISTER_FUNC + ASSERT_EQ(ret, ERR_DM_REGISTER_FUNC); } /** @@ -486,10 +486,10 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa std::string pkgName = pReq->GetPkgName(); sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteRemoteObject(listener)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } return DM_OK; } @@ -504,7 +504,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p { std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } return DM_OK; } @@ -521,10 +521,10 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteString(extra)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } return DM_OK; } @@ -540,8 +540,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt pDmDeviceinfo = nullptr; pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo)); if (pDmDeviceinfo == nullptr) { - pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED); - return DM_IPC_TRANSACTION_FAILED; + pRsp->SetErrCode(FAILED_DM_IPC_COMMUNICATION); + return FAILED_DM_IPC_COMMUNICATION; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -622,10 +622,10 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo(); if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -642,10 +642,10 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa std::string pkgName = pReq->GetPkgName(); uint16_t subscribeId = pReq->GetSubscribeId(); if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteInt16((int16_t)subscribeId)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -666,16 +666,16 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteString(extra)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteInt32(authType)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -693,10 +693,10 @@ ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Mess DmDeviceInfo deviceInfo = pReq->GetDeviceInfo(); std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -712,7 +712,7 @@ ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr pBaseReq, Mess std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string authPara = pReq->GetAuthPara(); if (!data.WriteString(authPara)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -728,7 +728,7 @@ ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr pBaseReq, Messa std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string packagename = pReq->GetPkgName(); if (!data.WriteString(packagename)) { - return DM_IPC_FLATTEN_OBJECT; + return FAILED_DM_IPC_WRITE; } return DM_OK; } @@ -756,7 +756,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, int32_t action = pReq->GetOperation(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteInt32(action)) { return ERR_DM_WRITE_FAILED; @@ -779,7 +779,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteString(extra)) { return ERR_DM_WRITE_FAILED; @@ -802,7 +802,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return FAILED_DM_IPC_COMMUNICATION; } if (!data.WriteString(extra)) { return ERR_DM_WRITE_FAILED; @@ -825,7 +825,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); + reply.WriteInt32(FAILED_DM_IPC_COPY); return DM_OK; } switch (deviceState) { @@ -856,8 +856,8 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); - return DM_IPC_COPY_FAILED; + reply.WriteInt32(FAILED_DM_IPC_COPY); + return FAILED_DM_IPC_COPY; } DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); reply.WriteInt32(DM_OK); diff --git a/test/unittest/UTTest_ipc_server_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index c0c7104f3..62f2d61b2 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -121,7 +121,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_002, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_IPC_FAILED + * 4. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/UTTest_pin_auth.cpp b/test/unittest/UTTest_pin_auth.cpp index 52ad52741..0c5b35de3 100644 --- a/test/unittest/UTTest_pin_auth.cpp +++ b/test/unittest/UTTest_pin_auth.cpp @@ -220,7 +220,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_003, testing::ext::TestSize.Level0) /** * @tc.name: DmAuthManager::VerifyAuthentication_004 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_AUTH_INPUT_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_AUTH_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -236,7 +236,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_004, testing::ext::TestSize.Level0) std::string authToken = authTokenJson.dump(); std::string authParam = authParamJson.dump(); int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_AUTH_INPUT_FAILED); + ASSERT_EQ(ret, ERR_DM_AUTH_INPUT_PARAMETER_EMPTY); } /** diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index ccd4fdd62..4583d5b35 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -272,7 +272,7 @@ HWTEST_F(SoftbusConnectorTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Le /** * @tc.name: StartDiscovery_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -280,12 +280,12 @@ HWTEST_F(SoftbusConnectorTest, StartDiscovery_001, testing::ext::TestSize.Level0 { DmSubscribeInfo dmSubscribeInfo; int ret = softbusConnector->StartDiscovery(dmSubscribeInfo); - EXPECT_EQ(ret, DM_DISCOVERY_FAILED); + EXPECT_EQ(ret, ERR_DM_DISCOVERY); } /** * @tc.name: StopDiscovery_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -298,7 +298,7 @@ HWTEST_F(SoftbusConnectorTest, StopDiscovery_001, testing::ext::TestSize.Level0) /** * @tc.name: GetUdidByNetworkId_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -312,7 +312,7 @@ HWTEST_F(SoftbusConnectorTest, GetUdidByNetworkId_001, testing::ext::TestSize.Le /** * @tc.name: GetUuidByNetworkId_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/device_manager_impl_test.cpp b/test/unittest/device_manager_impl_test.cpp index 95d08ab8e..53c05481e 100644 --- a/test/unittest/device_manager_impl_test.cpp +++ b/test/unittest/device_manager_impl_test.cpp @@ -70,7 +70,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Leve .Times(1) .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - ASSERT_EQ(ret, DM_IPC_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -111,7 +111,7 @@ HWTEST_F(DeviceManagerImplTest, VerifyAuthentication2, testing::ext::TestSize.Le .Times(1) .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().VerifyAuthentication(packName, authPara, callback); - ASSERT_EQ(ret, DM_IPC_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -168,7 +168,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery3, testing::ext::TestSize.Le .Times(1) .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, test_callback_); - ASSERT_EQ(ret, DM_IPC_FAILED); + ASSERT_EQ(ret, FAILED_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } } // namespace diff --git a/utils/src/ipc/lite/ipc_cmd_register.cpp b/utils/src/ipc/lite/ipc_cmd_register.cpp index 02db4ea6e..86f673726 100644 --- a/utils/src/ipc/lite/ipc_cmd_register.cpp +++ b/utils/src/ipc/lite/ipc_cmd_register.cpp @@ -28,7 +28,7 @@ int32_t IpcCmdRegister::SetRequest(int32_t cmdCode, std::shared_ptr pBas auto setRequestMapIter = setIpcRequestFuncMap_.find(cmdCode); if (setRequestMapIter == setIpcRequestFuncMap_.end()) { LOGE("cmdCode:%d not register SetRequestFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } return (setRequestMapIter->second)(pBaseReq, request, buffer, buffLen); } @@ -38,7 +38,7 @@ int32_t IpcCmdRegister::ReadResponse(int32_t cmdCode, IpcIo &reply, std::shared_ auto readResponseMapIter = readResponseFuncMap_.find(cmdCode); if (readResponseMapIter == readResponseFuncMap_.end()) { LOGE("cmdCode:%d not register ReadResponseFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } return (readResponseMapIter->second)(reply, pBaseRsp); } @@ -48,7 +48,7 @@ int32_t IpcCmdRegister::OnIpcCmd(int32_t cmdCode, IpcIo &reply) auto onIpcCmdMapIter = onIpcCmdFuncMap_.find(cmdCode); if (onIpcCmdMapIter == onIpcCmdFuncMap_.end()) { LOGE("cmdCode:%d not register OnIpcCmdFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } (onIpcCmdMapIter->second)(reply); return DM_OK; @@ -59,7 +59,7 @@ int32_t IpcCmdRegister::OnIpcServerCmd(int32_t cmdCode, IpcIo &req, IpcIo &reply auto onIpcServerCmdMapIter = onIpcServerCmdFuncMap_.find(cmdCode); if (onIpcServerCmdMapIter == onIpcServerCmdFuncMap_.end()) { LOGE("cmdCode:%d not register OnIpcCmdFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } (onIpcServerCmdMapIter->second)(req, reply); return DM_OK; diff --git a/utils/src/ipc/standard/ipc_cmd_register.cpp b/utils/src/ipc/standard/ipc_cmd_register.cpp index f3c1701dd..33f7c0ef4 100644 --- a/utils/src/ipc/standard/ipc_cmd_register.cpp +++ b/utils/src/ipc/standard/ipc_cmd_register.cpp @@ -33,7 +33,7 @@ int32_t IpcCmdRegister::SetRequest(int32_t cmdCode, std::shared_ptr pBas if (setIpcRequestFuncMap_.count(cmdCode) == 0) { LOGE("cmdCode:%d not register SetRequestFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } auto setRequestMapIter = setIpcRequestFuncMap_.find(cmdCode); @@ -48,7 +48,7 @@ int32_t IpcCmdRegister::ReadResponse(int32_t cmdCode, MessageParcel &reply, std: auto readResponseMapIter = readResponseFuncMap_.find(cmdCode); if (readResponseMapIter == readResponseFuncMap_.end()) { LOGE("cmdCode:%d not register ReadResponseFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } if (readResponseMapIter->second == nullptr) { return ERR_DM_POINT_NULL; @@ -61,7 +61,7 @@ int32_t IpcCmdRegister::OnIpcCmd(int32_t cmdCode, MessageParcel &data, MessagePa auto onIpcCmdMapIter = onIpcCmdFuncMap_.find(cmdCode); if (onIpcCmdMapIter == onIpcCmdFuncMap_.end()) { LOGE("cmdCode:%d not register OnIpcCmdFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } if (onIpcCmdMapIter->second == nullptr) { return ERR_DM_POINT_NULL; -- Gitee From a08066926b71a5e34b455188520a77b49d591312 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 26 Apr 2022 15:43:47 +0800 Subject: [PATCH 5/9] 11 Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 6 +++--- .../src/authentication/dm_auth_manager.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index a0a138faa..cf93c8347 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -72,9 +72,9 @@ enum { ERR_DM_AUTH_BUSINESS_BUSY = -20026, ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20027, FAILED_DM_AUTH_OPEN_SESSION = -20028, - - DM_AUTH_PEER_REJECT = -20033,/// - DM_AUTH_NOT_AUTH = -20034,/// + FAILED_DM_OPPOSITE_REFUSED_REJECT = -20029, + FAILED_DM_REFUSED_REJECT = -20030,/// + DM_AUTH_DONT_AUTH = -20035,/// DM_AUTH_NOT_START = -20036,//// ERR_DM_HICHAIN_CREATE_GROUP = -20037,//// diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 98ea8d09c..3efc8f5c8 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -413,7 +413,7 @@ void DmAuthManager::StartNegotiate(const int32_t &sessionId) char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); authResponseContext_->localDeviceId = localDeviceId; - authResponseContext_->reply = DM_AUTH_NOT_AUTH; + authResponseContext_->reply = FAILED_DM_REFUSED_REJECT; authResponseContext_->authType = authRequestContext_->authType; authResponseContext_->deviceId = authRequestContext_->deviceId; authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -432,9 +432,9 @@ void DmAuthManager::RespNegotiate(const int32_t &sessionId) bool ret = hiChainConnector_->IsDevicesInGroup(authResponseContext_->localDeviceId, localDeviceId); if (!ret) { LOGE("DmAuthManager::EstablishAuthChannel device is in group"); - authResponseContext_->reply = DM_AUTH_PEER_REJECT; + authResponseContext_->reply = FAILED_DM_OPPOSITE_REFUSED_REJECT; } else { - authResponseContext_->reply = DM_AUTH_NOT_AUTH; + authResponseContext_->reply = FAILED_DM_REFUSED_REJECT; } std::shared_ptr authentication = authenticationMap_[authResponseContext_->authType]; @@ -475,7 +475,7 @@ void DmAuthManager::SendAuthRequest(const int32_t &sessionId) if (authResponseContext_->cryptoSupport) { isCryptoSupport_ = true; } - if (authResponseContext_->reply == DM_AUTH_PEER_REJECT) { + if (authResponseContext_->reply == FAILED_DM_OPPOSITE_REFUSED_REJECT) { authRequestState_->TransitionTo(std::make_shared()); return; } @@ -524,7 +524,7 @@ void DmAuthManager::StartRespAuthProcess() } else { LOGE("do not accept"); authResponseContext_->state = AuthState::AUTH_REQUEST_REPLY; - authRequestContext_->reason = DM_AUTH_PEER_REJECT; + authRequestContext_->reason = FAILED_DM_OPPOSITE_REFUSED_REJECT; authRequestState_->TransitionTo(std::make_shared()); } } -- Gitee From 8a4d6b830527394dbca93a4376f0c31c1942a5db Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 26 Apr 2022 15:53:54 +0800 Subject: [PATCH 6/9] 123 Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 50 +++++++++---------- .../src/authentication/dm_auth_manager.cpp | 14 +++--- .../src/device_manager_service.cpp | 16 +++--- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index cf93c8347..2aff0b17d 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -52,32 +52,30 @@ enum { ERR_DM_UNINIT_FAILED = -20006, ERR_DM_POINT_NULL = -20007, ERR_DM_INPUT_PARAMETER_EMPTY = -20008, - DM_NO_PERMISSION = -20009,///111 - DM_FLATTEN_OBJECT = -20010,///11111 - ERR_DM_MALLOC_FAILED = -20011, - ERR_DM_STRCOPY_FAILED = -20012, - ERR_DM_WRITE_FAILED = -20013, - ERR_DM_DISCOVERY = -20014, - ERR_DM_KEY_ALREADY_EXISTS = -20015, - ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20016, - FAILED_DM_IPC = -20017, - FAILED_DM_IPC_COMMUNICATION = -20018, - FAILED_DM_IPC_WRITE = -20019, - FAILED_DM_IPC_COPY = -20020, - FAILED_DM_IPC_SEND_REQUEST = -20021, - ERR_DM_IPC_REGISTER_FUNC = -20022, - ERR_DM_IPC_RESPOND = -20023, - ERR_DM_IPC_WRITE_TOKEN = -20024, - ERR_DM_DISCOVERY_REPEATED = -20025, - ERR_DM_AUTH_BUSINESS_BUSY = -20026, - ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20027, - FAILED_DM_AUTH_OPEN_SESSION = -20028, - FAILED_DM_OPPOSITE_REFUSED_REJECT = -20029, - FAILED_DM_REFUSED_REJECT = -20030,/// - - DM_AUTH_DONT_AUTH = -20035,/// - DM_AUTH_NOT_START = -20036,//// - ERR_DM_HICHAIN_CREATE_GROUP = -20037,//// + ERR_DM_NO_PERMISSION = -20009, + ERR_DM_MALLOC_FAILED = -20010, + ERR_DM_STRCOPY_FAILED = -20011, + ERR_DM_WRITE_FAILED = -20012, + ERR_DM_DISCOVERY = -20013, + ERR_DM_KEY_ALREADY_EXISTS = -20014, + ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20015, + FAILED_DM_IPC = -20016, + FAILED_DM_IPC_COMMUNICATION = -20017, + FAILED_DM_IPC_WRITE = -20018, + FAILED_DM_IPC_COPY = -20019, + FAILED_DM_IPC_SEND_REQUEST = -20020, + ERR_DM_IPC_REGISTER_FUNC = -20021, + ERR_DM_IPC_RESPOND = -20022, + ERR_DM_IPC_WRITE_TOKEN = -20023, + ERR_DM_DISCOVERY_REPEATED = -20024, + ERR_DM_AUTH_BUSINESS_BUSY = -20025, + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20026, + FAILED_DM_AUTH_OPEN_SESSION = -20027, + FAILED_DM_OPPOSITE_REFUSED_REJECT = -20028, + FAILED_DM_REFUSED_REJECT = -20029, + FAILED_DM_AUTH_DONT_AUTH = -20030, + FAILED_DM_AUTH_NOT_START = -20031, + ERR_DM_HICHAIN_CREATE_GROUP = -20032, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 3efc8f5c8..c22f3b8f7 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -171,7 +171,7 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) LOGI("DmAuthManager::VerifyAuthentication"); if (authResponseContext_ == nullptr) { LOGE("authResponseContext_ is not init"); - return DM_AUTH_NOT_START; + return FAILED_DM_AUTH_NOT_START; } std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end() @@ -493,7 +493,7 @@ int32_t DmAuthManager::StartAuthProcess(const int32_t &action) LOGI("DmAuthManager:: StartAuthProcess"); if (authResponseContext_ == nullptr) { LOGI("Authenticate is not start"); - return DM_AUTH_NOT_START; + return FAILED_DM_AUTH_NOT_START; } authResponseContext_->reply = action; @@ -773,7 +773,7 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return FAILED_DM_AUTH_NOT_START; } dmAbilityMgr_->StartAbilityDone(); @@ -796,7 +796,7 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return FAILED_DM_AUTH_NOT_START; } switch (action) { @@ -811,7 +811,7 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) CancelDisplay(); break; case USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT: - authRequestContext_->reason = DM_AUTH_DONT_AUTH; + authRequestContext_->reason = FAILED_DM_AUTH_DONT_AUTH; authResponseContext_->state = authRequestState_->GetStateType(); AuthenticateFinish(); break; @@ -859,7 +859,7 @@ int32_t DmAuthManager::SetPageId(int32_t pageId) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return FAILED_DM_AUTH_NOT_START; } authResponseContext_->pageId = pageId; return DM_OK; @@ -869,7 +869,7 @@ int32_t DmAuthManager::SetReason(int32_t reason, int32_t state) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return FAILED_DM_AUTH_NOT_START; } if (state < AuthState::AUTH_REQUEST_FINISH) { authRequestContext_->reason = reason; diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index f24747d8d..ebafb5d0b 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -56,7 +56,7 @@ int32_t DeviceManagerService::Init() if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (softbusConnector_ == nullptr) { @@ -135,7 +135,7 @@ int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, c { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("GetTrustedDeviceList failed, singleton not init or init fail"); @@ -152,7 +152,7 @@ int32_t DeviceManagerService::GetLocalDeviceInfo(DmDeviceInfo &info) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); @@ -198,7 +198,7 @@ int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, c { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("StartDeviceDiscovery failed, singleton not init or init fail"); @@ -215,7 +215,7 @@ int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, ui { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("StopDeviceDiscovery failed, singleton not init or init fail"); @@ -233,7 +233,7 @@ int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("AuthenticateDevice failed, singleton not init or init fail"); @@ -254,7 +254,7 @@ int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, c { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("UnAuthenticateDevice failed, singleton not init or init fail"); @@ -275,7 +275,7 @@ int32_t DeviceManagerService::VerifyAuthentication(const std::string &authParam) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("VerifyAuthentication failed, singleton not init or init fail"); -- Gitee From 01833e060f8b42b100825a1ca427a03442535d2c Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 26 Apr 2022 16:11:34 +0800 Subject: [PATCH 7/9] 12w Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 31 ++++++------ .../src/ipc/lite/ipc_cmd_parser.cpp | 4 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 20 ++++---- .../src/authentication/dm_auth_manager.cpp | 2 +- .../dependency/hichain/hichain_connector.cpp | 2 +- test/unittest/UTTest_ipc_cmd_register.cpp | 50 +++++++++---------- 6 files changed, 54 insertions(+), 55 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 2aff0b17d..7f8c7a5f9 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -60,22 +60,21 @@ enum { ERR_DM_KEY_ALREADY_EXISTS = -20014, ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20015, FAILED_DM_IPC = -20016, - FAILED_DM_IPC_COMMUNICATION = -20017, - FAILED_DM_IPC_WRITE = -20018, - FAILED_DM_IPC_COPY = -20019, - FAILED_DM_IPC_SEND_REQUEST = -20020, - ERR_DM_IPC_REGISTER_FUNC = -20021, - ERR_DM_IPC_RESPOND = -20022, - ERR_DM_IPC_WRITE_TOKEN = -20023, - ERR_DM_DISCOVERY_REPEATED = -20024, - ERR_DM_AUTH_BUSINESS_BUSY = -20025, - ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20026, - FAILED_DM_AUTH_OPEN_SESSION = -20027, - FAILED_DM_OPPOSITE_REFUSED_REJECT = -20028, - FAILED_DM_REFUSED_REJECT = -20029, - FAILED_DM_AUTH_DONT_AUTH = -20030, - FAILED_DM_AUTH_NOT_START = -20031, - ERR_DM_HICHAIN_CREATE_GROUP = -20032, + FAILED_DM_IPC_WRITE = -20017, + FAILED_DM_IPC_COPY = -20018, + FAILED_DM_IPC_SEND_REQUEST = -20019, + ERR_DM_IPC_REGISTER_FUNC = -20020, + ERR_DM_IPC_RESPOND = -20021, + ERR_DM_IPC_WRITE_TOKEN = -20022, + ERR_DM_DISCOVERY_REPEATED = -20023, + ERR_DM_AUTH_BUSINESS_BUSY = -20024, + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20025, + FAILED_DM_AUTH_OPEN_SESSION = -20026, + FAILED_DM_OPPOSITE_REFUSED_REJECT = -20027, + FAILED_DM_REFUSED_REJECT = -20028, + FAILED_DM_AUTH_DONT_AUTH = -20029, + FAILED_DM_AUTH_NOT_START = -20030, + FAILED_DM_HICHAIN_CREATE_GROUP = -20031, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index c8398d463..7264307a3 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -96,8 +96,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptrSetErrCode(FAILED_DM_IPC_COMMUNICATION); - return FAILED_DM_IPC_COMMUNICATION; + pRsp->SetErrCode(FAILED_DM_IPC); + return FAILED_DM_IPC; } for (int32_t i = 0; i < deviceNum; ++i) { deviceInfoVec.emplace_back(*pDmDeviceinfo); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index 83c4b3e7b..cf9083409 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -46,11 +46,11 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteRemoteObject(listener)) { LOGE("write listener failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } return DM_OK; } @@ -70,7 +70,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { LOGE("write papam failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } return DM_OK; } @@ -88,11 +88,11 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { LOGE("write pkg failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } return DM_OK; } @@ -113,8 +113,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt LOGE("pRsp is null"); return ERR_DM_FAILED; } - pRsp->SetErrCode(FAILED_DM_IPC_COMMUNICATION); - return FAILED_DM_IPC_COMMUNICATION; + pRsp->SetErrCode(FAILED_DM_IPC); + return FAILED_DM_IPC; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -349,7 +349,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteInt32(action)) { LOGE("write action failed"); @@ -374,7 +374,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); @@ -399,7 +399,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index c22f3b8f7..9f1858c62 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -333,7 +333,7 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId return; } if (groupId == "{}") { - authResponseContext_->reply = ERR_DM_HICHAIN_CREATE_GROUP; + authResponseContext_->reply = FAILED_DM_HICHAIN_CREATE_GROUP; authMessageProcessor_->SetResponseContext(authResponseContext_); std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_AUTH); softbusConnector_->GetSoftbusSession()->SendData(authResponseContext_->sessionId, message); diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 2d1777520..d05d6753c 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -122,7 +122,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou int32_t ret = deviceGroupManager_->createGroup(userId, requestId, DM_PKG_NAME.c_str(), jsonObj.dump().c_str()); if (ret != 0) { LOGE("Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); - return ERR_DM_HICHAIN_CREATE_GROUP; + return FAILED_DM_HICHAIN_CREATE_GROUP; } return DM_OK; } diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index 1d3a51182..e4917e90b 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -85,7 +85,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_001, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC_COMMUNICATION + * 3. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -100,8 +100,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC_COMMUNICATION - ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); + // 3. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -110,7 +110,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with pkgName not null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC_COMMUNICATION + * 3. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -127,8 +127,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC_COMMUNICATION - ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); + // 3. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -137,7 +137,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC_COMMUNICATION + * 3. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -156,8 +156,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC_COMMUNICATION - ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); + // 3. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -166,7 +166,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC_COMMUNICATION + * 3. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -185,8 +185,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC_COMMUNICATION - ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); + // 3. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -294,7 +294,7 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_004, testing::ext::TestSize.Level0) * set MessageParcel reply null * set IpcRsp null * 2. call IpcCmdRegister ReadResponse with parameter - * 3. check ret is FAILED_DM_IPC_COMMUNICATION + * 3. check ret is FAILED_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -313,8 +313,8 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp);; - // 3. check ret is FAILED_DM_IPC_COMMUNICATION - ASSERT_EQ(ret, FAILED_DM_IPC_COMMUNICATION); + // 3. check ret is FAILED_DM_IPC + ASSERT_EQ(ret, FAILED_DM_IPC); } /** @@ -486,10 +486,10 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa std::string pkgName = pReq->GetPkgName(); sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteRemoteObject(listener)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } return DM_OK; } @@ -504,7 +504,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p { std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } return DM_OK; } @@ -521,10 +521,10 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteString(extra)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } return DM_OK; } @@ -540,8 +540,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt pDmDeviceinfo = nullptr; pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo)); if (pDmDeviceinfo == nullptr) { - pRsp->SetErrCode(FAILED_DM_IPC_COMMUNICATION); - return FAILED_DM_IPC_COMMUNICATION; + pRsp->SetErrCode(FAILED_DM_IPC); + return FAILED_DM_IPC; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -756,7 +756,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, int32_t action = pReq->GetOperation(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteInt32(action)) { return ERR_DM_WRITE_FAILED; @@ -779,7 +779,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteString(extra)) { return ERR_DM_WRITE_FAILED; @@ -802,7 +802,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_COMMUNICATION; + return FAILED_DM_IPC; } if (!data.WriteString(extra)) { return ERR_DM_WRITE_FAILED; -- Gitee From 59e2b778eaa18d136709b59ff95d4d90982dc6a4 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 27 Apr 2022 15:01:04 +0800 Subject: [PATCH 8/9] 12q Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 64 +++--- .../native_cpp/src/device_manager_impl.cpp | 26 +-- .../src/ipc/lite/ipc_cmd_parser.cpp | 4 +- .../ipc/standard/ipc_client_server_proxy.cpp | 4 +- .../src/ipc/standard/ipc_client_stub.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 50 ++--- .../src/authentication/dm_auth_manager.cpp | 28 +-- .../dependency/hichain/hichain_connector.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 6 +- .../ipc/standard/ipc_server_client_proxy.cpp | 4 +- .../src/ipc/standard/ipc_server_stub.cpp | 2 +- test/unittest/UTTest_device_manager_impl.cpp | 194 +++++++++--------- test/unittest/UTTest_ipc_client_manager.cpp | 34 +-- test/unittest/UTTest_ipc_client_proxy.cpp | 24 +-- test/unittest/UTTest_ipc_client_stub.cpp | 6 +- test/unittest/UTTest_ipc_cmd_register.cpp | 80 ++++---- test/unittest/UTTest_ipc_server_listener.cpp | 2 +- test/unittest/device_manager_impl_test.cpp | 6 +- 18 files changed, 269 insertions(+), 269 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 7f8c7a5f9..f054e2f57 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -43,38 +43,38 @@ const int32_t DISCOVER_STATUS_LEN = 20; const int32_t COMMON_CALLBACK_MAX_SIZE = 200; enum { - DM_OK = -20000, - ERR_DM_FAILED = -20001, - ERR_DM_TIME_OUT = -20002, - ERR_DM_NOT_INIT = -20003, - ERR_DM_INIT_REPEATED = -20004, - ERR_DM_INIT_FAILED = -20005, - ERR_DM_UNINIT_FAILED = -20006, - ERR_DM_POINT_NULL = -20007, - ERR_DM_INPUT_PARAMETER_EMPTY = -20008, - ERR_DM_NO_PERMISSION = -20009, - ERR_DM_MALLOC_FAILED = -20010, - ERR_DM_STRCOPY_FAILED = -20011, - ERR_DM_WRITE_FAILED = -20012, - ERR_DM_DISCOVERY = -20013, - ERR_DM_KEY_ALREADY_EXISTS = -20014, - ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20015, - FAILED_DM_IPC = -20016, - FAILED_DM_IPC_WRITE = -20017, - FAILED_DM_IPC_COPY = -20018, - FAILED_DM_IPC_SEND_REQUEST = -20019, - ERR_DM_IPC_REGISTER_FUNC = -20020, - ERR_DM_IPC_RESPOND = -20021, - ERR_DM_IPC_WRITE_TOKEN = -20022, - ERR_DM_DISCOVERY_REPEATED = -20023, - ERR_DM_AUTH_BUSINESS_BUSY = -20024, - ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20025, - FAILED_DM_AUTH_OPEN_SESSION = -20026, - FAILED_DM_OPPOSITE_REFUSED_REJECT = -20027, - FAILED_DM_REFUSED_REJECT = -20028, - FAILED_DM_AUTH_DONT_AUTH = -20029, - FAILED_DM_AUTH_NOT_START = -20030, - FAILED_DM_HICHAIN_CREATE_GROUP = -20031, + DM_OK = 0, + ERR_DM_FAILED = -20000, + ERR_DM_TIME_OUT = -20001, + ERR_DM_NOT_INIT = -20002, + ERR_DM_INIT_REPEATED = -20003, + ERR_DM_INIT_FAILED = -20004, + ERR_DM_UNINIT_FAILED = -20005, + ERR_DM_POINT_NULL = -20006, + ERR_DM_INPUT_PARAMETER_EMPTY = -20007, + ERR_DM_NO_PERMISSION = -20008, + ERR_DM_MALLOC_FAILED = -20009, + ERR_DM_STRCOPY_FAILED = -20010, + ERR_DM_WRITE_FAILED = -20011, + ERR_DM_DISCOVERY = -20012, + ERR_DM_KEY_ALREADY_EXISTS = -20013, + ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20014, + ERR_DM_IPC = -20015, + ERR_DM_IPC_WRITE = -20016, + ERR_DM_IPC_COPY = -20017, + ERR_DM_IPC_SEND_REQUEST = -20018, + ERR_DM_IPC_REGISTER_FUNC = -20019, + ERR_DM_IPC_RESPOND = -20020, + ERR_DM_IPC_WRITE_TOKEN = -20021, + ERR_DM_DISCOVERY_REPEATED = -20022, + ERR_DM_AUTH_BUSINESS_BUSY = -20023, + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20024, + ERR_DM_AUTH_OPEN_SESSION = -20025, + ERR_DM_OPPOSITE_REFUSED_REJECT = -20026, + ERR_DM_REFUSED_REJECT = -20027, + ERR_DM_AUTH_DONT_AUTH = -20028, + ERR_DM_AUTH_NOT_START = -20029, + ERR_DM_HICHAIN_CREATE_GROUP = -20030, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 5ad7bdacd..23a3f01a7 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -110,7 +110,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(GET_TRUST_DEVICE_LIST, req, rsp); if (ret != DM_OK) { LOGE("GetTrustedDeviceList error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -133,7 +133,7 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi int32_t ret = ipcClientProxy_->SendRequest(GET_LOCAL_DEVICE_INFO, req, rsp); if (ret != DM_OK) { LOGE("GetLocalDeviceInfo error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -199,7 +199,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(START_DEVICE_DISCOVER, req, rsp); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -228,7 +228,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 int32_t ret = ipcClientProxy_->SendRequest(STOP_DEVICE_DISCOVER, req, rsp); if (ret != DM_OK) { LOGE("StopDeviceDiscovery error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -263,7 +263,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -297,7 +297,7 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = ipcClientProxy_->SendRequest(UNAUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -353,7 +353,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(VERIFY_AUTHENTICATION, req, rsp); if (ret != DM_OK) { LOGE("VerifyAuthentication error: Send Request failed ret: %d", ret); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -379,7 +379,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d if (ipcClientProxy_->SendRequest(SERVER_GET_DMFA_INFO, req, rsp) != DM_OK) { LOGI("DeviceManagerImpl::GetFaParam start 2"); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } dmFaParam = rsp->GetDmAuthParam(); LOGI("GetFaParam completed, pkgName: %s", pkgName.c_str()); @@ -400,7 +400,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t req->SetOperation(action); if (ipcClientProxy_->SendRequest(SERVER_USER_AUTH_OPERATION, req, rsp) != DM_OK) { - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -425,7 +425,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const req->SetNetWorkId(netWorkId); if (ipcClientProxy_->SendRequest(GET_UDID_BY_NETWORK, req, rsp) != DM_OK) { - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -450,7 +450,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const req->SetNetWorkId(netWorkId); if (ipcClientProxy_->SendRequest(GET_UUID_BY_NETWORK, req, rsp) != DM_OK) { - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -474,7 +474,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, req->SetExtra(extra); if (ipcClientProxy_->SendRequest(REGISTER_DEV_STATE_CALLBACK, req, rsp) != DM_OK) { - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -497,7 +497,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName req->SetExtra(extra); if (ipcClientProxy_->SendRequest(UNREGISTER_DEV_STATE_CALLBACK, req, rsp) != DM_OK) { - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index 7264307a3..cc6d885c3 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -96,8 +96,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptrSetErrCode(FAILED_DM_IPC); - return FAILED_DM_IPC; + pRsp->SetErrCode(ERR_DM_IPC); + return ERR_DM_IPC; } for (int32_t i = 0; i < deviceNum; ++i) { deviceInfoVec.emplace_back(*pDmDeviceinfo); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp index 69b0459c6..530ac049d 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp @@ -38,11 +38,11 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r return ERR_DM_IPC_WRITE_TOKEN; } if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } if (remote->SendRequest((uint32_t)cmdCode, data, reply, option) != DM_OK) { LOGE("SendRequest fail, cmd:%d", cmdCode); - return FAILED_DM_IPC_SEND_REQUEST; + return ERR_DM_IPC_SEND_REQUEST; } return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp index 2b5a90e4e..6d8d5599e 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp @@ -48,7 +48,7 @@ int32_t IpcClientStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { LOGE("set request cmd failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } LOGI("cmdCode = %d, flags= %d.", cmdCode, option.GetFlags()); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index cf9083409..32796b7ab 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -46,11 +46,11 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteRemoteObject(listener)) { LOGE("write listener failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } return DM_OK; } @@ -70,7 +70,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { LOGE("write papam failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } return DM_OK; } @@ -88,11 +88,11 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { LOGE("write pkg failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } return DM_OK; } @@ -113,8 +113,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt LOGE("pRsp is null"); return ERR_DM_FAILED; } - pRsp->SetErrCode(FAILED_DM_IPC); - return FAILED_DM_IPC; + pRsp->SetErrCode(ERR_DM_IPC); + return ERR_DM_IPC; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -196,11 +196,11 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Mess const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) { LOGE("write subscribe info failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -218,11 +218,11 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa uint16_t subscribeId = pReq->GetSubscribeId(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt16((int16_t)subscribeId)) { LOGE("write subscribeId failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -248,19 +248,19 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { LOGE("write extra failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt32(authType)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -283,11 +283,11 @@ ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Mess std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { LOGE("write extra failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -303,7 +303,7 @@ ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr pBaseReq, Mess std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string authPara = pReq->GetAuthPara(); if (!data.WriteString(authPara)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -320,7 +320,7 @@ ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr pBaseReq, Messa std::string packagename = pReq->GetPkgName(); if (!data.WriteString(packagename)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -349,7 +349,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteInt32(action)) { LOGE("write action failed"); @@ -374,7 +374,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); @@ -399,7 +399,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); @@ -423,7 +423,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(FAILED_DM_IPC_COPY); + reply.WriteInt32(ERR_DM_IPC_COPY); return DM_OK; } switch (deviceState) { @@ -455,8 +455,8 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(FAILED_DM_IPC_COPY); - return FAILED_DM_IPC_COPY; + reply.WriteInt32(ERR_DM_IPC_COPY); + return ERR_DM_IPC_COPY; } DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); reply.WriteInt32(DM_OK); diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 9f1858c62..d49707215 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -171,7 +171,7 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) LOGI("DmAuthManager::VerifyAuthentication"); if (authResponseContext_ == nullptr) { LOGE("authResponseContext_ is not init"); - return FAILED_DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end() @@ -333,7 +333,7 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId return; } if (groupId == "{}") { - authResponseContext_->reply = FAILED_DM_HICHAIN_CREATE_GROUP; + authResponseContext_->reply = ERR_DM_HICHAIN_CREATE_GROUP; authMessageProcessor_->SetResponseContext(authResponseContext_); std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_AUTH); softbusConnector_->GetSoftbusSession()->SendData(authResponseContext_->sessionId, message); @@ -401,7 +401,7 @@ int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) LOGE("OpenAuthSession failed, stop the authentication"); authResponseContext_ = std::make_shared(); authResponseContext_->state = AuthState::AUTH_REQUEST_NEGOTIATE; - authRequestContext_->reason = FAILED_DM_AUTH_OPEN_SESSION; + authRequestContext_->reason = ERR_DM_AUTH_OPEN_SESSION; authRequestState_->TransitionTo(std::make_shared()); } return DM_OK; @@ -413,7 +413,7 @@ void DmAuthManager::StartNegotiate(const int32_t &sessionId) char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); authResponseContext_->localDeviceId = localDeviceId; - authResponseContext_->reply = FAILED_DM_REFUSED_REJECT; + authResponseContext_->reply = ERR_DM_REFUSED_REJECT; authResponseContext_->authType = authRequestContext_->authType; authResponseContext_->deviceId = authRequestContext_->deviceId; authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -432,9 +432,9 @@ void DmAuthManager::RespNegotiate(const int32_t &sessionId) bool ret = hiChainConnector_->IsDevicesInGroup(authResponseContext_->localDeviceId, localDeviceId); if (!ret) { LOGE("DmAuthManager::EstablishAuthChannel device is in group"); - authResponseContext_->reply = FAILED_DM_OPPOSITE_REFUSED_REJECT; + authResponseContext_->reply = ERR_DM_OPPOSITE_REFUSED_REJECT; } else { - authResponseContext_->reply = FAILED_DM_REFUSED_REJECT; + authResponseContext_->reply = ERR_DM_REFUSED_REJECT; } std::shared_ptr authentication = authenticationMap_[authResponseContext_->authType]; @@ -475,7 +475,7 @@ void DmAuthManager::SendAuthRequest(const int32_t &sessionId) if (authResponseContext_->cryptoSupport) { isCryptoSupport_ = true; } - if (authResponseContext_->reply == FAILED_DM_OPPOSITE_REFUSED_REJECT) { + if (authResponseContext_->reply == ERR_DM_OPPOSITE_REFUSED_REJECT) { authRequestState_->TransitionTo(std::make_shared()); return; } @@ -493,7 +493,7 @@ int32_t DmAuthManager::StartAuthProcess(const int32_t &action) LOGI("DmAuthManager:: StartAuthProcess"); if (authResponseContext_ == nullptr) { LOGI("Authenticate is not start"); - return FAILED_DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } authResponseContext_->reply = action; @@ -524,7 +524,7 @@ void DmAuthManager::StartRespAuthProcess() } else { LOGE("do not accept"); authResponseContext_->state = AuthState::AUTH_REQUEST_REPLY; - authRequestContext_->reason = FAILED_DM_OPPOSITE_REFUSED_REJECT; + authRequestContext_->reason = ERR_DM_OPPOSITE_REFUSED_REJECT; authRequestState_->TransitionTo(std::make_shared()); } } @@ -773,7 +773,7 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return FAILED_DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } dmAbilityMgr_->StartAbilityDone(); @@ -796,7 +796,7 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return FAILED_DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } switch (action) { @@ -811,7 +811,7 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) CancelDisplay(); break; case USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT: - authRequestContext_->reason = FAILED_DM_AUTH_DONT_AUTH; + authRequestContext_->reason = ERR_DM_AUTH_DONT_AUTH; authResponseContext_->state = authRequestState_->GetStateType(); AuthenticateFinish(); break; @@ -859,7 +859,7 @@ int32_t DmAuthManager::SetPageId(int32_t pageId) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return FAILED_DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } authResponseContext_->pageId = pageId; return DM_OK; @@ -869,7 +869,7 @@ int32_t DmAuthManager::SetReason(int32_t reason, int32_t state) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return FAILED_DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } if (state < AuthState::AUTH_REQUEST_FINISH) { authRequestContext_->reason = reason; diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index d05d6753c..2d1777520 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -122,7 +122,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou int32_t ret = deviceGroupManager_->createGroup(userId, requestId, DM_PKG_NAME.c_str(), jsonObj.dump().c_str()); if (ret != 0) { LOGE("Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); - return FAILED_DM_HICHAIN_CREATE_GROUP; + return ERR_DM_HICHAIN_CREATE_GROUP; } return DM_OK; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 3d1442245..5601b6af5 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -450,19 +450,19 @@ ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply) !reply.WriteInt32(authParam.business) || !reply.WriteInt32(authParam.pincode) || !reply.WriteInt32(appIconLen) || !reply.WriteInt32(appThumbnailLen)) { LOGE("write reply failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (appIconLen > 0 && authParam.imageinfo.GetAppIcon() != nullptr) { if (!reply.WriteRawData(authParam.imageinfo.GetAppIcon(), appIconLen)) { LOGE("write appIcon failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } } if (appThumbnailLen > 0 && authParam.imageinfo.GetAppThumbnail() != nullptr) { if (!reply.WriteRawData(authParam.imageinfo.GetAppThumbnail(), appThumbnailLen)) { LOGE("write appThumbnail failed"); - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } } return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp index 290d4bbf8..11837920b 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp @@ -34,11 +34,11 @@ int32_t IpcServerClientProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageParcel reply; MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (remote->SendRequest((uint32_t)cmdCode, data, reply, option) != DM_OK) { LOGE("SendRequest fail, cmd:%d", cmdCode); - return FAILED_DM_IPC; + return ERR_DM_IPC; } return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index af91dd99f..178a0b5e1 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -103,7 +103,7 @@ int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { LOGE("set request cmd failed"); - return FAILED_DM_IPC; + return ERR_DM_IPC; } int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); diff --git a/test/unittest/UTTest_device_manager_impl.cpp b/test/unittest/UTTest_device_manager_impl.cpp index faa415536..423669b6f 100644 --- a/test/unittest/UTTest_device_manager_impl.cpp +++ b/test/unittest/UTTest_device_manager_impl.cpp @@ -310,9 +310,9 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_001, testing::ext::TestSize * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -325,15 +325,15 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_002, testing::ext::TestSize std::string extra = ""; // set deviceList null std::vector deviceList; - // 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC_SEND_REQUEST)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC_SEND_REQUEST)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -376,7 +376,7 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_003, testing::ext::TestSize * set deviceList null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -397,7 +397,7 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_004, testing::ext::TestSize // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -444,14 +444,14 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1).WillOnce(testing::Return(DM_OK)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST + // 3. check ret is ERR_DM_IPC_SEND_REQUEST ASSERT_EQ(ret, DM_OK); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -461,9 +461,9 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.L * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -474,15 +474,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_002, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return FAILED_DM_IPC_SEND_REQUEST + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC_SEND_REQUEST)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC_SEND_REQUEST)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -523,7 +523,7 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_003, testing::ext::TestSize.L * set deviceList null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -542,7 +542,7 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_004, testing::ext::TestSize.L // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -571,7 +571,7 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_005, testing::ext::TestSize.L // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -874,8 +874,8 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_003, testing::ext::TestSize .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -919,7 +919,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_004, testing::ext::TestSize * set callback not null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -941,7 +941,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_005, testing::ext::TestSize // 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); // 4. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -973,7 +973,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_001, testing::ext::TestSize. * set subscribeId is 0 * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 3. check ret is FAILED_DM_IPC_SEND_REQUEST + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -991,8 +991,8 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_002, testing::ext::TestSize. .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1031,7 +1031,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_003, testing::ext::TestSize. * set subscribeId is 0 * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1049,8 +1049,8 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1060,7 +1060,7 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. * set subscribeId is 0 * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1078,8 +1078,8 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_005, testing::ext::TestSize. .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1122,7 +1122,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_001, testing::ext::TestSize.L * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1145,8 +1145,8 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_002, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1197,7 +1197,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_003, testing::ext::TestSize.L * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1221,8 +1221,8 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1235,7 +1235,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1259,8 +1259,8 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_005, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1297,7 +1297,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_001, testing::ext::TestSize * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1355,7 +1355,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_003, testing::ext::TestSize * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1374,8 +1374,8 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1388,7 +1388,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1407,8 +1407,8 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_005, testing::ext::TestSize .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1445,7 +1445,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_001, testing::ext::TestSize.Level0) * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1464,7 +1464,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_002, testing::ext::TestSize.Level0) // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); // 4. check ret is DM_OK - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1509,7 +1509,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_003, testing::ext::TestSize.Level0) * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1527,8 +1527,8 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1541,7 +1541,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) * set callback null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1559,8 +1559,8 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_005, testing::ext::TestSize.Level0) .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1592,7 +1592,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_001, testing::ext::TestSize.Lev * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1610,8 +1610,8 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_002, testing::ext::TestSize.Lev .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1650,7 +1650,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_003, testing::ext::TestSize.Lev * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1668,8 +1668,8 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1679,7 +1679,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1697,8 +1697,8 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_005, testing::ext::TestSize.Lev .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1731,7 +1731,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_001, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1750,8 +1750,8 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_002, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1791,7 +1791,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_003, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1810,8 +1810,8 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1821,7 +1821,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1840,8 +1840,8 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_005, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1874,7 +1874,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_001, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1893,8 +1893,8 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_002, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1934,7 +1934,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_003, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1953,8 +1953,8 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1964,7 +1964,7 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L * set action null * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is FAILED_DM_IPC_SEND_REQUEST + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1983,8 +1983,8 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2303,7 +2303,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_007, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is FAILED_DM_IPC_SEND_REQUEST + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2317,11 +2317,11 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_008, testing::ext::Test std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2331,7 +2331,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_008, testing::ext::Test * set extra not null * set callback not null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is FAILED_DM_IPC_SEND_REQUEST + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2348,8 +2348,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_009, testing::ext::Test .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2429,7 +2429,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_007, testing::ext::Te * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is FAILED_DM_IPC_SEND_REQUEST + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2443,11 +2443,11 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_008, testing::ext::Te std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2457,7 +2457,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_008, testing::ext::Te * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is FAILED_DM_IPC_SEND_REQUEST + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2474,8 +2474,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_009, testing::ext::Te .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is FAILED_DM_IPC_SEND_REQUEST - ASSERT_EQ(ret, FAILED_DM_IPC_SEND_REQUEST); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index 57e77cd9a..a8eb8ea14 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -224,9 +224,9 @@ HWTEST_F(IpcClientManagerTest, Init_004, testing::ext::TestSize.Level0) /** * @tc.name: Init_005 * @tc.desc: 1. set pkcName not null - * 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC * 3. call Init with pkgName - * 4. check ret is FAILED_DM_IPC + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -240,11 +240,11 @@ HWTEST_F(IpcClientManagerTest, Init_005, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 4. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 4. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -368,11 +368,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_004, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is FAILED_DM_IPC + * 6. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -380,11 +380,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -393,8 +393,8 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 6. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -530,11 +530,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_004, testing::ext::TestSize.Level0) /** * @tc.name: SendRequest_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is FAILED_DM_IPC + * 6. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -545,11 +545,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return FAILED_DM_IPC + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -558,8 +558,8 @@ HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 6. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** diff --git a/test/unittest/UTTest_ipc_client_proxy.cpp b/test/unittest/UTTest_ipc_client_proxy.cpp index 904af13b3..f9e53aa76 100644 --- a/test/unittest/UTTest_ipc_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_proxy.cpp @@ -140,9 +140,9 @@ HWTEST_F(IpcClientProxyTest, Init_004, testing::ext::TestSize.Level0) /** * @tc.name: Init_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return FAILED_DM_IPC + * 2. Mock IpcClient Init return ERR_DM_IPC * 3. call IpcClientProxy Init - * 4. check ret is FAILED_DM_IPC + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -150,15 +150,15 @@ HWTEST_F(IpcClientProxyTest, Init_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return FAILED_DM_IPC + // 2. Mock IpcClient Init return ERR_DM_IPC std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 4. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -258,9 +258,9 @@ HWTEST_F(IpcClientProxyTest, UnInit_004, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient UnInit return FAILED_DM_IPC + * 2. Mock IpcClient UnInit return ERR_DM_IPC * 3. call IpcClientProxy UnInit - * 4. check ret is FAILED_DM_IPC + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -268,15 +268,15 @@ HWTEST_F(IpcClientProxyTest, UnInit_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return FAILED_DM_IPC + // 2. Mock IpcClient Init return ERR_DM_IPC std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(FAILED_DM_IPC)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 4. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index 2996709f6..f08dcacd7 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -114,7 +114,7 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) * set req is nullptr * set rsp is nullptr * 2. call IpcClientStub SendCmd with parameter - * 3. check result is FAILED_DM_IPC + * 3. check result is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -129,8 +129,8 @@ HWTEST_F(IpcClientStubTest, SendCmd_001, testing::ext::TestSize.Level0) sptr instance = new IpcClientStub(); // 2. call IpcClientStub SendCmd with parameter int ret = instance->SendCmd(cmdCode, req, rsp); - // 3. check result is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 3. check result is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index e4917e90b..718c630f4 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -85,7 +85,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_001, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -100,8 +100,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -110,7 +110,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with pkgName not null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -127,8 +127,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -137,7 +137,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -156,8 +156,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -166,7 +166,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is FAILED_DM_IPC + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -185,8 +185,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -294,7 +294,7 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_004, testing::ext::TestSize.Level0) * set MessageParcel reply null * set IpcRsp null * 2. call IpcCmdRegister ReadResponse with parameter - * 3. check ret is FAILED_DM_IPC + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -313,8 +313,8 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp);; - // 3. check ret is FAILED_DM_IPC - ASSERT_EQ(ret, FAILED_DM_IPC); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -486,10 +486,10 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa std::string pkgName = pReq->GetPkgName(); sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteRemoteObject(listener)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } return DM_OK; } @@ -504,7 +504,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p { std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } return DM_OK; } @@ -521,10 +521,10 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } return DM_OK; } @@ -540,8 +540,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt pDmDeviceinfo = nullptr; pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo)); if (pDmDeviceinfo == nullptr) { - pRsp->SetErrCode(FAILED_DM_IPC); - return FAILED_DM_IPC; + pRsp->SetErrCode(ERR_DM_IPC); + return ERR_DM_IPC; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -622,10 +622,10 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -642,10 +642,10 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa std::string pkgName = pReq->GetPkgName(); uint16_t subscribeId = pReq->GetSubscribeId(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt16((int16_t)subscribeId)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -666,16 +666,16 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(extra)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt32(authType)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -693,10 +693,10 @@ ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Mess DmDeviceInfo deviceInfo = pReq->GetDeviceInfo(); std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -712,7 +712,7 @@ ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr pBaseReq, Mess std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string authPara = pReq->GetAuthPara(); if (!data.WriteString(authPara)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -728,7 +728,7 @@ ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr pBaseReq, Messa std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string packagename = pReq->GetPkgName(); if (!data.WriteString(packagename)) { - return FAILED_DM_IPC_WRITE; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -756,7 +756,7 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, int32_t action = pReq->GetOperation(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteInt32(action)) { return ERR_DM_WRITE_FAILED; @@ -779,7 +779,7 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { return ERR_DM_WRITE_FAILED; @@ -802,7 +802,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return FAILED_DM_IPC; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { return ERR_DM_WRITE_FAILED; @@ -825,7 +825,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(FAILED_DM_IPC_COPY); + reply.WriteInt32(ERR_DM_IPC_COPY); return DM_OK; } switch (deviceState) { @@ -856,8 +856,8 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(FAILED_DM_IPC_COPY); - return FAILED_DM_IPC_COPY; + reply.WriteInt32(ERR_DM_IPC_COPY); + return ERR_DM_IPC_COPY; } DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); reply.WriteInt32(DM_OK); diff --git a/test/unittest/UTTest_ipc_server_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index 62f2d61b2..b483764a0 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -121,7 +121,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_002, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is FAILED_DM_IPC + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/device_manager_impl_test.cpp b/test/unittest/device_manager_impl_test.cpp index 53c05481e..c29883e9f 100644 --- a/test/unittest/device_manager_impl_test.cpp +++ b/test/unittest/device_manager_impl_test.cpp @@ -70,7 +70,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Leve .Times(1) .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - ASSERT_EQ(ret, FAILED_DM_IPC); + ASSERT_EQ(ret, ERR_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -111,7 +111,7 @@ HWTEST_F(DeviceManagerImplTest, VerifyAuthentication2, testing::ext::TestSize.Le .Times(1) .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().VerifyAuthentication(packName, authPara, callback); - ASSERT_EQ(ret, FAILED_DM_IPC); + ASSERT_EQ(ret, ERR_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -168,7 +168,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery3, testing::ext::TestSize.Le .Times(1) .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, test_callback_); - ASSERT_EQ(ret, FAILED_DM_IPC); + ASSERT_EQ(ret, ERR_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } } // namespace -- Gitee From 98e5e916bd01ce27084720544e64ba726a70bc1d Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 5 May 2022 20:18:28 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- common/include/dm_constants.h | 49 +++++++++++++++++ .../kits/js/include/native_devicemanager_js.h | 1 + .../kits/js/src/native_devicemanager_js.cpp | 52 +++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index f054e2f57..fc3e02768 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -193,6 +193,55 @@ const std::string WAIT_REQUEST_TIMEOUT_TASK = TIMER_PREFIX + "waitRequest"; const std::string STATE_TIMER_PREFIX = "stateTimer_"; const int32_t TIMER_PREFIX_LENGTH = 19; const int32_t TIMER_DEFAULT = 0; + +//error code info +const std::string DM_OK_INFO = "DeviceManager APIs called successfully."; +const std::string DM_FAILED_INFO = "DeviceManager APIs called failed. Please try again later."; +const std::string DM_TIME_OUT_INFO = + "DeviceManager internal process execution timed out. Please try again later."; +const std::string DM_NOT_INIT_INFO = + "DeviceManager service has not been initialized. Restart the device and try again."; +const std::string DM_INIT_REPEATED_INFO = "DeviceManager service does not allowed repeated initialization."; +const std::string DM_INIT_FAILED_INFO = + "DeviceManager service fails to be initialized. Restart the device and try again."; +const std::string DM_UNINIT_FAILED_INFO = "DeviceManager failed to deinitialize. Restart the device and try again."; +const std::string DM_POINT_NULL_INFO = + "DeviceManager internal process occurs NullPointerException. Please try again later."; +const std::string DM_INPUT_PARAMETER_EMPTY_INFO = "The API input parameter is invalid. Please confirm and try again."; +const std::string DM_NO_PERMISSION_INFO = + "The hap application has no permission to call DeviceManager APIs. Please confirm and try again."; +const std::string DM_MALLOC_FAILED_INFO = + "Device resources are insufficient. Memory allocation failed. Restart the device and try again."; +const std::string DM_STRCOPY_FAILED_INFO = + "Device resources are insufficient. Memory copy failed. Restart the device and try again."; +const std::string DM_WRITE_FAILED_INFO = "IPC process abnormal. Write object failed. Restart the device and try again."; +const std::string DM_DISCOVERY_INFO = "Failed to discover devices. Please try again later."; +const std::string DM_KEY_ALREADY_EXISTS_INFO = "DeviceManager service abnormal. Restart the device and try again."; +const std::string DM_UNSUBSCRIBE_DP_EVENTS_INFO = + "Failed to call SubscribeProfileEvents API of DP module. Please try again later."; +const std::string DM_IPC_ERR_INFO = "IPC process abnormal. Restart the device and try again."; +const std::string DM_IPC_WRITE_INFO = "IPC process failed to write data. Restart the device and try again."; +const std::string DM_IPC_COPY_INFO = "IPC process failed to copy data. Restart the device and try again."; +const std::string DM_IPC_SEND_REQUEST_INFO = "IPC process failed to send request. Restart the device and try again."; +const std::string DM_IPC_REGISTER_FUNC_INFO = + "IPC process failed to register function. Restart the device and try again."; +const std::string DM_IPC_RESPOND_INFO = "IPC process failed to receive response. Restart the device and try again."; +const std::string DM_IPC_WRITE_TOKEN_INFO = "IPC process failed to write token. Restart the device and try again."; +const std::string DM_DISCOVERY_REPEATED_INFO = + "Repeat device discovery is not allowed within 1 minute. Please try again later."; +const std::string DM_AUTH_BUSINESS_BUSY_INFO = + "The device authentication request is being processed. Please try again later."; +const std::string DM_AUTH_INPUT_PARAMETER_EMPTY_INFO = + "The AuthenticateDevice API input parameter is invalid. Please confirm and try again."; +const std::string DM_AUTH_OPEN_SESSION_INFO = + "Failed to open authenticate session. Please restart the device and try again."; +const std::string DM_OPPOSITE_REFUSED_REJECT_INFO = + "The remote device rejected the request. Please confirm and try again."; +const std::string DM_REFUSED_REJECT_INFO = "The local device rejected the request. Please confirm and try again."; +const std::string DM_AUTH_DONT_AUTH_INFO = "The local device authentication failed. Please try again later."; +const std::string DM_AUTH_NOT_START_INFO = "The device authentication process has not started. Please try again later."; +const std::string DM_HICHAIN_CREATE_GROUP_INFO = + "HiChain module failed to create user group. Please restart the device and try again."; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_CONSTANTS_H diff --git a/interfaces/kits/js/include/native_devicemanager_js.h b/interfaces/kits/js/include/native_devicemanager_js.h index 8db0b6022..aa109c6df 100644 --- a/interfaces/kits/js/include/native_devicemanager_js.h +++ b/interfaces/kits/js/include/native_devicemanager_js.h @@ -311,5 +311,6 @@ private: std::string bundleName_; static AuthAsyncCallbackInfo authAsyncCallbackInfo_; static AuthAsyncCallbackInfo verifyAsyncCallbackInfo_; + std::map errCodeInfo_; }; #endif // OHOS_DM_NATIVE_DEVICEMANAGER_JS_H diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index acd42777c..1efd25574 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -428,6 +428,38 @@ DeviceManagerNapi::DeviceManagerNapi(napi_env env, napi_value thisVar) : DmNativ { env_ = env; wrapper_ = nullptr; + errCodeInfo_.insert(std::pair(DM_OK, DM_OK_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_FAILED, DM_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_TIME_OUT, DM_TIME_OUT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_NOT_INIT, DM_NOT_INIT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_INIT_REPEATED, DM_INIT_REPEATED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_INIT_FAILED, DM_INIT_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_UNINIT_FAILED, DM_UNINIT_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_POINT_NULL, DM_POINT_NULL_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_INPUT_PARAMETER_EMPTY, DM_INPUT_PARAMETER_EMPTY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_NO_PERMISSION, DM_NO_PERMISSION_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_MALLOC_FAILED, DM_MALLOC_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_STRCOPY_FAILED, DM_STRCOPY_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_WRITE_FAILED, DM_WRITE_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_DISCOVERY, DM_DISCOVERY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_UNSUBSCRIBE_DP_EVENTS, DM_UNSUBSCRIBE_DP_EVENTS_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC, DM_IPC_ERR_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_WRITE, DM_IPC_WRITE_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_COPY, DM_IPC_COPY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_SEND_REQUEST, DM_IPC_SEND_REQUEST_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_REGISTER_FUNC, DM_IPC_REGISTER_FUNC_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_RESPOND, DM_IPC_RESPOND_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_WRITE_TOKEN, DM_IPC_WRITE_TOKEN_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_DISCOVERY_REPEATED, DM_DISCOVERY_REPEATED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_BUSINESS_BUSY, DM_AUTH_BUSINESS_BUSY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_INPUT_PARAMETER_EMPTY, + DM_AUTH_INPUT_PARAMETER_EMPTY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_OPEN_SESSION, DM_AUTH_OPEN_SESSION_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_OPPOSITE_REFUSED_REJECT, DM_OPPOSITE_REFUSED_REJECT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_REFUSED_REJECT, DM_REFUSED_REJECT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_DONT_AUTH, DM_AUTH_DONT_AUTH_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_NOT_START, DM_AUTH_NOT_START_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_HICHAIN_CREATE_GROUP, DM_HICHAIN_CREATE_GROUP_INFO)); } DeviceManagerNapi::~DeviceManagerNapi() @@ -489,6 +521,16 @@ void DeviceManagerNapi::OnDiscoveryFailed(uint16_t subscribeId, int32_t failedRe napi_create_object(env_, &result); SetValueInt32(env_, "subscribeId", (int)subscribeId, result); SetValueInt32(env_, "reason", (int)failedReason, result); + std::map::iterator iter=errCodeInfo_.find(failedReason); + std::string tmp_iter; + if (iter != errCodeInfo_.end()) { + tmp_iter = iter->second; + LOGE("Found, the value is %s",tmp_iter.c_str()); + } else { + tmp_iter = "wyb success"; + LOGI("Do not found"); + } + SetValueUtf8String(env_, "errInfo", tmp_iter, result); OnEvent("discoverFail", DM_NAPI_ARGS_ONE, &result); } @@ -511,6 +553,16 @@ void DeviceManagerNapi::OnAuthResult(const std::string &deviceId, const std::str SetValueInt32(env_, "code", status, result[0]); SetValueInt32(env_, "reason", reason, result[0]); napi_get_undefined(env_, &result[1]); + std::map::iterator iter=errCodeInfo_.find(reason); + std::string tmp_iter; + if (iter != errCodeInfo_.end()) { + tmp_iter = iter->second; + LOGE("Found, the reason value is %s",tmp_iter.c_str()); + } else { + tmp_iter = "not found reason"; + LOGI("Do not found reason"); + } + SetValueUtf8String(env_, "errInfo", tmp_iter, result[0]); } napi_value callResult = nullptr; -- Gitee