mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 14:30:21 +00:00
可信超大函数整改
issue: https://gitee.com/openharmony/ability_dmsfwk/issues/I7XHCX Signed-off-by: hunili <lihucheng2@huawei.com>
This commit is contained in:
parent
0e843f73fd
commit
611733ec7e
@ -18,7 +18,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "base/continuationmgr_log.h"
|
||||
#include "device_connect_status.h"
|
||||
#include "distributed_ability_manager_client.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "napi_common_util.h"
|
||||
@ -482,33 +481,37 @@ NativeValue *JsContinuationManager::OnUpdateConnectStatus(NativeEngine &engine,
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string JsContinuationManager::GetErrorInfo(NativeEngine &engine, NativeCallbackInfo &info, int32_t &token,
|
||||
std::string &deviceId, DeviceConnectStatus &deviceConnectStatus)
|
||||
{
|
||||
if (info.argc != ARG_COUNT_THREE && info.argc != ARG_COUNT_FOUR) {
|
||||
return "Parameter error. The type of \"number of parameters\" must be 3 or 4";
|
||||
}
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], token)) {
|
||||
return "Parameter error. The type of \"token\" must be number";
|
||||
}
|
||||
if (!ConvertFromJsValue(engine, info.argv[ARG_COUNT_ONE], deviceId) || deviceId.empty()) {
|
||||
return "Parameter error. The type of \"deviceId\" must be string and not empty";
|
||||
}
|
||||
deviceConnectStatus = DeviceConnectStatus::IDLE;
|
||||
if (!ConvertFromJsValue(engine, info.argv[ARG_COUNT_TWO], deviceConnectStatus)) {
|
||||
return "Parameter error. The type of \"status\" must be DeviceConnectState";
|
||||
}
|
||||
if (static_cast<int32_t>(deviceConnectStatus) < static_cast<int32_t>(DeviceConnectStatus::IDLE) ||
|
||||
static_cast<int32_t>(deviceConnectStatus) > static_cast<int32_t>(DeviceConnectStatus::DISCONNECTING)) {
|
||||
HILOGE("deviceConnectStatus is invalid");
|
||||
return "Parameter error. The type of \"status\" must be DeviceConnectState";
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
NativeValue* JsContinuationManager::OnUpdateContinuationState(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
HILOGD("called.");
|
||||
int32_t token = -1;
|
||||
std::string deviceId;
|
||||
DeviceConnectStatus deviceConnectStatus;
|
||||
std::string errInfo = [this, &engine, &info, &token, &deviceId, &deviceConnectStatus, &errInfo]() -> std::string {
|
||||
if (info.argc != ARG_COUNT_THREE && info.argc != ARG_COUNT_FOUR) {
|
||||
return "Parameter error. The type of \"number of parameters\" must be 3 or 4";
|
||||
}
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], token)) {
|
||||
return "Parameter error. The type of \"token\" must be number";
|
||||
}
|
||||
if (!ConvertFromJsValue(engine, info.argv[ARG_COUNT_ONE], deviceId) || deviceId.empty()) {
|
||||
return "Parameter error. The type of \"deviceId\" must be string and not empty";
|
||||
}
|
||||
deviceConnectStatus = DeviceConnectStatus::IDLE;
|
||||
if (!ConvertFromJsValue(engine, info.argv[ARG_COUNT_TWO], deviceConnectStatus)) {
|
||||
return "Parameter error. The type of \"status\" must be DeviceConnectState";
|
||||
}
|
||||
if (static_cast<int32_t>(deviceConnectStatus) < static_cast<int32_t>(DeviceConnectStatus::IDLE) ||
|
||||
static_cast<int32_t>(deviceConnectStatus) > static_cast<int32_t>(DeviceConnectStatus::DISCONNECTING)) {
|
||||
HILOGE("deviceConnectStatus is invalid");
|
||||
return "Parameter error. The type of \"status\" must be DeviceConnectState";
|
||||
}
|
||||
return std::string();
|
||||
} ();
|
||||
std::string errInfo = GetErrorInfo(engine, info, token, deviceId, deviceConnectStatus);
|
||||
if (!errInfo.empty()) {
|
||||
HILOGE("%{public}s", errInfo.c_str());
|
||||
napi_throw(reinterpret_cast<napi_env>(&engine),
|
||||
@ -542,19 +545,25 @@ NativeValue* JsContinuationManager::OnUpdateContinuationState(NativeEngine &engi
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue *JsContinuationManager::OnStartDeviceManager(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
int32_t JsContinuationManager::CheckParamAndGetToken(NativeEngine &engine, NativeCallbackInfo &info, int32_t &token)
|
||||
{
|
||||
HILOGD("called.");
|
||||
int32_t errCode = 0;
|
||||
if (info.argc < ARG_COUNT_ONE) {
|
||||
HILOGE("Params not match");
|
||||
errCode = ERR_NOT_OK;
|
||||
}
|
||||
int32_t token = -1;
|
||||
if (!errCode && !ConvertFromJsValue(engine, info.argv[0], token)) {
|
||||
HILOGE("Parse token failed");
|
||||
errCode = ERR_NOT_OK;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
NativeValue *JsContinuationManager::OnStartDeviceManager(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
HILOGD("called.");
|
||||
int32_t token = -1;
|
||||
int32_t errCode = CheckParamAndGetToken(engine, info, token);
|
||||
decltype(info.argc) unwrapArgc = ARG_COUNT_ONE;
|
||||
std::shared_ptr<ContinuationExtraParams> continuationExtraParams = std::make_shared<ContinuationExtraParams>();
|
||||
if (info.argc > ARG_COUNT_ONE && info.argv[ARG_COUNT_ONE]->TypeOf() == NATIVE_OBJECT) {
|
||||
@ -598,36 +607,41 @@ NativeValue *JsContinuationManager::OnStartDeviceManager(NativeEngine &engine, N
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string JsContinuationManager::GetErrorForStartContinuation(NativeEngine &engine, NativeCallbackInfo &info,
|
||||
int32_t &token, int32_t &unwrapArgc, std::shared_ptr<ContinuationExtraParams> &continuationExtraParams)
|
||||
{
|
||||
if (info.argc < ARG_COUNT_ONE || info.argc > ARG_COUNT_THREE) {
|
||||
return "Parameter error. The type of \"number of parameters\" must be greater than 1 and less than 4";
|
||||
}
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], token)) {
|
||||
return "Parameter error. The type of \"token\" must be number";
|
||||
}
|
||||
continuationExtraParams = std::make_shared<ContinuationExtraParams>();
|
||||
if (info.argc > ARG_COUNT_ONE && info.argv[ARG_COUNT_ONE]->TypeOf() == NATIVE_OBJECT) {
|
||||
HILOGI("StartContinuationDeviceManager options is used.");
|
||||
if (!UnWrapContinuationExtraParams(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[ARG_COUNT_ONE]), continuationExtraParams)) {
|
||||
return "Parameter error. The type of \"options\" must be ContinuationExtraParams";
|
||||
}
|
||||
unwrapArgc++;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
NativeValue* JsContinuationManager::OnStartContinuationDeviceManager(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
HILOGD("called.");
|
||||
int32_t token = -1;
|
||||
decltype(info.argc) unwrapArgc = ARG_COUNT_ONE;
|
||||
int32_t argc = ARG_COUNT_ONE;
|
||||
std::shared_ptr<ContinuationExtraParams> continuationExtraParams;
|
||||
std::string errInfo = [this, &engine, &info, &token, & unwrapArgc, &continuationExtraParams]() -> std::string {
|
||||
if (info.argc < ARG_COUNT_ONE || info.argc > ARG_COUNT_THREE) {
|
||||
return "Parameter error. The type of \"number of parameters\" must be greater than 1 and less than 4";
|
||||
}
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], token)) {
|
||||
return "Parameter error. The type of \"token\" must be number";
|
||||
}
|
||||
continuationExtraParams = std::make_shared<ContinuationExtraParams>();
|
||||
if (info.argc > ARG_COUNT_ONE && info.argv[ARG_COUNT_ONE]->TypeOf() == NATIVE_OBJECT) {
|
||||
HILOGI("StartContinuationDeviceManager options is used.");
|
||||
if (!UnWrapContinuationExtraParams(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[ARG_COUNT_ONE]), continuationExtraParams)) {
|
||||
return "Parameter error. The type of \"options\" must be ContinuationExtraParams";
|
||||
}
|
||||
unwrapArgc++;
|
||||
}
|
||||
return std::string();
|
||||
} ();
|
||||
std::string errInfo = GetErrorForStartContinuation(engine, info, token, argc, continuationExtraParams);
|
||||
if (!errInfo.empty()) {
|
||||
HILOGE("%{public}s", errInfo.c_str());
|
||||
napi_throw(reinterpret_cast<napi_env>(&engine),
|
||||
GenerateBusinessError(reinterpret_cast<napi_env>(&engine), PARAMETER_CHECK_FAILED, errInfo));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
decltype(info.argc) unwrapArgc = argc;
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[this, token, continuationExtraParams, unwrapArgc](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
napi_handle_scope scope = nullptr;
|
||||
@ -635,7 +649,6 @@ NativeValue* JsContinuationManager::OnStartContinuationDeviceManager(NativeEngin
|
||||
if (scope == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t errCode = (unwrapArgc == ARG_COUNT_ONE) ?
|
||||
DistributedAbilityManagerClient::GetInstance().StartDeviceManager(token) :
|
||||
DistributedAbilityManagerClient::GetInstance().StartDeviceManager(token, continuationExtraParams);
|
||||
@ -645,10 +658,8 @@ NativeValue* JsContinuationManager::OnStartContinuationDeviceManager(NativeEngin
|
||||
errCode = ErrorCodeReturn(errCode);
|
||||
task.Reject(engine, CreateJsError(engine, errCode, ErrorMessageReturn(errCode)));
|
||||
}
|
||||
|
||||
napi_close_handle_scope(reinterpret_cast<napi_env>(&engine), scope);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= unwrapArgc) ? nullptr : info.argv[unwrapArgc];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsContinuationManager::OnStartContinuationDeviceManager",
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "continuation_extra_params.h"
|
||||
#include "device_connect_status.h"
|
||||
#include "js_device_selection_listener.h"
|
||||
#include "native_engine/native_engine.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
@ -54,12 +55,17 @@ private:
|
||||
NativeValue* OnUnregisterDeviceSelectionCallback(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnUpdateConnectStatus(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnStartDeviceManager(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
int32_t CheckParamAndGetToken(NativeEngine &engine, NativeCallbackInfo &info, int32_t &token);
|
||||
NativeValue* OnInitDeviceConnectStateObject(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnInitContinuationModeObject(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
static napi_status SetEnumItem(const napi_env& env, napi_value object, const char* name, int32_t value);
|
||||
NativeValue* OnRegisterContinuation(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnUnregisterContinuation(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnUpdateContinuationState(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
std::string GetErrorInfo(NativeEngine &engine, NativeCallbackInfo &info, int32_t &token,
|
||||
std::string &deviceId, DeviceConnectStatus &deviceConnectStatus);
|
||||
std::string GetErrorForStartContinuation(NativeEngine &engine, NativeCallbackInfo &info,
|
||||
int32_t &token, int32_t &unwrapArgc, std::shared_ptr<ContinuationExtraParams> &continuationExtraParams);
|
||||
NativeValue* OnStartContinuationDeviceManager(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
|
||||
static bool IsCallbackValid(NativeValue* listenerObj);
|
||||
|
@ -199,6 +199,8 @@ public:
|
||||
*/
|
||||
static DistributedWant* ParseUri(const std::string& uri);
|
||||
|
||||
static bool CheckParams(const std::string& uri);
|
||||
|
||||
/**
|
||||
* @description: Obtains the description of a URI in a DistributedWant.
|
||||
* @return Returns the URI description in the DistributedWant.
|
||||
|
@ -57,6 +57,9 @@ public:
|
||||
|
||||
static bool CompareInterface(const sptr<AAFwk::IInterface> iIt1, const sptr<AAFwk::IInterface> iIt2, int typeId);
|
||||
|
||||
static bool CompareNumberInterface(const sptr<AAFwk::IInterface> iIt1,
|
||||
const sptr<AAFwk::IInterface> iIt2, int typeId);
|
||||
|
||||
static int GetDataType(const sptr<AAFwk::IInterface> iIt);
|
||||
|
||||
static int GetNumberDataType(const sptr<AAFwk::IInterface> iIt);
|
||||
|
@ -239,6 +239,7 @@ private:
|
||||
const AccountInfo& accountInfo, int32_t flag, bool needQueryExtension);
|
||||
int32_t SaveConnectToken(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect);
|
||||
void SetCleanMissionFlag(const OHOS::AAFwk::Want& want, int32_t missionId);
|
||||
void RemoveConnectAbilityInfo(const std::string& deviceId);
|
||||
|
||||
std::shared_ptr<DSchedContinuation> dschedContinuation_;
|
||||
std::map<sptr<IRemoteObject>, std::list<ConnectAbilitySession>> distributedConnectAbilityMap_;
|
||||
|
@ -43,6 +43,7 @@ private:
|
||||
int32_t ConnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t DisconnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t ConnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t ReadDataForConnect(MessageParcel& data, CallerInfo callerInfo, AccountInfo accountInfo);
|
||||
int32_t DisconnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t NotifyProcessDiedFromRemoteInner(MessageParcel& data, MessageParcel& reply);
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
@ -65,6 +66,8 @@ private:
|
||||
int32_t ReleaseAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t StartRemoteFreeInstallInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t StartFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t ReadDataForFreeInstall(MessageParcel& data,
|
||||
CallerInfo &callerInfo, AccountInfo &accountInfo, int64_t &taskId);
|
||||
int32_t NotifyCompleteFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply);
|
||||
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
|
||||
int32_t StartRemoteShareFormInner(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -875,23 +875,29 @@ DistributedWant* DistributedWant::CloneOperation()
|
||||
return want;
|
||||
}
|
||||
|
||||
DistributedWant* DistributedWant::ParseUri(const std::string& uri)
|
||||
bool DistributedWant::CheckParams(const std::string& uri)
|
||||
{
|
||||
if (uri.length() <= 0) {
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
std::string head = WANT_HEADER;
|
||||
std::string end = ";end";
|
||||
if (uri.find(head) != 0) {
|
||||
return nullptr;
|
||||
if (uri.find(WANT_HEADER) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (uri.rfind(end) != (uri.length() - end.length())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DistributedWant* DistributedWant::ParseUri(const std::string& uri)
|
||||
{
|
||||
if (!CheckParams(uri)) {
|
||||
return nullptr;
|
||||
}
|
||||
bool ret = true;
|
||||
std::string content;
|
||||
std::size_t pos;
|
||||
std::size_t begin = head.length();
|
||||
std::size_t begin = WANT_HEADER.length();
|
||||
ElementName element;
|
||||
DistributedWant* want = new (std::nothrow) DistributedWant();
|
||||
if (want == nullptr) {
|
||||
@ -902,7 +908,7 @@ DistributedWant* DistributedWant::ParseUri(const std::string& uri)
|
||||
pos = uri.find_first_of(";", begin);
|
||||
do {
|
||||
if (pos != std::string::npos) {
|
||||
content = uri.substr(begin, pos - begin);
|
||||
std::string content = uri.substr(begin, pos - begin);
|
||||
if (content.compare("PICK") == 0) {
|
||||
want = new (std::nothrow) DistributedWant();
|
||||
if (want == nullptr) {
|
||||
@ -925,8 +931,6 @@ DistributedWant* DistributedWant::ParseUri(const std::string& uri)
|
||||
}
|
||||
} while (true);
|
||||
if (inPicker) {
|
||||
if (baseWant->GetBundle().empty()) {
|
||||
}
|
||||
want = baseWant;
|
||||
}
|
||||
if (ret) {
|
||||
|
@ -305,22 +305,11 @@ sptr<IInterface> DistributedWantParams::GetInterfaceByType(int typeId, const std
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DistributedWantParams::CompareInterface(const sptr<IInterface> iIt1, const sptr<IInterface> iIt2, int typeId)
|
||||
bool DistributedWantParams::CompareNumberInterface(const sptr<IInterface> iIt1,
|
||||
const sptr<IInterface> iIt2, int typeId)
|
||||
{
|
||||
bool flag = false;
|
||||
switch (typeId) {
|
||||
case VALUE_TYPE_BOOLEAN:
|
||||
flag = static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt1))));
|
||||
break;
|
||||
case VALUE_TYPE_BYTE:
|
||||
flag = static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt1))));
|
||||
break;
|
||||
case VALUE_TYPE_CHAR:
|
||||
flag = static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt1))));
|
||||
break;
|
||||
case VALUE_TYPE_SHORT:
|
||||
flag = static_cast<AAFwk::Short*>(AAFwk::IShort::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Short*>(AAFwk::IShort::Query(iIt1))));
|
||||
@ -341,6 +330,28 @@ bool DistributedWantParams::CompareInterface(const sptr<IInterface> iIt1, const
|
||||
flag = static_cast<AAFwk::Double*>(AAFwk::IDouble::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Double*>(AAFwk::IDouble::Query(iIt1))));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool DistributedWantParams::CompareInterface(const sptr<IInterface> iIt1, const sptr<IInterface> iIt2, int typeId)
|
||||
{
|
||||
bool flag = false;
|
||||
switch (typeId) {
|
||||
case VALUE_TYPE_BOOLEAN:
|
||||
flag = static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt1))));
|
||||
break;
|
||||
case VALUE_TYPE_BYTE:
|
||||
flag = static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt1))));
|
||||
break;
|
||||
case VALUE_TYPE_CHAR:
|
||||
flag = static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt1))));
|
||||
break;
|
||||
case VALUE_TYPE_STRING:
|
||||
flag = static_cast<AAFwk::String*>(AAFwk::IString::Query(iIt1))
|
||||
->Equals(*(static_cast<AAFwk::String*>(AAFwk::IString::Query(iIt1))));
|
||||
@ -354,6 +365,7 @@ bool DistributedWantParams::CompareInterface(const sptr<IInterface> iIt1, const
|
||||
->Equals(*(static_cast<DistributedWantParamWrapper*>(IDistributedWantParams::Query(iIt1))));
|
||||
break;
|
||||
default:
|
||||
flag = CompareNumberInterface(iIt1, iIt2, typeId);
|
||||
break;
|
||||
}
|
||||
return flag;
|
||||
|
@ -1695,15 +1695,8 @@ int32_t DistributedSchedService::NotifyProcessDiedFromRemote(const CallerInfo& c
|
||||
return errCode;
|
||||
}
|
||||
|
||||
void DistributedSchedService::ProcessDeviceOffline(const std::string& deviceId)
|
||||
void DistributedSchedService::RemoveConnectAbilityInfo(const std::string& deviceId)
|
||||
{
|
||||
HILOGI("ProcessDeviceOffline called");
|
||||
std::string localDeviceId;
|
||||
if (!GetLocalDeviceId(localDeviceId) || !CheckDeviceId(localDeviceId, deviceId)) {
|
||||
HILOGE("ProcessDeviceOffline check deviceId failed");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(distributedLock_);
|
||||
for (auto iter = distributedConnectAbilityMap_.begin(); iter != distributedConnectAbilityMap_.end();) {
|
||||
@ -1748,6 +1741,17 @@ void DistributedSchedService::ProcessDeviceOffline(const std::string& deviceId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedSchedService::ProcessDeviceOffline(const std::string& deviceId)
|
||||
{
|
||||
HILOGI("ProcessDeviceOffline called");
|
||||
std::string localDeviceId;
|
||||
if (!GetLocalDeviceId(localDeviceId) || !CheckDeviceId(localDeviceId, deviceId)) {
|
||||
HILOGE("ProcessDeviceOffline check deviceId failed");
|
||||
return;
|
||||
}
|
||||
RemoveConnectAbilityInfo(deviceId);
|
||||
ProcessCalleeOffline(deviceId);
|
||||
ProcessFreeInstallOffline(deviceId);
|
||||
}
|
||||
@ -2051,13 +2055,11 @@ int32_t DistributedSchedService::StartRemoteFreeInstall(const OHOS::AAFwk::Want&
|
||||
HILOGE("check deviceId failed");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
sptr<IDistributedSched> remoteDms = GetRemoteDms(deviceId);
|
||||
if (remoteDms == nullptr) {
|
||||
HILOGE("get remoteDms failed");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
if (dmsCallbackTask_ == nullptr) {
|
||||
HILOGE("callbackTask object null!");
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
@ -2087,8 +2089,7 @@ int32_t DistributedSchedService::StartRemoteFreeInstall(const OHOS::AAFwk::Want&
|
||||
}
|
||||
AAFwk::Want* newWant = const_cast<Want*>(&want);
|
||||
newWant->SetParam(DMS_SRC_NETWORK_ID, localDeviceId);
|
||||
FreeInstallInfo info = {.want = *newWant, .requestCode = requestCode, .callerInfo = callerInfo,
|
||||
.accountInfo = accountInfo};
|
||||
FreeInstallInfo info = {*newWant, requestCode, callerInfo, accountInfo};
|
||||
int32_t result = remoteDms->StartFreeInstallFromRemote(info, taskId);
|
||||
if (result != ERR_OK) {
|
||||
HILOGE("result = %{public}d", result);
|
||||
|
@ -546,6 +546,18 @@ int32_t DistributedSchedStub::DisconnectRemoteAbilityInner(MessageParcel& data,
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedStub::ReadDataForConnect(MessageParcel& data, CallerInfo callerInfo, AccountInfo accountInfo)
|
||||
{
|
||||
PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
|
||||
PARCEL_READ_HELPER(data, Int32, callerInfo.pid);
|
||||
PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
|
||||
callerInfo.callerType = CALLER_TYPE_HARMONY;
|
||||
accountInfo.accountType = data.ReadInt32();
|
||||
PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
|
||||
callerInfo.callerAppId = data.ReadString();
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t DistributedSchedStub::ConnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
if (!CheckCallingUid()) {
|
||||
@ -566,14 +578,11 @@ int32_t DistributedSchedStub::ConnectAbilityFromRemoteInner(MessageParcel& data,
|
||||
cmpAbilityInfo->ConvertToAbilityInfo(abilityInfo);
|
||||
sptr<IRemoteObject> connect = data.ReadRemoteObject();
|
||||
CallerInfo callerInfo;
|
||||
PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
|
||||
PARCEL_READ_HELPER(data, Int32, callerInfo.pid);
|
||||
PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
|
||||
callerInfo.callerType = CALLER_TYPE_HARMONY;
|
||||
AccountInfo accountInfo;
|
||||
accountInfo.accountType = data.ReadInt32();
|
||||
PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
|
||||
callerInfo.callerAppId = data.ReadString();
|
||||
int32_t result = ReadDataForConnect(data, callerInfo, accountInfo);
|
||||
if (result != ERR_NONE) {
|
||||
return result;
|
||||
}
|
||||
std::string extraInfo = data.ReadString();
|
||||
if (extraInfo.empty()) {
|
||||
HILOGD("extra info is empty!");
|
||||
@ -586,7 +595,7 @@ int32_t DistributedSchedStub::ConnectAbilityFromRemoteInner(MessageParcel& data,
|
||||
std::string package = abilityInfo.bundleName;
|
||||
std::string deviceId = abilityInfo.deviceId;
|
||||
int64_t begin = GetTickCount();
|
||||
int32_t result = ConnectAbilityFromRemote(*want, abilityInfo, connect, callerInfo, accountInfo);
|
||||
result = ConnectAbilityFromRemote(*want, abilityInfo, connect, callerInfo, accountInfo);
|
||||
BehaviorEventParam eventParam = { EventCallingType::REMOTE, BehaviorEvent::CONNECT_REMOTE_ABILITY, result,
|
||||
want->GetElement().GetBundleName(), want->GetElement().GetAbilityName(), callerInfo.uid };
|
||||
DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
|
||||
@ -1165,6 +1174,19 @@ int32_t DistributedSchedStub::StartRemoteFreeInstallInner(MessageParcel& data, M
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t DistributedSchedStub::ReadDataForFreeInstall(MessageParcel& data, CallerInfo &callerInfo,
|
||||
AccountInfo &accountInfo, int64_t &taskId)
|
||||
{
|
||||
callerInfo.callerType = CALLER_TYPE_HARMONY;
|
||||
PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
|
||||
PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
|
||||
accountInfo.accountType = data.ReadInt32();
|
||||
PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
|
||||
callerInfo.callerAppId = data.ReadString();
|
||||
PARCEL_READ_HELPER(data, Int64, taskId);
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t DistributedSchedStub::StartFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
if (!CheckCallingUid()) {
|
||||
@ -1178,15 +1200,12 @@ int32_t DistributedSchedStub::StartFreeInstallFromRemoteInner(MessageParcel& dat
|
||||
}
|
||||
int64_t begin = GetTickCount();
|
||||
CallerInfo callerInfo = {.accessToken = 0};
|
||||
callerInfo.callerType = CALLER_TYPE_HARMONY;
|
||||
AccountInfo accountInfo = {};
|
||||
int64_t taskId = 0;
|
||||
PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
|
||||
PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
|
||||
accountInfo.accountType = data.ReadInt32();
|
||||
PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
|
||||
callerInfo.callerAppId = data.ReadString();
|
||||
PARCEL_READ_HELPER(data, Int64, taskId);
|
||||
int32_t result = ReadDataForFreeInstall(data, callerInfo, accountInfo, taskId);
|
||||
if (result != ERR_NONE) {
|
||||
return result;
|
||||
}
|
||||
shared_ptr<DistributedWant> cmpDstbWant(data.ReadParcelable<DistributedWant>());
|
||||
shared_ptr<AAFwk::Want> cmpWant = nullptr;
|
||||
if (cmpDstbWant != nullptr) {
|
||||
@ -1211,7 +1230,7 @@ int32_t DistributedSchedStub::StartFreeInstallFromRemoteInner(MessageParcel& dat
|
||||
info.want.SetParam(PARAM_FREEINSTALL_APPID, callerInfo.callerAppId);
|
||||
info.want.SetParam(
|
||||
PARAM_FREEINSTALL_BUNDLENAMES, (*cmpWant).GetStringArrayParam(CMPT_PARAM_FREEINSTALL_BUNDLENAMES));
|
||||
int32_t result = StartFreeInstallFromRemote(info, taskId);
|
||||
result = StartFreeInstallFromRemote(info, taskId);
|
||||
HILOGI("result = %{public}d", result);
|
||||
PARCEL_WRITE_HELPER(reply, Int32, result);
|
||||
int64_t end = GetTickCount();
|
||||
|
@ -81,6 +81,14 @@ public:
|
||||
std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
|
||||
void AddStringParams(DistributedWant &want,
|
||||
std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
|
||||
void TestStringForParseUri(std::string uri,
|
||||
std::string keyString, std::size_t &length, std::string valueStringOrigin);
|
||||
void TestFloatForParseUri(std::string uri,
|
||||
std::string keyFloat, std::size_t &length, float valueFloatOrigin);
|
||||
void TestFloatArrayForParseUri(std::string uri,
|
||||
std::string keyFloatArray, std::size_t &length, std::vector<float> valueFloatArrayOrigin);
|
||||
void TestStringArrayForParseUri(std::string uri,
|
||||
std::string keyStringArray, std::size_t &length, std::vector<std::string> valueStringArrayOrigin);
|
||||
|
||||
std::string boolType = "bool";
|
||||
std::string boolArrayType = "boolArray";
|
||||
@ -153,56 +161,20 @@ HWTEST_F(DistributedWantBaseTest, DistributedSchedule_DistributedWant_Convert_01
|
||||
want.SetAction("Action");
|
||||
want.AddEntity("Entity1");
|
||||
want.SetParam(boolType, true);
|
||||
std::vector<bool> bv;
|
||||
bv.emplace_back(true);
|
||||
bv.emplace_back(false);
|
||||
want.SetParam(boolArrayType, bv);
|
||||
want.SetParam(byteType, 1);
|
||||
std::vector<byte> byv;
|
||||
byv.emplace_back(2);
|
||||
byv.emplace_back(3);
|
||||
want.SetParam(byteArrayType, byv);
|
||||
want.SetParam(charType, 6);
|
||||
std::vector<zchar> chv;
|
||||
chv.emplace_back('\n');
|
||||
chv.emplace_back('p');
|
||||
chv.emplace_back('i');
|
||||
want.SetParam(charArrayType, chv);
|
||||
want.SetParam(shortType, 444);
|
||||
std::vector<short> shv;
|
||||
shv.emplace_back(111);
|
||||
shv.emplace_back(222);
|
||||
shv.emplace_back(333);
|
||||
want.SetParam(shortArrayType, shv);
|
||||
want.SetParam(intType, 1111);
|
||||
std::vector<int> inv;
|
||||
inv.emplace_back(1111);
|
||||
inv.emplace_back(2222);
|
||||
inv.emplace_back(3333);
|
||||
inv.emplace_back(4444);
|
||||
want.SetParam(intArrayType, inv);
|
||||
want.SetParam(longType, 12345);
|
||||
std::vector<long> lgv;
|
||||
lgv.emplace_back(1111);
|
||||
lgv.emplace_back(2222);
|
||||
lgv.emplace_back(3333);
|
||||
lgv.emplace_back(4444);
|
||||
want.SetParam(longArrayType, lgv);
|
||||
want.SetParam(floatType, 1.1);
|
||||
std::vector<float> ftv;
|
||||
ftv.emplace_back(1111.1);
|
||||
ftv.emplace_back(2222.2);
|
||||
ftv.emplace_back(3333.3);
|
||||
ftv.emplace_back(4444.4);
|
||||
want.SetParam(floatArrayType, ftv);
|
||||
want.SetParam(doubleType, 1.11);
|
||||
want.SetParam(stringType, std::string("string..."));
|
||||
std::vector<double> dbv;
|
||||
dbv.emplace_back(1111.11);
|
||||
dbv.emplace_back(2222.22);
|
||||
dbv.emplace_back(3333.33);
|
||||
dbv.emplace_back(4444.44);
|
||||
want.SetParam(doubleArrayType, dbv);
|
||||
want.SetParam(stringType, std::string("string..."));
|
||||
std::vector<std::string> strv;
|
||||
strv.emplace_back("1111.11");
|
||||
strv.emplace_back("2222.22");
|
||||
@ -217,31 +189,78 @@ HWTEST_F(DistributedWantBaseTest, DistributedSchedule_DistributedWant_Convert_01
|
||||
EXPECT_STREQ(want.GetAction().c_str(), dstbWant.GetAction().c_str());
|
||||
EXPECT_EQ(want.GetEntities().size(), dstbWant.GetEntities().size());
|
||||
EXPECT_EQ(want.GetBoolParam(boolType, false), dstbWant.GetBoolParam(boolType, true));
|
||||
EXPECT_EQ(want.GetBoolArrayParam(boolArrayType).size(), dstbWant.GetBoolArrayParam(boolArrayType).size());
|
||||
EXPECT_EQ(want.GetByteParam(byteType, 0), dstbWant.GetByteParam(byteType, 0));
|
||||
EXPECT_EQ(want.GetByteArrayParam(byteArrayType).size(), dstbWant.GetByteArrayParam(byteArrayType).size());
|
||||
EXPECT_EQ(want.GetCharParam(charType, 0), dstbWant.GetCharParam(charType, 0));
|
||||
EXPECT_EQ(want.GetCharArrayParam(charArrayType).size(), dstbWant.GetCharArrayParam(charArrayType).size());
|
||||
EXPECT_EQ(want.GetShortParam(shortType, 0), dstbWant.GetShortParam(shortType, 0));
|
||||
EXPECT_EQ(want.GetShortArrayParam(shortArrayType).size(), dstbWant.GetShortArrayParam(shortArrayType).size());
|
||||
EXPECT_EQ(want.GetIntParam(intType, 0), dstbWant.GetIntParam(intType, 0));
|
||||
EXPECT_EQ(want.GetIntArrayParam(intArrayType).size(), dstbWant.GetIntArrayParam(intArrayType).size());
|
||||
EXPECT_EQ(want.GetLongParam(longType, 0), dstbWant.GetLongParam(longType, 0));
|
||||
EXPECT_EQ(want.GetLongArrayParam(longArrayType).size(), dstbWant.GetLongArrayParam(longArrayType).size());
|
||||
EXPECT_EQ(want.GetFloatParam(floatType, 0), dstbWant.GetFloatParam(floatType, 0));
|
||||
EXPECT_EQ(want.GetFloatArrayParam(floatArrayType).size(), dstbWant.GetFloatArrayParam(floatArrayType).size());
|
||||
EXPECT_EQ(want.GetDoubleParam(doubleType, 0), dstbWant.GetDoubleParam(doubleType, 0));
|
||||
EXPECT_EQ(want.GetDoubleArrayParam(doubleArrayType).size(), dstbWant.GetDoubleArrayParam(doubleArrayType).size());
|
||||
EXPECT_STREQ(want.GetStringParam(stringType).c_str(), dstbWant.GetStringParam(stringType).c_str());
|
||||
EXPECT_EQ(want.GetDoubleArrayParam(doubleArrayType).size(), dstbWant.GetDoubleArrayParam(doubleArrayType).size());
|
||||
EXPECT_EQ(want.GetStringArrayParam(stringArrayType).size(), dstbWant.GetStringArrayParam(stringArrayType).size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedScheduleWant_Action_0100
|
||||
* @tc.number: DistributedSchedule_DistributedWant_Convert_0101
|
||||
* @tc.name: distributedwant
|
||||
* @tc.desc: Verifying successful conversion of want to distributedwant.
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedSchedule_DistributedWant_Convert_0101, Function | MediumTest | Level3)
|
||||
{
|
||||
Want want;
|
||||
std::vector<bool> bv;
|
||||
bv.emplace_back(true);
|
||||
bv.emplace_back(false);
|
||||
want.SetParam(boolArrayType, bv);
|
||||
std::vector<byte> byv;
|
||||
byv.emplace_back(2);
|
||||
byv.emplace_back(3);
|
||||
want.SetParam(byteArrayType, byv);
|
||||
std::vector<zchar> chv;
|
||||
chv.emplace_back('\n');
|
||||
chv.emplace_back('p');
|
||||
chv.emplace_back('i');
|
||||
want.SetParam(charArrayType, chv);
|
||||
std::vector<short> shv;
|
||||
shv.emplace_back(111);
|
||||
shv.emplace_back(222);
|
||||
shv.emplace_back(333);
|
||||
want.SetParam(shortArrayType, shv);
|
||||
std::vector<int> inv;
|
||||
inv.emplace_back(1111);
|
||||
inv.emplace_back(2222);
|
||||
inv.emplace_back(3333);
|
||||
inv.emplace_back(4444);
|
||||
want.SetParam(intArrayType, inv);
|
||||
std::vector<long> lgv;
|
||||
lgv.emplace_back(1111);
|
||||
lgv.emplace_back(2222);
|
||||
lgv.emplace_back(3333);
|
||||
lgv.emplace_back(4444);
|
||||
want.SetParam(longArrayType, lgv);
|
||||
std::vector<float> ftv;
|
||||
ftv.emplace_back(1111.1);
|
||||
ftv.emplace_back(2222.2);
|
||||
ftv.emplace_back(3333.3);
|
||||
ftv.emplace_back(4444.4);
|
||||
want.SetParam(floatArrayType, ftv);
|
||||
DistributedWant dstbWant(want);
|
||||
EXPECT_EQ(want.GetBoolArrayParam(boolArrayType).size(), dstbWant.GetBoolArrayParam(boolArrayType).size());
|
||||
EXPECT_EQ(want.GetByteArrayParam(byteArrayType).size(), dstbWant.GetByteArrayParam(byteArrayType).size());
|
||||
EXPECT_EQ(want.GetCharArrayParam(charArrayType).size(), dstbWant.GetCharArrayParam(charArrayType).size());
|
||||
EXPECT_EQ(want.GetShortArrayParam(shortArrayType).size(), dstbWant.GetShortArrayParam(shortArrayType).size());
|
||||
EXPECT_EQ(want.GetIntArrayParam(intArrayType).size(), dstbWant.GetIntArrayParam(intArrayType).size());
|
||||
EXPECT_EQ(want.GetLongArrayParam(longArrayType).size(), dstbWant.GetLongArrayParam(longArrayType).size());
|
||||
EXPECT_EQ(want.GetFloatArrayParam(floatArrayType).size(), dstbWant.GetFloatArrayParam(floatArrayType).size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedSchedule_DistributedWant_Convert_0200
|
||||
* @tc.name: ToWant
|
||||
* @tc.desc: Verifying successful conversion of distributedwant to want.
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedSchedule_DistributedWant_Convert_0200, Function | MediumTest | Level3)
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedSchedule_Distributedwant_Convert_0200, Function | MediumTest | Level3)
|
||||
{
|
||||
std::shared_ptr<DistributedWant> dwant = std::make_shared<DistributedWant>();
|
||||
std::string description = "liuuy";
|
||||
@ -252,62 +271,26 @@ HWTEST_F(DistributedWantBaseTest, DistributedSchedule_DistributedWant_Convert_02
|
||||
dwant->SetAction("Action");
|
||||
dwant->AddEntity("Entity1");
|
||||
dwant->SetParam(boolType, true);
|
||||
std::vector<bool> bv;
|
||||
bv.emplace_back(true);
|
||||
bv.emplace_back(false);
|
||||
dwant->SetParam(boolArrayType, bv);
|
||||
dwant->SetParam(byteType, 1);
|
||||
std::vector<byte> byv;
|
||||
byv.emplace_back(2);
|
||||
byv.emplace_back(3);
|
||||
dwant->SetParam(byteArrayType, byv);
|
||||
dwant->SetParam(charType, 6);
|
||||
std::vector<zchar> chv;
|
||||
chv.emplace_back('\n');
|
||||
chv.emplace_back('p');
|
||||
chv.emplace_back('i');
|
||||
dwant->SetParam(charArrayType, chv);
|
||||
dwant->SetParam(shortType, 444);
|
||||
std::vector<short> shv;
|
||||
shv.emplace_back(111);
|
||||
shv.emplace_back(222);
|
||||
shv.emplace_back(333);
|
||||
dwant->SetParam(shortArrayType, shv);
|
||||
dwant->SetParam(intType, 1111);
|
||||
std::vector<int> inv;
|
||||
inv.emplace_back(1111);
|
||||
inv.emplace_back(2222);
|
||||
inv.emplace_back(3333);
|
||||
inv.emplace_back(4444);
|
||||
dwant->SetParam(intArrayType, inv);
|
||||
dwant->SetParam(longType, 12345);
|
||||
std::vector<long> lgv;
|
||||
lgv.emplace_back(1111);
|
||||
lgv.emplace_back(2222);
|
||||
lgv.emplace_back(3333);
|
||||
lgv.emplace_back(4444);
|
||||
dwant->SetParam(longArrayType, lgv);
|
||||
dwant->SetParam(floatType, 1.1);
|
||||
std::vector<float> ftv;
|
||||
ftv.emplace_back(1111.1);
|
||||
ftv.emplace_back(2222.2);
|
||||
ftv.emplace_back(3333.3);
|
||||
ftv.emplace_back(4444.4);
|
||||
dwant->SetParam(floatArrayType, ftv);
|
||||
dwant->SetParam(doubleType, 1.11);
|
||||
dwant->SetParam(stringType, std::string("string..."));
|
||||
std::vector<double> dbv;
|
||||
dbv.emplace_back(1111.11);
|
||||
dbv.emplace_back(2222.22);
|
||||
dbv.emplace_back(3333.33);
|
||||
dbv.emplace_back(4444.44);
|
||||
dwant->SetParam(doubleArrayType, dbv);
|
||||
dwant->SetParam(stringType, std::string("string..."));
|
||||
std::vector<std::string> strv;
|
||||
strv.emplace_back("1111.11");
|
||||
strv.emplace_back("2222.22");
|
||||
dwant->SetParam(stringArrayType, strv);
|
||||
std::shared_ptr<Want> want = dwant->ToWant();
|
||||
EXPECT_STREQ(want->GetAction().c_str(), dwant->GetAction().c_str());
|
||||
EXPECT_STREQ(want->GetType().c_str(), dwant->GetType().c_str());
|
||||
EXPECT_STREQ(want->GetElement().GetDeviceID().c_str(), dwant->GetElement().GetDeviceID().c_str());
|
||||
EXPECT_STREQ(want->GetElement().GetBundleName().c_str(), dwant->GetElement().GetBundleName().c_str());
|
||||
EXPECT_STREQ(want->GetElement().GetAbilityName().c_str(), dwant->GetElement().GetAbilityName().c_str());
|
||||
@ -316,25 +299,72 @@ HWTEST_F(DistributedWantBaseTest, DistributedSchedule_DistributedWant_Convert_02
|
||||
EXPECT_STREQ(want->GetAction().c_str(), dwant->GetAction().c_str());
|
||||
EXPECT_EQ(want->GetEntities().size(), dwant->GetEntities().size());
|
||||
EXPECT_EQ(want->GetBoolParam(boolType, false), dwant->GetBoolParam(boolType, true));
|
||||
EXPECT_EQ(want->GetBoolArrayParam(boolArrayType).size(), dwant->GetBoolArrayParam(boolArrayType).size());
|
||||
EXPECT_EQ(want->GetByteParam(byteType, 0), dwant->GetByteParam(byteType, 0));
|
||||
EXPECT_EQ(want->GetByteArrayParam(byteArrayType).size(), dwant->GetByteArrayParam(byteArrayType).size());
|
||||
EXPECT_EQ(want->GetCharParam(charType, 0), dwant->GetCharParam(charType, 0));
|
||||
EXPECT_EQ(want->GetCharArrayParam(charArrayType).size(), dwant->GetCharArrayParam(charArrayType).size());
|
||||
EXPECT_EQ(want->GetShortParam(shortType, 0), dwant->GetShortParam(shortType, 0));
|
||||
EXPECT_EQ(want->GetShortArrayParam(shortArrayType).size(), dwant->GetShortArrayParam(shortArrayType).size());
|
||||
EXPECT_EQ(want->GetIntParam(intType, 0), dwant->GetIntParam(intType, 0));
|
||||
EXPECT_EQ(want->GetIntArrayParam(intArrayType).size(), dwant->GetIntArrayParam(intArrayType).size());
|
||||
EXPECT_EQ(want->GetLongParam(longType, 0), dwant->GetLongParam(longType, 0));
|
||||
EXPECT_EQ(want->GetLongArrayParam(longArrayType).size(), dwant->GetLongArrayParam(longArrayType).size());
|
||||
EXPECT_EQ(want->GetFloatParam(floatType, 0), dwant->GetFloatParam(floatType, 0));
|
||||
EXPECT_EQ(want->GetFloatArrayParam(floatArrayType).size(), dwant->GetFloatArrayParam(floatArrayType).size());
|
||||
EXPECT_EQ(want->GetDoubleParam(doubleType, 0), dwant->GetDoubleParam(doubleType, 0));
|
||||
EXPECT_EQ(want->GetDoubleArrayParam(doubleArrayType).size(), dwant->GetDoubleArrayParam(doubleArrayType).size());
|
||||
EXPECT_STREQ(want->GetStringParam(stringType).c_str(), dwant->GetStringParam(stringType).c_str());
|
||||
EXPECT_EQ(want->GetDoubleArrayParam(doubleArrayType).size(), dwant->GetDoubleArrayParam(doubleArrayType).size());
|
||||
EXPECT_EQ(want->GetStringArrayParam(stringArrayType).size(), dwant->GetStringArrayParam(stringArrayType).size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedSchedule_DistributedWant_Convert_0201
|
||||
* @tc.name: ToWant
|
||||
* @tc.desc: Verifying successful conversion of distributedwant to want.
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedSchedule_Distributedwant_Convert_0201, Function | MediumTest | Level3)
|
||||
{
|
||||
std::shared_ptr<DistributedWant> dwant = std::make_shared<DistributedWant>();
|
||||
std::vector<bool> bv;
|
||||
bv.emplace_back(true);
|
||||
bv.emplace_back(false);
|
||||
dwant->SetParam(boolArrayType, bv);
|
||||
std::vector<byte> byv;
|
||||
byv.emplace_back(2);
|
||||
byv.emplace_back(3);
|
||||
dwant->SetParam(byteArrayType, byv);
|
||||
std::vector<zchar> chv;
|
||||
chv.emplace_back('\n');
|
||||
chv.emplace_back('p');
|
||||
chv.emplace_back('i');
|
||||
dwant->SetParam(charArrayType, chv);
|
||||
std::vector<short> shv;
|
||||
shv.emplace_back(111);
|
||||
shv.emplace_back(222);
|
||||
shv.emplace_back(333);
|
||||
dwant->SetParam(shortArrayType, shv);
|
||||
std::vector<int> inv;
|
||||
inv.emplace_back(1111);
|
||||
inv.emplace_back(2222);
|
||||
inv.emplace_back(3333);
|
||||
inv.emplace_back(4444);
|
||||
dwant->SetParam(intArrayType, inv);
|
||||
std::vector<long> lgv;
|
||||
lgv.emplace_back(1111);
|
||||
lgv.emplace_back(2222);
|
||||
lgv.emplace_back(3333);
|
||||
lgv.emplace_back(4444);
|
||||
dwant->SetParam(longArrayType, lgv);
|
||||
std::vector<float> ftv;
|
||||
ftv.emplace_back(1111.1);
|
||||
ftv.emplace_back(2222.2);
|
||||
ftv.emplace_back(3333.3);
|
||||
ftv.emplace_back(4444.4);
|
||||
dwant->SetParam(floatArrayType, ftv);
|
||||
std::shared_ptr<Want> want = dwant->ToWant();
|
||||
EXPECT_EQ(want->GetBoolArrayParam(boolArrayType).size(), dwant->GetBoolArrayParam(boolArrayType).size());
|
||||
EXPECT_EQ(want->GetByteArrayParam(byteArrayType).size(), dwant->GetByteArrayParam(byteArrayType).size());
|
||||
EXPECT_EQ(want->GetCharArrayParam(charArrayType).size(), dwant->GetCharArrayParam(charArrayType).size());
|
||||
EXPECT_EQ(want->GetShortArrayParam(shortArrayType).size(), dwant->GetShortArrayParam(shortArrayType).size());
|
||||
EXPECT_EQ(want->GetIntArrayParam(intArrayType).size(), dwant->GetIntArrayParam(intArrayType).size());
|
||||
EXPECT_EQ(want->GetLongArrayParam(longArrayType).size(), dwant->GetLongArrayParam(longArrayType).size());
|
||||
EXPECT_EQ(want->GetFloatArrayParam(floatArrayType).size(), dwant->GetFloatArrayParam(floatArrayType).size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedScheduleWant_Type_0100
|
||||
* @tc.name: SetType/GetType
|
||||
@ -389,9 +419,6 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0100, Funct
|
||||
return;
|
||||
}
|
||||
|
||||
WantIn_->SetAction("12345");
|
||||
WantIn_->SetFlags(123);
|
||||
|
||||
WantIn_->SetAction("12345");
|
||||
WantIn_->SetFlags(123);
|
||||
WantIn_->AddEntity("12345");
|
||||
@ -406,14 +433,11 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0100, Funct
|
||||
element.SetDeviceID("12345");
|
||||
WantIn_->SetElement(element);
|
||||
WantIn_->SetType("12345");
|
||||
size_t pos1;
|
||||
size_t pos2;
|
||||
bool result = false;
|
||||
|
||||
Parcel in;
|
||||
pos1 = in.GetWritePosition();
|
||||
result = WantIn_->Marshalling(in);
|
||||
pos2 = in.GetWritePosition();
|
||||
size_t pos1 = in.GetWritePosition();
|
||||
bool result = WantIn_->Marshalling(in);
|
||||
size_t pos2 = in.GetWritePosition();
|
||||
EXPECT_EQ(result, true);
|
||||
GTEST_LOG_(INFO) << " Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
|
||||
|
||||
@ -590,14 +614,10 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0400, Funct
|
||||
WantIn_->SetElement(element);
|
||||
WantIn_->SetType("12345");
|
||||
|
||||
size_t pos1;
|
||||
size_t pos2;
|
||||
bool result = false;
|
||||
|
||||
Parcel in;
|
||||
pos1 = in.GetWritePosition();
|
||||
result = WantIn_->Marshalling(in);
|
||||
pos2 = in.GetWritePosition();
|
||||
size_t pos1 = in.GetWritePosition();
|
||||
bool result = WantIn_->Marshalling(in);
|
||||
size_t pos2 = in.GetWritePosition();
|
||||
EXPECT_EQ(result, true);
|
||||
GTEST_LOG_(INFO) << "Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
|
||||
|
||||
@ -633,14 +653,12 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0400, Funct
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0500, Function | MediumTest | Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_005 start";
|
||||
GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_0500 start";
|
||||
std::shared_ptr<DistributedWant> WantIn_ = std::make_shared<DistributedWant>();
|
||||
if (WantIn_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
WantIn_->SetAction("system.test.action");
|
||||
WantIn_->SetFlags(64);
|
||||
WantIn_->AddEntity("system.test.entity");
|
||||
|
||||
OHOS::AppExecFwk::ElementName element;
|
||||
@ -658,54 +676,12 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0500, Funct
|
||||
wantParams.SetParam(keyStr, String::Box(valueString));
|
||||
WantIn_->SetParams(wantParams);
|
||||
|
||||
// want SetParam arraydata test
|
||||
std::vector<bool> boolArrayValue = {true, false, true};
|
||||
WantIn_->SetParam(std::string("bool_arraykey"), boolArrayValue);
|
||||
|
||||
std::vector<byte> byteArrayValue = {'?', 'a', '\\'};
|
||||
WantIn_->SetParam(std::string("byte_arraykey"), byteArrayValue);
|
||||
|
||||
std::vector<zchar> charArrayValue = {U'e', U'l', U'l', U'o'};
|
||||
WantIn_->SetParam(std::string("char_arraykey"), charArrayValue);
|
||||
|
||||
std::vector<short> shortArrayValue = {-1, 0, 1};
|
||||
WantIn_->SetParam(std::string("short_arraykey"), shortArrayValue);
|
||||
|
||||
std::vector<int> intArrayValue = {-10, 0, 10};
|
||||
WantIn_->SetParam(std::string("int_arraykey"), intArrayValue);
|
||||
|
||||
std::vector<long> longArrayValue = {-100, 0, 100};
|
||||
WantIn_->SetParam(std::string("long_arraykey"), longArrayValue);
|
||||
|
||||
std::vector<float> floatArrayValue = {-100.1, 0.1, 100.1};
|
||||
WantIn_->SetParam(std::string("float_arraykey"), floatArrayValue);
|
||||
|
||||
std::vector<double> doubleArrayValue = {-1000.1, 0.1, 1000.1};
|
||||
WantIn_->SetParam(std::string("double_arraykey"), doubleArrayValue);
|
||||
|
||||
std::vector<std::string> stringArrayValue = {"stringtest1", "string@test2", "string@!#test2"};
|
||||
WantIn_->SetParam(std::string("string_arraykey"), stringArrayValue);
|
||||
|
||||
DistributedWant wantCopy(*WantIn_);
|
||||
std::vector<std::string> teststringArrayValue1 = WantIn_->GetStringArrayParam(std::string("string_arraykey"));
|
||||
std::vector<std::string> teststringArrayValue2 = wantCopy.GetStringArrayParam(std::string("string_arraykey"));
|
||||
bool copyarraycompare = CompareArrayData<std::string>(teststringArrayValue1, teststringArrayValue1);
|
||||
EXPECT_EQ(copyarraycompare, true);
|
||||
std::string str = (copyarraycompare == true) ? "true" : "false";
|
||||
GTEST_LOG_(INFO) << "copyarraycompare=" << str.c_str();
|
||||
|
||||
Parcel in;
|
||||
bool result = false;
|
||||
result = WantIn_->Marshalling(in);
|
||||
EXPECT_EQ(result, true);
|
||||
std::shared_ptr<DistributedWant> WantOut_(DistributedWant::Unmarshalling(in));
|
||||
if (WantOut_ != nullptr) {
|
||||
GTEST_LOG_(INFO) << "WantOut_->GetAction().c_str(): " << WantOut_->GetAction().c_str();
|
||||
EXPECT_STREQ(WantOut_->GetAction().c_str(), std::string("system.test.action").c_str());
|
||||
|
||||
int flags = WantOut_->GetFlags();
|
||||
GTEST_LOG_(INFO) << "WantOut_->GetFlags(): " << flags;
|
||||
EXPECT_EQ(static_cast<int>(flags), 64);
|
||||
|
||||
bool hasentity = WantOut_->HasEntity("system.test.entity");
|
||||
GTEST_LOG_(INFO) << "WantOut_->HasEntity(system.test.entity)" << hasentity;
|
||||
@ -732,7 +708,54 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0500, Funct
|
||||
std::string param_content = WantOut_->GetStringParam(keyStr);
|
||||
GTEST_LOG_(INFO) << "WantOut_->GetStringParam(keyStr): " << param_content.c_str();
|
||||
|
||||
// want SetParam arraydata test
|
||||
GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_005 end";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedScheduleWant_Parcelable_0501
|
||||
* @tc.name: Marshalling/Unmarshalling
|
||||
* @tc.desc: marshalling Want, and then check result.
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0501, Function | MediumTest | Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_0501 start";
|
||||
std::shared_ptr<DistributedWant> WantIn_ = std::make_shared<DistributedWant>();
|
||||
if (WantIn_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
WantIn_->SetAction("system.test.action");
|
||||
|
||||
std::vector<bool> boolArrayValue = {true, false, true};
|
||||
WantIn_->SetParam(std::string("bool_arraykey"), boolArrayValue);
|
||||
|
||||
std::vector<byte> byteArrayValue = {'?', 'a', '\\'};
|
||||
WantIn_->SetParam(std::string("byte_arraykey"), byteArrayValue);
|
||||
|
||||
std::vector<zchar> charArrayValue = {U'e', U'l', U'l', U'o'};
|
||||
WantIn_->SetParam(std::string("char_arraykey"), charArrayValue);
|
||||
|
||||
std::vector<std::string> stringArrayValue = {"stringtest1", "string@test2", "string@!#test2"};
|
||||
WantIn_->SetParam(std::string("string_arraykey"), stringArrayValue);
|
||||
|
||||
DistributedWant wantCopy(*WantIn_);
|
||||
std::vector<std::string> teststringArrayValue1 = WantIn_->GetStringArrayParam(std::string("string_arraykey"));
|
||||
std::vector<std::string> teststringArrayValue2 = wantCopy.GetStringArrayParam(std::string("string_arraykey"));
|
||||
bool copyarraycompare = CompareArrayData<std::string>(teststringArrayValue1, teststringArrayValue1);
|
||||
EXPECT_EQ(copyarraycompare, true);
|
||||
std::string str = (copyarraycompare == true) ? "true" : "false";
|
||||
GTEST_LOG_(INFO) << "copyarraycompare=" << str.c_str();
|
||||
|
||||
Parcel in;
|
||||
bool result = false;
|
||||
result = WantIn_->Marshalling(in);
|
||||
EXPECT_EQ(result, true);
|
||||
std::shared_ptr<DistributedWant> WantOut_(DistributedWant::Unmarshalling(in));
|
||||
if (WantOut_ != nullptr) {
|
||||
GTEST_LOG_(INFO) << "WantOut_->GetAction().c_str(): " << WantOut_->GetAction().c_str();
|
||||
EXPECT_STREQ(WantOut_->GetAction().c_str(), std::string("system.test.action").c_str());
|
||||
|
||||
std::vector<bool> retboolArray;
|
||||
retboolArray = WantOut_->GetBoolArrayParam(std::string("bool_arraykey"));
|
||||
|
||||
@ -749,9 +772,56 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0500, Funct
|
||||
arraycompare = CompareArrayData<zchar>(retcharArrayValue, charArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<std::string> retstringArrayValue;
|
||||
retstringArrayValue = WantOut_->GetStringArrayParam(std::string("string_arraykey"));
|
||||
arraycompare = CompareArrayData<std::string>(retstringArrayValue, stringArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedScheduleWant_Parcelable_0502
|
||||
* @tc.name: Marshalling/Unmarshalling
|
||||
* @tc.desc: marshalling Want, and then check result.
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0502, Function | MediumTest | Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_0502 start";
|
||||
std::shared_ptr<DistributedWant> WantIn_ = std::make_shared<DistributedWant>();
|
||||
if (WantIn_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
WantIn_->SetFlags(64);
|
||||
|
||||
std::vector<short> shortArrayValue = {-1, 0, 1};
|
||||
WantIn_->SetParam(std::string("short_arraykey"), shortArrayValue);
|
||||
|
||||
std::vector<int> intArrayValue = {-10, 0, 10};
|
||||
WantIn_->SetParam(std::string("int_arraykey"), intArrayValue);
|
||||
|
||||
std::vector<long> longArrayValue = {-100, 0, 100};
|
||||
WantIn_->SetParam(std::string("long_arraykey"), longArrayValue);
|
||||
|
||||
std::vector<float> floatArrayValue = {-100.1, 0.1, 100.1};
|
||||
WantIn_->SetParam(std::string("float_arraykey"), floatArrayValue);
|
||||
|
||||
std::vector<double> doubleArrayValue = {-1000.1, 0.1, 1000.1};
|
||||
WantIn_->SetParam(std::string("double_arraykey"), doubleArrayValue);
|
||||
|
||||
Parcel in;
|
||||
bool result = false;
|
||||
result = WantIn_->Marshalling(in);
|
||||
EXPECT_EQ(result, true);
|
||||
std::shared_ptr<DistributedWant> WantOut_(DistributedWant::Unmarshalling(in));
|
||||
if (WantOut_ != nullptr) {
|
||||
int flags = WantOut_->GetFlags();
|
||||
GTEST_LOG_(INFO) << "WantOut_->GetFlags(): " << flags;
|
||||
EXPECT_EQ(static_cast<int>(flags), 64);
|
||||
|
||||
std::vector<short> retshortArrayValue;
|
||||
retshortArrayValue = WantOut_->GetShortArrayParam(std::string("short_arraykey"));
|
||||
arraycompare = CompareArrayData<short>(retshortArrayValue, shortArrayValue);
|
||||
bool arraycompare = CompareArrayData<short>(retshortArrayValue, shortArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<int> retintArrayValue;
|
||||
@ -773,13 +843,6 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0500, Funct
|
||||
retdoubleArrayValue = WantOut_->GetDoubleArrayParam(std::string("double_arraykey"));
|
||||
arraycompare = CompareArrayData<double>(retdoubleArrayValue, doubleArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<std::string> retstringArrayValue;
|
||||
retstringArrayValue = WantOut_->GetStringArrayParam(std::string("string_arraykey"));
|
||||
arraycompare = CompareArrayData<std::string>(retstringArrayValue, stringArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_005 end";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1201,6 +1264,99 @@ void DistributedWantBaseTest::AddStringParams(DistributedWant& want,
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedWantBaseTest::TestStringForParseUri(std::string uri,
|
||||
std::string keyString, std::size_t &length, std::string valueStringOrigin)
|
||||
{
|
||||
std::size_t head = length;
|
||||
std::string search = String::SIGNATURE + std::string(".") + keyString + std::string("=");
|
||||
std::size_t result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
std::size_t pos = result + search.length();
|
||||
std::size_t delims = uri.find(";", pos);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
std::string valueStringNew = String::Unbox(String::Parse(substring));
|
||||
EXPECT_EQ(valueStringNew, valueStringOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedWantBaseTest::TestFloatForParseUri(std::string uri,
|
||||
std::string keyFloat, std::size_t &length, float valueFloatOrigin)
|
||||
{
|
||||
std::size_t head = length;
|
||||
std::string search = Float::SIGNATURE + std::string(".") + keyFloat + std::string("=");
|
||||
std::size_t result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
std::size_t pos = result + search.length();
|
||||
std::size_t delims = uri.find(";", pos);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
float valueFloatNew = Float::Unbox(Float::Parse(substring));
|
||||
EXPECT_EQ(valueFloatNew, valueFloatOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedWantBaseTest::TestFloatArrayForParseUri(std::string uri,
|
||||
std::string keyFloatArray, std::size_t &length, std::vector<float> valueFloatArrayOrigin)
|
||||
{
|
||||
std::size_t head = length;
|
||||
std::string search = Array::SIGNATURE + std::string(".") + keyFloatArray + std::string("=");
|
||||
std::size_t result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
std::size_t pos = result + search.length();
|
||||
std::size_t delims = uri.find(";", result);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
sptr<IArray> array = Array::Parse(substring);
|
||||
std::vector<float> valueFloatArrayNew;
|
||||
auto func = [&valueFloatArrayNew](
|
||||
IInterface *object) { valueFloatArrayNew.push_back(Float::Unbox(IFloat::Query(object))); };
|
||||
Array::ForEach(array, func);
|
||||
EXPECT_EQ(valueFloatArrayNew, valueFloatArrayOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedWantBaseTest::TestStringArrayForParseUri(std::string uri,
|
||||
std::string keyStringArray, std::size_t &length, std::vector<std::string> valueStringArrayOrigin)
|
||||
{
|
||||
std::size_t head = length;
|
||||
std::string search = Array::SIGNATURE + std::string(".") + keyStringArray + std::string("=");
|
||||
std::size_t result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
std::size_t pos = result + search.length();
|
||||
std::size_t delims = uri.find(";", result);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
sptr<IArray> array = Array::Parse(substring);
|
||||
std::vector<std::string> valueStringArrayNew;
|
||||
auto func = [&valueStringArrayNew](IInterface *object) {
|
||||
valueStringArrayNew.push_back(String::Unbox(IString::Query(object)));
|
||||
};
|
||||
Array::ForEach(array, func);
|
||||
EXPECT_EQ(valueStringArrayNew, valueStringArrayOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DistributedScheduleWant_Parcelable_0600
|
||||
* @tc.name: parcelable
|
||||
@ -1432,12 +1588,8 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0200, F
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0300, Function | MediumTest | Level3)
|
||||
{
|
||||
std::string search;
|
||||
std::string substring;
|
||||
std::size_t pos = 0;
|
||||
std::size_t length = 0;
|
||||
std::size_t result = 0;
|
||||
std::size_t delims = 0;
|
||||
std::size_t head = 0;
|
||||
Want wantOrigin;
|
||||
std::string keyFloat = "keyFloat";
|
||||
@ -1446,29 +1598,14 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0300, F
|
||||
|
||||
std::string uri = wantOrigin.ToUri();
|
||||
|
||||
search = DistributedWantBaseTest::URI_STRING_HEAD;
|
||||
result = uri.find(search, pos);
|
||||
std::string search = DistributedWantBaseTest::URI_STRING_HEAD;
|
||||
std::size_t result = uri.find(search, pos);
|
||||
EXPECT_EQ(result, pos);
|
||||
if (result != std::string::npos) {
|
||||
head = result + search.length();
|
||||
}
|
||||
length += head;
|
||||
|
||||
search = Float::SIGNATURE + std::string(".") + keyFloat + std::string("=");
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
pos = result + search.length();
|
||||
delims = uri.find(";", pos);
|
||||
if (delims != std::string::npos) {
|
||||
substring = uri.substr(pos, delims - pos);
|
||||
float valueFloatNew = Float::Unbox(Float::Parse(substring));
|
||||
EXPECT_EQ(valueFloatNew, valueFloatOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
TestFloatForParseUri(uri, keyFloat, length, valueFloatOrigin);
|
||||
|
||||
search = DistributedWantBaseTest::URI_STRING_END;
|
||||
result = uri.find(search);
|
||||
@ -1499,12 +1636,8 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0300, F
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0400, Function | MediumTest | Level3)
|
||||
{
|
||||
std::string search;
|
||||
std::string substring;
|
||||
std::size_t pos = 0;
|
||||
std::size_t length = 0;
|
||||
std::size_t result = 0;
|
||||
std::size_t delims = 0;
|
||||
std::size_t head = 0;
|
||||
DistributedWant wantOrigin;
|
||||
std::string keyFloat = "keyFloat";
|
||||
@ -1516,46 +1649,16 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0400, F
|
||||
|
||||
std::string uri = wantOrigin.ToUri();
|
||||
|
||||
search = DistributedWantBaseTest::URI_STRING_HEAD;
|
||||
result = uri.find(search, pos);
|
||||
std::string search = DistributedWantBaseTest::URI_STRING_HEAD;
|
||||
std::size_t result = uri.find(search, pos);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_EQ(result, pos);
|
||||
if (result != std::string::npos) {
|
||||
head = result + search.length();
|
||||
}
|
||||
length += head;
|
||||
|
||||
search = Float::SIGNATURE + std::string(".") + keyFloat + std::string("=");
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
pos = result + search.length();
|
||||
delims = uri.find(";", pos);
|
||||
if (delims != std::string::npos) {
|
||||
substring = uri.substr(pos, delims - pos);
|
||||
float valueFloatNew = Float::Unbox(Float::Parse(substring));
|
||||
EXPECT_EQ(valueFloatNew, valueFloatOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
search = String::SIGNATURE + std::string(".") + keyString + std::string("=");
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
pos = result + search.length();
|
||||
delims = uri.find(";", result);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
std::string valueStringNew = String::Unbox(String::Parse(substring));
|
||||
EXPECT_EQ(valueStringNew, valueStringOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
TestFloatForParseUri(uri, keyFloat, length, valueFloatOrigin);
|
||||
TestStringForParseUri(uri, keyString, length, valueStringOrigin);
|
||||
|
||||
search = DistributedWantBaseTest::URI_STRING_END;
|
||||
result = uri.find(search);
|
||||
@ -1614,26 +1717,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0500, F
|
||||
}
|
||||
length += head;
|
||||
|
||||
search = Array::SIGNATURE + std::string(".") + keyFloatArray + std::string("=");
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
pos = result + search.length();
|
||||
delims = uri.find(";", result);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
sptr<IArray> array = Array::Parse(substring);
|
||||
std::vector<float> valueFloatArrayNew;
|
||||
auto func = [&valueFloatArrayNew](
|
||||
IInterface *object) { valueFloatArrayNew.push_back(Float::Unbox(IFloat::Query(object))); };
|
||||
Array::ForEach(array, func);
|
||||
EXPECT_EQ(valueFloatArrayNew, valueFloatArrayOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
TestFloatArrayForParseUri(uri, keyFloatArray, length, valueFloatArrayOrigin);
|
||||
search = DistributedWantBaseTest::URI_STRING_END;
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
@ -1663,12 +1747,8 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0500, F
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0600, Function | MediumTest | Level3)
|
||||
{
|
||||
std::string search;
|
||||
std::string substring;
|
||||
std::size_t pos = 0;
|
||||
std::size_t length = 0;
|
||||
std::size_t result = 0;
|
||||
std::size_t delims = 0;
|
||||
std::size_t head = 0;
|
||||
DistributedWant wantOrigin;
|
||||
std::string keyFloatArray = "keyFloatArray";
|
||||
@ -1680,8 +1760,8 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0600, F
|
||||
|
||||
std::string uri = wantOrigin.ToUri();
|
||||
|
||||
search = DistributedWantBaseTest::URI_STRING_HEAD;
|
||||
result = uri.find(search, pos);
|
||||
std::string search = DistributedWantBaseTest::URI_STRING_HEAD;
|
||||
std::size_t result = uri.find(search, pos);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_EQ(result, pos);
|
||||
if (result != std::string::npos) {
|
||||
@ -1689,46 +1769,8 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0600, F
|
||||
}
|
||||
length += head;
|
||||
|
||||
search = Array::SIGNATURE + std::string(".") + keyFloatArray + std::string("=");
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
pos = result + search.length();
|
||||
delims = uri.find(";", result);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
sptr<IArray> array = Array::Parse(substring);
|
||||
std::vector<float> valueFloatArrayNew;
|
||||
auto func = [&valueFloatArrayNew](
|
||||
IInterface *object) { valueFloatArrayNew.push_back(Float::Unbox(IFloat::Query(object))); };
|
||||
Array::ForEach(array, func);
|
||||
EXPECT_EQ(valueFloatArrayNew, valueFloatArrayOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
search = Array::SIGNATURE + std::string(".") + keyStringArray + std::string("=");
|
||||
result = uri.find(search);
|
||||
EXPECT_NE(result, std::string::npos);
|
||||
EXPECT_GE(result, head);
|
||||
length += search.length();
|
||||
if (result != std::string::npos) {
|
||||
pos = result + search.length();
|
||||
delims = uri.find(";", result);
|
||||
if (delims != std::string::npos) {
|
||||
std::string substring = uri.substr(pos, delims - pos);
|
||||
sptr<IArray> array = Array::Parse(substring);
|
||||
std::vector<std::string> valueStringArrayNew;
|
||||
auto func = [&valueStringArrayNew](IInterface *object) {
|
||||
valueStringArrayNew.push_back(String::Unbox(IString::Query(object)));
|
||||
};
|
||||
Array::ForEach(array, func);
|
||||
EXPECT_EQ(valueStringArrayNew, valueStringArrayOrigin);
|
||||
length += substring.length() + 1;
|
||||
}
|
||||
}
|
||||
TestFloatArrayForParseUri(uri, keyFloatArray, length, valueFloatArrayOrigin);
|
||||
TestStringArrayForParseUri(uri, keyStringArray, length, valueStringArrayOrigin);
|
||||
|
||||
search = DistributedWantBaseTest::URI_STRING_END;
|
||||
result = uri.find(search);
|
||||
@ -1972,9 +2014,17 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1400, F
|
||||
delete want;
|
||||
want = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
uri = "#Intent;param;end";
|
||||
want = DistributedWant::ParseUri(uri);
|
||||
/**
|
||||
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_1401
|
||||
* @tc.name: ParseUri and ToUri
|
||||
* @tc.desc: Verify the function when no '=' or only has a '='.
|
||||
*/
|
||||
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1401, Function | MediumTest | Level3)
|
||||
{
|
||||
std::string uri = "#Intent;param;end"; // test string
|
||||
DistributedWant* want = DistributedWant::ParseUri(uri);
|
||||
EXPECT_EQ(want, nullptr);
|
||||
if (want != nullptr) {
|
||||
delete want;
|
||||
@ -1982,7 +2032,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1400, F
|
||||
}
|
||||
|
||||
uri = "#Intent;=;end";
|
||||
want = DistributedWant::ParseUri(uri);
|
||||
want = DistributedWant::ParseUri(uri);
|
||||
EXPECT_NE(want, nullptr);
|
||||
if (want != nullptr) {
|
||||
delete want;
|
||||
|
Loading…
Reference in New Issue
Block a user