diff --git a/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp b/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp index 369c7d50ee0fe9fb96e8011474782dc2bf7e0952..52ef53de43199ee29716e3ba76552ce09d1702a5 100644 --- a/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp +++ b/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp @@ -77,6 +77,14 @@ napi_value JsInputMethodEngineSetting::Init(napi_env env, napi_value exports) "PATTERN_PASSWORD_NUMBER", GetJsConstProperty(env, static_cast(TextInputType::NUMBER_PASSWORD))), DECLARE_NAPI_PROPERTY("PATTERN_PASSWORD_SCREEN_LOCK", GetJsConstProperty(env, static_cast(TextInputType::SCREEN_LOCK_PASSWORD))), + DECLARE_NAPI_PROPERTY( + "PATTERN_USER_NAME", GetJsConstProperty(env, static_cast(TextInputType::USER_NAME))), + DECLARE_NAPI_PROPERTY( + "PATTERN_NEW_PASSWORD", GetJsConstProperty(env, static_cast(TextInputType::NEW_PASSWORD))), + DECLARE_NAPI_PROPERTY( + "PATTERN_NUMBER_DECIMAL", GetJsConstProperty(env, static_cast(TextInputType::NUMBER_DECIMAL))), + DECLARE_NAPI_PROPERTY( + "PATTERN_ONE_TIME_CODE", GetJsConstProperty(env, static_cast(TextInputType::ONE_TIME_CODE))), DECLARE_NAPI_FUNCTION("getInputMethodEngine", GetInputMethodEngine), DECLARE_NAPI_FUNCTION("getInputMethodAbility", GetInputMethodAbility), DECLARE_NAPI_STATIC_PROPERTY("PanelType", GetJsPanelTypeProperty(env)), @@ -89,7 +97,7 @@ napi_value JsInputMethodEngineSetting::Init(napi_env env, napi_value exports) NAPI_CALL( env, napi_define_properties(env, exports, sizeof(descriptor) / sizeof(napi_property_descriptor), descriptor)); return InitProperty(env, exports); -}; +} napi_value JsInputMethodEngineSetting::InitProperty(napi_env env, napi_value exports) { diff --git a/frameworks/js/napi/inputmethodclient/js_get_input_method_controller.cpp b/frameworks/js/napi/inputmethodclient/js_get_input_method_controller.cpp index b08b9be8efa1500e0afcd43dc74f6eb5c56a30e8..f06c95438adeb31d591b30a4a8dff0bfe6eb025f 100644 --- a/frameworks/js/napi/inputmethodclient/js_get_input_method_controller.cpp +++ b/frameworks/js/napi/inputmethodclient/js_get_input_method_controller.cpp @@ -162,6 +162,11 @@ napi_value JsGetInputMethodController::GetJsTextInputTypeProperty(napi_env env) napi_value typeUrl = nullptr; napi_value typeVisiblePassword = nullptr; napi_value typeNumberPassword = nullptr; + napi_value typeScreenLockPassword = nullptr; + napi_value typeUserName = nullptr; + napi_value typeNewPassword = nullptr; + napi_value typeNumberDecimal = nullptr; + napi_value typeOneTimeCode = nullptr; NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::NONE), &typeNone)); NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::TEXT), &typeText)); NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::MULTILINE), &typeMultiline)); @@ -172,6 +177,12 @@ napi_value JsGetInputMethodController::GetJsTextInputTypeProperty(napi_env env) NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::URL), &typeUrl)); NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::VISIBLE_PASSWORD), &typeVisiblePassword)); NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::NUMBER_PASSWORD), &typeNumberPassword)); + NAPI_CALL(env, napi_create_int32(env, + static_cast(TextInputType::SCREEN_LOCK_PASSWORD), &typeScreenLockPassword)); + NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::USER_NAME), &typeUserName)); + NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::NEW_PASSWORD), &typeNewPassword)); + NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::NUMBER_DECIMAL), &typeNumberDecimal)); + NAPI_CALL(env, napi_create_int32(env, static_cast(TextInputType::ONE_TIME_CODE), &typeOneTimeCode)); NAPI_CALL(env, napi_create_object(env, &textInputType)); NAPI_CALL(env, napi_set_named_property(env, textInputType, "NONE", typeNone)); NAPI_CALL(env, napi_set_named_property(env, textInputType, "TEXT", typeText)); @@ -183,6 +194,11 @@ napi_value JsGetInputMethodController::GetJsTextInputTypeProperty(napi_env env) NAPI_CALL(env, napi_set_named_property(env, textInputType, "URL", typeUrl)); NAPI_CALL(env, napi_set_named_property(env, textInputType, "VISIBLE_PASSWORD", typeVisiblePassword)); NAPI_CALL(env, napi_set_named_property(env, textInputType, "NUMBER_PASSWORD", typeNumberPassword)); + NAPI_CALL(env, napi_set_named_property(env, textInputType, "SCREEN_LOCK_PASSWORD", typeScreenLockPassword)); + NAPI_CALL(env, napi_set_named_property(env, textInputType, "USER_NAME", typeUserName)); + NAPI_CALL(env, napi_set_named_property(env, textInputType, "NEW_PASSWORD", typeNewPassword)); + NAPI_CALL(env, napi_set_named_property(env, textInputType, "NUMBER_DECIMAL", typeNumberDecimal)); + NAPI_CALL(env, napi_set_named_property(env, textInputType, "ONE_TIME_CODE", typeOneTimeCode)); return textInputType; } diff --git a/frameworks/native/inputmethod_controller/include/input_attribute.h b/frameworks/native/inputmethod_controller/include/input_attribute.h index 6d0242dcd6c372155df6c55d49fd345d5879bb4f..586078f39f8a8ca3b1aea55972baca36bee984be 100644 --- a/frameworks/native/inputmethod_controller/include/input_attribute.h +++ b/frameworks/native/inputmethod_controller/include/input_attribute.h @@ -30,6 +30,7 @@ struct InputAttribute { static const int32_t PATTERN_PASSWORD_NUMBER = 0x00000008; static const int32_t PATTERN_PASSWORD_SCREEN_LOCK = 0x00000009; static const int32_t PATTERN_NEWPASSWORD = 0x0000000b; + static const int32_t PATTERN_ONE_TIME_CODE = 0x0000000d; int32_t inputPattern = 0; int32_t enterKeyType = 0; int32_t inputOption = 0; @@ -45,6 +46,16 @@ struct InputAttribute { PATTERN_PASSWORD_NUMBER == inputPattern || PATTERN_NEWPASSWORD == inputPattern; } + bool IsOneTimeCodeFlag() const + { + return inputPattern == PATTERN_ONE_TIME_CODE; + } + + bool IsSecurityImeFlag() const + { + return GetSecurityFlag() || IsOneTimeCodeFlag(); + } + bool operator==(const InputAttribute &info) const { return inputPattern == info.inputPattern && enterKeyType == info.enterKeyType && @@ -69,6 +80,7 @@ struct InputAttributeInner : public Parcelable { static const int32_t PATTERN_PASSWORD_NUMBER = 0x00000008; static const int32_t PATTERN_PASSWORD_SCREEN_LOCK = 0x00000009; static const int32_t PATTERN_NEWPASSWORD = 0x0000000b; + static const int32_t PATTERN_ONE_TIME_CODE = 0x0000000d; int32_t inputPattern = 0; int32_t enterKeyType = 0; int32_t inputOption = 0; @@ -141,6 +153,16 @@ struct InputAttributeInner : public Parcelable { return inputPattern == PATTERN_PASSWORD || inputPattern == PATTERN_PASSWORD_SCREEN_LOCK || PATTERN_PASSWORD_NUMBER == inputPattern || PATTERN_NEWPASSWORD == inputPattern; } + + bool IsOneTimeCodeFlag() const + { + return inputPattern == PATTERN_ONE_TIME_CODE; + } + + bool IsSecurityImeFlag() const + { + return GetSecurityFlag() || IsOneTimeCodeFlag(); + } }; } // namespace MiscServices } // namespace OHOS diff --git a/frameworks/native/inputmethod_controller/include/input_method_utils.h b/frameworks/native/inputmethod_controller/include/input_method_utils.h index 454adcc27f071f54a898b3f318bba32cd4477515..084008e70e1161a20f74b49264ebceefa9c005bc 100644 --- a/frameworks/native/inputmethod_controller/include/input_method_utils.h +++ b/frameworks/native/inputmethod_controller/include/input_method_utils.h @@ -61,6 +61,7 @@ enum class TextInputType { USER_NAME, NEW_PASSWORD, NUMBER_DECIMAL, + ONE_TIME_CODE, }; enum class Direction { @@ -469,6 +470,7 @@ enum class InputType : int32_t { SECURITY_INPUT, VOICE_INPUT, VOICEKB_INPUT, + ONE_TIME_CODE = 13, END }; diff --git a/interfaces/kits/c/inputmethod_types_capi.h b/interfaces/kits/c/inputmethod_types_capi.h index cde9f352581f8c67e6b56e8c7b964c0f90a6ebc5..0a8a4e3b50b8cdafcb73bae041470ec1314796d3 100644 --- a/interfaces/kits/c/inputmethod_types_capi.h +++ b/interfaces/kits/c/inputmethod_types_capi.h @@ -215,6 +215,10 @@ typedef enum InputMethod_TextInputType { * The text input type is NUMBER DECIMAL. */ IME_TEXT_INPUT_TYPE_NUMBER_DECIMAL = 12, + /** + * The text input type is ONE TIME CODE. + */ + IME_TEXT_INPUT_TYPE_ONE_TIME_CODE = 13, } InputMethod_TextInputType; /** diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index b50213cb386670d9488ed896966e13e5165d95c9..d0589651adf0a4eac1f80825e34134885cbf629c 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -176,7 +176,7 @@ private: bool IsCurrentIme(int32_t userId); int32_t StartInputType(int32_t userId, InputType type); // if switch input type need to switch ime, then no need to hide panel first. - void NeedHideWhenSwitchInputType(int32_t userId, bool &needHide); + void NeedHideWhenSwitchInputType(int32_t userId, InputType type, bool &needHide); bool GetDeviceFunctionKeyState(int32_t functionKey, bool &isEnable); bool ModifyImeCfgWithWrongCaps(); void HandleBundleScanFinished(); @@ -188,6 +188,8 @@ private: std::pair GetCurrentImeInfoForHiSysEvent(int32_t userId); int32_t GetScreenLockIme(std::string &ime); int32_t GetAlternativeIme(std::string &ime); + static InputType GetSecurityInputType(const InputClientInfo &inputClientInfo); + int32_t StartSecurityIme(int32_t &userId, InputClientInfo &inputClientInfo); #ifdef IMF_ON_DEMAND_START_STOP_SA_ENABLE int64_t GetTickCount(); void ResetDelayUnloadTask(uint32_t code = 0); diff --git a/services/include/input_type_manager.h b/services/include/input_type_manager.h index 7a2a2374c5fb94de288d7e0752bf89ddd77f216a..d8032a4b0cb1650ee75adc0d3580d707c36a515d 100644 --- a/services/include/input_type_manager.h +++ b/services/include/input_type_manager.h @@ -47,6 +47,8 @@ public: bool IsCameraImeStarted(); bool IsVoiceImeStarted(); bool IsVoiceKbImeStarted(); + bool IsOneTimeCodeImeStarted(); + bool IsInputTypeImeStarted(InputType type); InputType GetCurrentInputType(); void Set(bool isStarted, const ImeIdentification ¤tIme = {}); ImeIdentification GetCurrentIme(); diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index bbe302c232d42b694786fe37243a915024e4ad2c..b8f4e2e30b9b3b109c5c1ff761bf7803b0b730d7 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -665,28 +665,12 @@ int32_t InputMethodSystemAbility::StartInputInner( int32_t InputMethodSystemAbility::CheckInputTypeOption(int32_t userId, InputClientInfo &inputClientInfo) { - IMSA_HILOGI("SecurityFlag: %{public}d, IsSameTextInput: %{public}d, IsStarted: %{public}d, " - "IsSecurityImeStarted: %{public}d.", - inputClientInfo.config.inputAttribute.GetSecurityFlag(), !inputClientInfo.isNotifyInputStart, - InputTypeManager::GetInstance().IsStarted(), InputTypeManager::GetInstance().IsSecurityImeStarted()); - if (inputClientInfo.config.inputAttribute.GetSecurityFlag()) { - if (!InputTypeManager::GetInstance().IsStarted()) { - IMSA_HILOGD("SecurityFlag, input type is not started, start."); - // if need to switch ime, no need to hide panel first. - NeedHideWhenSwitchInputType(userId, inputClientInfo.needHide); - return StartInputType(userId, InputType::SECURITY_INPUT); - } - if (!inputClientInfo.isNotifyInputStart) { - IMSA_HILOGD("SecurityFlag, same textField, input type is started, not deal."); - return ErrorCode::NO_ERROR; - } - if (!InputTypeManager::GetInstance().IsSecurityImeStarted()) { - IMSA_HILOGD("SecurityFlag, new textField, input type is started, but it is not security, switch."); - NeedHideWhenSwitchInputType(userId, inputClientInfo.needHide); - return StartInputType(userId, InputType::SECURITY_INPUT); - } - IMSA_HILOGD("SecurityFlag, other condition, not deal."); - return ErrorCode::NO_ERROR; + IMSA_HILOGI("SecurityImeFlag: %{public}d, IsSameTextInput: %{public}d, IsStarted: %{public}d.", + inputClientInfo.config.inputAttribute.IsSecurityImeFlag(), + !inputClientInfo.isNotifyInputStart, + InputTypeManager::GetInstance().IsStarted()); + if (inputClientInfo.config.inputAttribute.IsSecurityImeFlag()) { + return StartSecurityIme(userId, inputClientInfo); } if (!inputClientInfo.isNotifyInputStart) { IMSA_HILOGD("NormalFlag, same textField, not deal."); @@ -2332,28 +2316,38 @@ int32_t InputMethodSystemAbility::StartInputType(int32_t userId, InputType type) if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGW("not find input type: %{public}d.", type); // add for not adapter for SECURITY_INPUT - if (type == InputType::SECURITY_INPUT) { - return session->RestoreCurrentIme(DEFAULT_DISPLAY_ID); + if (type == InputType::SECURITY_INPUT || type == InputType::ONE_TIME_CODE) { + return session->RestoreCurrentIme(); } return ret; } SwitchInfo switchInfo = { std::chrono::system_clock::now(), ime.bundleName, ime.subName }; session->GetSwitchQueue().Push(switchInfo); IMSA_HILOGI("start input type: %{public}d.", type); - return type == InputType::SECURITY_INPUT ? OnStartInputType(userId, switchInfo, false) - : OnStartInputType(userId, switchInfo, true); + return (type == InputType::SECURITY_INPUT || type == InputType::ONE_TIME_CODE) ? + OnStartInputType(userId, switchInfo, false) : OnStartInputType(userId, switchInfo, true); } -void InputMethodSystemAbility::NeedHideWhenSwitchInputType(int32_t userId, bool &needHide) +void InputMethodSystemAbility::NeedHideWhenSwitchInputType(int32_t userId, InputType type, bool &needHide) { + if (!needHide) { + return; + } ImeIdentification ime; - InputTypeManager::GetInstance().GetImeByInputType(InputType::SECURITY_INPUT, ime); - auto currentImeCfg = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId); - if (currentImeCfg == nullptr) { - IMSA_HILOGI("currentImeCfg is nullptr"); + InputTypeManager::GetInstance().GetImeByInputType(type, ime); + auto session = UserSessionManager::GetInstance().GetUserSession(userId); + if (session == nullptr) { + IMSA_HILOGE("UserId: %{public}d session is nullptr!", userId_); + needHide = false; + return; + } + auto imeData = session->GetReadyImeData(ImeType::IME); + if (imeData == nullptr) { + IMSA_HILOGI("Readyime is nullptr"); + needHide = false; return; } - needHide = currentImeCfg->bundleName == ime.bundleName; + needHide = imeData->ime.first == ime.bundleName; } void InputMethodSystemAbility::HandleBundleScanFinished() @@ -2598,6 +2592,38 @@ int32_t InputMethodSystemAbility::GetAlternativeIme(std::string &ime) return ErrorCode::ERROR_NOT_IME; } +InputType InputMethodSystemAbility::GetSecurityInputType(const InputClientInfo &inputClientInfo) +{ + if (inputClientInfo.config.inputAttribute.IsOneTimeCodeFlag()) { + return InputType::ONE_TIME_CODE; + } else if (inputClientInfo.config.inputAttribute.GetSecurityFlag()) { + return InputType::SECURITY_INPUT; + } else { + return InputType::NONE; +} + +int32_t InputMethodSystemAbility::StartSecurityIme(int32_t &userId, InputClientInfo &inputClientInfo) +{ + InputType type = GetSecurityInputType(inputClientInfo); + IMSA_HILOGI("InputType:[%{public}d.", type); + if (!InputTypeManager::GetInstance().IsStarted()) { + IMSA_HILOGD("SecurityImeFlag, input type is not started, start."); + // if need to switch ime, no need to hide panel first. + NeedHideWhenSwitchInputType(userId, type, inputClientInfo.needHide); + return StartInputType(userId, type); + } + if (!inputClientInfo.isNotifyInputStart) { + IMSA_HILOGD("SecurityImeFlag, same textField, input type is started, not deal."); + return ErrorCode::NO_ERROR; + } + if (!InputTypeManager::GetInstance().IsInputTypeImeStarted(type)) { + IMSA_HILOGD("SecurityImeFlag, new textField, input type is started, but it is not target, switch."); + NeedHideWhenSwitchInputType(userId, type, inputClientInfo.needHide); + return StartInputType(userId, type); + } + return ErrorCode::NO_ERROR; +} + int32_t InputMethodSystemAbility::SendPrivateData( const Value &value) { diff --git a/services/src/input_type_manager.cpp b/services/src/input_type_manager.cpp index 81f236ae6695109dd5b873503155d159ce111704..039dec749b0a99dd4beec94d2f9036dbfac9f977 100644 --- a/services/src/input_type_manager.cpp +++ b/services/src/input_type_manager.cpp @@ -76,46 +76,43 @@ bool InputTypeManager::IsStarted() bool InputTypeManager::IsSecurityImeStarted() { - if (!IsStarted()) { - return false; - } - + InputType type = InputType::SECURITY_INPUT; + return IsInputTypeImeStarted(type); std::lock_guard lock(typesLock_); - return inputTypes_.find(InputType::SECURITY_INPUT) != inputTypes_.end() && - inputTypes_[InputType::SECURITY_INPUT] == GetCurrentIme(); } bool InputTypeManager::IsCameraImeStarted() { - if (!IsStarted()) { - return false; - } - - std::lock_guard lock(typesLock_); - return inputTypes_.find(InputType::CAMERA_INPUT) != inputTypes_.end() && - inputTypes_[InputType::CAMERA_INPUT] == GetCurrentIme(); + InputType type = InputType::CAMERA_INPUT; + return IsInputTypeImeStarted(type); } bool InputTypeManager::IsVoiceImeStarted() { - if (!IsStarted()) { - return false; - } - - std::lock_guard lock(typesLock_); - return inputTypes_.find(InputType::VOICE_INPUT) != inputTypes_.end() && - inputTypes_[InputType::VOICE_INPUT] == GetCurrentIme(); + InputType type = InputType::VOICE_INPUT; + return IsInputTypeImeStarted(type); } bool InputTypeManager::IsVoiceKbImeStarted() +{ + InputType type = InputType::VOICEKB_INPUT; + return IsInputTypeImeStarted(type); +} + +bool InputTypeManager::IsOneTimeCodeImeStarted() +{ + InputType type = InputType::ONE_TIME_CODE; + return IsInputTypeImeStarted(type); +} + +bool InputTypeManager::IsInputTypeImeStarted(InputType type) { if (!IsStarted()) { return false; } - std::lock_guard lock(typesLock_); - return inputTypes_.find(InputType::VOICEKB_INPUT) != inputTypes_.end() && - inputTypes_[InputType::VOICEKB_INPUT] == GetCurrentIme(); + return inputTypes_.find(type) != inputTypes_.end() && + inputTypes_[type] == GetCurrentIme(); } InputType InputTypeManager::GetCurrentInputType() @@ -132,6 +129,9 @@ InputType InputTypeManager::GetCurrentInputType() if (IsVoiceKbImeStarted()) { return InputType::VOICEKB_INPUT; } + if (IsOneTimeCodeImeStarted()) { + return InputType::ONE_TIME_CODE; + } return InputType::NONE; } 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 1e8483afeafe37029689c0a1e5dc71eb6b51bc7e..35f49c8a63c224519f1fa4e509973f60c774922a 100644 --- a/test/unittest/cpp_test/src/input_method_ability_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ability_test.cpp @@ -288,6 +288,23 @@ HWTEST_F(InputMethodAbilityTest, testSerializedInputAttribute, TestSize.Level0) EXPECT_TRUE(attribute->GetSecurityFlag()); } +/** + * @tc.name: testSerializedInputAttribute001 + * @tc.desc: Checkout the serialization of InputAttribute. + * @tc.type: FUNC + */ +HWTEST_F(InputMethodAbilityTest, testSerializedInputAttribute001, TestSize.Level0) +{ + InputAttributeInner inAttribute; + inAttribute.inputPattern = InputAttributeInner::PATTERN_ONE_TIME_CODE; + MessageParcel data; + EXPECT_TRUE(inAttribute.Marshalling(data)); + InputAttributeInner outAttribute; + auto attribute = InputAttributeInner::Unmarshalling(data); + EXPECT_TRUE(attribute->IsSecurityImeFlag()); + EXPECT_TRUE(attribute->IsOneTimeCodeFlag()); +} + /** * @tc.name: testSerializedInputAttribute * @tc.desc: Checkout the serialization of InputAttribute. @@ -1608,6 +1625,7 @@ HWTEST_F(InputMethodAbilityTest, BranchCoverage002, TestSize.Level0) std::string vailidString = ""; std::shared_ptr info; bool needHide = false; + InputType type = InputType::NONE; auto ret = imsa_->OnStartInputType(vailidUserId, switchInfo, true); EXPECT_NE(ret, ErrorCode::NO_ERROR); @@ -1616,7 +1634,7 @@ HWTEST_F(InputMethodAbilityTest, BranchCoverage002, TestSize.Level0) ret = imsa_->SwitchExtension(vailidUserId, info); EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER); ret = imsa_->SwitchSubType(vailidUserId, info); - imsa_->NeedHideWhenSwitchInputType(vailidUserId, needHide); + imsa_->NeedHideWhenSwitchInputType(vailidUserId, type, needHide); EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER); ret = imsa_->SwitchInputType(vailidUserId, switchInfo); EXPECT_EQ(ret, ErrorCode::ERROR_IMSA_USER_SESSION_NOT_FOUND); diff --git a/test/unittest/cpp_test/src/input_method_private_member_test.cpp b/test/unittest/cpp_test/src/input_method_private_member_test.cpp index 83bf8cfccf55b833af9ff0797009d49396fa2f60..02cd041b573a7d2ed1548009cb054c9a6c3eadb9 100644 --- a/test/unittest/cpp_test/src/input_method_private_member_test.cpp +++ b/test/unittest/cpp_test/src/input_method_private_member_test.cpp @@ -1276,8 +1276,9 @@ HWTEST_F(InputMethodPrivateMemberTest, BranchCoverage002, TestSize.Level0) EXPECT_EQ(ret2, ErrorCode::ERROR_IMSA_USER_SESSION_NOT_FOUND); bool needHide = false; + InputType type = InputType::NONE; auto ret3 = service_->IsCurrentIme(INVALID_USER_ID); - service_->NeedHideWhenSwitchInputType(INVALID_USER_ID, needHide); + service_->NeedHideWhenSwitchInputType(INVALID_USER_ID, type, needHide); EXPECT_FALSE(ret3); } diff --git a/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp b/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp index a74ff2b25c3a6e8de1175539cc1b3dbcd217f5b6..e215a5c081e135a502ea8f862bbb2645331c8440 100644 --- a/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp +++ b/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp @@ -144,6 +144,26 @@ HWTEST_F(InputMethodControllerCapiTest, TestTextConfig_001, TestSize.Level0) OH_TextConfig_Destroy(config); } + +/** + * @tc.name: TestTextConfig_002 + * @tc.desc: create and destroy TestTextConfig success + * @tc.type: FUNC + */ +HWTEST_F(InputMethodControllerCapiTest, TestTextConfig_002, TestSize.Level0) +{ + auto config = OH_TextConfig_Create(); + ASSERT_NE(nullptr, config); + + // test set and get inputType + InputMethod_TextInputType expInputType = IME_TEXT_INPUT_TYPE_ONE_TIME_CODE; + InputMethod_TextInputType actInputType = IME_TEXT_INPUT_TYPE_NONE; + EXPECT_EQ(IME_ERR_OK, OH_TextConfig_SetInputType(config, expInputType)); + EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetInputType(config, &actInputType)); + EXPECT_EQ(expInputType, actInputType); + OH_TextConfig_Destroy(config); +} + void GetTextConfigFunc(InputMethod_TextEditorProxy *proxy, InputMethod_TextConfig *config) { } void InsertTextFunc(InputMethod_TextEditorProxy *proxy, const char16_t *text, size_t length) { } void DeleteForwardFunc(InputMethod_TextEditorProxy *proxy, int32_t length) { }