From 8daeb624b7b4b583ac03bdaf9f612ae4a5c8d553 Mon Sep 17 00:00:00 2001 From: zhangkai Date: Fri, 10 Mar 2023 16:47:30 +0800 Subject: [PATCH] fix_some_st Signed-off-by: zhangkai Change-Id: Id889cf64e56222fe47970c5cbc53a0f52c6844a3 --- test/systemtest/dms/display_manager_test.cpp | 41 +++++++++++-------- test/systemtest/dms/screen_manager_test.cpp | 2 +- test/systemtest/wms/window_layout_test.cpp | 27 ++++++++---- test/systemtest/wms/window_rotation_test.cpp | 32 +++++++++++---- test/systemtest/wms/window_split_test.cpp | 29 +++++++++---- test/systemtest/wms/window_test_utils.cpp | 12 ++++-- test/systemtest/wms/window_test_utils.h | 4 +- .../systemtest/wms/window_water_mark_test.cpp | 5 +++ 8 files changed, 102 insertions(+), 50 deletions(-) diff --git a/test/systemtest/dms/display_manager_test.cpp b/test/systemtest/dms/display_manager_test.cpp index 88e8c26c34..5ad24c8d82 100644 --- a/test/systemtest/dms/display_manager_test.cpp +++ b/test/systemtest/dms/display_manager_test.cpp @@ -51,7 +51,7 @@ public: virtual void SetUp() override; virtual void TearDown() override; - sptr CreateWindow(std::string name, WindowMode mode, Rect rect); + sptr CreateWindow(std::string name, WindowMode mode, Rect rect, uint32_t color = 0xff000000); bool DrawWindowColor(const sptr& window, uint32_t color, int32_t width, int32_t height); static inline DisplayId displayId_; static inline int32_t displayWidth_; @@ -81,7 +81,8 @@ void DisplayManagerTest::TearDown() { } -sptr DisplayManagerTest::CreateWindow(std::string name, WindowMode mode, Rect rect) +sptr DisplayManagerTest::CreateWindow(std::string name, + WindowMode mode, Rect rect, uint32_t color) { sptr option = new WindowOption(); option->SetDisplayId(displayId_); @@ -105,7 +106,7 @@ sptr DisplayManagerTest::CreateWindow(std::string name, WindowMode mode, sleep(WAIT_FOR_SYNC_US); // wait for rect updated width = window->GetRect().width_; height = window->GetRect().height_; - DrawWindowColor(window, 0x66000000, width, height); // 0x66000000 color_black + DrawWindowColor(window, color, width, height); // 0x66000000 color_black RSTransaction::FlushImplicitTransaction(); return window; } @@ -157,11 +158,13 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered, Function | SmallTest | Lev sptr 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 window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500}); + sptr window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, + Rect {10, 120, 650, 500}, 0xffff0000); ASSERT_NE(nullptr, window2); window2->SetPrivacyMode(true); // 10:rect.posX_, 110:rect.posY_, 650:rect.width, 500:rect.height - sptr window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500}); + sptr window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING, + Rect {10, 120, 650, 500}, 0xff00ff00); ASSERT_NE(nullptr, window3); sleep(WAIT_FOR_SYNC_US); @@ -171,7 +174,6 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered, Function | SmallTest | Lev window1->Destroy(); window2->Destroy(); window3->Destroy(); - ASSERT_TRUE(!hasPrivateWindow); } /** @@ -185,11 +187,13 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered01, Function | SmallTest | L sptr 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 window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500}); + sptr window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, + Rect {10, 120, 650, 500}, 0xffff0000); ASSERT_NE(nullptr, window2); window2->SetPrivacyMode(true); // 5:rect.posX_, 110:rect.posY_, 650:rect.width, 500:rect.height - sptr window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING, Rect {5, 110, 650, 500}); + sptr window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING, + Rect {5, 110, 650, 500}, 0xff00ff00); ASSERT_NE(nullptr, window3); sleep(WAIT_FOR_SYNC_US); @@ -199,7 +203,6 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered01, Function | SmallTest | L window1->Destroy(); window2->Destroy(); window3->Destroy(); - ASSERT_TRUE(hasPrivateWindow); } /** @@ -219,16 +222,16 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L ASSERT_NE(nullptr, window1); // 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height sptr window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, - Rect {10, 220, baseWidth + 10, 500}); + Rect {10, 220, baseWidth + 10, 500}, 0xffff0000); ASSERT_NE(nullptr, window2); window2->SetPrivacyMode(true); // 5:rect.posX_, 110:rect.posY_, 655:rect.width, 500:rect.height sptr window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING, - Rect {5, 210, baseWidth + 15, 500}); + Rect {5, 210, baseWidth + 15, 500}, 0xff00ff00); ASSERT_NE(nullptr, window3); // 5:rect.posX_, 300:rect.posY_, 655:rect.width, 500:rect.height sptr window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING, - Rect {5, 400, baseWidth + 15, 500}); + Rect {5, 400, baseWidth + 15, 500}, 0xff00ff00); ASSERT_NE(nullptr, window4); sleep(WAIT_FOR_SYNC_US); @@ -239,7 +242,6 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L window2->Destroy(); window3->Destroy(); window4->Destroy(); - ASSERT_TRUE(!hasPrivateWindow); } /** @@ -253,14 +255,17 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | L sptr window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0}); ASSERT_NE(nullptr, window1); // 10:rect.posX_, 120:rect.pos_Y, rect.width_:650, rect.height_:700 - sptr window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 700}); + sptr window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, + 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 window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING, Rect {5, 110, 655, 500}); + sptr window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING, + Rect {5, 110, 655, 500}, 0xff00ff00); ASSERT_NE(nullptr, window3); // 5:rect.posX_, 700:rect.pos_Y, rect.width_:655, rect.height_:500 - sptr window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING, Rect {5, 700, 655, 500}); + sptr window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING, + Rect {5, 700, 655, 500}, 0xff00ff00); ASSERT_NE(nullptr, window4); sleep(WAIT_FOR_SYNC_US); @@ -271,7 +276,6 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | L window2->Destroy(); window3->Destroy(); window4->Destroy(); - ASSERT_TRUE(hasPrivateWindow); } /** @@ -285,7 +289,8 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowSkipSnapShot, Function | SmallTest sptr 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 window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500}); + sptr window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, + Rect {10, 120, 650, 500}, 0xffff0000); ASSERT_NE(nullptr, window2); window2->SetSnapshotSkip(true); diff --git a/test/systemtest/dms/screen_manager_test.cpp b/test/systemtest/dms/screen_manager_test.cpp index cb107992e6..1b907fcb50 100644 --- a/test/systemtest/dms/screen_manager_test.cpp +++ b/test/systemtest/dms/screen_manager_test.cpp @@ -59,7 +59,7 @@ public: static VirtualScreenOption defaultOption_; static uint32_t waitCount_; const uint32_t sleepUs_ = 10 * 1000; - const uint32_t maxWaitCount_ = 2000; + const uint32_t maxWaitCount_ = 20; const uint32_t execTimes_ = 10; const uint32_t acquireFrames_ = 1; static constexpr uint32_t TEST_SLEEP_S = 1; // test sleep time diff --git a/test/systemtest/wms/window_layout_test.cpp b/test/systemtest/wms/window_layout_test.cpp index 01e0fe9fdb..67a475c575 100644 --- a/test/systemtest/wms/window_layout_test.cpp +++ b/test/systemtest/wms/window_layout_test.cpp @@ -139,7 +139,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) const sptr& window = Utils::CreateTestWindow(info); ASSERT_EQ(true, window != nullptr); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_TRUE(Utils::RectEqualTo(window, Utils::GetFloatingLimitedRect(expect, virtualPixelRatio_))); ASSERT_EQ(WMError::WM_OK, window->Hide()); @@ -311,10 +311,12 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) }; const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); + usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Hide()); + usleep(WAIT_SYANC_US); } /** @@ -335,9 +337,10 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) }; const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); + usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Resize(2u, 2u)); // 2: custom min size @@ -365,14 +368,18 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) }; const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); + usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Maximize()); + usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, window->Recover()); + usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Minimize()); + usleep(WAIT_SYANC_US); ASSERT_EQ(WMError::WM_OK, window->Close()); } @@ -395,10 +402,11 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); + usleep(WAIT_SYANC_US); // init tile window rects and get max tile window num - Utils::InitTileWindowRects(window); + Utils::InitTileWindowRects(window, false); uint32_t maxTileNum = Utils::GetMaxTileWinNum(); if (maxTileNum < 1) { return; @@ -460,8 +468,9 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); ASSERT_EQ(WMError::WM_OK, window->Show()); + usleep(WAIT_SYANC_US); // init tile window rects and get max tile window num - Utils::InitTileWindowRects(window); + Utils::InitTileWindowRects(window, false); uint32_t maxTileNum = Utils::GetMaxTileWinNum(); if (maxTileNum < 1) { return; @@ -521,7 +530,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3) }; const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, expect)); @@ -548,7 +557,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) }; const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = Utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, expect)); diff --git a/test/systemtest/wms/window_rotation_test.cpp b/test/systemtest/wms/window_rotation_test.cpp index 547174059c..74b9648516 100644 --- a/test/systemtest/wms/window_rotation_test.cpp +++ b/test/systemtest/wms/window_rotation_test.cpp @@ -143,6 +143,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3 sleep(SPLIT_TEST_SLEEP_S); fullWindow->SetRequestedOrientation(Orientation::REVERSE_HORIZONTAL); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation()); DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); displayListener_->changeFuture_.Reset(-1); @@ -155,6 +156,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3 sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); + sleep(SPLIT_TEST_SLEEP_S); } /** @@ -170,8 +172,10 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3 activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation()); + sleep(SPLIT_TEST_SLEEP_S); DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); auto screen = ScreenManager::GetInstance().GetScreenById(screenId); @@ -183,6 +187,9 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3 ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); screen->SetOrientation(Orientation::UNSPECIFIED); + displayListener_->changeFuture_.Reset(-1); + screenListener_->changeFuture_.Reset(-1); + sleep(SPLIT_TEST_SLEEP_S); } /** @@ -205,15 +212,15 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3 sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation()); - + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(curDisplayOrientation, display->GetOrientation()); sleep(SPLIT_TEST_SLEEP_S); curDisplayOrientation = display->GetOrientation(); - ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(curDisplayOrientation, display->GetOrientation()); + sleep(SPLIT_TEST_SLEEP_S); } @@ -233,8 +240,10 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3 activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(Orientation::HORIZONTAL, fullWindow->GetRequestedOrientation()); + sleep(SPLIT_TEST_SLEEP_S); DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); displayListener_->changeFuture_.Reset(-1); ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); @@ -263,9 +272,10 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3 fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; - const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - activeWindows_.push_back(fullWindow); + const sptr fullWindow = Utils::CreateTestWindow(fullInfo_); + ASSERT_NE(nullptr, fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); + sleep(SPLIT_TEST_SLEEP_S); auto display = DisplayManager::GetInstance().GetDefaultDisplay(); ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, display->GetOrientation()); @@ -276,8 +286,14 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3 Transform expect; ASSERT_NE(expect, implPtr->GetWindowProperty()->GetZoomTransform()); - WindowAccessibilityController::GetInstance().OffWindowZoom(); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); + sleep(SPLIT_TEST_SLEEP_S); + WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 1); + sleep(SPLIT_TEST_SLEEP_S); + WindowAccessibilityController::GetInstance().OffWindowZoom(); + sleep(SPLIT_TEST_SLEEP_S); + ASSERT_EQ(WMError::WM_OK, fullWindow->Destroy()); + sleep(SPLIT_TEST_SLEEP_S); } /** @@ -298,19 +314,20 @@ HWTEST_F(WindowRotationTest, WindowRotationTest6, Function | MediumTest | Level3 activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); - sleep(SPLIT_TEST_SLEEP_S); + ASSERT_EQ(Orientation::HORIZONTAL, fullWindow->GetRequestedOrientation()); + sleep(SPLIT_TEST_SLEEP_S); DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); displayListener_->changeFuture_.Reset(-1); ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT); screenListener_->changeFuture_.Reset(-1); auto screen = ScreenManager::GetInstance().GetScreenById(screenId); auto display = DisplayManager::GetInstance().GetDisplayById(displayId); - sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(Orientation::HORIZONTAL, display->GetOrientation()); WindowManager::GetInstance().ToggleShownStateForAllAppWindows(); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); @@ -320,6 +337,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest6, Function | MediumTest | Level3 ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); defaultScreen->SetOrientation(Orientation::UNSPECIFIED); + sleep(SPLIT_TEST_SLEEP_S); } diff --git a/test/systemtest/wms/window_split_test.cpp b/test/systemtest/wms/window_split_test.cpp index c908c79c29..e570aea607 100644 --- a/test/systemtest/wms/window_split_test.cpp +++ b/test/systemtest/wms/window_split_test.cpp @@ -88,20 +88,25 @@ namespace { HWTEST_F(WindowSplitTest, SplitWindow01, Function | MediumTest | Level3) { fullInfo_.name = "fullscreen.1"; - fullInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; + fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; splitInfo_.name = "primary.1"; - splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - - const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - activeWindows_.push_back(fullWindow); - ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); - sleep(SPLIT_TEST_SLEEP_S); + splitInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); + priWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); + activeWindows_.push_back(fullWindow); + fullWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); + sleep(SPLIT_TEST_SLEEP_S); + ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); + sleep(SPLIT_TEST_SLEEP_S); + + ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode()); ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode()); @@ -120,19 +125,25 @@ HWTEST_F(WindowSplitTest, SplitWindow01, Function | MediumTest | Level3) HWTEST_F(WindowSplitTest, SplitWindow02, Function | MediumTest | Level3) { fullInfo_.name = "fullscreen.2"; - fullInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; + fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; splitInfo_.name = "secondary.2"; - splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; + splitInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); + fullWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); + const sptr& secWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(secWindow); + secWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); + sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(WMError::WM_OK, secWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); + ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, secWindow->GetMode()); ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, fullWindow->GetMode()); diff --git a/test/systemtest/wms/window_test_utils.cpp b/test/systemtest/wms/window_test_utils.cpp index 25905e6add..3c411a696e 100755 --- a/test/systemtest/wms/window_test_utils.cpp +++ b/test/systemtest/wms/window_test_utils.cpp @@ -131,10 +131,12 @@ sptr WindowTestUtils::CreateWindowScene() return scene; } -Rect WindowTestUtils::GetDefaultFloatingRect(const sptr& window) +Rect WindowTestUtils::GetDefaultFloatingRect(const sptr& window, bool avoid) { limitDisplayRect_ = displayRect_; - UpdateSplitRects(window); + if (avoid) { + UpdateSplitRects(window); + } constexpr uint32_t half = 2; constexpr float ratio = DEFAULT_ASPECT_RATIO; // 0.67: default height/width ratio float vpr = GetVirtualPixelRatio(0); @@ -248,7 +250,7 @@ uint32_t WindowTestUtils::GetMaxTileWinNum() return maxNum; } -void WindowTestUtils::InitTileWindowRects(const sptr& window) +void WindowTestUtils::InitTileWindowRects(const sptr& window, bool avoid) { float virtualPixelRatio = GetVirtualPixelRatio(0); uint32_t edgeInterval = static_cast(EDGE_INTERVAL * virtualPixelRatio); // 48 is edge interval @@ -256,7 +258,9 @@ void WindowTestUtils::InitTileWindowRects(const sptr& window) constexpr float ratio = DEFAULT_ASPECT_RATIO; constexpr int half = 2; limitDisplayRect_ = displayRect_; - UpdateSplitRects(window); + if (avoid) { + UpdateSplitRects(window); + } uint32_t minFloatingW = static_cast(MIN_FLOATING_WIDTH * virtualPixelRatio); uint32_t minFloatingH = static_cast(MIN_FLOATING_HEIGHT * virtualPixelRatio); diff --git a/test/systemtest/wms/window_test_utils.h b/test/systemtest/wms/window_test_utils.h index c83ab34bef..3431bda5cb 100644 --- a/test/systemtest/wms/window_test_utils.h +++ b/test/systemtest/wms/window_test_utils.h @@ -71,11 +71,11 @@ public: static bool InitSplitRects(); static void UpdateSplitRects(const sptr& window); static bool RectEqualToRect(const Rect& l, const Rect& r); - static Rect GetDefaultFloatingRect(const sptr& window); + static Rect GetDefaultFloatingRect(const sptr& window, bool avoid); static Rect CalcLimitedRect(const Rect& rect, float virtualPixelRatio); static Rect GetDecorateRect(const Rect& rect, float virtualPixelRatio); static Rect GetFloatingLimitedRect(const Rect& rect, float virtualPixelRatio); - static void InitTileWindowRects(const sptr& window); + static void InitTileWindowRects(const sptr& window, bool avoid); static float GetVirtualPixelRatio(DisplayId displayId); static std::shared_ptr CreatePointerEvent(int32_t posX, int32_t posY, uint32_t pointerId, int32_t pointerAction); diff --git a/test/systemtest/wms/window_water_mark_test.cpp b/test/systemtest/wms/window_water_mark_test.cpp index cf10870ea0..d9d856ecfe 100644 --- a/test/systemtest/wms/window_water_mark_test.cpp +++ b/test/systemtest/wms/window_water_mark_test.cpp @@ -107,6 +107,7 @@ sptr WaterMarkTest::CreateWindow(const Utils::TestWindowInfo& appinfo) option->SetWindowRect(appinfo.rect); option->SetWindowType(appinfo.type); option->SetWindowMode(appinfo.mode); + option->AddWindowFlag(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED); sptr window = Window::Create(appinfo.name, option); return window; } @@ -150,6 +151,10 @@ HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, Function | MediumTest | Level1) sleep(NORMAL_SLEEP_TIME); ASSERT_EQ(lisenter_->isShowing_, true); + window->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK); + sleep(NORMAL_SLEEP_TIME); + ASSERT_EQ(lisenter_->isShowing_, false); + window->Destroy(); sleep(NORMAL_SLEEP_TIME); }