!620 添加tdd信息和修改codecheck不合规问题

Merge pull request !620 from yaoyao/master
This commit is contained in:
openharmony_ci 2023-05-22 08:48:54 +00:00 committed by Gitee
commit 0510132e46
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 196 additions and 14 deletions

View File

@ -115,13 +115,13 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Parcelable_0300, F
std::string keyStr = "12345667";
int valueInteger = 12345;
wantParamsIn_->SetParam(keyStr, Integer::Box(valueInteger));
int right = Integer::Unbox(IInteger::Query(wantParamsIn_->GetParam(keyStr)));
Integer::Unbox(IInteger::Query(wantParamsIn_->GetParam(keyStr)));
Parcel in;
wantParamsIn_->Marshalling(in);
std::shared_ptr<DistributedWantParams> wantParamsOut_(DistributedWantParams::Unmarshalling(in));
if (wantParamsOut_ != nullptr) {
right = Integer::Unbox(IInteger::Query(wantParamsOut_->GetParam(keyStr)));
int right = Integer::Unbox(IInteger::Query(wantParamsOut_->GetParam(keyStr)));
EXPECT_EQ(valueInteger, right);
wantParamsOut_ = nullptr;
}
@ -454,7 +454,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0600,
HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0700, Function | MediumTest | Level3)
{
const std::string value = "-1";
sptr<IInterface> longObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, "-1");
sptr<IInterface> longObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
int type = DistributedWantParams::GetDataType(longObj);
EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_LONG);
}
@ -468,7 +468,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0800,
{
const std::string value = "-1.0004";
sptr<IInterface> floatObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, "-1.0004");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
int type = DistributedWantParams::GetDataType(floatObj);
EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_FLOAT);
}
@ -482,7 +482,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0900,
{
const std::string value = "-1.00000004";
sptr<IInterface> doubleObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, "-1.00000004");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
int type = DistributedWantParams::GetDataType(doubleObj);
EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_DOUBLE);
}
@ -496,7 +496,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_1000,
{
const std::string value = "hello";
sptr<IInterface> stringObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, "hello");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
int type = DistributedWantParams::GetDataType(stringObj);
EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_STRING);
}
@ -588,7 +588,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType
{
const std::string value = "-1";
sptr<IInterface> longObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, "-1");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
EXPECT_EQ(Long::Unbox(ILong::Query(longObj)), -1);
}
@ -601,7 +601,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType
{
const std::string value = "-1.0004";
sptr<IInterface> floatObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, "-1.0004");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
EXPECT_FLOAT_EQ(Float::Unbox(IFloat::Query(floatObj)), -1.0004);
}
@ -614,7 +614,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType
{
const std::string value = "-1.00000004";
sptr<IInterface> doubleObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, "-1.00000004");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
EXPECT_DOUBLE_EQ(Double::Unbox(IDouble::Query(doubleObj)), -1.00000004);
}
@ -627,7 +627,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType
{
const std::string value = "hello";
sptr<IInterface> stringObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, "hello");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
EXPECT_EQ(String::Unbox(IString::Query(stringObj)), std::string("hello"));
}
@ -752,7 +752,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0
{
const std::string value = "-1";
sptr<IInterface> interfaceObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, "-1");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
bool result =
DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_LONG);
EXPECT_TRUE(result);
@ -767,7 +767,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0
{
const std::string value = "-1.0004";
sptr<IInterface> interfaceObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, "-1.0004");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
bool result =
DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_FLOAT);
EXPECT_TRUE(result);
@ -782,7 +782,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0
{
const std::string value = "-1.00000004";
sptr<IInterface> interfaceObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, "-1.00000004");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
bool result =
DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_DOUBLE);
EXPECT_TRUE(result);
@ -797,7 +797,7 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0
{
const std::string value = "hello";
sptr<IInterface> interfaceObj =
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, "hello");
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
bool result =
DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_STRING);
EXPECT_TRUE(result);

View File

