mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 09:10:54 +00:00
add test for security exemption
Signed-off-by: ZhangYunFei555 <zhangyunfei15@huawei.com> Change-Id: Ibc95aa767f4877d6eff85156413015709cbd000b
This commit is contained in:
parent
5cef0b6f04
commit
2a50d28520
@ -2464,6 +2464,101 @@ HWTEST_F(RSUniRenderVisitorTest, QuickPrepareDisplayRenderNode004, TestSize.Leve
|
||||
ASSERT_FALSE(rsUniRenderVisitor->ancestorNodeHasAnimation_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdateVirtualScreenSecurityExemption001
|
||||
* @tc.desc: Test UpdateVirtualScreenSecurityExemption for no-mirror display
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSUniRenderVisitorTest, UpdateVirtualScreenSecurityExemption001, TestSize.Level2)
|
||||
{
|
||||
auto rsContext = std::make_shared<RSContext>();
|
||||
RSDisplayNodeConfig displayConfig;
|
||||
// 11 non-zero node id
|
||||
auto rsDisplayRenderNode = std::make_shared<RSDisplayRenderNode>(11, displayConfig, rsContext->weak_from_this());
|
||||
rsDisplayRenderNode->InitRenderParams();
|
||||
ASSERT_EQ(rsDisplayRenderNode->IsMirrorDisplay(), false);
|
||||
|
||||
auto rsUniRenderVisitor = std::make_shared<RSUniRenderVisitor>();
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdateVirtualScreenSecurityExemption002
|
||||
* @tc.desc: Test UpdateVirtualScreenSecurityExemption for mirror display with abnormal params
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSUniRenderVisitorTest, UpdateVirtualScreenSecurityExemption002, TestSize.Level2)
|
||||
{
|
||||
auto rsContext = std::make_shared<RSContext>();
|
||||
RSDisplayNodeConfig displayConfig;
|
||||
// 11 non-zero node id
|
||||
auto rsDisplayRenderNode = std::make_shared<RSDisplayRenderNode>(11, displayConfig, rsContext->weak_from_this());
|
||||
rsDisplayRenderNode->InitRenderParams();
|
||||
rsDisplayRenderNode->SetIsMirrorDisplay(true);
|
||||
ASSERT_EQ(rsDisplayRenderNode->GetMirrorSource().lock(), nullptr);
|
||||
|
||||
auto rsUniRenderVisitor = std::make_shared<RSUniRenderVisitor>();
|
||||
ASSERT_EQ(rsUniRenderVisitor->screenManager_, nullptr);
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
|
||||
// 12 non-zero node id
|
||||
auto mirrorNode = std::make_shared<RSDisplayRenderNode>(12, displayConfig, rsContext->weak_from_this());
|
||||
rsDisplayRenderNode->mirrorSource_ = mirrorNode;
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdateVirtualScreenSecurityExemption003
|
||||
* @tc.desc: Test UpdateVirtualScreenSecurityExemption for mirror display with normal params
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSUniRenderVisitorTest, UpdateVirtualScreenSecurityExemption003, TestSize.Level2)
|
||||
{
|
||||
auto rsContext = std::make_shared<RSContext>();
|
||||
RSDisplayNodeConfig displayConfig;
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
// 480, 320 width and height for test
|
||||
auto id = screenManager->CreateVirtualScreen("virtualScreen01", 480, 320, nullptr);
|
||||
// 480, 320 width and height for test
|
||||
auto mirrorId = screenManager->CreateVirtualScreen("virtualScreen02", 480, 320, nullptr);
|
||||
screenManager->SetScreenMirror(id, mirrorId);
|
||||
|
||||
displayConfig.screenId = id;
|
||||
auto rsDisplayRenderNode = std::make_shared<RSDisplayRenderNode>(id, displayConfig, rsContext->weak_from_this());
|
||||
rsDisplayRenderNode->InitRenderParams();
|
||||
rsDisplayRenderNode->SetIsMirrorDisplay(true);
|
||||
|
||||
displayConfig.screenId = mirrorId;
|
||||
auto mirrorNode = std::make_shared<RSDisplayRenderNode>(mirrorId, displayConfig, rsContext->weak_from_this());
|
||||
mirrorNode->AddSecurityLayer(1); // layerId for test
|
||||
mirrorNode->AddSecurityLayer(2); // layerId for test
|
||||
rsDisplayRenderNode->mirrorSource_ = mirrorNode;
|
||||
|
||||
auto rsUniRenderVisitor = std::make_shared<RSUniRenderVisitor>();
|
||||
rsUniRenderVisitor->screenManager_ = screenManager;
|
||||
ASSERT_NE(rsUniRenderVisitor->screenManager_, nullptr);
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
|
||||
screenManager->SetVirtualScreenSecurityExemptionList(id, {1});
|
||||
rsUniRenderVisitor->screenManager_ = screenManager;
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
|
||||
screenManager->SetVirtualScreenSecurityExemptionList(id, {1, 2}); // layerId for test
|
||||
rsUniRenderVisitor->screenManager_ = screenManager;
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
|
||||
screenManager->SetVirtualScreenSecurityExemptionList(id, {1, 2, 3}); // layerId for test
|
||||
rsUniRenderVisitor->screenManager_ = screenManager;
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
|
||||
screenManager->SetVirtualScreenSecurityExemptionList(id, {1, 3}); // layerId for test
|
||||
rsUniRenderVisitor->screenManager_ = screenManager;
|
||||
rsUniRenderVisitor->UpdateVirtualScreenSecurityExemption(*rsDisplayRenderNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsSubTreeOccluded001
|
||||
* @tc.desc: Test IsSubTreeOccluded with empty node
|
||||
|
@ -2164,6 +2164,104 @@ HWTEST_F(RSScreenManagerTest, SetVirtualScreenBlackList007, TestSize.Level1)
|
||||
ASSERT_EQ(screenManagerImpl.SetVirtualScreenBlackList(id, blackList), StatusCode::SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SetVirtualScreenSecurityExemptionList001
|
||||
* @tc.desc: Test SetVirtualScreenSecurityExemptionList with abnormal param
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSScreenManagerTest, SetVirtualScreenSecurityExemptionList001, TestSize.Level1)
|
||||
{
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
ASSERT_NE(nullptr, screenManager);
|
||||
OHOS::Rosen::impl::RSScreenManager& screenManagerImpl =
|
||||
static_cast<OHOS::Rosen::impl::RSScreenManager&>(*screenManager);
|
||||
|
||||
std::vector<uint64_t> securityExemptionList = {1, 2}; // id for test
|
||||
auto ret = screenManagerImpl.SetVirtualScreenSecurityExemptionList(INVALID_SCREEN_ID, securityExemptionList);
|
||||
ASSERT_EQ(ret, StatusCode::INVALID_ARGUMENTS);
|
||||
|
||||
ScreenId id = 11; // screenId for test
|
||||
ret = screenManagerImpl.SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
|
||||
ASSERT_EQ(ret, StatusCode::SCREEN_NOT_FOUND);
|
||||
|
||||
screenManagerImpl.screens_[id] = nullptr;
|
||||
ret = screenManagerImpl.SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
|
||||
ASSERT_EQ(ret, StatusCode::SCREEN_NOT_FOUND);
|
||||
|
||||
screenManagerImpl.screens_[id] = std::make_unique<impl::RSScreen>(id, false, nullptr, nullptr);
|
||||
ret = screenManagerImpl.SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
|
||||
ASSERT_EQ(ret, StatusCode::INVALID_ARGUMENTS);
|
||||
screenManagerImpl.screens_.erase(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SetVirtualScreenSecurityExemptionList002
|
||||
* @tc.desc: Test SetVirtualScreenSecurityExemptionList with normal param
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSScreenManagerTest, SetVirtualScreenSecurityExemptionList002, TestSize.Level1)
|
||||
{
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
ASSERT_NE(nullptr, screenManager);
|
||||
OHOS::Rosen::impl::RSScreenManager& screenManagerImpl =
|
||||
static_cast<OHOS::Rosen::impl::RSScreenManager&>(*screenManager);
|
||||
|
||||
ScreenId id = 1;
|
||||
std::vector<uint64_t> securityExemptionList = {1, 2}; // id for test
|
||||
screenManagerImpl.screens_[id] = std::make_unique<impl::RSScreen>(id, true, nullptr, nullptr);
|
||||
auto ret = screenManagerImpl.SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
|
||||
ASSERT_EQ(ret, StatusCode::SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: GetVirtualScreenSecurityExemptionList001
|
||||
* @tc.desc: Test GetVirtualScreenSecurityExemptionList with abnormal param
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSScreenManagerTest, GetVirtualScreenSecurityExemptionList001, TestSize.Level1)
|
||||
{
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
ASSERT_NE(nullptr, screenManager);
|
||||
OHOS::Rosen::impl::RSScreenManager& screenManagerImpl =
|
||||
static_cast<OHOS::Rosen::impl::RSScreenManager&>(*screenManager);
|
||||
|
||||
auto securityExemptionListGet = screenManagerImpl.GetVirtualScreenSecurityExemptionList(INVALID_SCREEN_ID);
|
||||
ASSERT_EQ(securityExemptionListGet.size(), 0);
|
||||
|
||||
ScreenId id = 1;
|
||||
screenManagerImpl.screens_[id] = nullptr;
|
||||
securityExemptionListGet = screenManagerImpl.GetVirtualScreenSecurityExemptionList(id);
|
||||
ASSERT_EQ(securityExemptionListGet.size(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: GetVirtualScreenSecurityExemptionList002
|
||||
* @tc.desc: Test GetVirtualScreenSecurityExemptionList with normal param
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSScreenManagerTest, GetVirtualScreenSecurityExemptionList002, TestSize.Level1)
|
||||
{
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
ASSERT_NE(nullptr, screenManager);
|
||||
OHOS::Rosen::impl::RSScreenManager& screenManagerImpl =
|
||||
static_cast<OHOS::Rosen::impl::RSScreenManager&>(*screenManager);
|
||||
|
||||
ScreenId id = 1;
|
||||
std::vector<uint64_t> securityExemptionList = {1, 2}; // id for test
|
||||
screenManagerImpl.screens_[id] = std::make_unique<impl::RSScreen>(id, true, nullptr, nullptr);
|
||||
auto ret = screenManagerImpl.SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
|
||||
ASSERT_EQ(ret, StatusCode::SUCCESS);
|
||||
auto securityExemptionListGet = screenManagerImpl.GetVirtualScreenSecurityExemptionList(id);
|
||||
ASSERT_EQ(securityExemptionListGet.size(), securityExemptionList.size());
|
||||
for (auto i = 0; i < securityExemptionList.size(); i++) {
|
||||
ASSERT_EQ(securityExemptionListGet[i], securityExemptionList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SetCastScreenEnableSkipWindow001
|
||||
* @tc.desc: Test SetCastScreenEnableSkipWindow, input id not in keys of screens_
|
||||
|
@ -1789,4 +1789,44 @@ HWTEST_F(RSScreenTest, GetVirtualScreenStatus_001, testing::ext::TestSize.Level1
|
||||
ASSERT_EQ(rsScreen->GetVirtualScreenStatus(), VirtualScreenStatus::VIRTUAL_SCREEN_PLAY);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SetSecurityExemptionList_001
|
||||
* @tc.desc: SetSecurityExemptionList Test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSScreenTest, SetSecurityExemptionList_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
ScreenId id = 0;
|
||||
auto rsScreen = std::make_unique<impl::RSScreen>(id, false, nullptr, nullptr);
|
||||
ASSERT_NE(nullptr, rsScreen);
|
||||
|
||||
std::vector<uint64_t> securityExemptionList = {1, 2}; // id for test
|
||||
rsScreen->SetSecurityExemptionList(securityExemptionList);
|
||||
ASSERT_EQ(rsScreen->securityExemptionList_.size(), securityExemptionList.size());
|
||||
for (auto i = 0; i < securityExemptionList.size(); i++) {
|
||||
ASSERT_EQ(rsScreen->securityExemptionList_[i], securityExemptionList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: GetSecurityExemptionList_001
|
||||
* @tc.desc: GetSecurityExemptionList Test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1YAT
|
||||
*/
|
||||
HWTEST_F(RSScreenTest, GetSecurityExemptionList_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
ScreenId id = 0;
|
||||
auto rsScreen = std::make_unique<impl::RSScreen>(id, false, nullptr, nullptr);
|
||||
ASSERT_NE(nullptr, rsScreen);
|
||||
|
||||
std::vector<uint64_t> securityExemptionList = {1, 2}; // id for test
|
||||
rsScreen->securityExemptionList_ = securityExemptionList;
|
||||
auto securityExemptionListGet = rsScreen->GetSecurityExemptionList();
|
||||
ASSERT_EQ(securityExemptionListGet.size(), securityExemptionList.size());
|
||||
for (auto i = 0; i < securityExemptionList.size(); i++) {
|
||||
ASSERT_EQ(securityExemptionListGet[i], securityExemptionList[i]);
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
Loading…
Reference in New Issue
Block a user