From 3efe32d3fa4e30be0ec173d80fe434b16bfdc1d0 Mon Sep 17 00:00:00 2001 From: leafly2021 Date: Mon, 9 May 2022 09:05:28 +0800 Subject: [PATCH] modify window_impl_test ut failed Signed-off-by: leafly2021 Change-Id: Ic60c68f319219d526a32c36d6051fa3b2ab5cbf9 --- wm/include/input_transfer_station.h | 2 +- wm/src/input_transfer_station.cpp | 3 +- wm/src/window_impl.cpp | 2 +- .../unittest/input_transfer_station_test.cpp | 2 +- wm/test/unittest/window_impl_test.cpp | 37 ++++++++++--------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/wm/include/input_transfer_station.h b/wm/include/input_transfer_station.h index dc9f0d04..c069a9cb 100644 --- a/wm/include/input_transfer_station.h +++ b/wm/include/input_transfer_station.h @@ -32,7 +32,7 @@ WM_DECLARE_SINGLE_INSTANCE(InputTransferStation); friend class InputEventListener; public: void AddInputWindow(const sptr& window); - void RemoveInputWindow(const sptr& window); + void RemoveInputWindow(uint32_t windowId); void SetInputListener(uint32_t windowId, const std::shared_ptr& listener); private: diff --git a/wm/src/input_transfer_station.cpp b/wm/src/input_transfer_station.cpp index 704f8a05..e5df66dc 100644 --- a/wm/src/input_transfer_station.cpp +++ b/wm/src/input_transfer_station.cpp @@ -80,9 +80,8 @@ void InputTransferStation::AddInputWindow(const sptr& window) } } -void InputTransferStation::RemoveInputWindow(const sptr& window) +void InputTransferStation::RemoveInputWindow(uint32_t windowId) { - uint32_t windowId = window->GetWindowId(); WLOGFI("Remove input window, windowId: %{public}u", windowId); std::lock_guard lock(mtx_); auto iter = windowInputChannels_.find(windowId); diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 4e62924d..25049038 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -715,7 +715,7 @@ WMError WindowImpl::Destroy(bool needNotifyServer) } WLOGFI("[Client] Window %{public}u Destroy", property_->GetWindowId()); - InputTransferStation::GetInstance().RemoveInputWindow(this); + InputTransferStation::GetInstance().RemoveInputWindow(property_->GetWindowId()); WMError ret = WMError::WM_OK; if (needNotifyServer) { NotifyBeforeDestroy(GetWindowName()); diff --git a/wm/test/unittest/input_transfer_station_test.cpp b/wm/test/unittest/input_transfer_station_test.cpp index fd3d0b75..ec0e1b09 100644 --- a/wm/test/unittest/input_transfer_station_test.cpp +++ b/wm/test/unittest/input_transfer_station_test.cpp @@ -65,7 +65,7 @@ HWTEST_F(InputTransferStationTest, AddInputWindow, Function | SmallTest | Level2 */ HWTEST_F(InputTransferStationTest, RemoveInputWindow, Function | SmallTest | Level2) { - InputTransferStation::GetInstance().RemoveInputWindow(window_); + InputTransferStation::GetInstance().RemoveInputWindow(window_->GetWindowId()); } /** diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index 2099d251..e70bbff9 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -662,18 +662,19 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType03, Function | SmallTest | Le */ HWTEST_F(WindowImplTest, Maximize02, Function | SmallTest | Level3) { - auto option = new WindowOption(); - option->SetWindowName("Maximize02"); - auto window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); + sptr option = new WindowOption(); + option->SetWindowName("Maximize02"); + sptr window = new WindowImpl(option); 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)); + ASSERT_EQ(WMError::WM_OK, window->Create("")); window->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); window->Maximize(); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode()); + EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Hide(); EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); @@ -687,15 +688,15 @@ HWTEST_F(WindowImplTest, Maximize02, Function | SmallTest | Level3) */ HWTEST_F(WindowImplTest, Recover01, Function | SmallTest | Level3) { - auto option = new WindowOption(); - option->SetWindowName("Recover01"); - auto window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); + sptr option = new WindowOption(); + option->SetWindowName("Recover01"); + sptr window = new WindowImpl(option); 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); window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Recover(); @@ -713,15 +714,15 @@ HWTEST_F(WindowImplTest, Recover01, Function | SmallTest | Level3) */ HWTEST_F(WindowImplTest, Recover02, Function | SmallTest | Level3) { - auto option = new WindowOption(); - option->SetWindowName("Recover02"); - auto window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); + sptr option = new WindowOption(); + option->SetWindowName("Recover02"); + sptr window = new WindowImpl(option); 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_SUB_WINDOW); window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); window->Recover(); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); @@ -740,7 +741,7 @@ HWTEST_F(WindowImplTest, Minimize01, Function | SmallTest | Level3) { auto option = new WindowOption(); option->SetWindowName("Minimize01"); - auto window = new WindowImpl(option); + sptr window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Create(""); @@ -765,7 +766,7 @@ HWTEST_F(WindowImplTest, Minimize02, Function | SmallTest | Level3) { auto option = new WindowOption(); option->SetWindowName("Minimize02"); - auto window = new WindowImpl(option); + sptr window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Create(""); @@ -789,7 +790,7 @@ HWTEST_F(WindowImplTest, IsSupportWideGamut01, Function | SmallTest | Level3) { auto option = new WindowOption(); option->SetWindowName("IsSupportWideGamut01"); - auto window = new WindowImpl(option); + sptr window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Create(""); @@ -809,7 +810,7 @@ HWTEST_F(WindowImplTest, SetColorSpace01, Function | SmallTest | Level3) { auto option = new WindowOption(); option->SetWindowName("SetColorSpace01"); - auto window = new WindowImpl(option); + sptr window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Create(""); @@ -829,7 +830,7 @@ HWTEST_F(WindowImplTest, GetColorSpace01, Function | SmallTest | Level3) { auto option = new WindowOption(); option->SetWindowName("GetColorSpace01"); - auto window = new WindowImpl(option); + sptr window = new WindowImpl(option); std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Create("");