@ -397,6 +397,8 @@ HWTEST_F(DistributedSchedAdapterTest, RegisterMissionListener_001, TestSize.Leve
HWTEST_F(DistributedSchedAdapterTest, RegisterMissionListener_002, TestSize.Level4)
{
DTEST_LOG << "DistributedSchedAdapterTest RegisterMissionListener_002 begin" << std::endl;
const sptr<IRemoteObject> connect = new MockRemoteStub();
distributedSchedAdapter_->ProcessCallResult(connect, nullptr);
const sptr<DistributedMissionChangeListener> listener = new DistributedMissionChangeListener();
int32_t result = distributedSchedAdapter_->RegisterMissionListener(listener);
EXPECT_NE(result, ERR_OK);
@ -412,6 +414,8 @@ HWTEST_F(DistributedSchedAdapterTest, RegisterMissionListener_002, TestSize.Leve
HWTEST_F(DistributedSchedAdapterTest, UnRegisterMissionListener_001, TestSize.Level4)
{
DTEST_LOG << "DistributedSchedAdapterTest UnRegisterMissionListener_001 begin" << std::endl;
const sptr<IRemoteObject> connect = new MockRemoteStub();
distributedSchedAdapter_->ProcessCallResult(nullptr, connect);
const sptr<DistributedMissionChangeListener> listener = nullptr;
int32_t result = distributedSchedAdapter_->UnRegisterMissionListener(listener);
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
@ -427,6 +431,8 @@ HWTEST_F(DistributedSchedAdapterTest, UnRegisterMissionListener_001, TestSize.Le
HWTEST_F(DistributedSchedAdapterTest, UnRegisterMissionListener_002, TestSize.Level4)
{
DTEST_LOG << "DistributedSchedAdapterTest UnRegisterMissionListener_002 begin" << std::endl;
const sptr<IRemoteObject> connect = new MockRemoteStub();
distributedSchedAdapter_->ProcessCallResult(connect, connect);
const sptr<DistributedMissionChangeListener> listener = new DistributedMissionChangeListener();
int32_t result = distributedSchedAdapter_->UnRegisterMissionListener(listener);
EXPECT_NE(result, INVALID_PARAMETERS_ERR);
@ -442,6 +448,7 @@ HWTEST_F(DistributedSchedAdapterTest, UnRegisterMissionListener_002, TestSize.Le
HWTEST_F(DistributedSchedAdapterTest, GetLocalMissionSnapshotInfo_001, TestSize.Level4)
{
DTEST_LOG << "DistributedSchedAdapterTest GetLocalMissionSnapshotInfo_001 begin" << std::endl;
distributedSchedAdapter_->ProcessCallResult(nullptr, nullptr);
const std::string networkId = "invalidNetworkId";
int32_t missionId = 0;
AAFwk::MissionSnapshot missionSnapshot;

View File

@ -34,6 +34,8 @@ const std::u16string MOCK_DEVICE_ID = u"MOCK_DEVICE_ID";
constexpr int32_t MOCK_SESSION_ID = 123;
constexpr int32_t MOCK_TASK_ID = 456;
const std::string LOCAL_DEVICE_ID = "192.168.43.100";
const string DMS_VERSION_ID = "dmsVersion";
const string DMS_VERSION = "4.0.0";
constexpr int32_t SLEEP_TIME = 1000;
constexpr int64_t FREE_INSTALL_TIMEOUT = 50000;
constexpr int32_t REQUEST_CODE_ERR = 305;
@ -1086,6 +1088,45 @@ HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_005, TestSize.Level1
DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_005 end" << std::endl;
}
/**
* @tc.name: StartFreeInstallFromRemote_006
* @tc.desc: call StartFreeInstallFromRemote
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_006, TestSize.Level1)
{
DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_006 start" << std::endl;
sptr<IDistributedSched> proxy = GetDms();
if (proxy == nullptr) {
return;
}
AAFwk::Want want;
AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
"com.ohos.distributedmusicplayer.MainAbility");
want.SetElement(element);
CallerInfo callerInfo;
callerInfo.uid = 0;
callerInfo.sourceDeviceId = "255.255.255.255";
callerInfo.extraInfoJson[DMS_VERSION_ID] = DMS_VERSION;
IDistributedSched::AccountInfo accountInfo;
IDistributedSched::FreeInstallInfo info = {.want = want,
.requestCode = 0,
.callerInfo = callerInfo,
.accountInfo = accountInfo
};
int result1 = proxy->StartFreeInstallFromRemote(info, 0);
DTEST_LOG << "result1 is" << result1 << std::endl;
AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
"com.ohos.distributedmusicplayer.MainAbilityService");
want.SetElement(element2);
int result2 = proxy->StartFreeInstallFromRemote(info, 0);
DTEST_LOG << "result2:" << result2 << std::endl;
DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_006 end" << std::endl;
}
/**
* @tc.name: NotifyCompleteFreeInstall_001
* @tc.desc: input invalid taskId.

View File

@ -431,6 +431,31 @@ HWTEST_F(DistributedSchedPermissionTest, CheckStartPermission_005, TestSize.Leve
DTEST_LOG << "DistributedSchedPermissionTest CheckStartPermission_005 end ret:" << ret << std::endl;
}
/**
* @tc.name: CheckStartPermission_006
* @tc.desc: input invalid params
* @tc.type: FUNC
* @tc.require: issueI5T6GJ
*/
HWTEST_F(DistributedSchedPermissionTest, CheckStartPermission_006, TestSize.Level3)
{
DTEST_LOG << "DistributedSchedPermissionTest CheckStartPermission_006 begin" << std::endl;
AAFwk::Want want;
want.SetParam(DMS_IS_CALLER_BACKGROUND, false);
CallerInfo callerInfo;
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo targetAbility;
targetAbility.visible = true;
targetAbility.isStageBasedModel = true;
int32_t ret = DistributedSchedPermission::GetInstance().CheckStartPermission(want,
callerInfo, accountInfo, targetAbility);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckStartPermission_006 end ret:" << ret << std::endl;
}
/**
* @tc.name: GetTargetAbility_001
* @tc.desc: input invalid params
@ -2046,5 +2071,44 @@ HWTEST_F(DistributedSchedPermissionTest, FromJson_002, TestSize.Level3)
EXPECT_EQ(groupInfo.groupName, "");
DTEST_LOG << "DistributedSchedPermissionTest FromJson_002 end " << std::endl;
}
/**
* @tc.name: MarkUriPermission_001
* @tc.desc: parse groupInfo from json with invalid params
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedPermissionTest, MarkUriPermission_001, TestSize.Level3)
{
DTEST_LOG << "DistributedSchedPermissionTest MarkUriPermission_001 begin" << std::endl;
AAFwk::Want want;
want.AddFlags(want.FLAG_ABILITY_CONTINUATION);
want.SetUri("urifile");
DistributedSchedPermission::GetInstance().MarkUriPermission(want, 0);
CallerInfo callerInfo;
callerInfo.accessToken = ACCESS_TOKEN;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
std::string groupId = INVALID_GROUP_ID;
accountInfo.groupIdList.push_back(groupId);
string targetBundle = INVALID_BUNDLE_NAME;
bool ret = DistributedSchedPermission::GetInstance().CheckAccountAccessPermission(
callerInfo, accountInfo, targetBundle);
EXPECT_EQ(ret, false);
DTEST_LOG << "DistributedSchedPermissionTest MarkUriPermission_001 end " << std::endl;
}
/**
* @tc.name: MarkUriPermission_001
* @tc.desc: parse groupInfo from json with invalid params
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedPermissionTest, GetDeviceSecurityLevel_001, TestSize.Level3)
{
DTEST_LOG << "DistributedSchedPermissionTest GetDeviceSecurityLevel_001 begin" << std::endl;
string udid = "123456";
int32_t ret = DistributedSchedPermission::GetInstance().GetDeviceSecurityLevel(udid);
EXPECT_NE(ret, 0);
DTEST_LOG << "DistributedSchedPermissionTest GetDeviceSecurityLevel_001 end " << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -1237,6 +1237,45 @@ HWTEST_F(DistributedSchedServiceTest, StartContinuation_007, TestSize.Level3)
DTEST_LOG << "DSchedContinuationTest StartContinuation_007 end" << std::endl;
}
/**
* @tc.name: StartContinuation_007
* @tc.desc: call StartContinuation
* @tc.type: FUNC
* @tc.type: I6O5T3
*/
HWTEST_F(DistributedSchedServiceTest, StartContinuation_008, TestSize.Level3)
{
DTEST_LOG << "DSchedContinuationTest StartContinuation_008 start" << std::endl;
if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) {
DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
}
AAFwk::Want want;
AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
"com.ohos.distributedmusicplayer.MainAbility");
int32_t flags = Want::FLAG_ABILITY_CONTINUATION;
want.SetElement(element);
want.SetFlags(flags);
int32_t missionId = 0;
int32_t callerUid = 0;
int32_t status = ERR_OK;
uint32_t accessToken = 0;
bool isSuccess = false;
/**
* @tc.steps: step1. call GetFormMgrProxy
*/
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
DTEST_LOG << "DSchedContinuationTest GetFormMgrProxy_001 start" << std::endl;
DistributedSchedService::GetInstance().GetFormMgrProxy();
DTEST_LOG << "DSchedContinuationTest GetFormMgrProxy_001 end" << std::endl;
#endif
int32_t ret = DistributedSchedService::GetInstance().StartContinuation(
want, missionId, callerUid, status, accessToken);
DistributedSchedService::GetInstance().NotifyCompleteContinuation(DEVICE_ID_NULL, SESSION_ID, isSuccess);
EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), ret);
DTEST_LOG << "DSchedContinuationTest StartContinuation_008 end" << std::endl;
}
/**
* @tc.name: NotifyCompleteContinuation_001
* @tc.desc: call NotifyCompleteContinuation

View File

@ -40,6 +40,7 @@ const std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.acces
const std::u16string MOCK_INVALID_DESCRIPTOR = u"invalid descriptor";
const std::string EXTRO_INFO_JSON_KEY_ACCESS_TOKEN = "accessTokenID";
const std::string EXTRO_INFO_JSON_KEY_REQUEST_CODE = "requestCode";
const std::string DMS_VERSION_ID = "dmsVersion";
const std::string CMPT_PARAM_FREEINSTALL_BUNDLENAMES = "ohos.extra.param.key.allowedBundles";
constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
constexpr int32_t MAX_WAIT_TIME = 5000;
@ -2060,6 +2061,21 @@ HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_001, TestSi
HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_002, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest NotifyStateChangedFromRemoteInner_002 begin" << std::endl;
nlohmann::json extraInfoJson;
CallerInfo callerInfo;
distributedSchedStub_->SaveExtraInfo(extraInfoJson, callerInfo);
nlohmann::json extraInfoJson1;
extraInfoJson[DMS_VERSION_ID] = "4";
CallerInfo callerInfo1;
distributedSchedStub_->SaveExtraInfo(extraInfoJson1, callerInfo1);
nlohmann::json extraInfoJson2;
extraInfoJson[DMS_VERSION_ID] = 4;
CallerInfo callerInfo2;
distributedSchedStub_->SaveExtraInfo(extraInfoJson2, callerInfo2);
MessageParcel data;
MessageParcel reply;
@ -2081,6 +2097,21 @@ HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_002, TestSi
HWTEST_F(DistributedSchedStubTest, StopRemoteExtensionAbilityInner_002, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest StopRemoteExtensionAbilityInner_002 begin" << std::endl;
nlohmann::json extraInfoJson;
CallerInfo callerInfo;
distributedSchedStub_->SaveExtraInfo(extraInfoJson, callerInfo);
nlohmann::json extraInfoJson1;
extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
CallerInfo callerInfo1;
distributedSchedStub_->SaveExtraInfo(extraInfoJson1, callerInfo1);
nlohmann::json extraInfoJson2;
extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = "4";
CallerInfo callerInfo2;
distributedSchedStub_->SaveExtraInfo(extraInfoJson2, callerInfo2);
int32_t code = DistributedSchedStub::STOP_REMOTE_EXTERNSION_ABILITY;
MessageParcel data;
MessageParcel reply;