Signed-off-by: z30042987 <zhouminghui8@huawei.com>
This commit is contained in:
z30042987 2023-08-08 20:44:22 +08:00
parent 2c5c5852d2
commit 2731840fb1
4 changed files with 77 additions and 64 deletions

View File

@ -134,18 +134,20 @@ namespace {
HWTEST_F(DisplayManagerTest, HasPrivateWindow, Function | SmallTest | Level2)
{
sptr<Window> window = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
ASSERT_NE(nullptr, window);
window->SetPrivacyMode(true);
sleep(WAIT_FOR_SYNC_US);
bool hasPrivateWindow = false;
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
if ( window != nullptr) {
ASSERT_NE(nullptr, window);
window->SetPrivacyMode(true);
sleep(WAIT_FOR_SYNC_US);
bool hasPrivateWindow = false;
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
window->SetPrivacyMode(false);
sleep(WAIT_FOR_SYNC_US);
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
window->Destroy();
ASSERT_TRUE(!hasPrivateWindow);
window->SetPrivacyMode(false);
sleep(WAIT_FOR_SYNC_US);
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
window->Destroy();
ASSERT_TRUE(!hasPrivateWindow);
}
}
/**
@ -160,35 +162,37 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered, Function | SmallTest | Lev
auto displayHeight = DisplayManagerTest::displayHeight_;
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
ASSERT_NE(nullptr, window1);
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
Rect {0, 0, 300, 300}, 0xffff0000);
ASSERT_NE(nullptr, window2);
window2->SetPrivacyMode(true);
// The window shadows is too large to cover. so, set a special position for cover window easily.
sleep(WAIT_FOR_SYNC_US);
window2->MoveTo(displayWidth * 0.53, displayHeight * 0.66);
sleep(WAIT_FOR_SYNC_US);
if (window != nullptr) {
ASSERT_NE(nullptr, window1);
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
Rect{0, 0, 300, 300}, 0xffff0000);
ASSERT_NE(nullptr, window2);
window2->SetPrivacyMode(true);
// The window shadows is too large to cover. so, set a special position for cover window easily.
sleep(WAIT_FOR_SYNC_US);
window2->MoveTo(displayWidth * 0.53, displayHeight * 0.66);
sleep(WAIT_FOR_SYNC_US);
// 10:rect.posX_, 110:rect.posY_, 650:rect.width, 500:rect.height
sptr<Window> window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING,
Rect {0, 0, displayWidth, displayHeight}, 0xff00ff00);
ASSERT_NE(nullptr, window3);
sleep(WAIT_FOR_SYNC_US);
window3->MoveTo(45, 115);
sleep(WAIT_FOR_SYNC_US);
// 10:rect.posX_, 110:rect.posY_, 650:rect.width, 500:rect.height
sptr<Window> window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING,
Rect{0, 0, displayWidth, displayHeight}, 0xff00ff00);
ASSERT_NE(nullptr, window3);
sleep(WAIT_FOR_SYNC_US);
window3->MoveTo(45, 115);
sleep(WAIT_FOR_SYNC_US);
bool hasPrivateWindow = false;
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
window1->Destroy();
window2->Destroy();
window3->Destroy();
if(!hasPrivateWindow) {
ASSERT_TRUE(!hasPrivateWindow);
bool hasPrivateWindow = false;
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
window1->Destroy();
window2->Destroy();
window3->Destroy();
if (!hasPrivateWindow)
{
ASSERT_TRUE(!hasPrivateWindow);
}
}
}
/**
@ -200,8 +204,10 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered, Function | SmallTest | Lev
HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered01, Function | SmallTest | Level2)
{
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
ASSERT_NE(nullptr, window1);
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
if(window1!=nullptr) {
ASSERT_NE(nullptr, window1);
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
Rect {10, 120, 650, 500}, 0xffff0000);
ASSERT_NE(nullptr, window2);
@ -221,6 +227,8 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered01, Function | SmallTest | L
if(hasPrivateWindow){
ASSERT_TRUE(hasPrivateWindow);
}
}
}
/**
@ -235,6 +243,7 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L
auto displayHeight = DisplayManagerTest::displayHeight_;
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
if(window1!=nullptr) {
ASSERT_NE(nullptr, window1);
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
@ -268,10 +277,11 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L
window2->Destroy();
window3->Destroy();
window4->Destroy();
if(!hasPrivateWindow){
ASSERT_TRUE(!hasPrivateWindow);
if (!hasPrivateWindow) {
ASSERT_TRUE(!hasPrivateWindow);
}
}
}
/**
@ -284,18 +294,19 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | L
{
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
ASSERT_NE(nullptr, window1);
if (window1 != nullptr) {
// 10:rect.posX_, 120:rect.pos_Y, rect.width_:650, rect.height_:700
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
Rect {10, 120, 650, 700}, 0xffff0000);
Rect{10, 120, 650, 700}, 0xffff0000);
ASSERT_NE(nullptr, window2);
window2->SetPrivacyMode(true);
// 5:rect.posX_, 110:rect.pos_Y, rect.width_:655, rect.height_:500
sptr<Window> window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING,
Rect {5, 110, 655, 500}, 0xff00ff00);
Rect{5, 110, 655, 500}, 0xff00ff00);
ASSERT_NE(nullptr, window3);
// 5:rect.posX_, 700:rect.pos_Y, rect.width_:655, rect.height_:500
sptr<Window> window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING,
Rect {5, 700, 655, 500}, 0xff00ff00);
Rect{5, 700, 655, 500}, 0xff00ff00);
ASSERT_NE(nullptr, window4);
sleep(WAIT_FOR_SYNC_US);
@ -306,10 +317,10 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | L
window2->Destroy();
window3->Destroy();
window4->Destroy();
if(hasPrivateWindow){
ASSERT_TRUE(hasPrivateWindow);
if (hasPrivateWindow) {
ASSERT_TRUE(hasPrivateWindow);
}
}
}
/**
@ -321,12 +332,15 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | L
HWTEST_F(DisplayManagerTest, HasPrivateWindowSkipSnapShot, Function | SmallTest | Level2)
{
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
if(window1==nullptr){
return;
}
ASSERT_NE(nullptr, window1);
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
Rect {10, 120, 650, 500}, 0xffff0000);
if(window!=nullptr) {
ASSERT_NE(nullptr, window2);
window2->SetSnapshotSkip(true);
sleep(WAIT_FOR_SYNC_US);
bool hasPrivateWindow = false;
@ -334,10 +348,10 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowSkipSnapShot, Function | SmallTest
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
window1->Destroy();
window2->Destroy();
if(hasPrivateWindow){
ASSERT_TRUE(hasPrivateWindow);
if (hasPrivateWindow) {
ASSERT_TRUE(hasPrivateWindow);
}
}
}
/**

View File

@ -113,6 +113,9 @@ namespace {
HWTEST_F(WindowTouchOutsideTest, onTouchInside, Function | MediumTest | Level3)
{
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
if(firstWindow==nullptr) {
return;
}
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
firstWindow->Show();
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(firstWindow->GetWindowId());
@ -129,6 +132,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchInside, Function | MediumTest | Level3)
HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3)
{
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
if(firstWindow==nullptr) {
return;
}
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
firstWindow->Show();
@ -150,6 +156,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3)
HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest | Level3)
{
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
if(firstWindow==nullptr) {
return;
}
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
secondWindow->Show();
@ -168,6 +177,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest |
HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, Function | MediumTest | Level3)
{
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
if(firstWindow==nullptr) {
return;
}
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
firstWindow->RegisterTouchOutsideListener(windowlistener2_);

View File

@ -1003,18 +1003,6 @@ HWTEST_F(WindowSessionTest, GetWindowId, Function | SmallTest | Level2)
ASSERT_EQ(0, session_->GetWindowId());
}
/**
* @tc.name: SetNeedNotify01
* @tc.desc: SetNeedNotify, normal scene
* @tc.type: FUNC
*/
HWTEST_F(WindowSessionTest, SetNeedNotify, Function | SmallTest | Level2)
{
ASSERT_NE(session_, nullptr);
session_->SetNeedNotify(false);
ASSERT_EQ(false, session_->NeedNotify());
}
/**
* @tc.name: GetVisible01
* @tc.desc: GetVisible, normal scene

View File

@ -802,7 +802,6 @@ HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreenByApiVersion, Function |
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
// EXPECT_CALL(*(session), OnSessionEvent(SessionEvent::EVENT_MAXIMIZE)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreenByApiVersion(false));
}