From 6a23265e2a0ced264ee9f1f339188acfce4671f0 Mon Sep 17 00:00:00 2001 From: zhaolinglan Date: Tue, 22 Apr 2025 22:37:15 +0800 Subject: [PATCH] add interface converage Signed-off-by: zhaolinglan --- .../inputmethod_ability/src/input_method_ability.cpp | 7 +++---- .../cpp_test/src/input_method_ability_test.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp index 8bf4cfa3d..d7b75ced2 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp @@ -782,17 +782,16 @@ int32_t InputMethodAbility::GetTextIndexAtCursorInner(int32_t &index) int32_t InputMethodAbility::GetTextConfig(TextTotalConfig &textConfig) { - IMSA_HILOGD("InputMethodAbility start."); + IMSA_HILOGI("InputMethodAbility start."); auto channel = GetInputDataChannelProxy(); if (channel == nullptr) { IMSA_HILOGE("channel is nullptr!"); return ErrorCode::ERROR_CLIENT_NULL_POINTER; } - TextTotalConfigInner textConfigInner = {}; - textConfigInner = InputMethodTools::GetInstance().TextTotalConfigToInner(textConfig); + TextTotalConfigInner textConfigInner = InputMethodTools::GetInstance().TextTotalConfigToInner(textConfig); auto ret = channel->GetTextConfig(textConfigInner); - textConfig = InputMethodTools::GetInstance().InnerToTextTotalConfig(textConfigInner); if (ret == ErrorCode::NO_ERROR) { + textConfig = InputMethodTools::GetInstance().InnerToTextTotalConfig(textConfigInner); textConfig.inputAttribute.bundleName = GetInputAttribute().bundleName; textConfig.inputAttribute.callingDisplayId = GetInputAttribute().callingDisplayId; textConfig.inputAttribute.windowId = textConfig.windowId; diff --git a/test/unittest/cpp_test/src/input_method_ability_test.cpp b/test/unittest/cpp_test/src/input_method_ability_test.cpp index 1e8483afe..57c46241c 100644 --- a/test/unittest/cpp_test/src/input_method_ability_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ability_test.cpp @@ -495,6 +495,11 @@ HWTEST_F(InputMethodAbilityTest, testSendFunctionKey, TestSize.Level0) auto ret = inputMethodAbility_->SendFunctionKey(funcKey); EXPECT_EQ(ret, ErrorCode::NO_ERROR); EXPECT_TRUE(TextListener::WaitSendFunctionKey(funcKey)); + + TextListener::ResetParam(); + ret = InputMethodAbilityInterface::GetInstance().SendFunctionKey(funcKey); + EXPECT_EQ(ret, ErrorCode::NO_ERROR); + EXPECT_TRUE(TextListener::WaitSendFunctionKey(funcKey)); } /** @@ -585,6 +590,11 @@ HWTEST_F(InputMethodAbilityTest, testGetTextConfig, TestSize.Level0) EXPECT_EQ(ret, ErrorCode::NO_ERROR); EXPECT_EQ(textTotalConfig.inputAttribute.inputPattern, textConfig.inputAttribute.inputPattern); EXPECT_EQ(textTotalConfig.inputAttribute.enterKeyType, textConfig.inputAttribute.enterKeyType); + + InputAttribute inputAttribute; + ret = InputMethodAbilityInterface::GetInstance().GetInputAttribute(inputAttribute); + EXPECT_EQ(ret, ErrorCode::NO_ERROR); + EXPECT_EQ(inputAttribute, textConfig.inputAttribute); } /** -- Gitee