!1070 Code rectification

Merge pull request !1070 from 师皓杰/master
This commit is contained in:
openharmony_ci 2024-09-13 03:45:21 +00:00 committed by Gitee
commit 33833c2fe7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 0 additions and 1266 deletions

View File

@ -174,33 +174,6 @@ public:
*/
OHOS::AppExecFwk::ElementName GetElement() const;
/**
* @description: Creates a DistributedWant with its corresponding attributes specified for
* starting the main ability of an application.
* @param ElementName Indicates the ElementName object defining the deviceId, bundleName,
* and abilityName sub-attributes of the operation attribute in a DistributedWant.
* @return Returns the DistributedWant object used to start the main ability of an application.
*/
static DistributedWant* MakeMainAbility(const OHOS::AppExecFwk::ElementName& elementName);
/**
* @description: Creates a DistributedWant instance by using a given Uniform Resource Identifier (URI).
* This method parses the input URI and saves it in a DistributedWant object.
* @param uri Indicates the URI to parse.
* @return Returns a DistributedWant object containing the URI.
*/
static DistributedWant* WantParseUri(const char* uri);
/**
* @description: Creates a DistributedWant instance by using a given Uniform Resource Identifier (URI).
* This method parses the input URI and saves it in a DistributedWant object.
* @param uri Indicates the URI to parse.
* @return Returns a DistributedWant object containing the URI.
*/
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.
@ -235,19 +208,6 @@ public:
*/
DistributedWant& SetUriAndType(const OHOS::Uri& uri, const std::string& type);
/**
* @description: Converts a DistributedWant into a URI string containing a representation of it.
* @param want Indicates the DistributedWant description.--DistributedWant.
* @return Returns an encoding URI string describing the DistributedWant object.
*/
std::string WantToUri(DistributedWant& want);
/**
* @description: Converts parameter information in a DistributedWant into a URI string.
* @return Returns the URI string.
*/
std::string ToUri() const;
/**
* @description: Formats a specified URI.
* This method uses the Uri.getLowerCaseScheme() method to format a URI and then saves
@ -347,35 +307,6 @@ public:
*/
DistributedWant& SetType(const std::string& type);
/**
* @description: Formats a specified MIME type. This method uses
* the formatMimeType(java.lang.String) method to format a MIME type
* and then saves the formatted type to this DistributedWant object.
* @param type Indicates the MIME type to format
* @return Returns this DistributedWant object that contains the formatted type attribute
*/
DistributedWant& FormatType(const std::string& type);
/**
* @description: Formats a specified URI and MIME type.
* This method works in the same way as formatUri(ohos.utils.net.URI)
* and formatType(java.lang.String).
* @param uri Indicates the URI to format.
* @param type Indicates the MIME type to format.
* @return Returns this DistributedWant object that contains the formatted URI and type attributes.
*/
DistributedWant& FormatUriAndType(const OHOS::Uri& uri, const std::string& type);
/**
* @description: This method formats data of a specified MIME type
* by removing spaces from the data and converting the data into
* lowercase letters. You can use this method to normalize
* the external data used to create DistributedWant information.
* @param type Indicates the MIME type to format
* @return Returns this DistributedWant object that contains the formatted type attribute
*/
static std::string FormatMimeType(const std::string& mimeType);
/**
* @description: clear the specific DistributedWant object.
* @param want Indicates the DistributedWant to clear
@ -420,15 +351,6 @@ public:
*/
DistributedWant& SetParam(const std::string& key, const sptr<IRemoteObject>& remoteObject);
/**
* @description: Obtains a IRemoteObject-type value matching the given key.
* @param key Indicates the key of WantParams.
* @param defaultValue Indicates the default IRemoteObject-type value.
* @return Returns the IRemoteObject-type value of the parameter matching the given key;
* returns the nullptr if the key does not exist.
*/
sptr<IRemoteObject> GetRemoteObject(const std::string& key) const;
/**
* @description: Sets a parameter value of the boolean type.
* @param key Indicates the key matching the parameter.
@ -755,13 +677,6 @@ public:
*/
bool OperationEquals(const DistributedWant& want);
/**
* @description: Creates a DistributedWant object that contains only
* the operation component of this DistributedWant.
* @return Returns the created DistributedWant object.
*/
DistributedWant* CloneOperation();
/**
* @description: Marshals a DistributedWant into a Parcel.
* Fields in the DistributedWant are marshalled separately. If any field fails to be marshalled, false is returned.
@ -829,20 +744,8 @@ private:
static constexpr int VALUE_OBJECT = 1;
private:
static bool ParseFlag(const std::string& content, DistributedWant& want);
static std::string Decode(const std::string& str);
static std::string Encode(const std::string& str);
static bool ParseContent(const std::string& content, std::string& prop, std::string& value);
static bool ParseUriInternal(
const std::string& content, OHOS::AppExecFwk::ElementName& element, DistributedWant& want);
bool ReadFromParcel(Parcel& parcel);
static bool CheckAndSetParameters(
DistributedWant& want, const std::string& key, std::string& prop, const std::string& value);
static bool CheckAndSetNumberParameters(
DistributedWant& want, const std::string& key, std::string& prop, const std::string& value);
OHOS::Uri GetLowerCaseScheme(const OHOS::Uri& uri);
void GenerateUriString(std::string& uriString) const;
void ToUriStringInner(std::string& uriString) const;
nlohmann::json ToJson() const;
bool ReadFromJson(nlohmann::json& wantJson);
bool CanReadFromJson(nlohmann::json& wantJson);

View File

@ -47,9 +47,7 @@ namespace DistributedSchedule {
namespace {
const std::regex NUMBER_REGEX("^[-+]?([0-9]+)([.]([0-9]+))?$");
const std::string TAG = "DistributedWant";
const char* REMOTE_OBJECT = "RemoteObject";
const char* TYPE_PROPERTY = "type";
const char* VALUE_PROPERTY = "value";
}; // namespace
const std::string DistributedWant::ACTION_PLAY("action.system.play");
const std::string DistributedWant::ACTION_HOME("action.system.home");
@ -251,13 +249,6 @@ DistributedWant& DistributedWant::SetType(const std::string& type)
return *this;
}
DistributedWant& DistributedWant::FormatType(const std::string& type)
{
std::string typetemp = FormatMimeType(type);
SetType(typetemp);
return *this;
}
Uri DistributedWant::GetLowerCaseScheme(const Uri& uri)
{
std::string dStrUri = const_cast<Uri&>(uri).ToString();
@ -283,28 +274,6 @@ Uri DistributedWant::GetLowerCaseScheme(const Uri& uri)
return Uri(dStrUri);
}
DistributedWant& DistributedWant::FormatUriAndType(const Uri& uri, const std::string& type)
{
return SetUriAndType(GetLowerCaseScheme(uri), FormatMimeType(type));
}
std::string DistributedWant::FormatMimeType(const std::string& mimeType)
{
std::string dStrMimeType = mimeType;
dStrMimeType.erase(std::remove(dStrMimeType.begin(), dStrMimeType.end(), ' '), dStrMimeType.end());
std::transform(dStrMimeType.begin(), dStrMimeType.end(), dStrMimeType.begin(), [](unsigned char c) {
return std::tolower(c);
});
std::size_t pos = 0;
std::size_t begin = 0;
pos = dStrMimeType.find_first_of(";", begin);
if (pos != std::string::npos) {
dStrMimeType = dStrMimeType.substr(begin, pos - begin);
}
return dStrMimeType;
}
std::string DistributedWant::GetAction() const
{
return operation_.GetAction();
@ -321,19 +290,6 @@ const std::string DistributedWant::GetScheme() const
return operation_.GetUri().GetScheme();
}
DistributedWant* DistributedWant::MakeMainAbility(const OHOS::AppExecFwk::ElementName& elementName)
{
DistributedWant* want = new (std::nothrow) DistributedWant();
if (want != nullptr) {
want->SetAction(ACTION_HOME);
want->AddEntity(ENTITY_HOME);
want->SetElement(elementName);
} else {
return nullptr;
}
return want;
}
const DistributedWantParams& DistributedWant::GetParams() const
{
return parameters_;
@ -383,32 +339,6 @@ DistributedWant& DistributedWant::SetParam(const std::string& key, const sptr<IR
return *this;
}
sptr<IRemoteObject> DistributedWant::GetRemoteObject(const std::string& key) const
{
auto value = parameters_.GetParam(key);
IDistributedWantParams* iwp = IDistributedWantParams::Query(value);
if (iwp == nullptr) {
return nullptr;
}
auto wp = DistributedWantParamWrapper::Unbox(iwp);
auto type = wp.GetParam(TYPE_PROPERTY);
AAFwk::IString* iString = AAFwk::IString::Query(type);
if (iString == nullptr) {
return nullptr;
}
if (REMOTE_OBJECT != AAFwk::String::Unbox(iString)) {
return nullptr;
}
auto remoteObjVal = wp.GetParam(VALUE_PROPERTY);
AAFwk::IRemoteObjectWrap* iRemoteObj = AAFwk::IRemoteObjectWrap::Query(remoteObjVal);
if (iRemoteObj == nullptr) {
return nullptr;
}
return AAFwk::RemoteObjectWrap::UnBox(iRemoteObj);
}
DistributedWant& DistributedWant::SetParam(const std::string& key, bool value)
{
parameters_.SetParam(key, AAFwk::Boolean::Box(value));
@ -867,89 +797,6 @@ bool DistributedWant::OperationEquals(const DistributedWant& want)
return (operation_ == want.operation_);
}
DistributedWant* DistributedWant::CloneOperation()
{
DistributedWant* want = new (std::nothrow) DistributedWant();
if (want == nullptr) {
return nullptr;
}
want->SetOperation(operation_);
return want;
}
bool DistributedWant::CheckParams(const std::string& uri)
{
if (uri.length() <= 0) {
return false;
}
std::string end = ";end";
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;
}
DistributedWant* baseWant = new (std::nothrow) DistributedWant();
if (baseWant == nullptr) {
return nullptr;
}
DistributedWant* pickWant = new (std::nothrow) DistributedWant();
if (pickWant == nullptr) {
delete baseWant;
return nullptr;
}
bool inPicker = false;
bool ret = true;
ElementName element;
std::size_t begin = WANT_HEADER.length();
std::size_t pos = uri.find_first_of(";", begin);
for (; pos != std::string::npos; pos = uri.find(";", begin)) {
std::string content = uri.substr(begin, pos - begin);
if (content.compare("PICK") == 0) {
inPicker = true;
begin = pos + 1;
continue;
}
ret = inPicker ? ParseUriInternal(content, element, *pickWant) : ParseUriInternal(content, element, *baseWant);
if (!ret) {
HILOGE("Parse uri internal fail, pos %{public}zu, inPicker %{public}d.", pos, inPicker);
break;
}
begin = pos + 1;
};
if (!ret) {
delete pickWant;
delete baseWant;
return nullptr;
}
DistributedWant* retWant = inPicker ? pickWant : baseWant;
DistributedWant* delWant = inPicker ? baseWant : pickWant;
delete delWant;
retWant->SetElement(element);
return retWant;
}
DistributedWant* DistributedWant::WantParseUri(const char* uri)
{
if (uri == nullptr) {
return nullptr;
}
std::string strUri(uri);
return ParseUri(strUri);
}
std::string DistributedWant::GetUriString() const
{
return operation_.GetUri().ToString();
@ -978,91 +825,6 @@ DistributedWant& DistributedWant::SetUriAndType(const OHOS::Uri& uri, const std:
return SetType(type);
}
std::string DistributedWant::WantToUri(DistributedWant& want)
{
return want.ToUri();
}
std::string DistributedWant::ToUri() const
{
std::string uriString = WANT_HEADER;
ToUriStringInner(uriString);
uriString += "end";
return uriString;
}
void DistributedWant::GenerateUriString(std::string& uriString) const
{
if (operation_.GetAction().length() > 0) {
uriString += "action=" + Encode(operation_.GetAction()) + ";";
}
if (GetUriString().length() > 0) {
uriString += "uri=" + Encode(GetUriString()) + ";";
}
for (auto dEntity : operation_.GetEntities()) {
if (dEntity.length() > 0) {
uriString += "entity=" + Encode(dEntity) + ";";
}
}
if (operation_.GetDeviceId().length() > 0) {
uriString += "device=" + Encode(operation_.GetDeviceId()) + ";";
}
if (operation_.GetBundleName().length() > 0) {
uriString += "bundle=" + Encode(operation_.GetBundleName()) + ";";
}
if (operation_.GetAbilityName().length() > 0) {
uriString += "ability=" + Encode(operation_.GetAbilityName()) + ";";
}
if (operation_.GetFlags() != 0) {
uriString += "flag=";
char buf[HEX_STRING_BUF_LEN] {0};
int lenth = snprintf_s(buf, HEX_STRING_BUF_LEN, HEX_STRING_BUF_LEN - 1, "0x%08x", operation_.GetFlags());
if (lenth == HEX_STRING_LEN) {
std::string flag = buf;
uriString += Encode(flag);
uriString += ";";
}
}
if (!operation_.GetBundleName().empty()) {
uriString.append("package=");
uriString.append(Encode(operation_.GetBundleName()));
uriString.append(";");
}
}
void DistributedWant::ToUriStringInner(std::string& uriString) const
{
GenerateUriString(uriString);
auto params = parameters_.GetParams();
auto iter = params.cbegin();
while (iter != params.cend()) {
sptr<AAFwk::IInterface> o = iter->second;
if (AAFwk::IString::Query(o) != nullptr) {
uriString += AAFwk::String::SIGNATURE;
} else if (AAFwk::IBoolean::Query(o) != nullptr) {
uriString += AAFwk::Boolean::SIGNATURE;
} else if (AAFwk::IChar::Query(o) != nullptr) {
uriString += AAFwk::Char::SIGNATURE;
} else if (AAFwk::IByte::Query(o) != nullptr) {
uriString += AAFwk::Byte::SIGNATURE;
} else if (AAFwk::IShort::Query(o) != nullptr) {
uriString += AAFwk::Short::SIGNATURE;
} else if (AAFwk::IInteger::Query(o) != nullptr) {
uriString += AAFwk::Integer::SIGNATURE;
} else if (AAFwk::ILong::Query(o) != nullptr) {
uriString += AAFwk::Long::SIGNATURE;
} else if (AAFwk::IFloat::Query(o) != nullptr) {
uriString += AAFwk::Float::SIGNATURE;
} else if (AAFwk::IDouble::Query(o) != nullptr) {
uriString += AAFwk::Double::SIGNATURE;
} else if (AAFwk::IArray::Query(o) != nullptr) {
uriString += AAFwk::Array::SIGNATURE;
}
uriString += "." + Encode(iter->first) + "=" + Encode(AAFwk::Object::ToString(*(o.GetRefPtr()))) + ";";
iter++;
}
}
DistributedWant& DistributedWant::FormatUri(const std::string& uri)
{
return FormatUri(OHOS::Uri(uri));
@ -1335,215 +1097,6 @@ bool DistributedWant::ReadFromParcel(Parcel& parcel)
return true;
}
bool DistributedWant::ParseUriInternal(const std::string& content, ElementName& element, DistributedWant& want)
{
static constexpr int TYPE_TAG_SIZE = 2;
std::string dProp;
std::string value;
if (content.empty() || content[0] == '=') {
return true;
}
if (!ParseContent(content, dProp, value)) {
return false;
}
if (value.empty()) {
return true;
}
if (dProp == "action") {
want.SetAction(value);
} else if (dProp == "entity") {
want.AddEntity(value);
} else if (dProp == "flag") {
if (!ParseFlag(value, want)) {
return false;
}
} else if (dProp == "device") {
element.SetDeviceID(value);
} else if (dProp == "bundle") {
element.SetBundleName(value);
} else if (dProp == "ability") {
element.SetAbilityName(value);
} else if (dProp == "package") {
want.SetBundle(Decode(value));
} else if (dProp.length() > TYPE_TAG_SIZE) {
std::string key = dProp.substr(TYPE_TAG_SIZE);
if (!DistributedWant::CheckAndSetParameters(want, key, dProp, value)) {
return false;
}
}
return true;
}
bool DistributedWant::ParseContent(const std::string& content, std::string& prop, std::string& value)
{
std::size_t dPos = content.find("=");
if (dPos != std::string::npos) {
std::string subString = content.substr(0, dPos);
prop = Decode(subString);
std::size_t length = content.length();
if (length < dPos + 1) {
return false;
}
length = length - dPos - 1;
subString = content.substr(dPos + 1, length);
value = Decode(subString);
return true;
}
return false;
}
bool DistributedWant::ParseFlag(const std::string& content, DistributedWant& want)
{
std::string dContentLower = LowerStr(content);
std::string prefix = "0x";
if (!dContentLower.empty()) {
if (dContentLower.find(prefix) != 0) {
return false;
}
for (std::size_t i = prefix.length(); i < dContentLower.length(); i++) {
if (!isxdigit(dContentLower[i])) {
return false;
}
}
int base = 16; // hex string
unsigned int flag = std::stoul(dContentLower, nullptr, base);
want.SetFlags(flag);
}
return true;
}
std::string DistributedWant::Decode(const std::string& str)
{
std::string dDecode;
for (std::size_t i = 0; i < str.length();) {
if (str[i] == '\\') {
if (++i >= str.length()) {
dDecode += "\\";
break;
}
if (str[i] == '\\') {
dDecode += "\\";
i++;
continue;
}
if (str[i] != '0') {
dDecode += "\\" + str.substr(i, 1);
i++;
continue;
}
if (str.compare(i, OCT_EQUALSTO.length(), OCT_EQUALSTO) == 0) {
dDecode += "=";
i += OCT_EQUALSTO.length();
} else if (str.compare(i, OCT_SEMICOLON.length(), OCT_SEMICOLON) == 0) {
dDecode += ";";
i += OCT_SEMICOLON.length();
} else {
dDecode += "\\" + str.substr(i, 1);
i++;
}
} else {
dDecode += str[i];
i++;
}
}
return dDecode;
}
std::string DistributedWant::Encode(const std::string& str)
{
std::string dEncode;
for (std::size_t i = 0; i < str.length(); i++) {
if (str[i] == '\\') {
dEncode += "\\\\";
} else if (str[i] == '=') {
dEncode += "\\" + OCT_EQUALSTO;
} else if (str[i] == ';') {
dEncode += "\\" + OCT_SEMICOLON;
} else {
dEncode += str[i];
}
}
return dEncode;
}
bool DistributedWant::CheckAndSetParameters(DistributedWant& want, const std::string& key,
std::string& prop, const std::string& value)
{
if (prop[0] == AAFwk::String::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IString> valueObj = AAFwk::String::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Boolean::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IBoolean> valueObj = AAFwk::Boolean::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Char::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IChar> valueObj = AAFwk::Char::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Byte::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IByte> valueObj = AAFwk::Byte::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Array::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IArray> valueObj = AAFwk::Array::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (!CheckAndSetNumberParameters(want, key, prop, value)) {
return false;
}
return true;
}
bool DistributedWant::CheckAndSetNumberParameters(DistributedWant& want, const std::string& key,
std::string& prop, const std::string& value)
{
if (prop[0] == AAFwk::Short::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IShort> valueObj = AAFwk::Short::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Integer::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IInteger> valueObj = AAFwk::Integer::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Long::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::ILong> valueObj = AAFwk::Long::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Float::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IFloat> valueObj = AAFwk::Float::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
} else if (prop[0] == AAFwk::Double::SIGNATURE && prop[1] == '.') {
sptr<AAFwk::IDouble> valueObj = AAFwk::Double::Parse(value);
if (valueObj == nullptr) {
return false;
}
want.parameters_.SetParam(key, valueObj);
}
return true;
}
nlohmann::json DistributedWant::ToJson() const
{
DistributedWantParamWrapper wrapper(parameters_);

View File

@ -1429,637 +1429,6 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0800, Funct
}
}
/**
* @tc.number: DistributedScheduleWant_FormatMimeType_0100
* @tc.name: formatMimeType
* @tc.desc: formats data of a specified MIME type.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_FormatMimeType_0100, Function | MediumTest | Level3)
{
std::string mimeType = "Application/Envoy";
std::string mimeTypeResult = "application/envoy";
EXPECT_EQ(mimeTypeResult, DistributedWant::FormatMimeType(mimeType));
}
/**
* @tc.number: DistributedScheduleWant_FormatMimeType_0200
* @tc.name: formatMimeType
* @tc.desc: formats data of a specified MIME type.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_FormatMimeType_0200, Function | MediumTest | Level3)
{
std::string mimeType = "APPLICATION/ENVOY";
std::string mimeTypeResult = "application/envoy";
EXPECT_EQ(mimeTypeResult, DistributedWant::FormatMimeType(mimeType));
}
/**
* @tc.number: DistributedScheduleWant_FormatMimeType_0300
* @tc.name: formatMimeType
* @tc.desc: formats data of a specified MIME type.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_FormatMimeType_0300, Function | MediumTest | Level3)
{
std::string mimeType = " Appl icati on/ Envoy ";
std::string mimeTypeResult = "application/envoy";
EXPECT_EQ(mimeTypeResult, DistributedWant::FormatMimeType(mimeType));
}
/**
* @tc.number: DistributedScheduleWant_FormatMimeType_0400
* @tc.name: formatMimeType
* @tc.desc: formats data of a specified MIME type.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_FormatMimeType_0400, Function | MediumTest | Level3)
{
std::string mimeType = " Appl icati on/ Envoy ; yovnE ;no itaci lppA ";
std::string mimeTypeResult = "application/envoy";
EXPECT_EQ(mimeTypeResult, DistributedWant::FormatMimeType(mimeType));
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0100
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when Want is empty.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0100, Function | MediumTest | Level3)
{
std::size_t pos = 0;
std::size_t content = 0;
std::size_t head = 0;
DistributedWant wantOrigin;
std::string uri = wantOrigin.ToUri();
head = uri.find(DistributedWantBaseTest::URI_STRING_HEAD, pos);
EXPECT_EQ(head, pos);
if (head != std::string::npos) {
pos += head + DistributedWantBaseTest::URI_STRING_HEAD.length() - 1;
}
content = uri.find(DistributedWantBaseTest::URI_STRING_END, pos);
EXPECT_EQ(content, pos);
if (content != std::string::npos) {
pos += DistributedWantBaseTest::URI_STRING_END.length();
}
EXPECT_EQ(uri.length(), pos);
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
EXPECT_EQ(wantNew->GetAction(), std::string(""));
for (auto entity : wantNew->GetEntities()) {
EXPECT_EQ(entity, std::string(""));
}
OHOS::AppExecFwk::ElementName element;
EXPECT_EQ(wantNew->GetElement(), element);
EXPECT_EQ(static_cast<int>(wantNew->GetFlags()), 0);
delete wantNew;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0200
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when Want only has action/entity/flag/element.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0200, Function | MediumTest | Level3)
{
std::string search;
std::string action = DistributedWant::ACTION_PLAY;
std::string entity = DistributedWant::ENTITY_VIDEO;
unsigned int flag = 0x0f0f0f0f;
std::string flagStr = "0x0f0f0f0f";
std::string device = "device1";
std::string bundle = "bundle1";
std::string ability = "ability1";
OHOS::AppExecFwk::ElementName element(device, bundle, ability);
DistributedWant wantOrigin;
wantOrigin.SetAction(action);
wantOrigin.AddEntity(entity);
wantOrigin.AddFlags(flag);
wantOrigin.SetElement(element);
std::string uri = wantOrigin.ToUri();
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
EXPECT_EQ(wantNew->GetAction(), action);
for (auto entityItem : wantNew->GetEntities()) {
EXPECT_EQ(entityItem, entity);
}
EXPECT_EQ(wantNew->GetElement().GetDeviceID(), device);
EXPECT_EQ(wantNew->GetElement().GetBundleName(), bundle);
EXPECT_EQ(wantNew->GetElement().GetAbilityName(), ability);
EXPECT_EQ(wantNew->GetFlags(), flag);
delete wantNew;
wantNew = nullptr;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0300
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when Want only has parameter and the parameter
* has only 1 float type element.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0300, Function | MediumTest | Level3)
{
std::size_t pos = 0;
std::size_t length = 0;
std::size_t head = 0;
Want wantOrigin;
std::string keyFloat = "keyFloat";
float valueFloatOrigin = 123.4;
wantOrigin.SetParam(keyFloat, valueFloatOrigin);
std::string uri = wantOrigin.ToUri();
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;
TestFloatForParseUri(uri, keyFloat, length, valueFloatOrigin);
search = DistributedWantBaseTest::URI_STRING_END;
result = uri.find(search);
EXPECT_NE(result, std::string::npos);
EXPECT_GE(result, head);
if (result != std::string::npos) {
length += search.length() - 1;
}
EXPECT_EQ(uri.length(), length);
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
float floatNew = wantNew->GetFloatParam(keyFloat, 0.1);
float floatOld = wantOrigin.GetFloatParam(keyFloat, 1.1);
EXPECT_EQ(floatNew, floatOld);
delete wantNew;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0400
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when Want only has parameter and the parameter
* has only one float and one string type element.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0400, Function | MediumTest | Level3)
{
std::size_t pos = 0;
std::size_t length = 0;
std::size_t head = 0;
DistributedWant wantOrigin;
std::string keyFloat = "keyFloat";
std::string keyString = "keyString";
float valueFloatOrigin = 123.4;
std::string valueStringOrigin = "abcd";
wantOrigin.SetParam(keyFloat, valueFloatOrigin);
wantOrigin.SetParam(keyString, valueStringOrigin);
std::string uri = wantOrigin.ToUri();
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;
TestFloatForParseUri(uri, keyFloat, length, valueFloatOrigin);
TestStringForParseUri(uri, keyString, length, valueStringOrigin);
search = DistributedWantBaseTest::URI_STRING_END;
result = uri.find(search);
EXPECT_NE(result, std::string::npos);
EXPECT_GE(result, head);
if (result != std::string::npos) {
length += search.length() - 1;
}
EXPECT_EQ(uri.length(), length);
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
float floatNew = wantNew->GetFloatParam(keyFloat, 0);
float floatOld = wantOrigin.GetFloatParam(keyFloat, 1);
EXPECT_EQ(floatNew, floatOld);
std::string stringNew = wantNew->GetStringParam(keyString);
std::string stringOld = wantOrigin.GetStringParam(keyString);
EXPECT_EQ(stringNew, stringOld);
delete wantNew;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0500
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when Want only has parameter and the parameter
* has only one float array type element.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0500, 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";
std::vector<float> valueFloatArrayOrigin = {1.1, 2.1, 3.1};
wantOrigin.SetParam(keyFloatArray, valueFloatArrayOrigin);
std::string uri = wantOrigin.ToUri();
search = DistributedWantBaseTest::URI_STRING_HEAD;
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;
TestFloatArrayForParseUri(uri, keyFloatArray, length, valueFloatArrayOrigin);
search = DistributedWantBaseTest::URI_STRING_END;
result = uri.find(search);
EXPECT_NE(result, std::string::npos);
EXPECT_GE(result, head);
if (result != std::string::npos) {
length += search.length() - 1;
}
EXPECT_EQ(uri.length(), length);
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
std::vector<float> arrayNew = wantNew->GetFloatArrayParam(keyFloatArray);
std::vector<float> arrayOld = wantOrigin.GetFloatArrayParam(keyFloatArray);
EXPECT_EQ(arrayNew, arrayOld);
delete wantNew;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0600
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when Want only has parameter and the parameter
* has only one int array and one string array type element
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0600, Function | MediumTest | Level3)
{
std::size_t pos = 0;
std::size_t length = 0;
std::size_t head = 0;
DistributedWant wantOrigin;
std::string keyFloatArray = "keyFloatArray";
std::string keyStringArray = "keyStringArray";
std::vector<float> valueFloatArrayOrigin = {1.1, 2.1, 3.1};
std::vector<std::string> valueStringArrayOrigin = {"aa", "bb", "cc"};
wantOrigin.SetParam(keyFloatArray, valueFloatArrayOrigin);
wantOrigin.SetParam(keyStringArray, valueStringArrayOrigin);
std::string uri = wantOrigin.ToUri();
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;
TestFloatArrayForParseUri(uri, keyFloatArray, length, valueFloatArrayOrigin);
TestStringArrayForParseUri(uri, keyStringArray, length, valueStringArrayOrigin);
search = DistributedWantBaseTest::URI_STRING_END;
result = uri.find(search);
EXPECT_NE(result, std::string::npos);
EXPECT_GE(result, head);
if (result != std::string::npos) {
length += search.length() - 1;
}
EXPECT_EQ(uri.length(), length);
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
std::vector<float> arrayFloatNew = wantNew->GetFloatArrayParam(keyFloatArray);
std::vector<float> arrayFloatOld = wantOrigin.GetFloatArrayParam(keyFloatArray);
EXPECT_EQ(arrayFloatNew, arrayFloatOld);
std::vector<std::string> arrayStringNew = wantNew->GetStringArrayParam(keyStringArray);
std::vector<std::string> arrayStringOld = wantOrigin.GetStringArrayParam(keyStringArray);
EXPECT_EQ(arrayStringNew, arrayStringOld);
delete wantNew;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0700
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when the length of input string is 0.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0700, Function | MediumTest | Level3)
{
std::string uri;
EXPECT_EQ(static_cast<int>(uri.length()), 0);
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0800
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when the action etc. are empty.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0800, Function | MediumTest | Level3)
{
std::string empty;
std::string uri = "#Intent;action=;entity=;device=;bundle=;ability=;flag=;end";
EXPECT_NE(static_cast<int>(uri.length()), 0);
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
EXPECT_EQ(want->GetAction(), empty);
for (auto entityItem : want->GetEntities()) {
EXPECT_EQ(entityItem, empty);
}
EXPECT_EQ(want->GetFlags(), (unsigned int)0);
OHOS::AppExecFwk::ElementName element;
EXPECT_EQ(want->GetElement(), element);
EXPECT_EQ(want->HasParameter(empty), false);
delete want;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_0900
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when flag is not number.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_0900, Function | MediumTest | Level3)
{
std::string empty;
std::string uri = "#Intent;action=want.action.VIEW;flag=\"123\";end";
EXPECT_NE(static_cast<int>(uri.length()), 0);
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_1000
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when head is not "#Intent".
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1000, Function | MediumTest | Level3)
{
std::string empty;
std::string uri = "action=want.action.VIEW;end";
EXPECT_NE(static_cast<int>(uri.length()), 0);
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_1100
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when flag is empty.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1100, Function | MediumTest | Level3)
{
std::string empty;
std::string uri = "#Intent;flag=;end";
EXPECT_NE(static_cast<int>(uri.length()), 0);
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
EXPECT_EQ(want->GetFlags(), static_cast<unsigned int>(0));
delete want;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_1200
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when x is capital.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1200, Function | MediumTest | Level3)
{
std::string empty;
unsigned int flag = 0X12345678;
std::string uri = "#Intent;flag=0X12345678;end";
EXPECT_NE(static_cast<int>(uri.length()), 0);
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
EXPECT_EQ(want->GetFlags(), flag);
delete want;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_1300
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when special character.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1300, Function | MediumTest | Level3)
{
std::string action = "\\";
std::string entity = "../../../jj/j=075/./.;;/07507399/\\\\;;--==.com.\a\b\tfoobar.vide\073\\075";
unsigned int flag = 0x0f0f0f0f;
std::string flagStr = "0x0f0f0f0f";
std::string key = "\\kkk=.=;";
std::string value = "==\\\\\\.;\\;\\;\\=\\\073075\\\\075073";
DistributedWant wantOrigin;
wantOrigin.SetAction(action);
wantOrigin.AddEntity(entity);
wantOrigin.AddFlags(flag);
wantOrigin.SetParam(key, value);
std::string uri = wantOrigin.ToUri();
DistributedWant* wantNew = DistributedWant::ParseUri(uri);
EXPECT_NE(wantNew, nullptr);
if (wantNew != nullptr) {
EXPECT_STREQ(wantNew->GetAction().c_str(), action.c_str());
for (auto entityItem : wantNew->GetEntities()) {
EXPECT_EQ(entityItem, entity);
}
EXPECT_EQ(wantNew->GetFlags(), flag);
EXPECT_EQ(wantNew->GetStringParam(key), value);
delete wantNew;
wantNew = nullptr;
}
}
/**
* @tc.number: DistributedScheduleWant_ParseUri_ToUri_1400
* @tc.name: ParseUri and ToUri
* @tc.desc: Verify the function when no '=' or only has a '='.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ParseUri_ToUri_1400, Function | MediumTest | Level3)
{
std::string uri = "#Intent;action;end";
DistributedWant* want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;entity;end";
want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;device;end";
want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;bundle;end";
want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;ability;end";
want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;flag;end";
want = DistributedWant::ParseUri(uri);
EXPECT_EQ(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
}
/**
* @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;
want = nullptr;
}
uri = "#Intent;=;end";
want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;abc=;end";
want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;=abc;end";
want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;xxxx=yyy;end";
want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
uri = "#Intent;;;;;;end";
want = DistributedWant::ParseUri(uri);
EXPECT_NE(want, nullptr);
if (want != nullptr) {
delete want;
want = nullptr;
}
}
/**
* @tc.number: DistributedScheduleWant_Flags_0100
* @tc.name: SetFlags/AddFlags/GetFlags/RemoveFlags
@ -2082,35 +1451,6 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Flags_0100, Function |
EXPECT_EQ(description, returnsflags);
}
/**
* @tc.number: DistributedScheduleWant_MakeMainAbility_0100
* @tc.name: MakeMainAbility
* @tc.desc: Verify MakeMainAbility.
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_MakeMainAbility_0100, Function | MediumTest | Level3)
{
ASSERT_NE(want_, nullptr);
ElementName elementName;
std::string action("action.system.home");
std::string entity("entity.system.home");
DistributedWant* wantNew = want_->MakeMainAbility(elementName);
if (wantNew != nullptr) {
std::vector<std::string> entities = wantNew->GetEntities();
EXPECT_EQ((size_t)1, entities.size());
if (entities.size() > 0) {
EXPECT_EQ(entity, entities.at(0));
}
EXPECT_EQ(action, wantNew->GetAction());
EXPECT_EQ(elementName, wantNew->GetElement());
delete wantNew;
wantNew = nullptr;
}
}
/**
* @tc.number: DistributedScheduleWant_ClearWant_0100
* @tc.name: ClearWant
@ -4177,24 +3517,6 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_HasParameter_0100, Fun
want_->SetParam(key2, vector);
EXPECT_EQ(true, want_->HasParameter(key2));
}
/**
* @tc.number: DistributedScheduleWant_HasParameter_0200
* @tc.name: SetParam and HasParameter
* @tc.desc: Verify HasParameter()
*/
HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_HasParameter_0200, Function | MediumTest | Level3)
{
std::string key = std::to_string(Array::SIGNATURE) + ".#Intent;key=3{\"\\b\\\";end";
std::vector<zchar> arrayValue = {'.', '=', ';'};
std::shared_ptr<DistributedWant> p1 = std::make_shared<DistributedWant>();
ASSERT_NE(nullptr, p1);
p1->SetParam(key, arrayValue);
DistributedWant* newWant = nullptr;
newWant = DistributedWant::ParseUri(p1->ToUri());
ASSERT_NE(nullptr, newWant);
std::shared_ptr<DistributedWant> p2(newWant);
CompareWant(p1, p2);
}
/**
* @tc.number: DistributedScheduleWant_ToString_0100
* @tc.name: ToString and FromString
@ -4436,19 +3758,5 @@ HWTEST_F(DistributedWantBaseTest, GetLowerCaseScheme_test_003, TestSize.Level3)
EXPECT_FALSE(strUri.empty());
GTEST_LOG_(INFO) << "GetLowerCaseScheme_test_003 end";
}
/**
* @tc.number: WantParseUri_test_001
* @tc.name: WantParseUri
* @tc.desc: Test WantParseUri.
* @tc.require: I77HFZ
*/
HWTEST_F(DistributedWantBaseTest, WantParseUri_test_001, TestSize.Level3)
{
GTEST_LOG_(INFO) << "WantParseUri_test_001 start";
char* uri = nullptr;
EXPECT_EQ(DistributedWant::WantParseUri(uri), nullptr);
GTEST_LOG_(INFO) << "WantParseUri_test_001 end";
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -69,26 +69,12 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_002(const char* data, size_
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
std::string type(data, size);
want->SetType(type);
want->FormatType(type);
Uri uri(type);
want->SetUri(uri);
want->SetUriAndType(uri, type);
want->FormatUri(uri);
want->FormatUri(type);
char* charUri;
want->WantParseUri(charUri);
want->GetLowerCaseScheme(uri);
want->FormatUriAndType(uri, type);
want->FormatMimeType(type);
std::string str(data, size);
want->CheckParams(str);
want->ParseUri(str);
DistributedWant wantNew;
want->WantToUri(wantNew);
want->ToUri();
want->GenerateUriString(str);
want->ToUriStringInner(str);
return true;
}
@ -96,30 +82,15 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_003(const char* data, size_
{
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
want->CountEntities();
DistributedWant *wantptr = nullptr;
want->GetScheme();
AppExecFwk::ElementName elementName;
wantptr = want->MakeMainAbility(elementName);
if (wantptr) {
delete wantptr;
wantptr = nullptr;
}
DistributedOperation operation;
want->SetOperation(operation);
wantptr = want->CloneOperation();
if (wantptr) {
delete wantptr;
wantptr = nullptr;
}
std::string key(data, size);
want->HasParameter(key);
std::string content(data, size);
std::string prop(data, size);
std::string value(data, size);
want->ParseContent(content, prop, value);
std::string str(data, size);
want->Decode(str);
want->Encode(str);
nlohmann::json wantJson;
want->ReadFromJson(wantJson);
return true;
@ -131,7 +102,6 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_004(const char* data, size_
std::string key(data, size);
sptr<IRemoteObject> remoteObject;
want->SetParam(key, remoteObject);
want->GetRemoteObject(key);
std::vector<bool> boolValue;
want->SetParam(key, boolValue);
want->GetBoolArrayParam(key);