mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-08-26 21:31:14 -04:00
add ut and st
Signed-off-by: l00574490 <liuqi149@huawei.com> Change-Id: Ib4b25174f1d7d32630276f7a175654ad3b7e8154
This commit is contained in:
+2
-1
@@ -90,7 +90,8 @@
|
||||
],
|
||||
"test": [
|
||||
"//foundation/windowmanager/wm:test",
|
||||
"//foundation/windowmanager/dm:test"
|
||||
"//foundation/windowmanager/dm:test",
|
||||
"//foundation/windowmanager/wmserver:test"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +584,10 @@ WMError WindowImpl::Destroy()
|
||||
|
||||
// FixMe: Remove "NotifyBeforeDestroy()" because of ACE bug, add when fixed
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().DestroyWindow(property_->GetWindowId());
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("destroy window failed with errCode:%{public}d", static_cast<int32_t>(ret));
|
||||
return ret;
|
||||
}
|
||||
windowMap_.erase(GetWindowName());
|
||||
if (subWindowMap_.count(property_->GetParentId()) > 0) { // remove from subWindowMap_
|
||||
std::vector<sptr<Window>>& subWindows = subWindowMap_.at(property_->GetParentId());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "pointer_event.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_impl.h"
|
||||
#include "window_test_utils.h"
|
||||
#include "wm_common_inner.h"
|
||||
using namespace testing;
|
||||
@@ -43,9 +44,8 @@ private:
|
||||
uint32_t pointerId,
|
||||
int32_t pointerAction);
|
||||
void CalExpectRects();
|
||||
void DoMoveOrDrag();
|
||||
void DoMoveOrDrag(bool isMove, bool isDrag);
|
||||
static inline std::vector<sptr<Window>> activeWindows_;
|
||||
static inline utils::TestWindowInfo winInfo_;
|
||||
static inline uint32_t pointerId_ = 0;
|
||||
static inline int32_t pointX_ = 0;
|
||||
static inline int32_t pointY_ = 0;
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
static inline bool hasStartMove_ = false;
|
||||
static inline Rect startPointRect_ = {0, 0, 0, 0};
|
||||
static inline Rect expectRect_ = {0, 0, 0, 0};
|
||||
static inline sptr<Window> window_ = nullptr;
|
||||
static inline sptr<WindowImpl> window_ = nullptr;
|
||||
static inline float virtualPixelRatio_ = 0.0;
|
||||
static inline uint32_t hotZone_ = 0;
|
||||
};
|
||||
@@ -65,9 +65,8 @@ void WindowMoveDragTest::SetUpTestCase()
|
||||
startPointY_ = 0;
|
||||
pointX_ = 0;
|
||||
pointY_ = 0;
|
||||
startPointRect_ = {0, 0, 0, 0};
|
||||
expectRect_ = {0, 0, 0, 0};
|
||||
winInfo_.rect = {0, 0, 0, 0};
|
||||
startPointRect_ = {0, 0, 0, 0};
|
||||
expectRect_ = {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
void WindowMoveDragTest::TearDownTestCase()
|
||||
@@ -89,16 +88,12 @@ void WindowMoveDragTest::SetUp()
|
||||
virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
hotZone_ = static_cast<uint32_t>(HOTZONE * virtualPixelRatio_);
|
||||
|
||||
winInfo_ = {
|
||||
.name = "Floating",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = true,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
window_ = utils::CreateTestWindow(winInfo_);
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowMoveDragTest");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
window_ = new WindowImpl(option);
|
||||
window_->Create("");
|
||||
ASSERT_TRUE((window_ != nullptr));
|
||||
}
|
||||
|
||||
@@ -125,7 +120,7 @@ std::shared_ptr<MMI::PointerEvent> WindowMoveDragTest::CreatePointerEvent(int32_
|
||||
return pointerEvent;
|
||||
}
|
||||
|
||||
void WindowMoveDragTest::DoMoveOrDrag()
|
||||
void WindowMoveDragTest::DoMoveOrDrag(bool isMove, bool isDrag)
|
||||
{
|
||||
pointerId_++;
|
||||
std::shared_ptr<MMI::PointerEvent> pointerEvent =
|
||||
@@ -137,6 +132,8 @@ void WindowMoveDragTest::DoMoveOrDrag()
|
||||
window_->ConsumePointerEvent(pointerEvent);
|
||||
CalExpectRects();
|
||||
ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_));
|
||||
ASSERT_EQ(isMove, window_->startMoveFlag_);
|
||||
ASSERT_EQ(isDrag, window_->startDragFlag_);
|
||||
|
||||
pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_UP);
|
||||
window_->ConsumePointerEvent(pointerEvent);
|
||||
@@ -198,7 +195,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow01, Function | MediumTest | Level3)
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ * POINT_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -217,7 +214,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow02, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -236,7 +233,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow03, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -255,7 +252,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow04, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -274,7 +271,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow05, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -293,7 +290,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow06, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -312,7 +309,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow07, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ - hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -331,7 +328,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow08, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, true);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -350,7 +347,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow09, Function | MediumTest | Level3)
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(false, false);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
@@ -371,7 +368,26 @@ HWTEST_F(WindowMoveDragTest, DragWindow10, Function | MediumTest | Level3)
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
window_->StartMove();
|
||||
hasStartMove_ = true;
|
||||
DoMoveOrDrag();
|
||||
DoMoveOrDrag(true, false);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DragWindow11
|
||||
* @tc.desc: drag inner
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000GGTV8
|
||||
*/
|
||||
HWTEST_F(WindowMoveDragTest, DragWindow11, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag(false, false);
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
utils::TestWindowInfo splitInfo_;
|
||||
|
||||
private:
|
||||
static constexpr uint32_t SPLIT_TEST_SPEEP_S = 1; // split test spleep time
|
||||
static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time
|
||||
};
|
||||
|
||||
void WindowSplitImmersiveTest::SetUpTestCase()
|
||||
@@ -96,14 +96,14 @@ HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Lev
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
// enter split mode
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
// check is enter split Immersive
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode());
|
||||
@@ -111,11 +111,11 @@ HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Lev
|
||||
Rect immersivePriRect = priWindow->GetRect();
|
||||
ASSERT_EQ(0, immersivePriRect.posX_);
|
||||
ASSERT_EQ(0, immersivePriRect.posY_);
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
// Exit split Mode.
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
// check is out split Immersive
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
@@ -125,9 +125,9 @@ HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Lev
|
||||
ASSERT_EQ(avoidArea.topRect.height_, curFullScreenRect.posY_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
utils::TestWindowInfo splitInfo_;
|
||||
|
||||
private:
|
||||
static constexpr uint32_t SPLIT_TEST_SPEEP_S = 1; // split test spleep time
|
||||
static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time
|
||||
};
|
||||
|
||||
void WindowSplitTest::SetUpTestCase()
|
||||
@@ -93,21 +93,21 @@ HWTEST_F(WindowSplitTest, SplitWindow01, Function | MediumTest | Level3)
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,20 +125,20 @@ HWTEST_F(WindowSplitTest, SplitWindow02, Function | MediumTest | Level3)
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
const sptr<Window>& secWindow = utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(secWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, secWindow->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, fullWindow->GetMode());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, secWindow->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,11 +158,11 @@ HWTEST_F(WindowSplitTest, SplitCreen03, Function | MediumTest | Level3)
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
utils::UpdateSplitRects(fullWindow);
|
||||
|
||||
@@ -170,9 +170,9 @@ HWTEST_F(WindowSplitTest, SplitCreen03, Function | MediumTest | Level3)
|
||||
ASSERT_TRUE(utils::RectEqualTo(priWindow, utils::splitRects_.primaryRect));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,11 +192,11 @@ HWTEST_F(WindowSplitTest, SplitCreen04, Function | MediumTest | Level3)
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
const sptr<Window>& secWindow = utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(secWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Show());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
utils::UpdateSplitRects(fullWindow);
|
||||
|
||||
@@ -204,9 +204,9 @@ HWTEST_F(WindowSplitTest, SplitCreen04, Function | MediumTest | Level3)
|
||||
ASSERT_TRUE(utils::RectEqualTo(secWindow, utils::splitRects_.secondaryRect));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Hide());
|
||||
sleep(SPLIT_TEST_SPEEP_S);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha));
|
||||
MOCK_METHOD2(SaveAbilityToken, WMError(const sptr<IRemoteObject>& abilityToken, uint32_t windowId));
|
||||
MOCK_METHOD3(SetSystemBarProperty, WMError(uint32_t windowId, WindowType type, const SystemBarProperty& property));
|
||||
MOCK_METHOD3(ResizeRect, WMError(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason));
|
||||
};
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -636,7 +636,7 @@ HWTEST_F(WindowImplTest, Recover01, Function | SmallTest | Level3)
|
||||
option->SetWindowName("WindowImplTest_Recover01");
|
||||
auto window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m_->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Create("");
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
@@ -775,6 +775,184 @@ HWTEST_F(WindowImplTest, GetColorSpace01, Function | SmallTest | Level3)
|
||||
window->SetColorSpace(ColorSpace::COLOR_SPACE_WIDE_GAMUT);
|
||||
ASSERT_EQ(ColorSpace::COLOR_SPACE_WIDE_GAMUT, window->GetColorSpace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MoveTo01
|
||||
* @tc.desc: create window but not show, move window, test rect
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, MoveTo01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_MoveTo01");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
Rect winRect = {10, 20, 30u, 40u}; // set window rect: 10, 20, 30, 40
|
||||
option->SetWindowRect(winRect);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
|
||||
ASSERT_FALSE(window->GetShowState());
|
||||
const float moveRatio = 0.5;
|
||||
Rect newRect = {winRect.posX_ * moveRatio, winRect.posY_ * moveRatio, winRect.width_, winRect.height_};
|
||||
window->MoveTo(newRect.posX_, newRect.posY_);
|
||||
ASSERT_EQ(newRect, window->GetRect());
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MoveTo02
|
||||
* @tc.desc: create and show window, move mvoe window return WM_ERROR_SAMGR, test rect
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, MoveTo02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_MoveTo02");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
Rect winRect = {10, 20, 30u, 40u}; // set window rect: 10, 20, 30, 40
|
||||
option->SetWindowRect(winRect);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Show();
|
||||
ASSERT_TRUE(window->GetShowState());
|
||||
EXPECT_CALL(m->Mock(), ResizeRect(_, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
|
||||
const float moveRatio = 0.5;
|
||||
Rect newRect = {winRect.posX_ * moveRatio, winRect.posY_ * moveRatio, winRect.width_, winRect.height_};
|
||||
window->MoveTo(newRect.posX_, newRect.posY_);
|
||||
ASSERT_EQ(winRect, window->GetRect());
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Resize01
|
||||
* @tc.desc: create window but not show, resize window, test rect
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, Resize01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_Resize01");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
Rect winRect = {10, 20, 30u, 40u}; // set window rect: 10, 20, 30, 40
|
||||
option->SetWindowRect(winRect);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
|
||||
ASSERT_FALSE(window->GetShowState());
|
||||
const float resizeRatio = 0.5;
|
||||
Rect newRect = {winRect.posX_, winRect.posY_, winRect.width_ * resizeRatio, winRect.height_ * resizeRatio};
|
||||
window->Resize(newRect.width_, newRect.height_);
|
||||
ASSERT_EQ(newRect, window->GetRect());
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Resize02
|
||||
* @tc.desc: create and show window, mock resize window return WM_ERROR_SAMGR, test rect
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, Resize02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_Resize02");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
Rect winRect = {10, 20, 30u, 40u}; // set window rect: 10, 20, 30, 40
|
||||
option->SetWindowRect(winRect);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Show();
|
||||
ASSERT_TRUE(window->GetShowState());
|
||||
EXPECT_CALL(m->Mock(), ResizeRect(_, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
|
||||
const float resizeRatio = 0.5;
|
||||
Rect newRect = {winRect.posX_, winRect.posY_, winRect.width_ * resizeRatio, winRect.height_ * resizeRatio};
|
||||
window->Resize(newRect.width_, newRect.height_);
|
||||
ASSERT_EQ(winRect, window->GetRect());
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartMove01
|
||||
* @tc.desc: start move main fullscreen window, test startMoveFlag
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, StartMove01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_StartMove01");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Show();
|
||||
window->StartMove();
|
||||
ASSERT_FALSE(window->startMoveFlag_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartMove02
|
||||
* @tc.desc: start move main fullscreen window, test startMoveFlag
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, StartMove02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_StartMove02");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Show();
|
||||
|
||||
window->StartMove();
|
||||
ASSERT_TRUE(window->startMoveFlag_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartMove03
|
||||
* @tc.desc: start move divider, test startMoveFlag
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, StartMove03, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_StartMove03");
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Show();
|
||||
window->StartMove();
|
||||
ASSERT_FALSE(window->startMoveFlag_);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -107,3 +107,8 @@ ohos_shared_library("libwms") {
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
}
|
||||
|
||||
group("test") {
|
||||
testonly = true
|
||||
deps = [ "test:test" ]
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#endif
|
||||
#include "transaction/rs_transaction.h"
|
||||
#include "ui/rs_surface_extractor.h"
|
||||
#include "single_instance.h"
|
||||
#include "wm_single_instance.h"
|
||||
#include "singleton_delegator.h"
|
||||
#include "window.h"
|
||||
#include "wm_common.h"
|
||||
@@ -51,10 +51,10 @@ WM_DECLARE_SINGLE_INSTANCE(WindowInnerManager);
|
||||
public:
|
||||
void Init();
|
||||
void SendMessage(InnerWMCmd cmdType, DisplayId displayId = 0);
|
||||
void HandleMessage();
|
||||
private:
|
||||
static inline SingletonDelegator<WindowInnerManager> delegator;
|
||||
|
||||
void HandleMessage();
|
||||
sptr<Window> CreateWindow(DisplayId displayId, const WindowType& type, const Rect& rect);
|
||||
void CreateAndShowDivider(std::unique_ptr<WindowMessage> msg);
|
||||
void HideAndDestroyDivider(std::unique_ptr<WindowMessage> msg);
|
||||
|
||||
@@ -215,7 +215,12 @@ void WindowInnerManager::HideAndDestroyDivider(std::unique_ptr<WindowMessage> ms
|
||||
WLOGFE("Window is nullptr");
|
||||
return;
|
||||
}
|
||||
WMError res = window->Destroy();
|
||||
WMError res = window->Hide();
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("Hide window failed");
|
||||
return;
|
||||
}
|
||||
res = window->Destroy();
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("Destroy window failed");
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
group("test") {
|
||||
testonly = true
|
||||
deps = [ "unittest:unittest" ]
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
module_out_path = "window_manager/wms"
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":wms_window_inner_manager_test" ]
|
||||
}
|
||||
|
||||
## UnitTest wms_window_inner_manager_test {{{
|
||||
ohos_unittest("wms_window_inner_manager_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_inner_manager_test.cpp" ]
|
||||
|
||||
deps = [ ":wms_unittest_common" ]
|
||||
}
|
||||
|
||||
## UnitTest wms_window_inner_manager_test }}}
|
||||
|
||||
## Build wms_unittest_common.a {{{
|
||||
config("wms_unittest_common_public_config") {
|
||||
include_dirs = [
|
||||
"//foundation/windowmanager/wm/include",
|
||||
"//foundation/windowmanager/wm/test/unittest",
|
||||
"//foundation/windowmanager/wmserver/include",
|
||||
"//foundation/windowmanager/wmserver/include/window_snapshot",
|
||||
"//foundation/windowmanager/interfaces/innerkits/wm",
|
||||
"//foundation/windowmanager/utils/include",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
|
||||
"//third_party/googletest/googlemock/include",
|
||||
|
||||
# for abilityContext
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include",
|
||||
"//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime/context",
|
||||
"//base/global/resmgr_standard/interfaces/innerkits/include",
|
||||
"//third_party/node/deps/icu-small/source/common",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content",
|
||||
"//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/base/include",
|
||||
"//third_party/jsoncpp/include",
|
||||
"//third_party/json/include",
|
||||
|
||||
# abilityContext end
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-g3",
|
||||
"-Dprivate=public",
|
||||
"-Dprotected=public",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_static_library("wms_unittest_common") {
|
||||
visibility = [ ":*" ]
|
||||
testonly = true
|
||||
|
||||
public_configs = [ ":wms_unittest_common_public_config" ]
|
||||
|
||||
public_deps = [
|
||||
"//foundation/ace/ace_engine/interfaces/innerkits/ace:ace_uicontent",
|
||||
|
||||
# todo need delete it for abilitycontext
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"//foundation/ace/ace_engine/build/external_config/flutter/skia:ace_skia_ohos",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
"//foundation/windowmanager/wmserver:libwms",
|
||||
"//third_party/googletest:gmock",
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [ "ability_runtime:ability_context_native" ]
|
||||
}
|
||||
## Build wms_unittest_common.a }}}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "window_inner_manager_test.h"
|
||||
|
||||
#include "mock_window_adapter.h"
|
||||
#include "singleton_mocker.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Mocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
|
||||
WindowInnerManager& WindowInnerManagerTest::innerManager_ = SingletonContainer::Get<WindowInnerManager>();
|
||||
|
||||
void WindowInnerManagerTest::SetUpTestCase()
|
||||
{
|
||||
innerManager_.Init();
|
||||
ASSERT_TRUE(innerManager_.hasInitThread_);
|
||||
ASSERT_FALSE(innerManager_.needDestroyThread_);
|
||||
}
|
||||
|
||||
void WindowInnerManagerTest::TearDownTestCase()
|
||||
{
|
||||
innerManager_.SendMessage(INNER_WM_DESTROY_THREAD);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_FALSE(innerManager_.hasInitThread_);
|
||||
ASSERT_TRUE(innerManager_.needDestroyThread_);
|
||||
}
|
||||
|
||||
void WindowInnerManagerTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowInnerManagerTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: SendMessage01
|
||||
* @tc.desc: Init thread, wait for message, test dividerMap
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowInnerManagerTest, InitThread01, Function | SmallTest | Level3)
|
||||
{
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) == nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendMessage01
|
||||
* @tc.desc: create and show divider, mock create window return nullptr
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowInnerManagerTest, SendMessage01, Function | SmallTest | Level3)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
|
||||
innerManager_.SendMessage(INNER_WM_CREATE_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) == nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendMessage02
|
||||
* @tc.desc: create and show divider, mock create window return new window, hide and destroy success
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowInnerManagerTest, SendMessage02, Function | SmallTest | Level3)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
innerManager_.SendMessage(INNER_WM_CREATE_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) != nullptr);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
innerManager_.SendMessage(INNER_WM_DESTROY_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) == nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendMessage03
|
||||
* @tc.desc: create and show divider, mock hide return error
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowInnerManagerTest, SendMessage03, Function | SmallTest | Level3)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
innerManager_.SendMessage(INNER_WM_CREATE_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) != nullptr);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
|
||||
innerManager_.SendMessage(INNER_WM_DESTROY_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) != nullptr);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
innerManager_.SendMessage(INNER_WM_DESTROY_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendMessage04
|
||||
* @tc.desc: create and show divider, mock destroy return error
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowInnerManagerTest, SendMessage04, Function | SmallTest | Level3)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
innerManager_.SendMessage(INNER_WM_CREATE_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) != nullptr);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
|
||||
innerManager_.SendMessage(INNER_WM_DESTROY_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
ASSERT_TRUE(innerManager_.GetDividerWindow(displayId_) != nullptr);
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
innerManager_.SendMessage(INNER_WM_DESTROY_DIVIDER, displayId_);
|
||||
sleep(SEND_MSG_SLEEP_S);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_WM_TEST_UT_WINDOW_INNER_MANAGER_TEST_H
|
||||
#define FRAMEWORKS_WM_TEST_UT_WINDOW_INNER_MANAGER_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "window_inner_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowInnerManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
DisplayId displayId_ = 0;
|
||||
static WindowInnerManager& innerManager_;
|
||||
static constexpr uint32_t SEND_MSG_SLEEP_S = 1; // send message sleep time
|
||||
};
|
||||
} // namespace ROSEN
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FRAMEWORKS_WM_TEST_UT_WINDOW_INNER_MANAGER_TEST_H
|
||||
Reference in New Issue
Block a user