Merge pull request !893 from 师皓杰/master
This commit is contained in:
openharmony_ci 2024-05-09 06:12:22 +00:00 committed by Gitee
commit 28be58501f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 296 additions and 0 deletions

View File

@ -59,6 +59,18 @@ sptr<IRemoteObject> DSchedContinueManagerTest::GetDSchedService() const
return dsched;
}
std::shared_ptr<DSchedContinue> DSchedContinueManagerTest::CreateObject()
{
int32_t subServiceType = 0;
int32_t direction = 0;
sptr<IRemoteObject> callback = nullptr;
DSchedContinueInfo continueInfo;
std::shared_ptr<DSchedContinue> dContinue = std::make_shared<DSchedContinue>(subServiceType, direction,
callback, continueInfo);
dContinue->Init();
return dContinue;
}
/**
* @tc.name: Init_001
* @tc.desc: test Init func
@ -226,5 +238,121 @@ HWTEST_F(DSchedContinueManagerTest, GetContinueInfo_001, TestSize.Level3)
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_001 end" << std::endl;
}
/**
* @tc.name: GetContinueInfo_002
* @tc.desc: test GetContinueInfo func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, GetContinueInfo_002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_002 begin" << std::endl;
DSchedContinueManager::GetInstance().OnShutdown(1, true);
DSchedContinueManager::GetInstance().OnShutdown(1, false);
DSchedContinueManager::GetInstance().OnShutdown(1, false);
DSchedContinueInfo info;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
std::string localDeviceId = "localdeviceid";
std::string remoteDeviceId = "remotedeviceid";
DSchedContinueManager::GetInstance().continues_[info] = dContinue;
int32_t ret = DSchedContinueManager::GetInstance().GetContinueInfo(localDeviceId, remoteDeviceId);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_002 end" << std::endl;
}
/**
* @tc.name: HandleNotifyCompleteContinuation_001
* @tc.desc: test HandleNotifyCompleteContinuation func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, HandleNotifyCompleteContinuation_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest HandleNotifyCompleteContinuation_001 begin" << std::endl;
std::u16string devId;
int32_t missionId = 0;
DSchedContinueManager::GetInstance().continues_.clear();
DSchedContinueManager::GetInstance().HandleNotifyCompleteContinuation(devId, missionId, false);
DSchedContinueInfo info;
std::shared_ptr<DSchedContinue> ptr = nullptr;
DSchedContinueManager::GetInstance().continues_[info] = ptr;
DSchedContinueManager::GetInstance().HandleNotifyCompleteContinuation(devId, missionId, false);
bool ret = DSchedContinueManager::GetInstance().continues_.empty();
EXPECT_EQ(ret, false);
DTEST_LOG << "DSchedContinueManagerTest HandleNotifyCompleteContinuation_001 end" << std::endl;
}
/**
* @tc.name: NotifyCompleteContinuation_001
* @tc.desc: test NotifyCompleteContinuation func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, NotifyCompleteContinuation_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest NotifyCompleteContinuation_001 begin" << std::endl;
std::u16string devId;
int32_t sessionId = 0;
bool isSuccess = false;
DSchedContinueManager::GetInstance().Init();
int32_t ret = DSchedContinueManager::GetInstance().NotifyCompleteContinuation(devId,
sessionId, isSuccess);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueManagerTest NotifyCompleteContinuation_001 end" << std::endl;
}
/**
* @tc.name: OnContinueEnd_001
* @tc.desc: test OnContinueEnd func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, OnContinueEnd_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest OnContinueEnd_001 begin" << std::endl;
DSchedContinueInfo info(LOCAL_DEVICEID, "sourceBundleName", REMOTE_DEVICEID, "sinkBundleName",
"continueType");
DSchedContinueManager::GetInstance().UnInit();
int32_t ret = DSchedContinueManager::GetInstance().OnContinueEnd(info);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DSchedContinueManager::GetInstance().Init();
ret = DSchedContinueManager::GetInstance().OnContinueEnd(info);
EXPECT_EQ(ret, ERR_OK);
DSchedContinueManager::GetInstance().UnInit();
DTEST_LOG << "DSchedContinueManagerTest OnContinueEnd_001 end" << std::endl;
}
/**
* @tc.name: HandleContinueEnd_001
* @tc.desc: test HandleContinueEnd func
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueManagerTest, HandleContinueEnd_001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueManagerTest HandleContinueEnd_001 begin" << std::endl;
DSchedContinueInfo info(LOCAL_DEVICEID, "sourceBundleName", REMOTE_DEVICEID, "sinkBundleName",
"continueType");
DSchedContinueManager::GetInstance().UnInit();
DSchedContinueManager::GetInstance().RemoveTimeout(info);
DSchedContinueManager::GetInstance().Init();
DSchedContinueManager::GetInstance().RemoveTimeout(info);
DSchedContinueManager::GetInstance().continues_.clear();
DSchedContinueManager::GetInstance().HandleContinueEnd(info);
int32_t ret = DSchedContinueManager::GetInstance().continues_.empty();
EXPECT_EQ(ret, true);
DSchedContinueManager::GetInstance().cntSource_ = 0;
std::shared_ptr<DSchedContinue> ptr = nullptr;
DSchedContinueManager::GetInstance().continues_[info] = ptr;
DSchedContinueManager::GetInstance().HandleContinueEnd(info);
EXPECT_EQ(DSchedContinueManager::GetInstance().cntSource_, 0);
DSchedContinueManager::GetInstance().UnInit();
DTEST_LOG << "DSchedContinueManagerTest HandleContinueEnd_001 end" << std::endl;
}
}
}

View File

@ -29,6 +29,7 @@ public:
static void TearDownTestCase();
void SetUp();
void TearDown();
std::shared_ptr<DSchedContinue> CreateObject();
sptr<IRemoteObject> GetDSchedService() const;
};
} // namespace DistributedSchedule

View File

@ -382,6 +382,27 @@ HWTEST_F(DSchedContinueDataStateTest, SinkExecuteTest001, TestSize.Level3)
DTEST_LOG << "DSchedContinueDataStateTest SinkExecuteTest001 end" << std::endl;
}
/**
* @tc.name: SinkExecuteTest002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueDataStateTest, SinkExecuteTest002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueDataStateTest SinkExecuteTest002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSCHED_CONTINUE_DATA_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = dataStateTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueDataStateTest SinkExecuteTest002 end" << std::endl;
}
/**
* @tc.name: SinkGetStateType001
* @tc.desc: GetStateType
@ -458,6 +479,27 @@ HWTEST_F(DSchedContinueSinkEndStateTest, TestSinkExecute001, TestSize.Level3)
DTEST_LOG << "DSchedContinueSinkEndStateTest TestSinkExecute001 end" << std::endl;
}
/**
* @tc.name: TestSinkExecute002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueSinkEndStateTest, TestSinkExecute002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueSinkEndStateTest SinkExecuteTest001 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSCHED_CONTINUE_END_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = sinkEndStateTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSinkEndStateTest TestSinkExecute002 end" << std::endl;
}
/**
* @tc.name: TestSinkGetStateType001
* @tc.desc: GetStateType
@ -513,6 +555,27 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkExecuteTest_001, TestSize.Level3)
DTEST_LOG << "DSchedContinueSinkStartStateTest SinkExecuteTest_001 end" << std::endl;
}
/**
* @tc.name: SinkExecuteTest_002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueSinkStartStateTest, SinkExecuteTest_002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueSinkStartStateTest SinkExecuteTest_002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSCHED_CONTINUE_REQ_PULL_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = sinkStartStateTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSinkStartStateTest SinkExecuteTest_002 end" << std::endl;
}
/**
* @tc.name: SinkGetStateTypeTest_001
* @tc.desc: GetStateTypeTest
@ -613,6 +676,26 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkExecute001, TestSize.Level3)
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkExecute001 end" << std::endl;
}
/**
* @tc.name: SinkExecute002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkExecute002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkExecute002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSCHED_CONTINUE_COMPLETE_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = sinkWaitEndTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkExecute002 end" << std::endl;
}
/**
* @tc.name: SinkGetStateType001
@ -693,6 +776,27 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcExecuteTest001, TestSize.Level3)
DTEST_LOG << "DSchedContinueAbilityStateTest SrcExecuteTest001 end" << std::endl;
}
/**
* @tc.name: SrcExecuteTest002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueAbilityStateTest, SrcExecuteTest002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueAbilityStateTest SrcExecuteTest002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSHCED_CONTINUE_SEND_DATA_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = abilityStateTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcExecuteTest002 end" << std::endl;
}
/**
* @tc.name: SrcGetStateType001
* @tc.desc: GetStateType
@ -769,6 +873,27 @@ HWTEST_F(DSchedContinueEndStateTest, SrcExecuteTest001, TestSize.Level3)
DTEST_LOG << "DSchedContinueEndStateTest SrcExecuteTest001 end" << std::endl;
}
/**
* @tc.name: SrcExecuteTest002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueEndStateTest, SrcExecuteTest002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueEndStateTest SrcExecuteTest002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSCHED_CONTINUE_END_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = srcEndStateTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueEndStateTest SrcExecuteTest002 end" << std::endl;
}
/**
* @tc.name: SrcGetStateTypeTest001
* @tc.desc: GetStateTypeTest
@ -824,6 +949,27 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcExecuteTest_001, TestSize.Level3
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcExecuteTest_001 end" << std::endl;
}
/**
* @tc.name: SrcExecuteTest_002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueSourceStartStateTest, SrcExecuteTest_002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcExecuteTest_002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSHCED_CONTINUE_REQ_PUSH_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = srcStartStateTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcExecuteTest_002 end" << std::endl;
}
/**
* @tc.name: SrcGetStateTypeTest_001
* @tc.desc: GetStateType
@ -924,6 +1070,27 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcExecute_001, TestSize.Level3)
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcExecute_001 end" << std::endl;
}
/**
* @tc.name: SrcExecute_002
* @tc.desc: Execute
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueWaitEndStateTest, SrcExecute_002, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcExecute_002 begin" << std::endl;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
event->innerEventId_ = static_cast<uint32_t>(DSCHED_CONTINUE_COMPLETE_EVENT);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = srcWaitEndTest_->Execute(dContinue, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcExecute_002 end" << std::endl;
}
/**
* @tc.name: SrcGetStateType_001
* @tc.desc: GetStateType