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 e606c68b603e7e125299bad0032850e42050e28e..71bce3a3a32e5bd566f8a6d2541c5d1e77bd5369 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 16cb08caaee255ee6847e813855a7ebd3bccc766..1c713c3beeb50d2b8d3fb411917b5dad7c8c3bc7 100644 --- a/frameworks/js/napi/inputmethodclient/js_get_input_method_controller.cpp +++ b/frameworks/js/napi/inputmethodclient/js_get_input_method_controller.cpp @@ -165,6 +165,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)); @@ -175,6 +180,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)); @@ -186,6 +197,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 764e038904d0f32b13e886f5ce5fee3a82e5b421..4e57e140be6a77fbcaaa0441ecccc70d432e1c00 100644 --- a/frameworks/native/inputmethod_controller/include/input_attribute.h +++ b/frameworks/native/inputmethod_controller/include/input_attribute.h @@ -29,6 +29,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; @@ -60,6 +61,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 && diff --git a/frameworks/native/inputmethod_controller/include/input_method_utils.h b/frameworks/native/inputmethod_controller/include/input_method_utils.h index fb9e5ce40ae11029746a507f7a90fa6102a82834..e3c21dda19766c74d5ee41974f29ceb5fd0fb0b2 100644 --- a/frameworks/native/inputmethod_controller/include/input_method_utils.h +++ b/frameworks/native/inputmethod_controller/include/input_method_utils.h @@ -59,6 +59,7 @@ enum class TextInputType { USER_NAME, NEW_PASSWORD, NUMBER_DECIMAL, + ONE_TIME_CODE, }; enum class Direction { @@ -297,6 +298,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 0d5f715afed1e1153a322ee89e2be67a62a76bcc..11f8a8f200bf9fd196b532cd4c88d678f6e95b78 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -171,7 +171,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(); @@ -185,6 +185,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 afac345308c19fe7a66b545fe1371afec028f826..cc5c7f97832ececc23d0de1b4ffc76258d9dd197 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -619,28 +619,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."); @@ -2155,7 +2139,7 @@ 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) { + if (type == InputType::SECURITY_INPUT || type == InputType::ONE_TIME_CODE) { return session->RestoreCurrentIme(); } return ret; @@ -2163,20 +2147,30 @@ int32_t InputMethodSystemAbility::StartInputType(int32_t userId, InputType type) 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() @@ -2414,5 +2408,38 @@ int32_t InputMethodSystemAbility::GetAlternativeIme(std::string &ime) IMSA_HILOGE("GetAlternativeIme is failed!"); 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; +} } // namespace MiscServices } // namespace OHOS \ No newline at end of file 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 78c4a94a53213201996c7ecfc97b68dd22407201..4fdc5b6d2a78568c691bbadcaec73d957f7268c9 100644 --- a/test/unittest/cpp_test/src/input_method_ability_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ability_test.cpp @@ -275,6 +275,23 @@ HWTEST_F(InputMethodAbilityTest, testSerializedInputAttribute, TestSize.Level0) EXPECT_TRUE(outAttribute.GetSecurityFlag()); } +/** + * @tc.name: testSerializedInputAttribute001 + * @tc.desc: Checkout the serialization of InputAttribute. + * @tc.type: FUNC + */ +HWTEST_F(InputMethodAbilityTest, testSerializedInputAttribute001, TestSize.Level0) +{ + InputAttribute inAttribute; + inAttribute.inputPattern = InputAttribute::PATTERN_ONE_TIME_CODE; + MessageParcel data; + EXPECT_TRUE(InputAttribute::Marshalling(inAttribute, data)); + InputAttribute outAttribute; + EXPECT_TRUE(InputAttribute::Unmarshalling(outAttribute, data)); + EXPECT_TRUE(outAttribute.IsSecurityImeFlag()); + EXPECT_TRUE(outAttribute.IsOneTimeCodeFlag()); +} + /** * @tc.name: testSerializedInputAttribute * @tc.desc: Checkout the serialization of InputAttribute. @@ -1525,6 +1542,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); @@ -1533,7 +1551,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 851db291ecaa64ccfd86da94fbcaa2033b0ff0a8..7c816845aa78b740e5cc67548f21f6e2a743ec66 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 @@ -1247,8 +1247,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) { }