From 58e19e89e1f9e9de9ef07745036c991bcc1c21c6 Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Mon, 25 Aug 2025 14:00:28 +0800 Subject: [PATCH] =?UTF-8?q?TDD=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shuangshuangliu Change-Id: I29098328a6dec4f70dd2c9c77d18c27bb92fb147 --- wm/test/unittest/BUILD.gn | 11 + wm/test/unittest/window_agent_new_test.cpp | 681 +++++++++++++++++++++ 2 files changed, 692 insertions(+) create mode 100644 wm/test/unittest/window_agent_new_test.cpp diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 6a9fca35b8..85c701fd8c 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -35,6 +35,7 @@ group("unittest") { ":wm_screen_scene_test", ":wm_vsync_station_test", ":wm_web_picture_in_picture_controller_test", + ":wm_window_agent_new_test", ":wm_window_agent_test", ":wm_window_display_change_adapter_test", ":wm_window_effect_test", @@ -521,6 +522,16 @@ ohos_unittest("wm_window_agent_test") { external_deps = test_external_deps } +ohos_unittest("wm_window_agent_new_test") { + module_out_path = module_out_path + defines = [ "FRAME_TRACE_ENABLE" ] + sources = [ "window_agent_new_test.cpp" ] + + deps = [ ":wm_unittest_common" ] + + external_deps = test_external_deps +} + ohos_unittest("wm_root_scene_test") { module_out_path = module_out_path diff --git a/wm/test/unittest/window_agent_new_test.cpp b/wm/test/unittest/window_agent_new_test.cpp new file mode 100644 index 0000000000..b8ffe955b0 --- /dev/null +++ b/wm/test/unittest/window_agent_new_test.cpp @@ -0,0 +1,681 @@ +/* + * 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 +#include + +#include "modifier_render_thread/rs_modifiers_draw_thread.h" +#include "rs_adapter.h" +#include "window_agent.h" +#include "window_manager_hilog.h" +#include "window_stub.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +class WindowAgentNewTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + sptr windowAgent_; +}; + +void WindowAgentNewTest::SetUpTestCase() {} + +void WindowAgentNewTest::TearDownTestCase() +{ +#ifdef RS_ENABLE_VK + RSModifiersDrawThread::Destroy(); +#endif +} + +void WindowAgentNewTest::SetUp() +{ + sptr option = new WindowOption(); + sptr window = new WindowImpl(option); + windowAgent_ = new WindowAgent(window); +} + +void WindowAgentNewTest::TearDown() +{ + windowAgent_ = nullptr; +} + +namespace { +/** + * @tc.name: UpdateWindowRect + * @tc.desc: UpdateWindowRect + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowRect001, TestSize.Level1) +{ + Rect rect = Rect{ 0, 0, 0, 0 }; + bool status = true; + WMError err = windowAgent_->UpdateWindowRect(rect, status, WindowSizeChangeReason::HIDE); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateWindowRect + * @tc.desc: UpdateWindowRect + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowRect002, TestSize.Level1) +{ + Rect rect = Rect{ 0, 0, 0, 0 }; + bool status = true; + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateWindowRect(rect, status, WindowSizeChangeReason::HIDE); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateWindowMode + * @tc.desc: UpdateWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowMode001, TestSize.Level1) +{ + WMError err = windowAgent_->UpdateWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateWindowMode + * @tc.desc: UpdateWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowMode002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateWindowModeSupportType + * @tc.desc: UpdateWindowModeSupportType + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowModeSupportType001, TestSize.Level1) +{ + WMError err = windowAgent_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateWindowModeSupportType + * @tc.desc: UpdateWindowModeSupportType + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowModeSupportType002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateFocusStatus + * @tc.desc: UpdateFocusStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateFocusStatus001, TestSize.Level1) +{ + WMError err = windowAgent_->UpdateFocusStatus(true); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateFocusStatus + * @tc.desc: UpdateFocusStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateFocusStatus002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateFocusStatus(true); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateAvoidArea + * @tc.desc: UpdateAvoidArea + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateAvoidArea001, TestSize.Level1) +{ + const sptr& avoidArea = new AvoidArea(); + WMError err = windowAgent_->UpdateAvoidArea(avoidArea, AvoidAreaType::TYPE_SYSTEM); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateAvoidArea + * @tc.desc: UpdateAvoidArea + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateAvoidArea002, TestSize.Level1) +{ + const sptr& avoidArea = new AvoidArea(); + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateAvoidArea(avoidArea, AvoidAreaType::TYPE_SYSTEM); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateWindowState + * @tc.desc: UpdateWindowState + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowState001, TestSize.Level1) +{ + WMError err = windowAgent_->UpdateWindowState(WindowState::STATE_BOTTOM); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateWindowState + * @tc.desc: UpdateWindowState + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowState002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateWindowState(WindowState::STATE_SHOWN); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateWindowDragInfo + * @tc.desc: UpdateWindowDragInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowDragInfo001, TestSize.Level1) +{ + PointInfo point; + point.x = 1; + point.y = 2; + WMError err = windowAgent_->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_MOVE); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateWindowDragInfo + * @tc.desc: UpdateWindowDragInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateWindowDragInfo002, TestSize.Level1) +{ + PointInfo point; + point.x = 1; + point.y = 2; + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_MOVE); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateDisplayId + * @tc.desc: UpdateDisplayId + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateDisplayId001, TestSize.Level1) +{ + WMError err = windowAgent_->UpdateDisplayId(0, 1); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateDisplayId + * @tc.desc: UpdateDisplayId + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateDisplayId002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateDisplayId(0, 1); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateOccupiedAreaChangeInfo + * @tc.desc: UpdateOccupiedAreaChangeInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateOccupiedAreaChangeInfo001, TestSize.Level1) +{ + Rect overlapRect = { 0, 0, 0, 0 }; + sptr info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect); + WMError err = windowAgent_->UpdateOccupiedAreaChangeInfo(info); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateOccupiedAreaChangeInfo + * @tc.desc: UpdateOccupiedAreaChangeInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateOccupiedAreaChangeInfo002, TestSize.Level1) +{ + Rect overlapRect = { 0, 0, 0, 0 }; + sptr info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect); + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateOccupiedAreaChangeInfo(info); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateOccupiedAreaAndRect + * @tc.desc: UpdateOccupiedAreaAndRect + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateOccupiedAreaAndRect, TestSize.Level1) +{ + Rect overlapRect = { 0, 0, 0, 0 }; + sptr info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect); + std::shared_ptr rsUIContext; + if (windowAgent_->window_) { + rsUIContext = windowAgent_->window_->GetRSUIContext(); + } + auto rsTransaction = RSSyncTransactionAdapter::GetRSTransaction(rsUIContext); + + WMError err = windowAgent_->UpdateOccupiedAreaAndRect(info, overlapRect, rsTransaction); + ASSERT_EQ(err, WMError::WM_OK); + + windowAgent_->window_ = nullptr; + err = windowAgent_->UpdateOccupiedAreaAndRect(info, overlapRect, rsTransaction); + ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateOccupiedAreaAndRect + * @tc.desc: UpdateOccupiedAreaAndRect + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateOccupiedAreaAndRect001, TestSize.Level1) +{ + Rect overlapRect = { 0, 0, 0, 0 }; + sptr info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect); + std::shared_ptr rsUIContext; + if (windowAgent_->window_) { + rsUIContext = windowAgent_->window_->GetRSUIContext(); + } + auto rsTransaction = RSSyncTransactionAdapter::GetRSTransaction(rsUIContext); + + WMError err = windowAgent_->UpdateOccupiedAreaAndRect(info, overlapRect, rsTransaction); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateOccupiedAreaAndRect + * @tc.desc: UpdateOccupiedAreaAndRect + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateOccupiedAreaAndRect002, TestSize.Level1) +{ + Rect overlapRect = { 0, 0, 0, 0 }; + sptr info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect); + std::shared_ptr rsUIContext; + if (windowAgent_->window_) { + rsUIContext = windowAgent_->window_->GetRSUIContext(); + } + auto rsTransaction = RSSyncTransactionAdapter::GetRSTransaction(rsUIContext); + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateOccupiedAreaAndRect(info, overlapRect, rsTransaction); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateActiveStatus + * @tc.desc: UpdateActiveStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateActiveStatus001, TestSize.Level1) +{ + WMError err = windowAgent_->UpdateActiveStatus(false); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateActiveStatus + * @tc.desc: UpdateActiveStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateActiveStatus002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateActiveStatus(false); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: GetWindowProperty + * @tc.desc: GetWindowProperty + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, GetWindowProperty, TestSize.Level1) +{ + auto windowProperty = windowAgent_->GetWindowProperty(); + ASSERT_NE(windowProperty, nullptr); + + windowAgent_->window_ = nullptr; + windowProperty = windowAgent_->GetWindowProperty(); + ASSERT_EQ(windowProperty, nullptr); +} + +/** + * @tc.name: RestoreSplitWindowMode + * @tc.desc: RestoreSplitWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, RestoreSplitWindowMode001, TestSize.Level1) +{ + WMError err = windowAgent_->RestoreSplitWindowMode(static_cast(WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: RestoreSplitWindowMode + * @tc.desc: RestoreSplitWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, RestoreSplitWindowMode002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->RestoreSplitWindowMode(static_cast(WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyTouchOutside + * @tc.desc: NotifyTouchOutside + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyTouchOutside001, TestSize.Level1) +{ + WMError err = windowAgent_->NotifyTouchOutside(); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyTouchOutside + * @tc.desc: NotifyTouchOutside + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyTouchOutside002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyTouchOutside(); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyScreenshot + * @tc.desc: NotifyScreenshot + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyScreenshot001, TestSize.Level1) +{ + WMError err = windowAgent_->NotifyScreenshot(); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyScreenshot + * @tc.desc: NotifyScreenshot + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyScreenshot002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyScreenshot(); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyScreenshotAppEvent + * @tc.desc: NotifyScreenshotAppEvent + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyScreenshotAppEvent001, TestSize.Level1) +{ + WMError err = windowAgent_->NotifyScreenshotAppEvent(ScreenshotEventType::SCROLL_SHOT_START); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyScreenshotAppEvent + * @tc.desc: NotifyScreenshotAppEvent + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyScreenshotAppEvent002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyScreenshotAppEvent(ScreenshotEventType::SCROLL_SHOT_START); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: DumpInfo + * @tc.desc: DumpInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, DumpInfo, TestSize.Level1) +{ + std::vector params; + WMError err = windowAgent_->DumpInfo(params); + ASSERT_EQ(err, WMError::WM_OK); + + windowAgent_->window_ = nullptr; + err = windowAgent_->DumpInfo(params); + ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: DumpInfo + * @tc.desc: DumpInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, DumpInfo001, TestSize.Level1) +{ + std::vector params; + WMError err = windowAgent_->DumpInfo(params); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: DumpInfo + * @tc.desc: DumpInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, DumpInfo002, TestSize.Level1) +{ + std::vector params; + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->DumpInfo(params); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: UpdateZoomTransform + * @tc.desc: UpdateZoomTransform + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateZoomTransform001, TestSize.Level1) +{ + Transform transform; + WMError err = windowAgent_->UpdateZoomTransform(transform, false); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: UpdateZoomTransform + * @tc.desc: UpdateZoomTransform + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, UpdateZoomTransform002, TestSize.Level1) +{ + Transform transform; + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->UpdateZoomTransform(transform, false); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyDestroy + * @tc.desc: NotifyDestroy + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyDestroy001, TestSize.Level1) +{ + WMError err = windowAgent_->NotifyDestroy(); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyDestroy + * @tc.desc: NotifyDestroy + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyDestroy002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyDestroy(); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyForeground + * @tc.desc: NotifyForeground + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyForeground001, TestSize.Level1) +{ + WMError err = windowAgent_->NotifyForeground(); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyForeground + * @tc.desc: NotifyForeground + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyForeground002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyForeground(); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyBackground + * @tc.desc: NotifyBackground + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyBackground001, TestSize.Level1) +{ + WMError err = windowAgent_->NotifyBackground(); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyBackground + * @tc.desc: NotifyBackground + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyBackground002, TestSize.Level1) +{ + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyBackground(); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: NotifyWindowClientPointUp + * @tc.desc: NotifyWindowClientPointUp + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyWindowClientPointUp001, TestSize.Level1) +{ + auto pointerEvent = MMI::PointerEvent::Create(); + WMError err = windowAgent_->NotifyWindowClientPointUp(pointerEvent); + EXPECT_EQ(err, WMError::WM_OK); +} + +/** + * @tc.name: NotifyWindowClientPointUp + * @tc.desc: NotifyWindowClientPointUp + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyWindowClientPointUp002, TestSize.Level1) +{ + auto pointerEvent = MMI::PointerEvent::Create(); + windowAgent_->window_ = nullptr; + WMError err = windowAgent_->NotifyWindowClientPointUp(pointerEvent); + EXPECT_EQ(err, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: ConsumeKeyEvent + * @tc.desc: ConsumeKeyEvent + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, ConsumeKeyEvent, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + auto keyEvent = MMI::KeyEvent::Create(); + windowAgent_->ConsumeKeyEvent(keyEvent); + + windowAgent_->window_ = nullptr; + windowAgent_->ConsumeKeyEvent(keyEvent); + EXPECT_TRUE(g_errLog.find("window_ is nullptr") != std::string::npos); + LOG_SetCallback(nullptr); +} + +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: NotifyForegroundInteractiveStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentNewTest, NotifyForegroundInteractiveStatus, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + bool interactive = false; + windowAgent_->NotifyForegroundInteractiveStatus(interactive); + + interactive = true; + windowAgent_->window_ = nullptr; + windowAgent_->NotifyForegroundInteractiveStatus(interactive); + EXPECT_TRUE(g_errLog.find("window_ is nullptr") != std::string::npos); + LOG_SetCallback(nullptr); +} +} +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file -- Gitee