Merge remote-tracking branch 'upstream/master'

This commit is contained in:
MisterE 2024-09-14 17:19:27 +08:00
commit 2d7c6dd9cc
12 changed files with 374 additions and 1630 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

@ -541,5 +541,110 @@ HWTEST_F(BundleManagerInternalTest, GetBundleNameId_002, TestSize.Level3)
EXPECT_EQ(ret, CAN_NOT_FOUND_ABILITY_ERR);
DTEST_LOG << "BundleManagerInternalTest GetBundleNameId_002 end "<< std::endl;
}
/**
* @tc.name: IsSameDeveloperId_001
* @tc.desc: IsSameDeveloperId
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, IsSameDeveloperId_001, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest IsSameDeveloperId_001 begin" << std::endl;
std::string bundleNameInCurrentSide;
std::string developerId4OtherSide;
bool ret = BundleManagerInternal::IsSameDeveloperId(bundleNameInCurrentSide, developerId4OtherSide);
EXPECT_EQ(ret, false);
developerId4OtherSide = "developerId4OtherSide";
ret = BundleManagerInternal::IsSameDeveloperId(bundleNameInCurrentSide, developerId4OtherSide);
EXPECT_EQ(ret, false);
bundleNameInCurrentSide = "bundleNameInCurrentSide";
ret = BundleManagerInternal::IsSameDeveloperId(bundleNameInCurrentSide, developerId4OtherSide);
EXPECT_EQ(ret, false);
developerId4OtherSide.clear();
ret = BundleManagerInternal::IsSameDeveloperId(bundleNameInCurrentSide, developerId4OtherSide);
EXPECT_EQ(ret, false);
DTEST_LOG << "BundleManagerInternalTest IsSameDeveloperId_001 end "<< std::endl;
}
/**
* @tc.name: GetContinueBundle4Src_001
* @tc.desc: GetContinueBundle4Src
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetContinueBundle4Src_001, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetContinueBundle4Src_001 begin" << std::endl;
std::string srcBundleName;
std::vector<std::string> bundleNameList;
bool ret = BundleManagerInternal::GetContinueBundle4Src(srcBundleName, bundleNameList);
EXPECT_EQ(ret, false);
DTEST_LOG << "BundleManagerInternalTest GetContinueBundle4Src_001 end "<< std::endl;
}
/**
* @tc.name: GetAppProvisionInfo4CurrentUser_001
* @tc.desc: GetAppProvisionInfo4CurrentUser
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetAppProvisionInfo4CurrentUser_001, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetAppProvisionInfo4CurrentUser_001 begin" << std::endl;
std::string bundleName;
AppExecFwk::AppProvisionInfo appProvisionInfo;
bool ret = BundleManagerInternal::GetAppProvisionInfo4CurrentUser(bundleName, appProvisionInfo);
EXPECT_EQ(ret, false);
DTEST_LOG << "BundleManagerInternalTest GetAppProvisionInfo4CurrentUser_001 end "<< std::endl;
}
/**
* @tc.name: GetContinueType_001
* @tc.desc: GetContinueType
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetContinueType_001, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetContinueType_001 begin" << std::endl;
std::string networkId = "networkId";
std::string bundleName;
uint8_t continueTypeId = 0;
std::string str = BundleManagerInternal::GetContinueType(networkId, bundleName, continueTypeId);
EXPECT_EQ(str, "");
DTEST_LOG << "BundleManagerInternalTest GetContinueType_001 end "<< std::endl;
}
/**
* @tc.name: GetContinueTypeId_001
* @tc.desc: GetContinueTypeId
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetContinueTypeId_001, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetContinueTypeId_001 begin" << std::endl;
std::string networkId = "networkId";
std::string abilityName;
uint8_t continueTypeId = 0;
int32_t ret = BundleManagerInternal::GetContinueTypeId(networkId, abilityName, continueTypeId);
EXPECT_EQ(ret, CAN_NOT_FOUND_ABILITY_ERR);
DTEST_LOG << "BundleManagerInternalTest GetContinueTypeId_001 end "<< std::endl;
}
/**
* @tc.name: GetBundleNameById_001
* @tc.desc: GetBundleNameById
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetBundleNameById_001, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetBundleNameById_001 begin" << std::endl;
std::string networkId = "networkId";
std::string bundleName;
uint16_t bundleNameId = 0;
int32_t ret = BundleManagerInternal::GetBundleNameById(networkId, bundleNameId, bundleName);
EXPECT_EQ(ret, CAN_NOT_FOUND_ABILITY_ERR);
DTEST_LOG << "BundleManagerInternalTest GetBundleNameById_001 end "<< std::endl;
}
}
}
}

View File

@ -388,5 +388,64 @@ HWTEST_F(DSchedContinueManagerTest, HandleContinueEnd_001, TestSize.Level3)
EXPECT_EQ(DSchedContinueManager::GetInstance().cntSource_, 0);
DTEST_LOG << "DSchedContinueManagerTest HandleContinueEnd_001 end" << std::endl;
}
/**
* @tc.name: GetFirstBundleName_001
* @tc.desc: test GetFirstBundleName func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, GetFirstBundleName_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest GetFirstBundleName_001 begin" << std::endl;
DSchedContinueInfo info(LOCAL_DEVICEID, "sourceBundleName", REMOTE_DEVICEID, "sinkBundleName",
"continueType");
std::string firstBundleName;
std::string bundleName;
std::string deviceId;
int32_t direction = 1;
int32_t subType;
const sptr<IRemoteObject> callback = nullptr;
const OHOS::AAFwk::WantParams wantParams;
DSchedContinueManager::GetInstance().CompleteBundleName(info, direction, subType);
direction = 0;
DSchedContinueManager::GetInstance().CompleteBundleName(info, direction, subType);
DSchedContinueManager::GetInstance().HandleContinueMissionWithBundleName(info, callback, wantParams);
bool ret = DSchedContinueManager::GetInstance().GetFirstBundleName(info, firstBundleName, bundleName, deviceId);
EXPECT_EQ(ret, false);
DTEST_LOG << "DSchedContinueManagerTest GetFirstBundleName_001 end" << std::endl;
}
/**
* @tc.name: GetDSchedContinueByWant_001
* @tc.desc: test GetDSchedContinueByWant func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, GetDSchedContinueByWant_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest GetDSchedContinueByWant_001 begin" << std::endl;
OHOS::AAFwk::Want want;
int32_t missionId = 0;
DSchedContinueManager::GetInstance().continues_.clear();
auto ret = DSchedContinueManager::GetInstance().GetDSchedContinueByWant(want, missionId);
EXPECT_EQ(ret, nullptr);
DTEST_LOG << "DSchedContinueManagerTest GetDSchedContinueByWant_001 end" << std::endl;
}
/**
* @tc.name: NotifyTerminateContinuation_001
* @tc.desc: test NotifyTerminateContinuation func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, NotifyTerminateContinuation_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest NotifyTerminateContinuation_001 begin" << std::endl;
int32_t missionId = 0;
int32_t sessionId = 0;
DSchedContinueManager::GetInstance().continues_.clear();
DSchedContinueManager::GetInstance().HandleDataRecv(sessionId, nullptr);
DSchedContinueManager::GetInstance().NotifyTerminateContinuation(missionId);
EXPECT_EQ(DSchedContinueManager::GetInstance().continues_.empty(), true);
DTEST_LOG << "DSchedContinueManagerTest NotifyTerminateContinuation_001 end" << std::endl;
}
}
}
}

View File

@ -18,6 +18,7 @@
#include "distributed_sched_service.h"
#include "dsched_continue.h"
#include "dtbschedmgr_log.h"
#include "softbus_error_code.h"
#include "test_log.h"
using namespace testing;
@ -28,6 +29,7 @@ namespace DistributedSchedule {
namespace {
const std::string BASEDIR = "/data/service/el1/public/database/DistributedSchedule";
const std::string BUNDLEMAME_1 = "bundleName";
const int32_t WAITTIME = 2000;
const uint32_t DSCHED_BUFFER_SIZE = 1024;
}
@ -1050,5 +1052,64 @@ HWTEST_F(DSchedContinueTest, UpdateStateTest_033_1, TestSize.Level0)
EXPECT_NE(nullptr, conti->stateMachine_);
DTEST_LOG << "DSchedContinueTest UpdateStateTest_033_1 end" << std::endl;
}
/**
* @tc.name: CheckStartPermission_034_1
* @tc.desc: CheckStartPermission
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueTest, CheckStartPermission_034_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueTest CheckStartPermission_034_1 begin" << std::endl;
auto cmd = std::make_shared<DSchedContinueDataCmd>();
ASSERT_NE(nullptr, cmd);
cmd->srcBundleName_ = BUNDLEMAME_1;
cmd->dstBundleName_ = BUNDLEMAME_1;
std::string deviceId = "123";
std::string bundleName = "test";
int32_t subType = CONTINUE_PULL;
int32_t direction = CONTINUE_SINK;
sptr<IRemoteObject> callback = nullptr;
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
int32_t ret = conti->CheckStartPermission(cmd);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
cmd->srcBundleName_.clear();
ret = conti->CheckStartPermission(cmd);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest CheckStartPermission_034_1 end" << std::endl;
}
/**
* @tc.name: ConvertToDmsSdkErr_035_1
* @tc.desc: ConvertToDmsSdkErr
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueTest, ConvertToDmsSdkErr_035_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueTest ConvertToDmsSdkErr_035_1 begin" << std::endl;
auto cmd = std::make_shared<DSchedContinueDataCmd>();
ASSERT_NE(nullptr, cmd);
cmd->srcBundleName_ = BUNDLEMAME_1;
cmd->dstBundleName_ = BUNDLEMAME_1;
std::string deviceId = "123";
std::string bundleName = "test";
int32_t subType = CONTINUE_PULL;
int32_t direction = CONTINUE_SINK;
sptr<IRemoteObject> callback = nullptr;
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
int32_t ret = conti->ConvertToDmsSdkErr(0);
EXPECT_EQ(ret, ERR_OK);
ret = conti->ConvertToDmsSdkErr(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_STA_CHIP_CONFLICT);
EXPECT_EQ(ret, DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE);
ret = conti->ConvertToDmsSdkErr(-1);
EXPECT_EQ(ret, DmsInterfaceSdkErr::ERR_DMS_WORK_ABNORMALLY);
DTEST_LOG << "DSchedContinueTest ConvertToDmsSdkErr_035_1 end" << std::endl;
}
}
}

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

@ -1468,5 +1468,23 @@ HWTEST_F(DistributedSchedServiceSecondTest, StartAbility_001, TestSize.Level3)
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DistributedSchedServiceSecondTest StartAbility_001 end" << std::endl;
}
/**
* @tc.name: CheckTargetPermission4DiffBundle_001
* @tc.desc: CheckTargetPermission4DiffBundle
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedServiceSecondTest, CheckTargetPermission4DiffBundle_001, TestSize.Level3)
{
DTEST_LOG << "DistributedSchedServiceSecondTest CheckTargetPermission4DiffBundle_001 start" << std::endl;
OHOS::AAFwk::Want want;
CallerInfo callerInfo;
AccountInfo accountInfo;
int32_t flag = 0;
int32_t ret = DistributedSchedService::GetInstance().CheckTargetPermission4DiffBundle(want,
callerInfo, accountInfo, flag, true);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DistributedSchedServiceSecondTest CheckTargetPermission4DiffBundle_001 end" << std::endl;
}
}
}
}

View File

@ -564,5 +564,25 @@ HWTEST_F(DistributedBmStorageTest, DelDataOfLogoutDevTest_001, TestSize.Level1)
}
DTEST_LOG << "DistributedBmStorageTest DelDataOfLogoutDevTest_001 end" << std::endl;
}
/**
* @tc.name: GetDistributedBundleInfoTest_001
* @tc.desc: test GetDistributedBundleInfo
* @tc.type: FUNC
*/
HWTEST_F(DistributedBmStorageTest, GetDistributedBundleInfoTest_001, TestSize.Level1)
{
DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleInfoTest_001 start" << std::endl;
auto distributedDataStorage = GetDmsBmStorage();
EXPECT_NE(distributedDataStorage, nullptr);
if (distributedDataStorage != nullptr) {
std::string networkId;
uint16_t bundleNameId = 0;
DmsBundleInfo distributeBundleInfo;
bool ret = dmsBmStorage_->GetDistributedBundleInfo(networkId, bundleNameId, distributeBundleInfo);
EXPECT_EQ(ret, false);
}
DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleInfoTest_001 end" << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS
} // namespace OHOS

