!6706 支持删除指定任务UT补充

Merge pull request !6706 from hubijie/master
This commit is contained in:
openharmony_ci 2024-06-03 06:44:44 +00:00 committed by Gitee
commit ed96a56c59
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 58 additions and 6 deletions

View File

@ -2454,6 +2454,8 @@ bool Session::IsSupportDetectWindow(bool isAttach)
}
// Only detecting cold start scenarios on PC
if (isPc && (!isAttach || state_ != SessionState::STATE_DISCONNECT)) {
TLOGI(WmsLogTag::WMS_LIFE, "Window state detect not support: Only support cold start on pc, "
"persistentId:%{public}d", persistentId_);
RemoveWindowDetectTask();
return false;
}

View File

@ -1541,20 +1541,18 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo06, Function | SmallTes
}
/**
* @tc.name: ClearMainSessions
* @tc.desc: SceneSessionManager get all main window infos, input params are not empty.
* @tc.name: ClearMainSessions001
* @tc.desc: SceneSessionManager clear main session by persistentid.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest, ClearMainSessions, Function | SmallTest | Level3)
HWTEST_F(SceneSessionManagerTest, ClearMainSessions001, Function | SmallTest | Level3)
{
SessionInfo info;
info.abilityName_ = "test1";
info.bundleName_ = "test1";
info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
if (sceneSession == nullptr) {
return;
}
ASSERT_NE(nullptr, sceneSession);
std::vector<int32_t> clearFailedIds;
ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
std::vector<int32_t> persistentIds = {sceneSession->GetPersistentId()};
@ -1562,6 +1560,58 @@ HWTEST_F(SceneSessionManagerTest, ClearMainSessions, Function | SmallTest | Leve
EXPECT_EQ(result, WMError::WM_OK);
EXPECT_EQ(clearFailedIds.size(), 0);
}
/**
* @tc.name: ClearMainSessions002
* @tc.desc: SceneSessionManager clear main session by persistentid.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest, ClearMainSessions002, Function | SmallTest | Level3)
{
SessionInfo info1;
info1.abilityName_ = "test1";
info1.bundleName_ = "test1";
info1.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
sptr<SceneSession> sceneSession1 = new (std::nothrow) SceneSession(info1, nullptr);
ASSERT_NE(nullptr, sceneSession1);
SessionInfo info2;
info2.abilityName_ = "test1";
info2.bundleName_ = "test1";
info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
sptr<SceneSession> sceneSession2 = new (std::nothrow) SceneSession(info2, nullptr);
ASSERT_NE(nullptr, sceneSession2);
std::vector<int32_t> clearFailedIds;
ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
std::vector<int32_t> persistentIds = {sceneSession1->GetPersistentId(), sceneSession2->GetPersistentId()};
auto result = ssm_->ClearMainSessions(persistentIds, clearFailedIds);
EXPECT_EQ(result, WMError::WM_OK);
EXPECT_EQ(clearFailedIds.size(), 1);
}
/**
* @tc.name: ClearMainSessions003
* @tc.desc: SceneSessionManager clear main session by persistentid.
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest, ClearMainSessions003, Function | SmallTest | Level3)
{
SessionInfo info;
info.abilityName_ = "test1";
info.bundleName_ = "test1";
info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
ASSERT_NE(nullptr, sceneSession);
int32_t invalidPersistentId = -1;
std::vector<int32_t> clearFailedIds;
ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
std::vector<int32_t> persistentIds = {sceneSession->GetPersistentId(), invalidPersistentId};
auto result = ssm_->ClearMainSessions(persistentIds, clearFailedIds);
EXPECT_EQ(result, WMError::WM_OK);
EXPECT_EQ(clearFailedIds.size(), 1);
}
}
} // namespace Rosen
} // namespace OHOS