From 6104471b464eef6924d4b7788a3fb2cc59682318 Mon Sep 17 00:00:00 2001 From: hemenghao Date: Fri, 30 May 2025 16:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=8F=8A=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hemenghao --- .../src/identity_checker_impl.cpp | 2 +- services/src/peruser_session.cpp | 2 +- .../imeenabledinfomanager_fuzzer.cpp | 5 +++-- .../inputmethodsystemability_fuzzer.cpp | 3 ++- test/unittest/cpp_test/src/ime_proxy_test.cpp | 15 +++++++++++++++ .../unittest/cpp_test/src/window_adapter_test.cpp | 14 ++++++++++++++ 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/services/identity_checker/src/identity_checker_impl.cpp b/services/identity_checker/src/identity_checker_impl.cpp index 4eaa81fb0..c407dc989 100644 --- a/services/identity_checker/src/identity_checker_impl.cpp +++ b/services/identity_checker/src/identity_checker_impl.cpp @@ -117,7 +117,7 @@ bool IdentityCheckerImpl::IsFocusedUIExtension(uint32_t callingTokenId, sptr(focusInfo.windowId_); } bool isFocused = false; diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 2a7b30ec2..237dab045 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -2123,7 +2123,7 @@ ImfCallingWindowInfo PerUserSession::GetCallingWindowInfo(const InputClientInfo return finalWindowInfo; } if (finalWindowId == INVALID_WINDOW_ID) { - finalWindowId = focusInfo.windowId_; + finalWindowId = static_cast(focusInfo.windowId_); } return { finalWindowId, callingWindowInfo.displayId_ }; } diff --git a/test/fuzztest/imeenabledinfomanager_fuzzer/imeenabledinfomanager_fuzzer.cpp b/test/fuzztest/imeenabledinfomanager_fuzzer/imeenabledinfomanager_fuzzer.cpp index 9abace6a7..3558d4332 100644 --- a/test/fuzztest/imeenabledinfomanager_fuzzer/imeenabledinfomanager_fuzzer.cpp +++ b/test/fuzztest/imeenabledinfomanager_fuzzer/imeenabledinfomanager_fuzzer.cpp @@ -19,6 +19,7 @@ using namespace OHOS::MiscServices; namespace OHOS { +const int8_t EVEN_CHECK_NUMBER = 2; std::string GetString(const uint8_t *data, size_t size) { if (data == nullptr || size == 0) { @@ -122,7 +123,7 @@ void FuzzSetCurrentIme(const uint8_t *data, size_t size) auto userId = static_cast(size); auto fuzzedString = GetString(data, size); std::string imeId = fuzzedString; - if (size % 2 == 0) { + if (size % EVEN_NUMBER == 0) { imeId = fuzzedString + "/" + "ext"; } bool isSetByUser = false; @@ -137,7 +138,7 @@ void FuzzSetTmpIme(const uint8_t *data, size_t size) auto userId = static_cast(size); auto fuzzedString = GetString(data, size); std::string imeId = fuzzedString; - if (size % 2 == 0) { + if (size % EVEN_NUMBER == 0) { imeId = fuzzedString + "/" + "ext"; } ImeEnabledInfoManager::GetInstance().SetTmpIme(userId, imeId); diff --git a/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp b/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp index 0fa0496a9..ae56b0d91 100644 --- a/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp +++ b/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp @@ -141,7 +141,8 @@ void FuzzHandleOperation(const uint8_t *data, size_t size) DelayedSingleton::GetInstance()->HandleWmsConnected(fuzzedInt32, fuzzedInt32); DelayedSingleton::GetInstance()->HandleScbStarted(fuzzedInt32, fuzzedInt32); DelayedSingleton::GetInstance()->HandleWmsDisconnected(fuzzedInt32, fuzzedInt32); - DelayedSingleton::GetInstance()->NeedHideWhenSwitchInputType(fuzzedInt32, inputType, fuzzedBool); + DelayedSingleton::GetInstance()->NeedHideWhenSwitchInputType(fuzzedInt32, inputType, + fuzzedBool); DelayedSingleton::GetInstance()->GetAlternativeIme(fuzzedInt32, fuzzedString); } } // namespace OHOS diff --git a/test/unittest/cpp_test/src/ime_proxy_test.cpp b/test/unittest/cpp_test/src/ime_proxy_test.cpp index c5b91f4c7..72cfb645b 100644 --- a/test/unittest/cpp_test/src/ime_proxy_test.cpp +++ b/test/unittest/cpp_test/src/ime_proxy_test.cpp @@ -668,5 +668,20 @@ HWTEST_F(ImeProxyTest, DiscardTypingTextTest, TestSize.Level0) auto ret = InputMethodAbility::GetInstance().OnDiscardTypingText(); EXPECT_EQ(ret, ErrorCode::NO_ERROR); } + +/** + * @tc.name: TestRegisterProxyIme + * @tc.desc: Test RegisterProxyIme + * @tc.type: FUNC + */ +HWTEST_F(ImeProxyTest, RegisterProxyImeTest, TestSize.Level0) +{ + IMSA_HILOGI("ImeProxyTest::TestRegisterProxyImeTest"); + uint64_t displayId = -1; + auto ret = InputMethodAbilityInterface::GetInstance().RegisterProxyIme(displayId); + EXPECT_NE(ret, ErrorCode::NO_ERROR); + ret = InputMethodAbilityInterface::GetInstance().UnregisterProxyIme(displayId); + EXPECT_NE(ret, ErrorCode::NO_ERROR); +} } // namespace MiscServices } // namespace OHOS diff --git a/test/unittest/cpp_test/src/window_adapter_test.cpp b/test/unittest/cpp_test/src/window_adapter_test.cpp index a3315abc2..afb9f89ba 100644 --- a/test/unittest/cpp_test/src/window_adapter_test.cpp +++ b/test/unittest/cpp_test/src/window_adapter_test.cpp @@ -72,5 +72,19 @@ HWTEST_F(WindowAdapterTest, WindowAdapter_GetFocusInfo, TestSize.Level0) WindowAdapter::GetInstance().GetFocusInfo(focusInfo); EXPECT_TRUE(focusInfo.displayId_ >= 0); } + +/** + * @tc.name: WindowAdapter_GetDisplayId + * @tc.desc: + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(WindowAdapterTest, WindowAdapter_GetDisplayId, TestSize.Level0) +{ + int64_t callingPid = -1000; + uint64_t displayId = 0; + auto ret = WindowAdapter::GetInstance().GetDisplayId(callingPid, displayId); + EXPECT_TRUE(ret); +} } // namespace MiscServices } // namespace OHOS -- Gitee