mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
tdd补充
Signed-off-by: hemenghao <hemenghao2@huawei.com>
This commit is contained in:
parent
04465fccd5
commit
baeab06103
@ -421,7 +421,6 @@ napi_value JsTextInputClientEngine::InsertTextSync(napi_env env, napi_callback_i
|
||||
HandleParamCheckFailure(env));
|
||||
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], text), "text covert failed!", TYPE_NONE,
|
||||
HandleParamCheckFailure(env));
|
||||
IMSA_HILOGD("insert text, text: %{public}s.", text.c_str());
|
||||
int32_t ret = InputMethodAbility::GetInstance()->InsertText(text);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
JsUtils::ThrowException(env, JsUtils::Convert(ret), "failed to insert text!", TYPE_NONE);
|
||||
|
@ -55,7 +55,6 @@ bool FileOperator::Read(const std::string &path, std::string &content)
|
||||
|
||||
bool FileOperator::Write(const std::string &path, const std::string &content, int32_t flags, mode_t mode)
|
||||
{
|
||||
IMSA_HILOGD("content: %{public}s.", content.c_str());
|
||||
auto fd = open(path.c_str(), flags, mode);
|
||||
if (fd < 0) {
|
||||
IMSA_HILOGE("%{public}s open fail, errno: %{public}d", path.c_str(), errno);
|
||||
|
@ -21,7 +21,7 @@ bool Serializable::Unmarshall(const std::string &content)
|
||||
{
|
||||
auto root = cJSON_Parse(content.c_str());
|
||||
if (root == NULL) {
|
||||
IMSA_HILOGE("%{public}s: parse failed!", content.c_str());
|
||||
IMSA_HILOGE("content parse failed!");
|
||||
return false;
|
||||
}
|
||||
auto ret = Unmarshal(root);
|
||||
|
@ -318,8 +318,6 @@ void ImCommonEventManager::EventSubscriber::HandlePackageEvent(int32_t messageId
|
||||
IMSA_HILOGE("invalid user id, messageId:%{public}d", messageId);
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGD(
|
||||
"messageId:%{public}d, bundleName:%{public}s, userId:%{public}d", messageId, bundleName.c_str(), userId);
|
||||
if (messageId == MessageID::MSG_ID_PACKAGE_REMOVED) {
|
||||
if (!FullImeInfoManager::GetInstance().Has(userId, bundleName)) {
|
||||
return;
|
||||
|
@ -645,5 +645,19 @@ HWTEST_F(ImeProxyTest, onInputFinishTest_OnClientInactive, TestSize.Level0)
|
||||
InputMethodAbility::GetInstance()->OnClientInactive(nullptr);
|
||||
EXPECT_TRUE(InputMethodEngineListenerImpl::WaitInputFinish());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testIsFromTs
|
||||
* @tc.desc: ImeProxyTest testIsFromTs
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(ImeProxyTest, testIsFromTs, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("ImeProxyTest testDelete Test START");
|
||||
sptr<OnTextChangedListener> testListener = new TextListener();
|
||||
bool isFrom = testListener->IsFromTs();
|
||||
EXPECT_FALSE(isFrom);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "input_control_channel_stub.h"
|
||||
#include "input_data_channel_proxy.h"
|
||||
#include "input_data_channel_stub.h"
|
||||
#include "input_method_ability_interface.h"
|
||||
#include "input_method_agent_stub.h"
|
||||
#include "input_method_core_proxy.h"
|
||||
#include "input_method_core_stub.h"
|
||||
@ -436,7 +437,14 @@ HWTEST_F(InputMethodAbilityTest, testDeleteText, TestSize.Level0)
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(TextListener::WaitDeleteBackward(deleteForwardLenth));
|
||||
|
||||
ret = InputMethodAbilityInterface::GetInstance().DeleteForward(deleteForwardLenth);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(TextListener::WaitDeleteBackward(deleteForwardLenth));
|
||||
|
||||
int32_t deleteBackwardLenth = 2;
|
||||
ret = InputMethodAbilityInterface::GetInstance().DeleteBackward(deleteBackwardLenth);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(TextListener::WaitDeleteForward(deleteBackwardLenth));
|
||||
ret = inputMethodAbility_->DeleteBackward(deleteBackwardLenth);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(TextListener::WaitDeleteForward(deleteBackwardLenth));
|
||||
@ -1330,5 +1338,51 @@ HWTEST_F(InputMethodAbilityTest, testFinishTextPreview_003, TestSize.Level0)
|
||||
EXPECT_FALSE(TextListener::isFinishTextPreviewCalled_);
|
||||
InputMethodAbilityTest::GetIMCDetachIMA();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BranchCoverage001
|
||||
* @tc.desc: BranchCoverage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, BranchCoverage001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest BranchCoverage001 TEST START");
|
||||
auto ret = InputMethodAbilityTest::inputMethodAbility_->OnStopInputService(false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
InputMethodAbilityTest::inputMethodAbility_->imeListener_ = nullptr;
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->OnStopInputService(false);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_IME_NOT_STARTED);
|
||||
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->OnSecurityChange(INVALID_VALUE);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->HideKeyboardImplWithoutLock(INVALID_VALUE);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->ShowKeyboardImplWithoutLock(INVALID_VALUE);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->ShowPanel(nullptr);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
PanelFlag flag = PanelFlag::FLG_FIXED;
|
||||
Trigger trigger = Trigger::IME_APP;
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->ShowPanel(nullptr, flag, trigger);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->HidePanel(nullptr);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
ret = InputMethodAbilityTest::inputMethodAbility_->HidePanel(nullptr, flag, trigger);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
InputMethodAbilityTest::inputMethodAbility_->isCurrentIme_ = true;
|
||||
auto ret2 = InputMethodAbilityTest::inputMethodAbility_->IsCurrentIme();
|
||||
EXPECT_TRUE(ret2);
|
||||
|
||||
ret2 = InputMethodAbilityTest::inputMethodAbility_->IsEnable();
|
||||
EXPECT_FALSE(ret2);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -1699,5 +1699,21 @@ HWTEST_F(InputMethodControllerTest, testIMCReset, TestSize.Level0)
|
||||
EXPECT_EQ(inputMethodController_->abilityManager_, nullptr);
|
||||
inputMethodController_->abilityManager_ = imsaProxy_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testIsDefaultImeSetAndEnableIme
|
||||
* @tc.desc: test IMC Reset
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, testIsDefaultImeSetAndEnableIme, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testIsDefaultImeSetAndEnableIme Test START");
|
||||
auto ret = inputMethodController_->IsDefaultImeSet();
|
||||
EXPECT_FALSE(ret);
|
||||
const std::string bundleName = "";
|
||||
ret = inputMethodController_->EnableIme(bundleName);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user