From 998fdc061b06e62d48f03a8c37478e15142fb2db Mon Sep 17 00:00:00 2001 From: koroltang Date: Thu, 10 Apr 2025 18:21:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=A7=E6=95=B0=E6=8D=AE=E6=89=93?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- utils/include/perform_reporter.h | 21 ++++++ utils/src/perform_reporter.cpp | 34 +++++++++ utils/test/unittest/perform_reporter_test.cpp | 50 +++++++++++++ .../session/host/include/keyboard_session.h | 4 ++ window_scene/session/host/include/session.h | 15 ++++ .../session/host/src/keyboard_session.cpp | 35 +++++++++ window_scene/session/host/src/session.cpp | 62 ++++++++++++++++ .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 26 +++++++ window_scene/test/unittest/session_test4.cpp | 72 +++++++++++++++++++ 10 files changed, 320 insertions(+) diff --git a/utils/include/perform_reporter.h b/utils/include/perform_reporter.h index 248d22d17a..10989bcf95 100644 --- a/utils/include/perform_reporter.h +++ b/utils/include/perform_reporter.h @@ -47,6 +47,25 @@ struct WindowProfileInfo { int32_t windowSceneMode = -1; }; +enum class KeyboardLifeCycleException { + ANIM_SYNC_EXCEPTION, + CREATE_EXCEPTION, +}; + +const std::map KEYBOARD_LIFE_CYCLE_EXCEPTION_MAP = { + {KeyboardLifeCycleException::ANIM_SYNC_EXCEPTION, "ANIM_SYNC_EXCEPTION"}, + {KeyboardLifeCycleException::CREATE_EXCEPTION, "CREATE_EXCEPTION"} +}; + +struct WindowLifeCycleReportInfo { + std::string bundleName; + int32_t windowId; + int32_t windowType; + int32_t windowMode; + int32_t windowFlag; + std::string timeoutStage; +}; + class PerformReporter { public: PerformReporter(const std::string& tag, const std::vector& timeSpiltsMs, uint32_t reportInterval = 50); @@ -94,6 +113,8 @@ public: int32_t ReportUIExtensionException(int32_t exceptionType, int32_t pid, int32_t persistentId, const std::string& uiextInfo); int32_t ReportEventDispatchException(int32_t exceptionType, int32_t pid, const std::string& flushInfo); + int32_t ReportKeyboardLifeCycleException(int32_t windowId, KeyboardLifeCycleException subType, std::string& msg); + int32_t ReportSpecWindowLifeCycleChange(WindowLifeCycleReportInfo reportInfo); private: void UpdateReportInfo(FullInfoMap& infoMap, const std::string& bundleName, diff --git a/utils/src/perform_reporter.cpp b/utils/src/perform_reporter.cpp index 02a4236dee..8fea7a952c 100644 --- a/utils/src/perform_reporter.cpp +++ b/utils/src/perform_reporter.cpp @@ -360,5 +360,39 @@ int32_t WindowInfoReporter::ReportEventDispatchException(int32_t exceptionType, } return ret; } + +int32_t WindowInfoReporter::ReportKeyboardLifeCycleException(int32_t windowId, KeyboardLifeCycleException subType, + std::string& msg) +{ + std::string eventName = "KEYBOARD_LIFE_CYCLE_EXCEPTION"; + int32_t ret = HiSysEventWrite( + HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER, eventName, + HiviewDFX::HiSysEvent::EventType::FAULT, + "WINDOW_ID", windowId, + "SUB_TYPE", KEYBOARD_LIFE_CYCLE_EXCEPTION_MAP.at(subType), + "MSG", msg); + if (ret != 0) { + TLOGE(WmsLogTag::DEFAULT, "write HiSysEvent error, ret: %{public}d", ret); + } + return ret; +} + +int32_t WindowInfoReporter::ReportSpecWindowLifeCycleChange(WindowLifeCycleReportInfo reportInfo) +{ + std::string eventName = "SPEC_WINDOW_LIFE_CYCLE_CHANGE"; + int32_t ret = HiSysEventWrite( + HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER, eventName, + HiviewDFX::HiSysEvent::EventType::FAULT, + "BUNDLE_NAME", reportInfo.bundleName, + "WINDOW_ID", reportInfo.windowId, + "WINDOW_TYPE", reportInfo.windowType, + "WINDOW_MODE", reportInfo.windowMode, + "WINDOW_FLAG", reportInfo.windowFlag, + "STAGE", reportInfo.timeoutStage); + if (ret != 0) { + TLOGE(WmsLogTag::DEFAULT, "write HiSysEvent error, ret: %{public}d", ret); + } + return ret; +} } // namespace Rosen } \ No newline at end of file diff --git a/utils/test/unittest/perform_reporter_test.cpp b/utils/test/unittest/perform_reporter_test.cpp index 23dad34dc6..7d4e1d43d4 100644 --- a/utils/test/unittest/perform_reporter_test.cpp +++ b/utils/test/unittest/perform_reporter_test.cpp @@ -19,6 +19,7 @@ #include "input_manager.h" #include "perform_reporter.h" #include "window_manager_hilog.h" +#include "wm_common.h" using namespace testing; using namespace testing::ext; @@ -483,6 +484,55 @@ HWTEST_F(PerformReporterTest, ReportWindowProfileInfo017, TestSize.Level1) res = windowInfoReporter.ReportWindowProfileInfo(windowProfileInfo); ASSERT_EQ(res, 0); } + +/** + * @tc.name: ReportWindowProfileInfo018 + * @tc.desc: ReportKeyboardLifeCycleException test + * @tc.type: FUNC + */ +HWTEST_F(PerformReporterTest, ReportKeyboardLifeCycleException18, Function | SmallTest | Level2) +{ + KeyboardLifeCycleException subEventType = KeyboardLifeCycleException::ANIM_SYNC_EXCEPTION; + int32_t windowId = 198; + std::string msg = "ReportKeyboardLifeCycleExceptionTestMSG"; + WindowInfoReporter windowInfoReporter; + int32_t res = windowInfoReporter.ReportKeyboardLifeCycleException(windowId, subEventType, msg); + ASSERT_EQ(res, 0); +} + +/** + * @tc.name: ReportWindowProfileInfo019 + * @tc.desc: ReportKeyboardLifeCycleException test + * @tc.type: FUNC + */ +HWTEST_F(PerformReporterTest, ReportKeyboardLifeCycleException19, Function | SmallTest | Level2) +{ + KeyboardLifeCycleException subEventType = KeyboardLifeCycleException::CREATE_EXCEPTION; + int32_t windowId = 198; + std::string msg = "ReportKeyboardLifeCycleExceptionTestMSG"; + WindowInfoReporter windowInfoReporter; + int32_t res = windowInfoReporter.ReportKeyboardLifeCycleException(windowId, subEventType, msg); + ASSERT_EQ(res, 0); +} + +/** + * @tc.name: ReportWindowProfileInfo018 + * @tc.desc: ReportSpecWindowLifeCycleChange test + * @tc.type: FUNC + */ +HWTEST_F(PerformReporterTest, ReportSpecWindowLifeCycleChange, Function | SmallTest | Level2) +{ + int32_t windowId = 198; + std::string stage = "attach"; + WindowLifeCycleReportInfo reportInfo = { "bundleName", windowId, + static_cast(WindowType::WINDOW_TYPE_APP_SUB_WINDOW), + static_cast(WindowMode::WINDOW_MODE_FULLSCREEN), + static_cast(WindowFlag::WINDOW_FLAG_IS_TEXT_MENU), + stage}; + WindowInfoReporter windowInfoReporter; + int32_t res = windowInfoReporter.ReportSpecWindowLifeCycleChange(reportInfo); + ASSERT_EQ(res, 0); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index c131321d86..9efd8530d7 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -38,6 +38,8 @@ using OnSystemKeyboardAvoidChangeCallback = std::function; using NotifyOccupiedAreaChangeCallback = std::function& info)>; +const std::string KEYBOARD_ANIM_SYNC_EVENT_NAME { "KeyboardAnimationSyncException" }; + class KeyboardSession : public SystemSession { public: // callback for notify SceneSessionManager @@ -73,6 +75,7 @@ public: void SetKeyboardViewModeChangeListener(const NotifyKeyboarViewModeChangeFunc& func) override; void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip) override; WSError UpdateSizeChangeReason(SizeChangeReason reason) override; + bool GetIsKeyboardSyncTransactionOpen() const { return isKeyboardSyncTransactionOpen_; } void SetSkipEventOnCastPlus(bool isSkip) override; protected: @@ -107,6 +110,7 @@ private: void NotifyRootSceneOccupiedAreaChange(const sptr& info); void SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool needFlush = true) override; bool IsNeedRaiseSubWindow(const sptr& callingSession, const WSRect& callingSessionRect); + void ReportLifeCycleException(); sptr keyboardCallback_ = nullptr; bool isKeyboardSyncTransactionOpen_ = false; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 5140997f08..2b64295a89 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -136,6 +136,9 @@ struct DetectTaskInfo { DetectTaskState taskState = DetectTaskState::NO_TASK; }; +const std::string ATTACH_EVENT_NAME { "wms::ReportWindowTimeout_Attach" }; +const std::string DETACH_EVENT_NAME { "wms::ReportWindowTimeout_Detach" }; + class Session : public SessionStub { public: friend class HidumpController; @@ -669,6 +672,11 @@ public: */ void SetBorderUnoccupied(bool borderUnoccupied = false); bool GetBorderUnoccupied() const; + + /* + * Specific Window + */ + void SetWindowAnimationDuration(int32_t duration); protected: class SessionLifeCycleTask : public virtual RefBase { @@ -901,6 +909,8 @@ private: bool ShouldCreateDetectTask(bool isAttach, WindowMode windowMode) const; bool ShouldCreateDetectTaskInRecent(bool newShowRecent, bool oldShowRecent, bool isAttach) const; void CreateDetectStateTask(bool isAttach, WindowMode windowMode); + void ReportWindowTimeout(std::string eventName); // only report for specific window + bool IsNeedReportTimeout() const; /* * Window Rotate Animation @@ -1022,6 +1032,11 @@ private: * Window Pattern */ bool borderUnoccupied_ = false; + + /* + * Specific Window + */ + int32_t windowAnimationDuration_; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 93df3adff1..91b565564b 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "perform_reporter.h" #include "session/host/include/keyboard_session.h" #include @@ -634,6 +635,7 @@ void KeyboardSession::OpenKeyboardSyncTransaction() if (transactionController) { transactionController->OpenSyncTransaction(session->GetEventHandler()); } + session->ReportLifeCycleException(); return WSError::WS_OK; }; PostSyncTask(task); @@ -668,6 +670,11 @@ void KeyboardSession::CloseKeyboardSyncTransaction(uint32_t callingId, const WSR return WSError::WS_OK; } session->isKeyboardSyncTransactionOpen_ = false; + auto handler = session->GetEventHandler(); + if (handler) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard anim_sync event cancelled"); + handler->RemoveTask(KEYBOARD_ANIM_SYNC_EVENT_NAME); + } auto transactionController = RSSyncTransactionController::GetInstance(); if (transactionController) { transactionController->CloseSyncTransaction(session->GetEventHandler()); @@ -886,6 +893,34 @@ void KeyboardSession::SetSkipSelfWhenShowOnVirtualScreen(bool isSkip) }, __func__); } +void KeyboardSession::ReportLifeCycleException() +{ + // anim_sync_exception + int32_t const THRESHOLD = 1000; + auto task = [weakThis = wptr(this)]() { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_KEYBOARD, "keyboard session is null"); + return; + } + if (!session->GetIsKeyboardSyncTransactionOpen()) { + TLOGND(WmsLogTag::WMS_KEYBOARD, "closed anim_sync in time"); + return; + } + std::string msg("close anim_sync timeout"); + WindowInfoReporter::GetInstance().ReportKeyboardLifeCycleException( + session->GetPersistentId(), + KeyboardLifeCycleException::ANIM_SYNC_EXCEPTION, + msg); + }; + auto handler = GetEventHandler(); + if (!handler) { + TLOGNE(WmsLogTag::WMS_KEYBOARD, "handler is null"); + return; + } + handler->PostTask(task, KEYBOARD_ANIM_SYNC_EVENT_NAME, THRESHOLD); +} + void KeyboardSession::SetSkipEventOnCastPlus(bool isSkip) { PostTask([weakThis = wptr(this), isSkip, where = __func__]() { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index ea17eb0129..5fb2586e97 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1350,6 +1350,8 @@ WSError Session::Foreground(sptr property, bool isFromCli NotifyForeground(); isTerminating_ = false; + isNeedSyncSessionRect_ = true; + ReportWindowTimeout(ATTACH_EVENT_NAME); return WSError::WS_OK; } @@ -1422,6 +1424,7 @@ WSError Session::Background(bool isFromClient, const std::string& identityToken) UpdateSessionState(SessionState::STATE_BACKGROUND); SetIsPendingToBackgroundState(false); NotifyBackground(); + ReportWindowTimeout(DETACH_EVENT_NAME); return WSError::WS_OK; } @@ -1637,6 +1640,9 @@ void Session::SetIsActivatedAfterScreenLocked(bool isActivatedAfterScreenLocked) void Session::SetAttachState(bool isAttach, WindowMode windowMode) { isAttach_ = isAttach; + if (handler_ && IsNeedReportTimeout()) { + handler_->RemoveTask(isAttach_ ? ATTACH_EVENT_NAME : DETACH_EVENT_NAME); + } PostTask([weakThis = wptr(this), isAttach]() { auto session = weakThis.promote(); if (session == nullptr) { @@ -4155,4 +4161,60 @@ bool Session::GetBorderUnoccupied() const { return borderUnoccupied_; } + +void Session::SetWindowAnimationDuration(int32_t duration) +{ + windowAnimationDuration_ = duration; +} + +bool Session::IsNeedReportTimeout() const +{ + WindowType type = GetWindowType(); + return WindowHelper::IsSubWindow(type) || (WindowHelper::IsAboveSystemWindow(type) && + type != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT && type != WindowType::WINDOW_TYPE_PANEL); +} + +void Session::ReportWindowTimeout(std::string eventName) +{ + const int32_t THRESHOLD = 20; + if (!IsNeedReportTimeout()) { + TLOGD(WmsLogTag::DEFAULT, "not specific window"); + return; + } + // if configured animation, don't report + if (windowAnimationDuration_) { + TLOGD(WmsLogTag::DEFAULT, "window configured animation, don't report"); + return; + } + if (!handler_) { + TLOGE(WmsLogTag::DEFAULT, "handler is null"); + return; + } + handler_->RemoveTask(eventName == ATTACH_EVENT_NAME ? + DETACH_EVENT_NAME : ATTACH_EVENT_NAME); + auto task = [weakThis = wptr(this), eventName]() { + auto session = weakThis.promote(); + if (!session) { + TLOGNI(WmsLogTag::DEFAULT, "session is null."); + return; + } + bool isAttach = session->GetAttachState(); + if ((isAttach && eventName == ATTACH_EVENT_NAME) || + (!isAttach && eventName == DETACH_EVENT_NAME) + ) { + TLOGND(WmsLogTag::DEFAULT, "detached or attached in time"); + return; + } + WindowLifeCycleReportInfo reportInfo { + session->GetSessionInfo().bundleName_, + static_cast(session->GetPersistentId()), + static_cast(session->GetWindowType()), + static_cast(session->GetWindowMode()), + static_cast(session->GetSessionProperty()->GetWindowFlags()), + eventName + }; + WindowInfoReporter::GetInstance().ReportSpecWindowLifeCycleChange(reportInfo); + }; + PostTask(task, eventName, THRESHOLD); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 3a846d6194..eed8b83957 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -465,6 +465,7 @@ public: void RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func); void GetKeyboardOccupiedAreaWithRotation( int32_t persistentId, Rotation rotation, std::vector>& avoidAreas); + void ReportKeyboardCreateException(sptr& keyboardSession); /* * UIExtension diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 9f55789efa..f57dbe5185 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2104,6 +2104,7 @@ void SceneSessionManager::CreateKeyboardPanelSession(sptr keyboard if (panelSession == nullptr) { if (panelVec.size() >= 2) { // 2 is max number of keyboard panel, one input method and one system keyboard TLOGE(WmsLogTag::WMS_KEYBOARD, "Error size of keyboardPanel, size: %{public}zu", panelVec.size()); + ReportKeyboardCreateException(keyboardSession); return; } std::string panelName = keyboardSession->IsSystemKeyboard() ? "SCBSystemKeyboardPanel" : "SCBKeyboardPanel"; @@ -2153,6 +2154,7 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se TLOGE(WmsLogTag::WMS_LIFE, "Invalid window type"); } if (sceneSession != nullptr) { + sceneSession->SetWindowAnimationDuration(appWindowSceneConfig_.windowAnimation_.duration_); sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId()); sceneSession->isKeyboardPanelEnabled_ = isKeyboardPanelEnabled_; sceneSession->RegisterForceSplitListener([this](const std::string& bundleName) { @@ -14614,6 +14616,30 @@ void SceneSessionManager::RegisterHookSceneSessionActivationFunc(const sptr& keyboardSession) { + std::string msg = "UITYPE:" + std::to_string(static_cast(systemConfig_.windowUIType_)) + ",PanelId:["; + for (const auto& session : GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL)) { + if (!session) { + TLOGW(WmsLogTag::DEFAULT, "session nullptr"); + continue; + } + msg += std::to_string(session->GetPersistentId()) + ","; + } + msg += "],"; + for (const auto& session : GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)) { + if (!session) { + TLOGW(WmsLogTag::DEFAULT, "session nullptr"); + continue; + } + msg += "id:" + std::to_string(session->GetPersistentId()) + ","; + msg += "screenId:" + std::to_string(session->GetScreenId()) + ","; + } + WindowInfoReporter::GetInstance().ReportKeyboardLifeCycleException( + keyboardSession->GetPersistentId(), + KeyboardLifeCycleException::CREATE_EXCEPTION, + msg); +} + void SceneSessionManager::RegisterSceneSessionDestructCallback(NotifySceneSessionDestructFunc&& func) { onSceneSessionDestruct_ = std::move(func); diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index e176b092b4..0b8edf8b45 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -1118,6 +1118,78 @@ HWTEST_F(WindowSessionTest4, SafelySetWant01, TestSize.Level1) ASSERT_NE(nullptr, sessionInfo.want); EXPECT_EQ(sessionInfo.SafelyGetWant().GetBundle(), "SafelySetWantTest"); } + +/** + * @tc.name: ReportWindowTimeout + * @tc.desc: ReportWindowTimeout Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, ReportWindowTimeout, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "ReportWindowTimeout"; + sessionInfo.bundleName_ = "ReportWindowTimeout"; + + sptr session = sptr::MakeSptr(sessionInfo); + sptr property = sptr::MakeSptr(); + property->isSystemCalling_ = true; + session->SetSessionProperty(property); + + property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, property->GetWindowType()); + session->ReportWindowTimeout(ATTACH_EVENT_NAME); + + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + EXPECT_EQ(WindowType::WINDOW_TYPE_FLOAT, property->GetWindowType()); + session->windowAnimationDuration_ = 0; + session->ReportWindowTimeout(ATTACH_EVENT_NAME); + + session->windowAnimationDuration_ = 1; + session->handler_ = nullptr; + session->ReportWindowTimeout(ATTACH_EVENT_NAME); +} + +/** + * @tc.name: ReportWindowTimeout01 + * @tc.desc: ReportWindowTimeout01 Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, ReportWindowTimeout01, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "ReportWindowTimeout01"; + sessionInfo.bundleName_ = "ReportWindowTimeout01"; + + sptr session = sptr::MakeSptr(sessionInfo); + sptr property = sptr::MakeSptr(); + property->isSystemCalling_ = true; + session->SetSessionProperty(property); + + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + EXPECT_EQ(WindowType::WINDOW_TYPE_FLOAT, property->GetWindowType()); + session->windowAnimationDuration_ = 1; + session->ReportWindowTimeout(ATTACH_EVENT_NAME); + + session->SetAttachState(false); + session->ReportWindowTimeout(ATTACH_EVENT_NAME); + bool isAttach = session->GetAttachState(); + EXPECT_EQ(false, isAttach); + + session->SetAttachState(false); + session->ReportWindowTimeout(DETACH_EVENT_NAME); + isAttach = session->GetAttachState(); + EXPECT_EQ(false, isAttach); + + session->SetAttachState(true); + session->ReportWindowTimeout(ATTACH_EVENT_NAME); + isAttach = session->GetAttachState(); + EXPECT_EQ(true, isAttach); + + session->SetAttachState(true); + session->ReportWindowTimeout(DETACH_EVENT_NAME); + isAttach = session->GetAttachState(); + EXPECT_EQ(true, isAttach); +} } } // namespace Rosen } // namespace OHOS -- Gitee From a41079043a50675ed2e78c176e63a737ed5dbaaf Mon Sep 17 00:00:00 2001 From: koroltang Date: Sun, 13 Apr 2025 21:12:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?TDD=E7=94=A8=E4=BE=8B=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- window_scene/test/unittest/session_test4.cpp | 172 +++++++++++++++---- 1 file changed, 134 insertions(+), 38 deletions(-) diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index 0b8edf8b45..00aa9f3e80 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -40,7 +40,14 @@ namespace { const std::string UNDEFINED = "undefined"; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4"}; } - +namespace { +std::string logMsg; +void SessionTest4LogCallBack( + const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg) +{ + logMsg = msg; +} +} class WindowSessionTest4 : public testing::Test { public: static void SetUpTestCase(); @@ -1120,75 +1127,164 @@ HWTEST_F(WindowSessionTest4, SafelySetWant01, TestSize.Level1) } /** - * @tc.name: ReportWindowTimeout - * @tc.desc: ReportWindowTimeout Test + * @tc.name: IsNeedReportTimeout + * @tc.desc: Case of non-specific window * @tc.type: FUNC */ -HWTEST_F(WindowSessionTest4, ReportWindowTimeout, TestSize.Level1) +HWTEST_F(WindowSessionTest4, IsNeedReportTimeout_NonSpecific_Window, TestSize.Level1) { SessionInfo sessionInfo; - sessionInfo.abilityName_ = "ReportWindowTimeout"; - sessionInfo.bundleName_ = "ReportWindowTimeout"; + sessionInfo.abilityName_ = "IsNeedReportTimeout_NonSpecific_Window"; + sessionInfo.bundleName_ = "IsNeedReportTimeout_NonSpecific_Window"; sptr session = sptr::MakeSptr(sessionInfo); sptr property = sptr::MakeSptr(); property->isSystemCalling_ = true; - session->SetSessionProperty(property); - property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, property->GetWindowType()); - session->ReportWindowTimeout(ATTACH_EVENT_NAME); - property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); - EXPECT_EQ(WindowType::WINDOW_TYPE_FLOAT, property->GetWindowType()); - session->windowAnimationDuration_ = 0; - session->ReportWindowTimeout(ATTACH_EVENT_NAME); + session->SetSessionProperty(property); + EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, session->GetWindowType()); + EXPECT_EQ(false, session->IsNeedReportTimeout()); - session->windowAnimationDuration_ = 1; - session->handler_ = nullptr; - session->ReportWindowTimeout(ATTACH_EVENT_NAME); + property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); + EXPECT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, property->GetWindowType()); + + session->SetSessionProperty(property); + EXPECT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, session->GetWindowType()); + EXPECT_EQ(false, session->IsNeedReportTimeout()); +} + +/** + * @tc.name: IsNeedReportTimeout + * @tc.desc: Case of specific window + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, IsNeedReportTimeout_specific_window, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "IsNeedReportTimeout_specific_window"; + sessionInfo.bundleName_ = "IsNeedReportTimeout_specific_window"; + + sptr session = sptr::MakeSptr(sessionInfo); + sptr property = sptr::MakeSptr(); + property->isSystemCalling_ = true; + property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); + + session->SetSessionProperty(property); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); + EXPECT_EQ(true, session->IsNeedReportTimeout()); } /** - * @tc.name: ReportWindowTimeout01 - * @tc.desc: ReportWindowTimeout01 Test + * @tc.name: ReportWindowTimeout + * @tc.desc: Test Case about non specific window * @tc.type: FUNC */ -HWTEST_F(WindowSessionTest4, ReportWindowTimeout01, TestSize.Level1) +HWTEST_F(WindowSessionTest4, ReportWindowTimeout_NonSpecificWindow, TestSize.Level1) { + LOG_SetCallback(SessionTest4LogCallBack); + logMsg.clear(); SessionInfo sessionInfo; - sessionInfo.abilityName_ = "ReportWindowTimeout01"; - sessionInfo.bundleName_ = "ReportWindowTimeout01"; + sessionInfo.abilityName_ = "ReportWindowTimeout_NonSpecificWindow"; + sessionInfo.bundleName_ = "ReportWindowTimeout_NonSpecificWindow"; sptr session = sptr::MakeSptr(sessionInfo); sptr property = sptr::MakeSptr(); property->isSystemCalling_ = true; + property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); session->SetSessionProperty(property); + EXPECT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, property->GetWindowType()); + EXPECT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, session->GetWindowType()); + session->ReportWindowTimeout(ATTACH_EVENT_NAME); + EXPECT_EQ(false, session->IsNeedReportTimeout()); +} + +/** + * @tc.name: ReportWindowTimeout + * @tc.desc: Test Case about non specific window + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, ReportWindowTimeout_SpecificWindow, TestSize.Level1) +{ + LOG_SetCallback(SessionTest4LogCallBack); + logMsg.clear(); + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "ReportWindowTimeout_SpecificWindow"; + sessionInfo.bundleName_ = "ReportWindowTimeout_SpecificWindow"; - property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); - EXPECT_EQ(WindowType::WINDOW_TYPE_FLOAT, property->GetWindowType()); - session->windowAnimationDuration_ = 1; + sptr session = sptr::MakeSptr(sessionInfo); + sptr property = sptr::MakeSptr(); + property->isSystemCalling_ = true; + property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + session->SetSessionProperty(property); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); session->ReportWindowTimeout(ATTACH_EVENT_NAME); + EXPECT_TRUE(logMsg.find("not specific window") == std::string::npos); +} + +/** + * @tc.name: ReportWindowTimeout + * @tc.desc: Test Case about handler is not nullptr + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, ReportWindowTimeout_Handler_NOT_NULL, TestSize.Level1) +{ + LOG_SetCallback(SessionTest4LogCallBack); + logMsg.clear(); + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "ReportWindowTimeout_Handler_NOT_NULL"; + sessionInfo.bundleName_ = "ReportWindowTimeout_Handler_NOT_NULL"; - session->SetAttachState(false); + sptr session = sptr::MakeSptr(sessionInfo); + sptr property = sptr::MakeSptr(); + property->isSystemCalling_ = true; + property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + session->SetSessionProperty(property); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); session->ReportWindowTimeout(ATTACH_EVENT_NAME); - bool isAttach = session->GetAttachState(); - EXPECT_EQ(false, isAttach); - session->SetAttachState(false); - session->ReportWindowTimeout(DETACH_EVENT_NAME); - isAttach = session->GetAttachState(); - EXPECT_EQ(false, isAttach); + sptr sceneSessionManager = sptr::MakeSptr(); + session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), + sceneSessionManager->eventHandler_); + EXPECT_TRUE(logMsg.find("not specific window") == std::string::npos); + EXPECT_TRUE(logMsg.find("handler is null") == std::string::npos); +} + +/** + * @tc.name: ReportWindowTimeout + * @tc.desc: Test Case about window animation duration + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, ReportWindowTimeout_WindowAnimationDuration, TestSize.Level1) +{ + LOG_SetCallback(SessionTest4LogCallBack); + logMsg.clear(); + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "ReportWindowTimeout_WindowAnimationDuration"; + sessionInfo.bundleName_ = "ReportWindowTimeout_WindowAnimationDuration"; - session->SetAttachState(true); + sptr session = sptr::MakeSptr(sessionInfo); + sptr property = sptr::MakeSptr(); + property->isSystemCalling_ = true; + property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + session->SetSessionProperty(property); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); session->ReportWindowTimeout(ATTACH_EVENT_NAME); - isAttach = session->GetAttachState(); - EXPECT_EQ(true, isAttach); + sptr sceneSessionManager = sptr::MakeSptr(); + session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), + sceneSessionManager->eventHandler_); + EXPECT_TRUE(logMsg.find("handler is null") == std::string::npos); + + session->SetWindowAnimationDuration(true); + EXPECT_EQ(true, session->IsNeedReportTimeout()); - session->SetAttachState(true); - session->ReportWindowTimeout(DETACH_EVENT_NAME); - isAttach = session->GetAttachState(); - EXPECT_EQ(true, isAttach); + session->SetWindowAnimationDuration(false); + EXPECT_TRUE(logMsg.find("window configured animation") == std::string::npos); } } } // namespace Rosen -- Gitee From 7fb9071cac78c129e21c110489fd8e4d3bc2ad41 Mon Sep 17 00:00:00 2001 From: koroltang Date: Mon, 14 Apr 2025 16:22:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- utils/include/perform_reporter.h | 12 +++++- utils/src/perform_reporter.cpp | 2 +- .../session/host/include/keyboard_session.h | 2 +- window_scene/session/host/include/session.h | 2 +- .../session/host/src/keyboard_session.cpp | 6 +-- window_scene/session/host/src/session.cpp | 18 ++++----- .../src/scene_session_manager.cpp | 5 ++- window_scene/test/unittest/session_test4.cpp | 38 +++++++++---------- 8 files changed, 47 insertions(+), 38 deletions(-) diff --git a/utils/include/perform_reporter.h b/utils/include/perform_reporter.h index 10989bcf95..d5ccbd619f 100644 --- a/utils/include/perform_reporter.h +++ b/utils/include/perform_reporter.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "wm_single_instance.h" namespace OHOS { @@ -64,6 +65,14 @@ struct WindowLifeCycleReportInfo { int32_t windowMode; int32_t windowFlag; std::string timeoutStage; + + inline std::string ToString() const + { + std::stringstream ss; + ss << "[bundleName:" << bundleName << ", id:" << windowId << ", type:" << windowType << ", windowMode:" << + windowMode << ", flag:" << windowFlag << "]"; + return ss.str(); + } }; class PerformReporter { @@ -113,7 +122,8 @@ public: int32_t ReportUIExtensionException(int32_t exceptionType, int32_t pid, int32_t persistentId, const std::string& uiextInfo); int32_t ReportEventDispatchException(int32_t exceptionType, int32_t pid, const std::string& flushInfo); - int32_t ReportKeyboardLifeCycleException(int32_t windowId, KeyboardLifeCycleException subType, std::string& msg); + int32_t ReportKeyboardLifeCycleException(int32_t windowId, KeyboardLifeCycleException subType, + const std::string& msg); int32_t ReportSpecWindowLifeCycleChange(WindowLifeCycleReportInfo reportInfo); private: diff --git a/utils/src/perform_reporter.cpp b/utils/src/perform_reporter.cpp index 8fea7a952c..7a8661f0f4 100644 --- a/utils/src/perform_reporter.cpp +++ b/utils/src/perform_reporter.cpp @@ -362,7 +362,7 @@ int32_t WindowInfoReporter::ReportEventDispatchException(int32_t exceptionType, } int32_t WindowInfoReporter::ReportKeyboardLifeCycleException(int32_t windowId, KeyboardLifeCycleException subType, - std::string& msg) + const std::string& msg) { std::string eventName = "KEYBOARD_LIFE_CYCLE_EXCEPTION"; int32_t ret = HiSysEventWrite( diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index 9efd8530d7..4eda9112fd 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -110,7 +110,7 @@ private: void NotifyRootSceneOccupiedAreaChange(const sptr& info); void SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool needFlush = true) override; bool IsNeedRaiseSubWindow(const sptr& callingSession, const WSRect& callingSessionRect); - void ReportLifeCycleException(); + void PostKeyboardAnimationSyncTimeoutTask(); sptr keyboardCallback_ = nullptr; bool isKeyboardSyncTransactionOpen_ = false; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 2b64295a89..6d17565478 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -909,7 +909,7 @@ private: bool ShouldCreateDetectTask(bool isAttach, WindowMode windowMode) const; bool ShouldCreateDetectTaskInRecent(bool newShowRecent, bool oldShowRecent, bool isAttach) const; void CreateDetectStateTask(bool isAttach, WindowMode windowMode); - void ReportWindowTimeout(std::string eventName); // only report for specific window + void PostSpecificSessionLifeCycleTimeoutTask(const std::string& eventName); // only report for specific window bool IsNeedReportTimeout() const; /* diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 91b565564b..cf0fdaac5e 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -635,7 +635,7 @@ void KeyboardSession::OpenKeyboardSyncTransaction() if (transactionController) { transactionController->OpenSyncTransaction(session->GetEventHandler()); } - session->ReportLifeCycleException(); + session->PostKeyboardAnimationSyncTimeoutTask(); return WSError::WS_OK; }; PostSyncTask(task); @@ -893,7 +893,7 @@ void KeyboardSession::SetSkipSelfWhenShowOnVirtualScreen(bool isSkip) }, __func__); } -void KeyboardSession::ReportLifeCycleException() +void KeyboardSession::PostKeyboardAnimationSyncTimeoutTask() { // anim_sync_exception int32_t const THRESHOLD = 1000; @@ -915,7 +915,7 @@ void KeyboardSession::ReportLifeCycleException() }; auto handler = GetEventHandler(); if (!handler) { - TLOGNE(WmsLogTag::WMS_KEYBOARD, "handler is null"); + TLOGE(WmsLogTag::WMS_KEYBOARD, "handler is null"); return; } handler->PostTask(task, KEYBOARD_ANIM_SYNC_EVENT_NAME, THRESHOLD); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 5fb2586e97..d5a3d0fb60 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1346,12 +1346,10 @@ WSError Session::Foreground(sptr property, bool isFromCli SetActive(true); } isStarting_ = false; - NotifyForeground(); isTerminating_ = false; - isNeedSyncSessionRect_ = true; - ReportWindowTimeout(ATTACH_EVENT_NAME); + PostSpecificSessionLifeCycleTimeoutTask(ATTACH_EVENT_NAME); return WSError::WS_OK; } @@ -1424,7 +1422,7 @@ WSError Session::Background(bool isFromClient, const std::string& identityToken) UpdateSessionState(SessionState::STATE_BACKGROUND); SetIsPendingToBackgroundState(false); NotifyBackground(); - ReportWindowTimeout(DETACH_EVENT_NAME); + PostSpecificSessionLifeCycleTimeoutTask(DETACH_EVENT_NAME); return WSError::WS_OK; } @@ -4174,7 +4172,7 @@ bool Session::IsNeedReportTimeout() const type != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT && type != WindowType::WINDOW_TYPE_PANEL); } -void Session::ReportWindowTimeout(std::string eventName) +void Session::PostSpecificSessionLifeCycleTimeoutTask(const std::string& eventName) { const int32_t THRESHOLD = 20; if (!IsNeedReportTimeout()) { @@ -4192,17 +4190,16 @@ void Session::ReportWindowTimeout(std::string eventName) } handler_->RemoveTask(eventName == ATTACH_EVENT_NAME ? DETACH_EVENT_NAME : ATTACH_EVENT_NAME); - auto task = [weakThis = wptr(this), eventName]() { + auto task = [weakThis = wptr(this), eventName, where = __func__]() { auto session = weakThis.promote(); if (!session) { - TLOGNI(WmsLogTag::DEFAULT, "session is null."); + TLOGNI(WmsLogTag::DEFAULT, "%{public}s, session is null.", where); return; } bool isAttach = session->GetAttachState(); if ((isAttach && eventName == ATTACH_EVENT_NAME) || - (!isAttach && eventName == DETACH_EVENT_NAME) - ) { - TLOGND(WmsLogTag::DEFAULT, "detached or attached in time"); + (!isAttach && eventName == DETACH_EVENT_NAME)) { + TLOGND(WmsLogTag::DEFAULT, "%{public}s, detached or attached in time", where); return; } WindowLifeCycleReportInfo reportInfo { @@ -4213,6 +4210,7 @@ void Session::ReportWindowTimeout(std::string eventName) static_cast(session->GetSessionProperty()->GetWindowFlags()), eventName }; + TLOGNI(WmsLogTag::DEFAULT, "%{public}s report msg: %{public}s", where, reportInfo.ToString().c_str()); WindowInfoReporter::GetInstance().ReportSpecWindowLifeCycleChange(reportInfo); }; PostTask(task, eventName, THRESHOLD); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index f57dbe5185..c0fc7d5da7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -14623,7 +14623,8 @@ void SceneSessionManager::ReportKeyboardCreateException(sptr& keyb TLOGW(WmsLogTag::DEFAULT, "session nullptr"); continue; } - msg += std::to_string(session->GetPersistentId()) + ","; + msg += "PanelId:" + std::to_string(session->GetPersistentId()) + ","; + msg += "screenId:" + std::to_string(session->GetScreenId()) + ","; } msg += "],"; for (const auto& session : GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)) { @@ -14631,7 +14632,7 @@ void SceneSessionManager::ReportKeyboardCreateException(sptr& keyb TLOGW(WmsLogTag::DEFAULT, "session nullptr"); continue; } - msg += "id:" + std::to_string(session->GetPersistentId()) + ","; + msg += "keyboardId:" + std::to_string(session->GetPersistentId()) + ","; msg += "screenId:" + std::to_string(session->GetScreenId()) + ","; } WindowInfoReporter::GetInstance().ReportKeyboardLifeCycleException( diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index 00aa9f3e80..f90a33fed9 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -41,11 +41,11 @@ const std::string UNDEFINED = "undefined"; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4"}; } namespace { -std::string logMsg; +std::string g_logMsg; void SessionTest4LogCallBack( const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg) { - logMsg = msg; + g_logMsg = msg; } } class WindowSessionTest4 : public testing::Test { @@ -1178,14 +1178,14 @@ HWTEST_F(WindowSessionTest4, IsNeedReportTimeout_specific_window, TestSize.Level } /** - * @tc.name: ReportWindowTimeout + * @tc.name: PostSpecificSessionLifeCycleTimeoutTask * @tc.desc: Test Case about non specific window * @tc.type: FUNC */ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_NonSpecificWindow, TestSize.Level1) { LOG_SetCallback(SessionTest4LogCallBack); - logMsg.clear(); + g_logMsg.clear(); SessionInfo sessionInfo; sessionInfo.abilityName_ = "ReportWindowTimeout_NonSpecificWindow"; sessionInfo.bundleName_ = "ReportWindowTimeout_NonSpecificWindow"; @@ -1197,19 +1197,19 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_NonSpecificWindow, TestSize.Lev session->SetSessionProperty(property); EXPECT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, property->GetWindowType()); EXPECT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, session->GetWindowType()); - session->ReportWindowTimeout(ATTACH_EVENT_NAME); + session->PostSpecificSessionLifeCycleTimeoutTask(ATTACH_EVENT_NAME); EXPECT_EQ(false, session->IsNeedReportTimeout()); } /** - * @tc.name: ReportWindowTimeout + * @tc.name: PostSpecificSessionLifeCycleTimeoutTask * @tc.desc: Test Case about non specific window * @tc.type: FUNC */ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_SpecificWindow, TestSize.Level1) { LOG_SetCallback(SessionTest4LogCallBack); - logMsg.clear(); + g_logMsg.clear(); SessionInfo sessionInfo; sessionInfo.abilityName_ = "ReportWindowTimeout_SpecificWindow"; sessionInfo.bundleName_ = "ReportWindowTimeout_SpecificWindow"; @@ -1221,19 +1221,19 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_SpecificWindow, TestSize.Level1 session->SetSessionProperty(property); EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); - session->ReportWindowTimeout(ATTACH_EVENT_NAME); - EXPECT_TRUE(logMsg.find("not specific window") == std::string::npos); + session->PostSpecificSessionLifeCycleTimeoutTask(ATTACH_EVENT_NAME); + EXPECT_TRUE(g_logMsg.find("not specific window") == std::string::npos); } /** - * @tc.name: ReportWindowTimeout + * @tc.name: PostSpecificSessionLifeCycleTimeoutTask * @tc.desc: Test Case about handler is not nullptr * @tc.type: FUNC */ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_Handler_NOT_NULL, TestSize.Level1) { LOG_SetCallback(SessionTest4LogCallBack); - logMsg.clear(); + g_logMsg.clear(); SessionInfo sessionInfo; sessionInfo.abilityName_ = "ReportWindowTimeout_Handler_NOT_NULL"; sessionInfo.bundleName_ = "ReportWindowTimeout_Handler_NOT_NULL"; @@ -1245,24 +1245,24 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_Handler_NOT_NULL, TestSize.Leve session->SetSessionProperty(property); EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); - session->ReportWindowTimeout(ATTACH_EVENT_NAME); + session->PostSpecificSessionLifeCycleTimeoutTask(ATTACH_EVENT_NAME); sptr sceneSessionManager = sptr::MakeSptr(); session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), sceneSessionManager->eventHandler_); - EXPECT_TRUE(logMsg.find("not specific window") == std::string::npos); - EXPECT_TRUE(logMsg.find("handler is null") == std::string::npos); + EXPECT_TRUE(g_logMsg.find("not specific window") == std::string::npos); + EXPECT_TRUE(g_logMsg.find("handler is null") == std::string::npos); } /** - * @tc.name: ReportWindowTimeout + * @tc.name: PostSpecificSessionLifeCycleTimeoutTask * @tc.desc: Test Case about window animation duration * @tc.type: FUNC */ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_WindowAnimationDuration, TestSize.Level1) { LOG_SetCallback(SessionTest4LogCallBack); - logMsg.clear(); + g_logMsg.clear(); SessionInfo sessionInfo; sessionInfo.abilityName_ = "ReportWindowTimeout_WindowAnimationDuration"; sessionInfo.bundleName_ = "ReportWindowTimeout_WindowAnimationDuration"; @@ -1274,17 +1274,17 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_WindowAnimationDuration, TestSi session->SetSessionProperty(property); EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, property->GetWindowType()); EXPECT_EQ(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, session->GetWindowType()); - session->ReportWindowTimeout(ATTACH_EVENT_NAME); + session->PostSpecificSessionLifeCycleTimeoutTask(ATTACH_EVENT_NAME); sptr sceneSessionManager = sptr::MakeSptr(); session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), sceneSessionManager->eventHandler_); - EXPECT_TRUE(logMsg.find("handler is null") == std::string::npos); + EXPECT_TRUE(g_logMsg.find("handler is null") == std::string::npos); session->SetWindowAnimationDuration(true); EXPECT_EQ(true, session->IsNeedReportTimeout()); session->SetWindowAnimationDuration(false); - EXPECT_TRUE(logMsg.find("window configured animation") == std::string::npos); + EXPECT_TRUE(g_logMsg.find("window configured animation") == std::string::npos); } } } // namespace Rosen -- Gitee