mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>
Changes to be committed:
This commit is contained in:
parent
389f3d8590
commit
122326a260
@ -742,7 +742,7 @@ void JsInputMethodEngineSetting::OnSecurityChange(int32_t security)
|
||||
FreeWorkIfFail(ret, work);
|
||||
}
|
||||
|
||||
void JsInputMethodEngineSetting::OnSendPrivateCommand(
|
||||
void JsInputMethodEngineSetting::ReceivePrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
IMSA_HILOGD("JsInputMethodEngineSetting, run in");
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
void OnSetCallingWindow(uint32_t windowId) override;
|
||||
void OnSetSubtype(const SubProperty &property) override;
|
||||
void OnSecurityChange(int32_t security) override;
|
||||
void OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
|
||||
private:
|
||||
struct PanelContext : public AsyncCall::Context {
|
||||
|
@ -29,6 +29,7 @@ using namespace std::chrono;
|
||||
thread_local napi_ref JsTextInputClientEngine::TICRef_ = nullptr;
|
||||
const std::string JsTextInputClientEngine::TIC_CLASS_NAME = "TextInputClient";
|
||||
constexpr int32_t MAX_WAIT_TIME = 5000;
|
||||
constexpr int32_t MAX_WAIT_TIME_PRIVATE_COMMAND = 2000;
|
||||
BlockQueue<EditorEventInfo> JsTextInputClientEngine::editorQueue_{ MAX_WAIT_TIME };
|
||||
BlockQueue<PrivateCommandInfo> JsTextInputClientEngine::privateCommandQueue_{ MAX_WAIT_TIME };
|
||||
napi_value JsTextInputClientEngine::Init(napi_env env, napi_value info)
|
||||
|
@ -80,7 +80,7 @@ int32_t JsGetInputMethodTextChangedListener::GetTextIndexAtCursor()
|
||||
return JsGetInputMethodController::GetInstance()->GetTextIndexAtCursor();
|
||||
}
|
||||
|
||||
int32_t JsGetInputMethodTextChangedListener::OnSendPrivateCommand(
|
||||
int32_t JsGetInputMethodTextChangedListener::ReceivePrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
return ErrorCode::NO_ERROR;
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
std::u16string GetLeftTextOfCursor(int32_t number) override;
|
||||
std::u16string GetRightTextOfCursor(int32_t number) override;
|
||||
int32_t GetTextIndexAtCursor() override;
|
||||
int32_t OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
|
||||
private:
|
||||
static std::mutex listenerMutex_;
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
void OnClientInactive(const sptr<IRemoteObject> &channel);
|
||||
void NotifyKeyboardHeight(const std::shared_ptr<InputMethodPanel> inputMethodPanel);
|
||||
int32_t SendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
int32_t OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
bool IsDefaultIme();
|
||||
|
||||
private:
|
||||
|
@ -481,7 +481,7 @@ void InputMethodAbility::InvokeTextChangeCallback(const TextTotalConfig &textCon
|
||||
imeListener_->OnSetCallingWindow(textConfig.windowId);
|
||||
if (TextConfig::IsPrivateCommandValid(textConfig.privateCommand) && IsDefaultIme()) {
|
||||
IMSA_HILOGI("notify privateCommand.");
|
||||
imeListener_->OnSendPrivateCommand(textConfig.privateCommand);
|
||||
imeListener_->ReceivePrivateCommand(textConfig.privateCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1013,6 +1013,10 @@ int32_t InputMethodAbility::SendPrivateCommand(const std::unordered_map<std::str
|
||||
IMSA_HILOGE("current is not default ime.");
|
||||
return ErrorCode::ERROR_NOT_DEFAULT_IME;
|
||||
}
|
||||
if (!TextConfig::IsPrivateCommandValid(privateCommand)) {
|
||||
IMSA_HILOGE("privateCommand size limit 32KB, count limit 5.");
|
||||
return ErrorCode::ERROR_INVALID_PRIVATE_COMMAND_SIZE;
|
||||
}
|
||||
auto channel = GetInputDataChannelProxy();
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGE("channel is nullptr");
|
||||
@ -1021,7 +1025,7 @@ int32_t InputMethodAbility::SendPrivateCommand(const std::unordered_map<std::str
|
||||
return channel->SendPrivateCommand(privateCommand);
|
||||
}
|
||||
|
||||
int32_t InputMethodAbility::OnSendPrivateCommand(
|
||||
int32_t InputMethodAbility::ReceivePrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
if (!IsDefaultIme()) {
|
||||
@ -1032,7 +1036,7 @@ int32_t InputMethodAbility::OnSendPrivateCommand(
|
||||
IMSA_HILOGE("imeListener is nullptr");
|
||||
return ErrorCode::ERROR_IME;
|
||||
}
|
||||
imeListener_->OnSendPrivateCommand(privateCommand);
|
||||
imeListener_->ReceivePrivateCommand(privateCommand);
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
} // namespace MiscServices
|
||||
|
@ -113,7 +113,7 @@ int32_t InputMethodAgentStub::SendPrivateCommandOnRemote(MessageParcel &data, Me
|
||||
IMSA_HILOGE("failed to read message parcel");
|
||||
return ErrorCode::ERROR_EX_PARCELABLE;
|
||||
}
|
||||
auto ret = InputMethodAbility::GetInstance()->OnSendPrivateCommand(privateCommand);
|
||||
auto ret = InputMethodAbility::GetInstance()->ReceivePrivateCommand(privateCommand);
|
||||
return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
|
||||
}
|
||||
|
||||
|
@ -193,17 +193,17 @@ struct TextConfig {
|
||||
}
|
||||
size_t totalSize = 0;
|
||||
for (const auto &iter : privateCommand) {
|
||||
size_t keySize = sizeof(iter.first);
|
||||
size_t keySize = iter.first.size();
|
||||
size_t idx = iter.second.index();
|
||||
size_t valueSize = 0;
|
||||
|
||||
if (idx == static_cast<size_t>(PrivateDataValueType::VALUE_TYPE_STRING)) {
|
||||
auto stringValue = std::get_if<std::string>(&iter.second);
|
||||
if (stringValue != nullptr) {
|
||||
valueSize = (*stringValue).size();
|
||||
if (stringValue == nullptr) {
|
||||
IMSA_HILOGE("get stringValue failed.");
|
||||
return false;
|
||||
}
|
||||
IMSA_HILOGE("get stringValue failed.");
|
||||
return false;
|
||||
valueSize = (*stringValue).size();
|
||||
} else if (idx == static_cast<size_t>(PrivateDataValueType::VALUE_TYPE_BOOL)) {
|
||||
valueSize = sizeof(bool);
|
||||
} else if (idx == static_cast<size_t>(PrivateDataValueType::VALUE_TYPE_NUMBER)) {
|
||||
|
@ -23,7 +23,7 @@ namespace MiscServices {
|
||||
class PrivateCommandInterface {
|
||||
public:
|
||||
virtual int32_t SendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) = 0;
|
||||
virtual int32_t OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) = 0;
|
||||
virtual int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) = 0;
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -316,7 +316,7 @@ void InputDataChannelStub::NotifyKeyboardHeight(uint32_t height)
|
||||
int32_t InputDataChannelStub::SendPrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
return InputMethodController::GetInstance()->OnSendPrivateCommand(privateCommand);
|
||||
return InputMethodController::GetInstance()->ReceivePrivateCommand(privateCommand);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -611,7 +611,7 @@ int32_t InputMethodController::OnCursorUpdate(CursorInfo cursorInfo)
|
||||
auto agent = GetAgent();
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGE("agent is nullptr");
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
IMSA_HILOGI("left: %{public}d, top: %{public}d, height: %{public}d", static_cast<int32_t>(cursorInfo.left),
|
||||
static_cast<int32_t>(cursorInfo.top), static_cast<int32_t>(cursorInfo.height));
|
||||
@ -645,7 +645,7 @@ int32_t InputMethodController::OnSelectionChange(std::u16string text, int start,
|
||||
auto agent = GetAgent();
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGE("agent is nullptr");
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
IMSA_HILOGI("IMC size: %{public}zu, range: %{public}d/%{public}d", text.size(), start, end);
|
||||
agent->OnSelectionChange(textString_, selectOldBegin_, selectOldEnd_, selectNewBegin_, selectNewEnd_);
|
||||
@ -672,7 +672,7 @@ int32_t InputMethodController::OnConfigurationChange(Configuration info)
|
||||
auto agent = GetAgent();
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGE("agent is nullptr");
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
agent->OnConfigurationChange(info);
|
||||
return ErrorCode::NO_ERROR;
|
||||
@ -740,7 +740,7 @@ int32_t InputMethodController::DispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> k
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGE("agent is nullptr");
|
||||
keyEventQueue_.Pop();
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
IMSA_HILOGI("start");
|
||||
sptr<IKeyEventConsumer> consumer = new (std::nothrow) KeyEventConsumerStub(callback, keyEvent);
|
||||
@ -815,7 +815,7 @@ int32_t InputMethodController::SetCallingWindow(uint32_t windowId)
|
||||
auto agent = GetAgent();
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGE("agent_ is nullptr");
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
IMSA_HILOGI("windowId = %{public}d", windowId);
|
||||
agent->SetCallingWindow(windowId);
|
||||
@ -1215,7 +1215,8 @@ void InputMethodController::PrintLogIfAceTimeout(int64_t start)
|
||||
IMSA_HILOGW("timeout:[%{public}" PRId64 ", %{public}" PRId64 "]", start, end);
|
||||
}
|
||||
}
|
||||
int32_t InputMethodController::OnSendPrivateCommand(
|
||||
|
||||
int32_t InputMethodController::ReceivePrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
auto listener = GetTextListener();
|
||||
@ -1223,9 +1224,9 @@ int32_t InputMethodController::OnSendPrivateCommand(
|
||||
IMSA_HILOGE("textListener_ is nullptr");
|
||||
return ErrorCode::ERROR_EX_NULL_POINTER;
|
||||
}
|
||||
auto ret = listener->OnSendPrivateCommand(privateCommand);
|
||||
auto ret = listener->ReceivePrivateCommand(privateCommand);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("OnSendPrivateCommand err, ret %{public}d", ret);
|
||||
IMSA_HILOGE("ReceivePrivateCommand err, ret %{public}d", ret);
|
||||
return ErrorCode::ERROR_TEXT_LISTENER_ERROR;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
@ -1249,7 +1250,7 @@ int32_t InputMethodController::SendPrivateCommand(
|
||||
auto agent = GetAgent();
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGE("agent is nullptr");
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
return agent->SendPrivateCommand(privateCommand);
|
||||
}
|
||||
|
@ -414,20 +414,24 @@ bool ITypesUtil::Unmarshalling(SwitchTrigger &output, MessageParcel &data)
|
||||
bool ITypesUtil::Marshalling(const PrivateDataValue &input, MessageParcel &data)
|
||||
{
|
||||
size_t idx = input.index();
|
||||
if (!data.WriteInt32(static_cast<int32_t>(idx))) {
|
||||
IMSA_HILOGE("Write index failed.");
|
||||
return false;
|
||||
}
|
||||
if (idx == static_cast<size_t>(PrivateDataValueType::VALUE_TYPE_STRING)) {
|
||||
auto stringValue = std::get_if<std::string>(&input);
|
||||
if (stringValue != nullptr) {
|
||||
return data.WriteInt32(static_cast<int32_t>(idx)) && data.WriteString(*stringValue);
|
||||
return data.WriteString(*stringValue);
|
||||
}
|
||||
} else if (idx == static_cast<size_t>(PrivateDataValueType::VALUE_TYPE_BOOL)) {
|
||||
auto boolValue = std::get_if<bool>(&input);
|
||||
if (boolValue != nullptr) {
|
||||
return data.WriteInt32(static_cast<int32_t>(idx)) && data.WriteBool(*boolValue);
|
||||
return data.WriteBool(*boolValue);
|
||||
}
|
||||
} else if (idx == static_cast<size_t>(PrivateDataValueType::VALUE_TYPE_NUMBER)) {
|
||||
auto numberValue = std::get_if<int32_t>(&input);
|
||||
if (numberValue != nullptr) {
|
||||
return data.WriteInt32(static_cast<int32_t>(idx)) && data.WriteInt32(*numberValue);
|
||||
return data.WriteInt32(*numberValue);
|
||||
}
|
||||
}
|
||||
IMSA_HILOGE("write PrivateDataValue with wrong type.");
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
virtual void OnSecurityChange(int32_t security) = 0;
|
||||
virtual void OnSetCallingWindow(uint32_t windowId) = 0;
|
||||
virtual void OnSetSubtype(const SubProperty &property) = 0;
|
||||
virtual void OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) = 0;
|
||||
virtual void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) = 0;
|
||||
virtual void OnInputFinish()
|
||||
{
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
virtual std::u16string GetLeftTextOfCursor(int32_t number) = 0;
|
||||
virtual std::u16string GetRightTextOfCursor(int32_t number) = 0;
|
||||
virtual int32_t GetTextIndexAtCursor() = 0;
|
||||
virtual int32_t OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
virtual int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
@ -749,7 +749,7 @@ public:
|
||||
* @return Returns 0 for success, others for failure.
|
||||
* @since 12
|
||||
*/
|
||||
IMF_API int32_t OnSendPrivateCommand(
|
||||
IMF_API int32_t ReceivePrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
|
||||
private:
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
void OnSetCallingWindow(uint32_t windowId) override;
|
||||
void OnSetSubtype(const SubProperty &property) override;
|
||||
void OnInputFinish() override;
|
||||
void OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
bool IsEnable() override;
|
||||
};
|
||||
} // namespace MiscServices
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
std::u16string GetLeftTextOfCursor(int32_t number) override;
|
||||
std::u16string GetRightTextOfCursor(int32_t number) override;
|
||||
int32_t GetTextIndexAtCursor() override;
|
||||
int32_t OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
|
||||
static void ResetParam();
|
||||
static bool WaitSendKeyboardStatusCallback(const KeyboardStatus &keyboardStatus);
|
||||
static bool WaitNotifyPanelStatusInfoCallback(const PanelStatusInfo &info);
|
||||
|
@ -63,10 +63,10 @@ void InputMethodEngineListenerImpl::OnInputFinish()
|
||||
isInputFinish_ = true;
|
||||
imeListenerCv_.notify_one();
|
||||
}
|
||||
void InputMethodEngineListenerImpl::OnSendPrivateCommand(
|
||||
void InputMethodEngineListenerImpl::ReceivePrivateCommand(
|
||||
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
IMSA_HILOGI("OnSendPrivateCommand");
|
||||
IMSA_HILOGI("ReceivePrivateCommand");
|
||||
privateCommand_ = privateCommand;
|
||||
imeListenerCv_.notify_one();
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ int32_t TextListener::GetTextIndexAtCursor()
|
||||
return TEXT_INDEX;
|
||||
}
|
||||
|
||||
int32_t TextListener::OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
int32_t TextListener::ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
privateCommand_ = privateCommand;
|
||||
return 0;
|
||||
|
@ -44,6 +44,7 @@ using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
constexpr uint32_t DEALY_TIME = 1;
|
||||
constexpr size_t PRIVATE_COMMAND_SIZE_MAX = 32 * 1024;
|
||||
class InputMethodAbilityTest : public testing::Test {
|
||||
public:
|
||||
static std::mutex imeListenerCallbackLock_;
|
||||
@ -95,13 +96,13 @@ public:
|
||||
IMSA_HILOGI("InputMethodEngineListenerImpl OnSecurityChange");
|
||||
}
|
||||
|
||||
void OnSendPrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodEngineListenerImpl OnSendPrivateCommand");
|
||||
IMSA_HILOGI("InputMethodEngineListenerImpl ReceivePrivateCommand");
|
||||
}
|
||||
};
|
||||
|
||||
static void SetDefaultIme()
|
||||
static void StubSelfAsDefault()
|
||||
{
|
||||
std::shared_ptr<Property> property = std::make_shared<Property>();
|
||||
auto ret = InputMethodController::GetInstance()->GetDefaultInputMethod(property);
|
||||
@ -1060,6 +1061,7 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_001 Test START");
|
||||
TextListener::ResetParam();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
imc_->Close();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
auto ret = inputMethodAbility_->SendPrivateCommand(privateCommand);
|
||||
@ -1078,7 +1080,7 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_002, TestSize.Level0)
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_002 Test START");
|
||||
TextListener::ResetParam();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
InputMethodAbilityTest::SetDefaultIme();
|
||||
InputMethodAbilityTest::StubSelfAsDefault();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = std::string("stringValue");
|
||||
privateCommand.insert({ "value1", privateDataValue1 });
|
||||
@ -1100,7 +1102,7 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_003, TestSize.Level0)
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
auto ret = imc_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodAbilityTest::SetDefaultIme();
|
||||
InputMethodAbilityTest::StubSelfAsDefault();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = std::string("stringValue");
|
||||
PrivateDataValue privateDataValue2 = true;
|
||||
@ -1125,8 +1127,9 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_003, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_004, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_004 Test START");
|
||||
auto ret = imc_->Attach(textListener_, false);
|
||||
TextListener::ResetParam();
|
||||
InputMethodAbilityTest::SetDefaultIme();
|
||||
InputMethodAbilityTest::StubSelfAsDefault();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = std::string("stringValue");
|
||||
privateCommand.emplace("value1", privateDataValue1);
|
||||
@ -1135,9 +1138,10 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_004, TestSize.Level0)
|
||||
privateCommand.emplace("value4", privateDataValue1);
|
||||
privateCommand.emplace("value5", privateDataValue1);
|
||||
privateCommand.emplace("value6", privateDataValue1);
|
||||
auto ret = inputMethodAbility_->SendPrivateCommand(privateCommand);
|
||||
ret = inputMethodAbility_->SendPrivateCommand(privateCommand);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_PRIVATE_COMMAND_SIZE);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
imc_->Close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1150,17 +1154,21 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_004, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_005, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_005 Test START");
|
||||
auto ret = imc_->Attach(textListener_, false);
|
||||
TextListener::ResetParam();
|
||||
InputMethodAbilityTest::SetDefaultIme();
|
||||
string str(32768, 'a');
|
||||
IMSA_HILOGE("str size : %{public}zu", str.size());
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = str;
|
||||
privateCommand.emplace("value1", privateDataValue1);
|
||||
IMSA_HILOGE("privateDataValue1 size : %{public}zu", std::get<std::string>(privateDataValue1).size());
|
||||
auto ret = inputMethodAbility_->SendPrivateCommand(privateCommand);
|
||||
InputMethodAbilityTest::StubSelfAsDefault();
|
||||
string str(32767, 'a');
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand1{ { "v", string(PRIVATE_COMMAND_SIZE_MAX - 2, 'a') } };
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand2{ { "v", string(PRIVATE_COMMAND_SIZE_MAX - 1, 'a') } };
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand3{ { "v", string(PRIVATE_COMMAND_SIZE_MAX, 'a') } };
|
||||
ret = inputMethodAbility_->SendPrivateCommand(privateCommand1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = inputMethodAbility_->SendPrivateCommand(privateCommand2);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = inputMethodAbility_->SendPrivateCommand(privateCommand3);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_PRIVATE_COMMAND_SIZE);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
imc_->Close();
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user