View File

@ -887,5 +887,38 @@ HWTEST_F(DMSContinueManagerTest, testUpdateContinueLaunchMission_001, TestSize.L
EXPECT_TRUE(DMSContinueSendMgr::GetInstance().UpdateContinueLaunchMission(info));
DTEST_LOG << "DMSContinueManagerTest testUpdateContinueLaunchMission_001 end" << std::endl;
}
/**
* @tc.name: testGetFinalBundleName_001
* @tc.desc: test GetFinalBundleName
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, testGetFinalBundleName_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testGetFinalBundleName_001 start" << std::endl;
DmsBundleInfo info;
std::string finalBundleName;
AppExecFwk::BundleInfo localBundleInfo;
std::string continueType;
bool ret = DMSContinueRecvMgr::GetInstance().GetFinalBundleName(info, finalBundleName,
localBundleInfo, continueType);
EXPECT_EQ(ret, false);
DTEST_LOG << "DMSContinueManagerTest testGetFinalBundleName_001 end" << std::endl;
}
/**
* @tc.name: testContinueTypeCheck_001
* @tc.desc: test ContinueTypeCheck
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, testContinueTypeCheck_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testContinueTypeCheck_001 start" << std::endl;
AppExecFwk::BundleInfo localBundleInfo;
std::string continueType;
bool ret = DMSContinueRecvMgr::GetInstance().ContinueTypeCheck(localBundleInfo, continueType);
EXPECT_EQ(ret, false);
DTEST_LOG << "DMSContinueManagerTest testContinueTypeCheck_001 end" << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS
} // namespace OHOS

View File

@ -409,23 +409,12 @@ HWTEST_F(DMSMissionManagerTest, testNeedSyncDevice002, TestSize.Level3)
HWTEST_F(DMSMissionManagerTest, testHasSyncListener001, TestSize.Level3)
{
DTEST_LOG << "testHasSyncListener001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().CleanMissionResources(DEVICE_ID);
bool ret = DistributedSchedMissionManager::GetInstance().HasSyncListener(DEVICE_ID);
EXPECT_FALSE(ret);
DTEST_LOG << "testHasSyncListener001 end" << std::endl;
}
/**
* @tc.name: testCleanMissionResources001
* @tc.desc: prepare and sync missions from remote
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testCleanMissionResources001, TestSize.Level3)
{
DTEST_LOG << "testCleanMissionResources001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().CleanMissionResources(DEVICE_ID);
DTEST_LOG << "testCleanMissionResources001 end" << std::endl;
}
/**
* @tc.name: testStopSyncRemoteMissions001
* @tc.desc: stop sync missions from remote with fake deviceId
@ -1149,35 +1138,12 @@ HWTEST_F(DMSMissionManagerTest, testDeviceOnlineNotify003, TestSize.Level3)
{
DTEST_LOG << "testDeviceOnlineNotify003 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify("");
DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify(DEVICE_ID);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionHandler_, nullptr);
DTEST_LOG << "testDeviceOnlineNotify003 end" << std::endl;
}
/**
* @tc.name: testDeviceOfflineNotify001
* @tc.desc: test device offline notify
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify001, TestSize.Level3)
{
DTEST_LOG << "testDeviceOfflineNotify001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify("");
DTEST_LOG << "testDeviceOfflineNotify001 end" << std::endl;
}
/**
* @tc.name: testDeviceOfflineNotify002
* @tc.desc: test device offline notify
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify002, TestSize.Level3)
{
DTEST_LOG << "testDeviceOfflineNotify002 begin" << std::endl;
std::set<std::string> remoteSyncDeviceSet_ = set<std::string>();
DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify(DEVICE_ID);
DTEST_LOG << "testDeviceOfflineNotify002 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDied001
* @tc.desc: test on remote died
@ -1186,22 +1152,18 @@ HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify002, TestSize.Level3)
HWTEST_F(DMSMissionManagerTest, testOnRemoteDied001, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDied001 begin" << std::endl;
//DeviceOfflineNotify
DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify("");
std::set<std::string> remoteSyncDeviceSet_ = set<std::string>();
DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify(DEVICE_ID);
//OnRemoteDied
wptr<IRemoteObject> remote = nullptr;
DistributedSchedMissionManager::GetInstance().OnRemoteDied(remote);
DTEST_LOG << "testOnRemoteDied001 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDied002
* @tc.desc: test on remote died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDied002, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDied002 begin" << std::endl;
wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
remote = new RemoteMissionListenerTest();
DistributedSchedMissionManager::GetInstance().OnRemoteDied(remote);
DTEST_LOG << "testOnRemoteDied002 end" << std::endl;
EXPECT_NE(remote.promote(), nullptr);
DTEST_LOG << "testOnRemoteDied001 end" << std::endl;
}
/**
@ -1230,26 +1192,13 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncMissionsFromRemote001, TestSize.Lev
HWTEST_F(DMSMissionManagerTest, testStopSyncMissionsFromRemote001, TestSize.Level3)
{
DTEST_LOG << "testStopSyncMissionsFromRemote001 begin" << std::endl;
std::vector<DstbMissionInfo> missionInfos;
CallerInfo callerInfo;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote("");
DTEST_LOG << "testStopSyncMissionsFromRemote001 end" << std::endl;
}
/**
* @tc.name: testStopSyncMissionsFromRemote002
* @tc.desc: stop sync missions from remote
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testStopSyncMissionsFromRemote002, TestSize.Level3)
{
DTEST_LOG << "testStopSyncMissionsFromRemote002 begin" << std::endl;
std::vector<DstbMissionInfo> missionInfos;
CallerInfo callerInfo;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.clear();
DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.insert(DEVICE_ID);
DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(DEVICE_ID);
DTEST_LOG << "testStopSyncMissionsFromRemote002 end" << std::endl;
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.empty(), true);
DTEST_LOG << "testStopSyncMissionsFromRemote001 end" << std::endl;
}
/**
@ -1305,6 +1254,7 @@ HWTEST_F(DMSMissionManagerTest, testNotifyLocalMissionsChanged001, TestSize.Leve
DTEST_LOG << "testNotifyLocalMissionsChanged001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().NotifyLocalMissionsChanged();
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionChangeHandler_, nullptr);
DTEST_LOG << "testNotifyLocalMissionsChanged001 end" << std::endl;
}
@ -1316,8 +1266,11 @@ HWTEST_F(DMSMissionManagerTest, testNotifyLocalMissionsChanged001, TestSize.Leve
HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotCreated001, TestSize.Level3)
{
DTEST_LOG << "testNotifyMissionSnapshotCreated001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().missionChangeHandler_ = nullptr;
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionChangeHandler_, nullptr);
DTEST_LOG << "testNotifyMissionSnapshotCreated001 end" << std::endl;
}
@ -1331,6 +1284,7 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotChanged001, TestSize.Le
DTEST_LOG << "testNotifyMissionSnapshotChanged001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotChanged(1);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionChangeHandler_, nullptr);
DTEST_LOG << "testNotifyMissionSnapshotChanged001 end" << std::endl;
}
@ -1344,6 +1298,7 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotDestroyed001, TestSize.
DTEST_LOG << "testNotifyMissionSnapshotDestroyed001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotDestroyed(1);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionChangeHandler_, nullptr);
DTEST_LOG << "testNotifyMissionSnapshotDestroyed001 end" << std::endl;
}
@ -1361,35 +1316,6 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemote001, TestSize.L
DTEST_LOG << "testNotifyMissionsChangedToRemote001 end" << std::endl;
}
/**
* @tc.name: testNotifyMissionsChangedToRemoteInner001
* @tc.desc: notify missions changed to remote inner
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner001, TestSize.Level3)
{
DTEST_LOG << "testNotifyMissionsChangedToRemoteInner001 begin" << std::endl;
CallerInfo callerInfo;
std::vector<DstbMissionInfo> missionInfos;
DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner("", missionInfos, callerInfo);
DTEST_LOG << "testNotifyMissionsChangedToRemoteInner001 end" << std::endl;
}
/**
* @tc.name: testNotifyMissionsChangedToRemoteInner002
* @tc.desc: notify missions changed to remote inner
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner002, TestSize.Level3)
{
DTEST_LOG << "testNotifyMissionsChangedToRemoteInner002 begin" << std::endl;
CallerInfo callerInfo;
std::vector<DstbMissionInfo> missionInfos;
DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner(
DEVICE_ID, missionInfos, callerInfo);
DTEST_LOG << "testNotifyMissionsChangedToRemoteInner002 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDmsDied001
* @tc.desc: on remote dms died
@ -1398,102 +1324,24 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner002, TestS
HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied001, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDmsDied001 begin" << std::endl;
//NotifyMissionsChangedToRemoteInner
CallerInfo callerInfo;
std::vector<DstbMissionInfo> missionInfos;
DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner("", missionInfos, callerInfo);
DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner(
DEVICE_ID, missionInfos, callerInfo);
wptr<IRemoteObject> remote = nullptr;
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
remote = wptr<IRemoteObject>();
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().missionHandler_, nullptr);
DTEST_LOG << "testOnRemoteDmsDied001 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDmsDied002
* @tc.desc: on remote dms died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied002, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDmsDied002 begin" << std::endl;
wptr<IRemoteObject> remote = wptr<IRemoteObject>();
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
DTEST_LOG << "testOnRemoteDmsDied002 end" << std::endl;
}
/**
* @tc.name: testRetryStartSyncRemoteMissions001
* @tc.desc: retry start sync remote missions
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions001, TestSize.Level3)
{
DTEST_LOG << "testRetryStartSyncRemoteMissions001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions("", localDeviceId_, 1);
DTEST_LOG << "testRetryStartSyncRemoteMissions001 end" << std::endl;
}
/**
* @tc.name: testRetryStartSyncRemoteMissions002
* @tc.desc: retry start sync remote missions
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions002, TestSize.Level3)
{
DTEST_LOG << "testRetryStartSyncRemoteMissions002 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
DTEST_LOG << "testRetryStartSyncRemoteMissions002 end" << std::endl;
}
/**
* @tc.name: testOnMissionListenerDied001
* @tc.desc: on mission listener died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied001, TestSize.Level3)
{
DTEST_LOG << "testOnMissionListenerDied001 begin" << std::endl;
sptr<IRemoteObject> remote = nullptr;
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(remote);
DTEST_LOG << "testOnMissionListenerDied001 end" << std::endl;
}
/**
* @tc.name: testOnMissionListenerDied002
* @tc.desc: on mission listener died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied002, TestSize.Level3)
{
DTEST_LOG << "testOnMissionListenerDied002 begin" << std::endl;
sptr<IRemoteObject> remote = sptr<IRemoteObject>();
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(remote);
DTEST_LOG << "testOnMissionListenerDied002 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDmsDied003
* @tc.desc: on remote dms died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied003, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDmsDied003 begin" << std::endl;
sptr<IRemoteObject> remote = nullptr;
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
DTEST_LOG << "testOnRemoteDmsDied003 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDmsDied004
* @tc.desc: on remote dms died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied004, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDmsDied004 begin" << std::endl;
sptr<IRemoteObject> remote = sptr<IRemoteObject>();
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
DTEST_LOG << "testOnRemoteDmsDied004 end" << std::endl;
}
/**
* @tc.name: testRetryRegisterMissionChange001
* @tc.desc: retry register mission change
@ -1502,8 +1350,21 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied004, TestSize.Level3)
HWTEST_F(DMSMissionManagerTest, testRetryRegisterMissionChange001, TestSize.Level3)
{
DTEST_LOG << "testRetryRegisterMissionChange001 begin" << std::endl;
//RetryStartSyncRemoteMissions
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions("", localDeviceId_, 1);
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
//OnMissionListenerDied
sptr<IRemoteObject> remote = nullptr;
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(remote);
remote = sptr<IRemoteObject>();
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(remote);
//RetryRegisterMissionChange
DistributedSchedMissionManager::GetInstance().RetryRegisterMissionChange(1);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionHandler_, nullptr);
DTEST_LOG << "testRetryRegisterMissionChange001 end" << std::endl;
}
@ -1523,19 +1384,6 @@ HWTEST_F(DMSMissionManagerTest, testMissionSnapshotChanged001, TestSize.Level3)
DTEST_LOG << "testMissionSnapshotChanged001 end" << std::endl;
}
/**
* @tc.name: testOnDnetDied001
* @tc.desc: on dnet died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnDnetDied001, TestSize.Level3)
{
DTEST_LOG << "testOnDnetDied001 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().OnDnetDied();
DTEST_LOG << "testOnDnetDied001 end" << std::endl;
}
/**
* @tc.name: ProxyCallStopSyncMissionsFromRemote001
* @tc.desc: call dms proxy StopSyncMissionsFromRemote
@ -1545,6 +1393,13 @@ HWTEST_F(DMSMissionManagerTest, testOnDnetDied001, TestSize.Level3)
HWTEST_F(DMSMissionManagerTest, ProxyCallStopSyncMissionsFromRemote001, TestSize.Level3)
{
DTEST_LOG << "DistributedSchedServiceTest ProxyCallStopSyncMissionsFromRemote001 start" << std::endl;
//OnDnetDied
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().OnDnetDied();
DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = false;
DistributedSchedMissionManager::GetInstance().OnDnetDied();
//proxy StopSyncMissionsFromRemote
sptr<IDistributedSched> proxy = GetDms();
ASSERT_NE(nullptr, proxy);
CallerInfo callerInfo;
@ -2120,6 +1975,7 @@ HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify003, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = remoteDmsObj;
}
DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify(DEVICE_ID);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().remoteDmsMap_.empty(), true);
DTEST_LOG << "testDeviceOfflineNotify003 end" << std::endl;
}
@ -2374,6 +2230,7 @@ HWTEST_F(DMSMissionManagerTest, testCleanMissionResources002, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
}
DistributedSchedMissionManager::GetInstance().CleanMissionResources(DEVICE_ID);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), true);
DTEST_LOG << "testCleanMissionResources002 end" << std::endl;
}
@ -2482,26 +2339,11 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncMissionsFromRemote003, TestSize.Lev
DistributedSchedMissionManager::GetInstance().GenerateCallerInfo(callerInfo);
DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = false;
auto ret = DistributedSchedMissionManager::GetInstance().StartSyncMissionsFromRemote(callerInfo, missionInfos);
DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(DEVICE_ID);
EXPECT_EQ(ret, ERR_NONE);
DTEST_LOG << "testStartSyncMissionsFromRemote003 end" << std::endl;
}
/**
* @tc.name: testStopSyncMissionsFromRemote003
* @tc.desc: stop sync missions from remote
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testStopSyncMissionsFromRemote003, TestSize.Level3)
{
DTEST_LOG << "testStopSyncMissionsFromRemote003 begin" << std::endl;
std::vector<DstbMissionInfo> missionInfos;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
DistributedSchedMissionManager::GetInstance().missonChangeListener_ = nullptr;
DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(DEVICE_ID);
DTEST_LOG << "testStopSyncMissionsFromRemote003 end" << std::endl;
}
/**
* @tc.name: testNeedSyncDevice003
* @tc.desc: need sync device
@ -2606,20 +2448,6 @@ HWTEST_F(DMSMissionManagerTest, testHasSyncListener002, TestSize.Level3)
DTEST_LOG << "testHasSyncListener002 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDied003
* @tc.desc: test on remote died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDied003, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDied003 begin" << std::endl;
wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
DistributedSchedMissionManager::GetInstance().OnRemoteDied(remote);
DTEST_LOG << "testOnRemoteDied003 end" << std::endl;
}
/**
* @tc.name: testDequeueCachedSnapshotInfo003
* @tc.desc: enqueue cached snapshot info
@ -2721,37 +2549,6 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedFromRemote003, TestSize
DTEST_LOG << "testNotifyMissionsChangedFromRemote003 end" << std::endl;
}
/**
* @tc.name: testNotifyMissionSnapshotCreated002
* @tc.desc: notify mission snapshot created
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotCreated002, TestSize.Level3)
{
DTEST_LOG << "testNotifyMissionSnapshotCreated002 begin" << std::endl;
auto missionChangeRunner = AppExecFwk::EventRunner::Create("DistributedMissionChange");
DistributedSchedMissionManager::GetInstance().missionChangeHandler_ =
std::make_shared<AppExecFwk::EventHandler>(missionChangeRunner);
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
DTEST_LOG << "testNotifyMissionSnapshotCreated002 end" << std::endl;
}
/**
* @tc.name: testNotifyMissionSnapshotCreated003
* @tc.desc: notify mission snapshot created
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotCreated003, TestSize.Level3)
{
DTEST_LOG << "testNotifyMissionSnapshotCreated003 begin" << std::endl;
auto missionChangeRunner = AppExecFwk::EventRunner::Create("DistributedMissionChange");
DistributedSchedMissionManager::GetInstance().missionChangeHandler_ =
std::make_shared<AppExecFwk::EventHandler>(missionChangeRunner);
DistributedSchedMissionManager::GetInstance().distributedDataStorage_ = nullptr;
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
DTEST_LOG << "testNotifyMissionSnapshotCreated003 end" << std::endl;
}
/**
* @tc.name: testNotifyMissionsChangedToRemote002
* @tc.desc: notify missions changed to remote
@ -2812,31 +2609,6 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemote003, TestSize.L
DTEST_LOG << "testNotifyMissionsChangedToRemote003 end" << std::endl;
}
/**
* @tc.name: testNotifyMissionsChangedToRemoteInner003
* @tc.desc: notify missions changed to remote inner
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner003, TestSize.Level3)
{
DTEST_LOG << "testNotifyMissionsChangedToRemoteInner003 begin" << std::endl;
sptr<IDistributedSched> proxy = GetDms();
ASSERT_NE(nullptr, proxy);
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
}
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
}
CallerInfo callerInfo;
std::vector<DstbMissionInfo> missionInfos;
DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner(
DEVICE_ID, missionInfos, callerInfo);
DTEST_LOG << "testNotifyMissionsChangedToRemoteInner003 end" << std::endl;
}
/**
* @tc.name: testFetchDeviceHandler003
* @tc.desc: fetch device handler
@ -2936,49 +2708,6 @@ HWTEST_F(DMSMissionManagerTest, testFetchDeviceHandler005, TestSize.Level3)
DTEST_LOG << "testFetchDeviceHandler005 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDmsDied009
* @tc.desc: on remote dms died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied009, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDmsDied009 begin" << std::endl;
wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
DTEST_LOG << "testOnRemoteDmsDied009 end" << std::endl;
}
/**
* @tc.name: testOnRemoteDmsDied005
* @tc.desc: on remote dms died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied005, TestSize.Level3)
{
DTEST_LOG << "testOnRemoteDmsDied005 begin" << std::endl;
wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
DTEST_LOG << "testOnRemoteDmsDied005 end" << std::endl;
}
/**
* @tc.name: testRetryStartSyncRemoteMissions003
* @tc.desc: retry start sync remote missions
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions003, TestSize.Level3)
{
DTEST_LOG << "testRetryStartSyncRemoteMissions003 begin" << std::endl;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
DTEST_LOG << "testRetryStartSyncRemoteMissions003 end" << std::endl;
}
/**
* @tc.name: testRetryStartSyncRemoteMissions004
* @tc.desc: retry start sync remote missions
@ -3003,6 +2732,7 @@ HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions004, TestSize.Le
DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
}
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionHandler_, nullptr);
DTEST_LOG << "testRetryStartSyncRemoteMissions004 end" << std::endl;
}
@ -3040,6 +2770,7 @@ HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions005, TestSize.Le
DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
}
DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionHandler_, nullptr);
DTEST_LOG << "testRetryStartSyncRemoteMissions005 end" << std::endl;
}
@ -3065,6 +2796,7 @@ HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied003, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
}
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(listener);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), true);
DTEST_LOG << "testOnMissionListenerDied003 end" << std::endl;
}
@ -3092,6 +2824,7 @@ HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied004, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
}
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(listener);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), false);
DTEST_LOG << "testOnMissionListenerDied004 end" << std::endl;
}
@ -3117,6 +2850,7 @@ HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied005, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
}
DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(listener);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), true);
DTEST_LOG << "testOnMissionListenerDied005 end" << std::endl;
}
@ -3141,6 +2875,7 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied006, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = remoteDmsObj;
}
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), true);
DTEST_LOG << "testOnRemoteDmsDied006 end" << std::endl;
}
@ -3166,6 +2901,7 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied007, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
}
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), true);
DTEST_LOG << "testOnRemoteDmsDied007 end" << std::endl;
}
@ -3202,36 +2938,8 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied008, TestSize.Level3)
DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
}
DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
EXPECT_EQ(DistributedSchedMissionManager::GetInstance().listenDeviceMap_.empty(), false);
DTEST_LOG << "testOnRemoteDmsDied008 end" << std::endl;
}
/**
* @tc.name: testRetryRegisterMissionChange002
* @tc.desc: retry register mission change
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testRetryRegisterMissionChange002, TestSize.Level3)
{
DTEST_LOG << "testRetryRegisterMissionChange002 begin" << std::endl;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
DistributedSchedMissionManager::GetInstance().RetryRegisterMissionChange(1);
DTEST_LOG << "testRetryRegisterMissionChange002 end" << std::endl;
}
/**
* @tc.name: testOnDnetDied002
* @tc.desc: on dnet died
* @tc.type: FUNC
*/
HWTEST_F(DMSMissionManagerTest, testOnDnetDied002, TestSize.Level3)
{
DTEST_LOG << "testOnDnetDied002 begin" << std::endl;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = false;
DistributedSchedMissionManager::GetInstance().OnDnetDied();
DTEST_LOG << "testOnDnetDied002 end" << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS
} // namespace OHOS

View File

@ -253,6 +253,12 @@ public:
{
return ERR_OK;
};
ErrCode RequestPublishProxyFormWithSnapshot(Want &want, bool withFormBindingData,
std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId,
const std::vector<FormDataProxy> &formDataProxies) override
{
return ERR_OK;
}
};
} // namespace AppExecFwk
} // 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);