From 6479646e001804a091068e6f4ca221734a1dff18 Mon Sep 17 00:00:00 2001 From: hejiaogirl Date: Sat, 26 Jul 2025 17:54:12 +0800 Subject: [PATCH] fix : widget tip bug Signed-off-by: hejiaogirl Change-Id: Ice1a4aed0f1c258222a070cde62b64da8ac23135 --- frameworks/common/inc/auth_common.h | 5 +- services/context/inc/widget_context.h | 11 +- services/context/src/widget_client.cpp | 19 ++- services/context/src/widget_context.cpp | 128 ++---------------- services/core/inc/widget_schedule_node.h | 8 +- .../core/inc/widget_schedule_node_callback.h | 2 +- .../core/src/widget_schedule_node_impl.cpp | 33 +++-- services/core/src/widget_schedule_node_impl.h | 5 +- services/ipc/src/user_auth_service.cpp | 1 - test/unittest/services/mocks/mock_context.h | 2 +- .../mocks/mock_widget_schedule_node.h | 2 +- .../mock_widget_schedule_node_callback.h | 2 +- .../services/src/widget_client_test.cpp | 18 ++- .../services/src/widget_context_test.cpp | 80 ----------- 14 files changed, 79 insertions(+), 237 deletions(-) diff --git a/frameworks/common/inc/auth_common.h b/frameworks/common/inc/auth_common.h index 64697fb0e..517db15f1 100644 --- a/frameworks/common/inc/auth_common.h +++ b/frameworks/common/inc/auth_common.h @@ -50,8 +50,9 @@ constexpr const char *NOTICE_EVENT_USER_NAVIGATION = "EVENT_AUTH_USER_NAVIGATION constexpr const char *NOTICE_EVENT_WIDGET_PARA_INVALID = "EVENT_AUTH_WIDGET_PARA_INVALID"; constexpr const char *NOTICE_EVENT_END = "EVENT_AUTH_END"; constexpr const char *NOTICE_EVENT_RELOAD = "EVENT_AUTH_RELOAD"; -constexpr const char *EVENT_AUTH_WIDGET_LOADED = "EVENT_AUTH_WIDGET_LOADED"; -constexpr const char *EVENT_AUTH_WIDGET_RELEASED = "EVENT_AUTH_WIDGET_RELEASED"; +constexpr const char *NOTICE_EVENT_AUTH_WIDGET_LOADED = "EVENT_AUTH_WIDGET_LOADED"; +constexpr const char *NOTICE_EVENT_AUTH_WIDGET_RELEASED = "EVENT_AUTH_WIDGET_RELEASED"; +constexpr const char *NOTICE_EVENT_PROCESS_TERMINATE = "EVENT_PROCESS_TERMINATE"; // For API6 enum class AuthenticationResult : int32_t { diff --git a/services/context/inc/widget_context.h b/services/context/inc/widget_context.h index 0f42bf3d5..5f6e9d0ed 100644 --- a/services/context/inc/widget_context.h +++ b/services/context/inc/widget_context.h @@ -82,7 +82,7 @@ public: void AuthResult(int32_t resultCode, int32_t authType, const Attributes &finalResult); void AuthTipInfo(int32_t tipInfo, int32_t authType, const Attributes &extraInfo); - void SendAuthResult() override; + void ClearSchedule() override; void SendAuthTipInfo(int32_t authType, int32_t tipInfo) override; protected: @@ -123,12 +123,6 @@ private: void ProcAuthResult(int32_t resultCode, AuthType authType, int32_t freezingTime, const Attributes &finalResult); void ProcAuthTipInfo(int32_t tip, AuthType authType, const std::vector &extraInfo); - void StartOnResultTimer(int32_t resultCode, AuthType authType, int32_t freezingTime); - void StopOnResultTimer(); - void OnResultTimerTimeOut(int32_t resultCode, AuthType authType, int32_t freezingTime); - void StartOnTipTimer(AuthType authType, int32_t freezingTime); - void StopOnTipTimer(); - void OnTipTimerTimeOut(AuthType authType, int32_t freezingTime); private: struct TaskInfo { @@ -166,9 +160,6 @@ private: WidgetAuthResultInfo authResultInfo_ {}; int32_t faceReload_ {0}; uint32_t widgetAlreadyLoad_ {0}; - uint32_t onResultTimerId_ {0}; - uint32_t onTipTimerId_ {0}; - ResultInfo resultInfo_{0}; nlohmann::json jsonBuf_ = {}; }; } // namespace UserAuth diff --git a/services/context/src/widget_client.cpp b/services/context/src/widget_client.cpp index b3ea69856..6d49af4d6 100644 --- a/services/context/src/widget_client.cpp +++ b/services/context/src/widget_client.cpp @@ -116,11 +116,12 @@ void WidgetClient::ProcessNotice(const WidgetNotice ¬ice, std::vectorWidgetReload(notice.orientation, notice.needRotate, notice.alreadyLoad, authTypeList[0]); } - } else if (notice.event == EVENT_AUTH_WIDGET_LOADED) { + } else if (notice.event == NOTICE_EVENT_AUTH_WIDGET_LOADED) { schedule_->SendAuthTipInfo(authTypeList, TIP_CODE_WIDGET_LOADED); - } else if (notice.event == EVENT_AUTH_WIDGET_RELEASED) { + } else if (notice.event == NOTICE_EVENT_AUTH_WIDGET_RELEASED) { schedule_->SendAuthTipInfo(authTypeList, TIP_CODE_WIDGET_RELEASED); - schedule_->SendAuthResult(); + } else if (notice.event == NOTICE_EVENT_PROCESS_TERMINATE) { + schedule_->ClearSchedule(); } } @@ -240,12 +241,9 @@ void WidgetClient::Reset() void WidgetClient::ForceStopAuth() { IAM_LOGE("stop auth process forcely by disconnect"); - if (widgetContextId_ != 0) { - IAM_LOGE("widget context id hasn't been reset"); - UserIam::UserAuth::ReportSystemFault(Common::GetNowTimeString(), "AuthWidget"); - } if (schedule_ != nullptr) { schedule_->StopSchedule(); + schedule_->ClearSchedule(); } } @@ -319,8 +317,9 @@ bool WidgetClient::IsValidNoticeType(const WidgetNotice ¬ice) notice.event != NOTICE_EVENT_WIDGET_PARA_INVALID && notice.event != NOTICE_EVENT_RELOAD && notice.event != NOTICE_EVENT_END && - notice.event != EVENT_AUTH_WIDGET_LOADED && - notice.event != EVENT_AUTH_WIDGET_RELEASED) { + notice.event != NOTICE_EVENT_AUTH_WIDGET_LOADED && + notice.event != NOTICE_EVENT_AUTH_WIDGET_RELEASED && + notice.event != NOTICE_EVENT_PROCESS_TERMINATE) { return false; } return true; @@ -337,4 +336,4 @@ void WidgetClient::SetCallingBundleName(const std::string &callingBundleName) } } // namespace UserAuth } // namespace UserIam -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/context/src/widget_context.cpp b/services/context/src/widget_context.cpp index 74612a3f2..227eaf560 100644 --- a/services/context/src/widget_context.cpp +++ b/services/context/src/widget_context.cpp @@ -66,7 +66,6 @@ const std::string TO_PORTRAIT = "90"; const std::string TO_INVERTED = "180"; const std::string TO_PORTRAIT_INVERTED = "270"; const std::string SUPPORT_FOLLOW_CALLER_UI = "const.useriam.authWidget.supportFollowCallerUi"; -static constexpr uint32_t RESULT_TIMER_LEN_MS = 100; WidgetContext::WidgetContext(uint64_t contextId, const ContextFactory::AuthWidgetContextPara ¶, std::shared_ptr callback, const sptr &modalCallback) @@ -669,7 +668,6 @@ void WidgetContext::StopAllRunTask(const ResultCode &resultCode) IAM_LOGE("failed to release launch widget."); } } - WidgetClient::Instance().Reset(); } void WidgetContext::BuildStartPinSubType(WidgetCmdParameters &widgetCmdParameters) @@ -824,13 +822,22 @@ void WidgetContext::ProcAuthResult(int32_t resultCode, AuthType authType, int32_ if (resultCode != ResultCode::SUCCESS) { SetLatestError(resultCode); } + schedule_->SuccessAuth(authType); } else { SetLatestError(resultCode); if (resultCode != ResultCode::CANCELED) { SendAuthTipInfo(authType, GetAuthTipCode(resultCode, freezingTime)); } + if (para_.skipLockedBiometricAuth && freezingTime > 0) { + if (IsSingleFaceOrFingerPrintAuth()) { + schedule_->FailAuth(authType); + } else if (IsNavigationAuth()) { + schedule_->NaviPinAuth(); + } + } else { + schedule_->StopAuthList({authType}); + } } - StartOnResultTimer(resultCode, authType, freezingTime); } void WidgetContext::ProcAuthTipInfo(int32_t tip, AuthType authType, const std::vector &extraInfo) @@ -850,106 +857,6 @@ void WidgetContext::ProcAuthTipInfo(int32_t tip, AuthType authType, const std::v if (resultCode != ResultCode::CANCELED) { SendAuthTipInfo(authType, GetAuthTipCode(resultCode, freezingTime)); } - StartOnTipTimer(authType, freezingTime); -} - -void WidgetContext::StartOnResultTimer(int32_t resultCode, AuthType authType, int32_t freezingTime) -{ - IAM_LOGI("start"); - std::lock_guard lock(mutex_); - resultInfo_.resultCode = resultCode; - resultInfo_.authType = authType; - resultInfo_.freezingTime = freezingTime; - if (onResultTimerId_ != 0) { - IAM_LOGI("onResult timer is already start"); - return; - } - - onResultTimerId_ = RelativeTimer::GetInstance().Register( - [weakSelf = weak_from_this(), resultCode, authType, freezingTime] { - auto self = weakSelf.lock(); - if (self == nullptr) { - IAM_LOGE("context is released"); - return; - } - self->OnResultTimerTimeOut(resultCode, authType, freezingTime); - }, - RESULT_TIMER_LEN_MS); -} - -void WidgetContext::StopOnResultTimer() -{ - IAM_LOGI("start"); - std::lock_guard lock(mutex_); - if (onResultTimerId_ == 0) { - IAM_LOGI("onResult timer is already stop"); - return; - } - - RelativeTimer::GetInstance().Unregister(onResultTimerId_); - onResultTimerId_ = 0; -} - -void WidgetContext::OnResultTimerTimeOut(int32_t resultCode, AuthType authType, int32_t freezingTime) -{ - IAM_LOGI("start"); - IF_FALSE_LOGE_AND_RETURN(schedule_ != nullptr); - if (resultCode == ResultCode::SUCCESS || resultCode == ResultCode::COMPLEXITY_CHECK_FAILED) { - schedule_->SuccessAuth(authType); - } else { - if (para_.skipLockedBiometricAuth && freezingTime > 0) { - if (IsSingleFaceOrFingerPrintAuth()) { - schedule_->FailAuth(authType); - } else if (IsNavigationAuth()) { - schedule_->NaviPinAuth(); - } - } else { - schedule_->StopAuthList({authType}); - } - } -} - -void WidgetContext::StartOnTipTimer(AuthType authType, int32_t freezingTime) -{ - IAM_LOGI("start"); - std::lock_guard lock(mutex_); - resultInfo_.resultCode = FAIL; - resultInfo_.authType = authType; - resultInfo_.freezingTime = freezingTime; - if (onTipTimerId_ != 0) { - IAM_LOGI("onTip timer is already start"); - return; - } - - onTipTimerId_ = RelativeTimer::GetInstance().Register( - [weakSelf = weak_from_this(), authType, freezingTime] { - auto self = weakSelf.lock(); - if (self == nullptr) { - IAM_LOGE("context is released"); - return; - } - self->OnTipTimerTimeOut(authType, freezingTime); - }, - RESULT_TIMER_LEN_MS); -} - -void WidgetContext::StopOnTipTimer() -{ - IAM_LOGI("start"); - std::lock_guard lock(mutex_); - if (onTipTimerId_ == 0) { - IAM_LOGI("onTip timer is already stop"); - return; - } - - RelativeTimer::GetInstance().Unregister(onTipTimerId_); - onTipTimerId_ = 0; -} - -void WidgetContext::OnTipTimerTimeOut(AuthType authType, int32_t freezingTime) -{ - IAM_LOGI("start"); - IF_FALSE_LOGE_AND_RETURN(schedule_ != nullptr); if (para_.skipLockedBiometricAuth && freezingTime > 0) { if (IsSingleFaceOrFingerPrintAuth()) { schedule_->FailAuth(authType); @@ -959,19 +866,12 @@ void WidgetContext::OnTipTimerTimeOut(AuthType authType, int32_t freezingTime) } } -void WidgetContext::SendAuthResult() +void WidgetContext::ClearSchedule() { IAM_LOGI("start"); - std::lock_guard lock(mutex_); - if (onTipTimerId_ != 0 && resultInfo_.resultCode != SUCCESS) { - OnTipTimerTimeOut(resultInfo_.authType, resultInfo_.freezingTime); - StopOnTipTimer(); - } - - if (onResultTimerId_ != 0) { - OnResultTimerTimeOut(resultInfo_.resultCode, resultInfo_.authType, resultInfo_.freezingTime); - StopOnResultTimer(); - } + WidgetClient::Instance().Reset(); + auto result = ContextPool::Instance().Delete(GetContextId()); + IAM_LOGI("context ****%{public}hx deleted %{public}s", static_cast(contextId_), result ? "succ" : "fail"); } } // namespace UserAuth } // namespace UserIam diff --git a/services/core/inc/widget_schedule_node.h b/services/core/inc/widget_schedule_node.h index fb16dcd8f..3d93090c7 100644 --- a/services/core/inc/widget_schedule_node.h +++ b/services/core/inc/widget_schedule_node.h @@ -38,7 +38,8 @@ public: S_WIDGET_WAITING = 1, S_WIDGET_AUTH_RUNNING = 2, S_WIDGET_AUTH_FINISHED = 3, - S_WIDGET_RELOAD_WAITING = 4 + S_WIDGET_RELOAD_WAITING = 4, + S_WIDGET_RELEASED = 5, }; enum Event : uint32_t { @@ -51,6 +52,7 @@ public: E_WIDGET_PARA_INVALID = 6, E_WIDGET_RELOAD = 7, E_STOP_AUTH = 8, + E_WIDGET_RELEASE = 9, }; virtual ~WidgetScheduleNode() = default; @@ -67,9 +69,9 @@ public: AuthType &rotateAuthType) = 0; virtual void SetCallback(std::shared_ptr callback) = 0; virtual void SendAuthTipInfo(const std::vector &authTypeList, int32_t tipCode) = 0; - virtual void SendAuthResult() = 0; + virtual bool ClearSchedule() = 0; }; } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // IAM_WIDGET_SCHEDULE_NODE_H \ No newline at end of file +#endif // IAM_WIDGET_SCHEDULE_NODE_H diff --git a/services/core/inc/widget_schedule_node_callback.h b/services/core/inc/widget_schedule_node_callback.h index 2f409317f..2c64b092b 100644 --- a/services/core/inc/widget_schedule_node_callback.h +++ b/services/core/inc/widget_schedule_node_callback.h @@ -44,7 +44,7 @@ public: AuthType &rotateAuthType) = 0; virtual void AuthWidgetReloadInit() = 0; virtual void SendAuthTipInfo(int32_t authType, int32_t tipInfo) = 0; - virtual void SendAuthResult() = 0; + virtual void ClearSchedule() = 0; }; } // namespace UserAuth } // namespace UserIam diff --git a/services/core/src/widget_schedule_node_impl.cpp b/services/core/src/widget_schedule_node_impl.cpp index 0f6cf98c5..82304d1f8 100644 --- a/services/core/src/widget_schedule_node_impl.cpp +++ b/services/core/src/widget_schedule_node_impl.cpp @@ -80,6 +80,15 @@ std::shared_ptr WidgetScheduleNodeImpl::MakeFiniteStateMachi builder->MakeTransition(S_WIDGET_RELOAD_WAITING, E_CANCEL_AUTH, S_WIDGET_WAITING, [this](FiniteStateMachine &machine, uint32_t event) { OnWidgetReload(machine, event); }); + builder->MakeTransition(S_WIDGET_INIT, E_WIDGET_RELEASE, S_WIDGET_RELEASED, + [this](FiniteStateMachine &machine, uint32_t event) { OnWidgetRelease(machine, event); }); + builder->MakeTransition(S_WIDGET_WAITING, E_WIDGET_RELEASE, S_WIDGET_RELEASED, + [this](FiniteStateMachine &machine, uint32_t event) { OnWidgetRelease(machine, event); }); + builder->MakeTransition(S_WIDGET_AUTH_RUNNING, E_WIDGET_RELEASE, S_WIDGET_RELEASED, + [this](FiniteStateMachine &machine, uint32_t event) { OnWidgetRelease(machine, event); }); + builder->MakeTransition(S_WIDGET_AUTH_FINISHED, E_WIDGET_RELEASE, S_WIDGET_RELEASED, + [this](FiniteStateMachine &machine, uint32_t event) { OnWidgetRelease(machine, event); }); + return builder->Build(); } @@ -111,6 +120,12 @@ bool WidgetScheduleNodeImpl::StopSchedule() return TryKickMachine(E_CANCEL_AUTH); } +bool WidgetScheduleNodeImpl::ClearSchedule() +{ + std::lock_guard lock(mutex_); + return TryKickMachine(E_WIDGET_RELEASE); +} + bool WidgetScheduleNodeImpl::StartAuthList(const std::vector &authTypeList, bool endAfterFirstFail, AuthIntent authIntent) { @@ -269,23 +284,23 @@ void WidgetScheduleNodeImpl::OnWidgetReload(FiniteStateMachine &machine, uint32_ } } -void WidgetScheduleNodeImpl::SendAuthTipInfo(const std::vector &authTypeList, int32_t tipCode) +void WidgetScheduleNodeImpl::OnWidgetRelease(FiniteStateMachine &machine, uint32_t event) { auto callback = callback_.lock(); IF_FALSE_LOGE_AND_RETURN(callback != nullptr); - IAM_LOGI("send mid auth result"); - for (auto &authType : authTypeList) { - callback->SendAuthTipInfo(authType, tipCode); - } + IAM_LOGI("clear schedule"); + callback->ClearSchedule(); } -void WidgetScheduleNodeImpl::SendAuthResult() +void WidgetScheduleNodeImpl::SendAuthTipInfo(const std::vector &authTypeList, int32_t tipCode) { auto callback = callback_.lock(); IF_FALSE_LOGE_AND_RETURN(callback != nullptr); - IAM_LOGI("send auth result"); - callback->SendAuthResult(); + IAM_LOGI("send mid auth result"); + for (auto &authType : authTypeList) { + callback->SendAuthTipInfo(authType, tipCode); + } } } // namespace UserAuth } // namespace UserIam -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/core/src/widget_schedule_node_impl.h b/services/core/src/widget_schedule_node_impl.h index 69456e0ad..73a121c91 100644 --- a/services/core/src/widget_schedule_node_impl.h +++ b/services/core/src/widget_schedule_node_impl.h @@ -50,7 +50,7 @@ public: AuthType &rotateAuthType) override; void SetCallback(std::shared_ptr callback) override; void SendAuthTipInfo(const std::vector &authTypeList, int32_t tipCode) override; - void SendAuthResult() override; + bool ClearSchedule() override; protected: void OnStartSchedule(FiniteStateMachine &machine, uint32_t event); @@ -63,6 +63,7 @@ protected: void OnWidgetReload(FiniteStateMachine &machine, uint32_t event); void OnWidgetReloadInit(FiniteStateMachine &machine, uint32_t event); void OnFailAuth(FiniteStateMachine &machine, uint32_t event); + void OnWidgetRelease(FiniteStateMachine &machine, uint32_t event); private: std::shared_ptr MakeFiniteStateMachine(); @@ -89,4 +90,4 @@ private: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // IAM_WIDGET_SCHEDULE_NODE_IMPL_H \ No newline at end of file +#endif // IAM_WIDGET_SCHEDULE_NODE_IMPL_H diff --git a/services/ipc/src/user_auth_service.cpp b/services/ipc/src/user_auth_service.cpp index 0eee2ac1f..973e84a75 100644 --- a/services/ipc/src/user_auth_service.cpp +++ b/services/ipc/src/user_auth_service.cpp @@ -1171,7 +1171,6 @@ uint64_t UserAuthService::StartWidgetContext(const std::shared_ptrSetTraceRequestContextId(context->GetContextId()); - contextCallback->SetCleaner(ContextHelper::Cleaner(context)); if (!context->Start()) { int32_t errorCode = context->GetLatestError(); IAM_LOGE("start widget context fail %{public}d", errorCode); diff --git a/test/unittest/services/mocks/mock_context.h b/test/unittest/services/mocks/mock_context.h index a1045daa4..7336ffb68 100644 --- a/test/unittest/services/mocks/mock_context.h +++ b/test/unittest/services/mocks/mock_context.h @@ -142,4 +142,4 @@ protected: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // IAM_MOCK_CONTEXT_H \ No newline at end of file +#endif // IAM_MOCK_CONTEXT_H diff --git a/test/unittest/services/mocks/mock_widget_schedule_node.h b/test/unittest/services/mocks/mock_widget_schedule_node.h index 5b7a15550..274f53dbf 100644 --- a/test/unittest/services/mocks/mock_widget_schedule_node.h +++ b/test/unittest/services/mocks/mock_widget_schedule_node.h @@ -37,7 +37,7 @@ public: MOCK_METHOD4(WidgetReload, bool(uint32_t orientation, uint32_t needRotate, uint32_t alreadyLoad, AuthType &rotateAuthType)); MOCK_METHOD2(SendAuthTipInfo, void(const std::vector &authTypeList, int32_t tipCode)); - MOCK_METHOD0(SendAuthResult, void()); + MOCK_METHOD0(ClearSchedule, bool()); }; } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/services/mocks/mock_widget_schedule_node_callback.h b/test/unittest/services/mocks/mock_widget_schedule_node_callback.h index 4963fa6ff..79b072cdb 100644 --- a/test/unittest/services/mocks/mock_widget_schedule_node_callback.h +++ b/test/unittest/services/mocks/mock_widget_schedule_node_callback.h @@ -37,7 +37,7 @@ public: MOCK_METHOD1(SuccessAuth, void(AuthType authType)); MOCK_METHOD1(FailAuth, void(AuthType authType)); MOCK_METHOD2(SendAuthTipInfo, void(int32_t authType, int32_t tipInfo)); - MOCK_METHOD0(SendAuthResult, void()); + MOCK_METHOD0(ClearSchedule, void()); MOCK_METHOD4(AuthWidgetReload, bool(uint32_t orientation, uint32_t needRotate, uint32_t alreadyLoad, AuthType &rotateAuthType)); MOCK_METHOD0(AuthWidgetReloadInit, void()); diff --git a/test/unittest/services/src/widget_client_test.cpp b/test/unittest/services/src/widget_client_test.cpp index 16879eacf..2cc59c134 100644 --- a/test/unittest/services/src/widget_client_test.cpp +++ b/test/unittest/services/src/widget_client_test.cpp @@ -498,7 +498,7 @@ HWTEST_F(WidgetClientTest, WidgetClientTestProcessNotice_006, TestSize.Level0) { WidgetNotice widgetNotice; widgetNotice.widgetContextId = 1; - widgetNotice.event = EVENT_AUTH_WIDGET_LOADED; + widgetNotice.event = NOTICE_EVENT_AUTH_WIDGET_LOADED; widgetNotice.typeList.push_back("pin"); WidgetClient::Instance().Reset(); std::vector authTypeList; @@ -512,7 +512,21 @@ HWTEST_F(WidgetClientTest, WidgetClientTestProcessNotice_007, TestSize.Level0) { WidgetNotice widgetNotice; widgetNotice.widgetContextId = 1; - widgetNotice.event = EVENT_AUTH_WIDGET_RELEASED; + widgetNotice.event = NOTICE_EVENT_AUTH_WIDGET_RELEASED; + widgetNotice.typeList.push_back("pin"); + WidgetClient::Instance().Reset(); + std::vector authTypeList; + authTypeList.emplace_back(AuthType::PIN); + WidgetClient::Instance().SetAuthTypeList(authTypeList); + WidgetClient::Instance().SetWidgetSchedule(BuildSchedule()); + EXPECT_NO_THROW(WidgetClient::Instance().ProcessNotice(widgetNotice, authTypeList)); +} + +HWTEST_F(WidgetClientTest, WidgetClientTestProcessNotice_007, TestSize.Level0) +{ + WidgetNotice widgetNotice; + widgetNotice.widgetContextId = 1; + widgetNotice.event = NOTICE_EVENT_PROCESS_TERMINATE; widgetNotice.typeList.push_back("pin"); WidgetClient::Instance().Reset(); std::vector authTypeList; diff --git a/test/unittest/services/src/widget_context_test.cpp b/test/unittest/services/src/widget_context_test.cpp index 19f3e0c0d..481112c24 100644 --- a/test/unittest/services/src/widget_context_test.cpp +++ b/test/unittest/services/src/widget_context_test.cpp @@ -718,86 +718,6 @@ HWTEST_F(WidgetContextTest, WidgetContextTestProcAuthTipInfo, TestSize.Level0) EXPECT_NO_THROW(widgetContext->ProcAuthTipInfo(0, PIN, extraInfo)); } -HWTEST_F(WidgetContextTest, WidgetContextTestStopOnResultTimer, TestSize.Level0) -{ - uint64_t contextId = 1; - ContextFactory::AuthWidgetContextPara para; - auto widgetContext = CreateWidgetContext(contextId, para); - EXPECT_NE(widgetContext, nullptr); - EXPECT_NO_THROW(widgetContext->StopOnResultTimer()); - widgetContext->onResultTimerId_ = 1; - EXPECT_NO_THROW(widgetContext->StopOnResultTimer()); -} - -HWTEST_F(WidgetContextTest, WidgetContextTestOnResultTimerTimeOut, TestSize.Level0) -{ - uint64_t contextId = 1; - ContextFactory::AuthWidgetContextPara para; - auto widgetContext = CreateWidgetContext(contextId, para); - int32_t resultCode = 0; - AuthType authType = AuthType::ALL; - int32_t freezingTime = 0; - widgetContext->BuildSchedule(); - EXPECT_NO_THROW(widgetContext->OnResultTimerTimeOut(resultCode, authType, freezingTime)); - resultCode = 1; - EXPECT_NO_THROW(widgetContext->OnResultTimerTimeOut(resultCode, authType, freezingTime)); - freezingTime = 1; - widgetContext->para_.skipLockedBiometricAuth = true; - EXPECT_NO_THROW(widgetContext->OnResultTimerTimeOut(resultCode, authType, freezingTime)); - widgetContext->para_.widgetParam.navigationButtonText = "1"; - EXPECT_NO_THROW(widgetContext->OnResultTimerTimeOut(resultCode, authType, freezingTime)); - widgetContext->para_.widgetParam.navigationButtonText = ""; - authType = AuthType::FACE; - widgetContext->para_.authTypeList.emplace_back(authType); - EXPECT_NO_THROW(widgetContext->OnResultTimerTimeOut(resultCode, authType, freezingTime)); -} - -HWTEST_F(WidgetContextTest, WidgetContextTestStopOnTipTimer, TestSize.Level0) -{ - uint64_t contextId = 1; - ContextFactory::AuthWidgetContextPara para; - auto widgetContext = CreateWidgetContext(contextId, para); - EXPECT_NE(widgetContext, nullptr); - EXPECT_NO_THROW(widgetContext->StopOnTipTimer()); - widgetContext->onTipTimerId_ = 1; - EXPECT_NO_THROW(widgetContext->StopOnTipTimer()); -} - -HWTEST_F(WidgetContextTest, WidgetContextTestOnTipTimerTimeOut, TestSize.Level0) -{ - uint64_t contextId = 1; - ContextFactory::AuthWidgetContextPara para; - auto widgetContext = CreateWidgetContext(contextId, para); - EXPECT_NE(widgetContext, nullptr); - AuthType authType = AuthType::ALL; - int32_t freezingTime = 0; - widgetContext->BuildSchedule(); - EXPECT_NO_THROW(widgetContext->OnTipTimerTimeOut(authType, freezingTime)); - widgetContext->para_.skipLockedBiometricAuth = true; - freezingTime = 1; - EXPECT_NO_THROW(widgetContext->OnTipTimerTimeOut(authType, freezingTime)); - widgetContext->para_.widgetParam.navigationButtonText = "1"; - EXPECT_NO_THROW(widgetContext->OnTipTimerTimeOut(authType, freezingTime)); - widgetContext->para_.widgetParam.navigationButtonText = ""; - authType = AuthType::FACE; - widgetContext->para_.authTypeList.emplace_back(authType); - EXPECT_NO_THROW(widgetContext->OnTipTimerTimeOut(authType, freezingTime)); -} - -HWTEST_F(WidgetContextTest, WidgetContextTestSendAuthResult, TestSize.Level0) -{ - uint64_t contextId = 1; - ContextFactory::AuthWidgetContextPara para; - auto widgetContext = CreateWidgetContext(contextId, para); - EXPECT_NE(widgetContext, nullptr); - EXPECT_NO_THROW(widgetContext->SendAuthResult()); - widgetContext->onTipTimerId_ = 1; - widgetContext->resultInfo_.resultCode = 1; - EXPECT_NO_THROW(widgetContext->SendAuthResult()); - widgetContext->onResultTimerId_ = 1; - EXPECT_NO_THROW(widgetContext->SendAuthResult()); -} - HWTEST_F(WidgetContextTest, WidgetContextTestSetSysDialogZOrder, TestSize.Level0) { uint64_t contextId = 1; -- Gitee