code check add

Signed-off-by: wangdongqi <wangdongqi2@h-partners.com>
This commit is contained in:
wangdongqi 2024-11-19 20:04:55 +08:00
parent 39cfa1a2e3
commit 700ca9a109
55 changed files with 835 additions and 792 deletions

View File

@ -51,9 +51,7 @@ constexpr const char *STRICT_MODE = "strictMode";
constexpr const char *ISOLATED_SANDBOX = "isolatedSandbox";
constexpr uint32_t CHECK_IME_RUNNING_RETRY_INTERVAL = 60;
constexpr uint32_t CHECK_IME_RUNNING_RETRY_TIMES = 10;
PerUserSession::PerUserSession(int userId) : userId_(userId)
{
}
PerUserSession::PerUserSession(int userId) : userId_(userId) { }
PerUserSession::PerUserSession(int32_t userId, const std::shared_ptr<AppExecFwk::EventHandler> &eventHandler)
: userId_(userId), eventHandler_(eventHandler)
@ -64,9 +62,7 @@ PerUserSession::PerUserSession(int32_t userId, const std::shared_ptr<AppExecFwk:
}
}
PerUserSession::~PerUserSession()
{
}
PerUserSession::~PerUserSession() { }
int PerUserSession::AddClientInfo(sptr<IRemoteObject> inputClient, const InputClientInfo &clientInfo,
ClientAddEvent event)

View File

@ -27,6 +27,7 @@ Property ImeSettingListenerTestImpl::property_{};
std::mutex ImeSettingListenerTestImpl::imeSettingListenerLock_;
bool ImeSettingListenerTestImpl::isImeChange_ { false };
std::condition_variable ImeSettingListenerTestImpl::imeSettingListenerCv_;
void ImeSettingListenerTestImpl::ResetParam()
{
status_ = InputWindowStatus::NONE;
@ -34,43 +35,52 @@ void ImeSettingListenerTestImpl::ResetParam()
property_ = {};
isImeChange_ = false;
}
bool ImeSettingListenerTestImpl::WaitPanelHide()
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS),
[]() { return status_ == InputWindowStatus::HIDE; });
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS), []() {
return status_ == InputWindowStatus::HIDE;
});
return status_ == InputWindowStatus::HIDE;
}
bool ImeSettingListenerTestImpl::WaitPanelShow()
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS),
[]() { return status_ == InputWindowStatus::SHOW; });
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS), []() {
return status_ == InputWindowStatus::SHOW;
});
return status_ == InputWindowStatus::SHOW;
}
bool ImeSettingListenerTestImpl::WaitImeChange()
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME), []() { return isImeChange_; });
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME), []() {
return isImeChange_;
});
return isImeChange_;
}
bool ImeSettingListenerTestImpl::WaitTargetImeChange(const std::string &bundleName)
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME),
[&bundleName]() { return bundleName == property_.name; });
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME), [&bundleName]() {
return bundleName == property_.name;
});
return isImeChange_ && bundleName == property_.name;
}
bool ImeSettingListenerTestImpl::WaitImeChange(const SubProperty &subProperty)
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME),
[&subProperty]() { return subProperty_.id == subProperty.id && subProperty_.name == subProperty.name; });
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME), [&subProperty]() {
return subProperty_.id == subProperty.id && subProperty_.name == subProperty.name;
});
return subProperty_.id == subProperty.id && subProperty_.name == subProperty.name;
}
void ImeSettingListenerTestImpl::OnImeChange(const Property &property, const SubProperty &subProperty)
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
@ -82,6 +92,7 @@ void ImeSettingListenerTestImpl::OnImeChange(const Property &property, const Sub
property_ = property;
imeSettingListenerCv_.notify_one();
}
void ImeSettingListenerTestImpl::OnImeShow(const ImeWindowInfo &info)
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
@ -89,6 +100,7 @@ void ImeSettingListenerTestImpl::OnImeShow(const ImeWindowInfo &info)
status_ = InputWindowStatus::SHOW;
imeSettingListenerCv_.notify_one();
}
void ImeSettingListenerTestImpl::OnImeHide(const ImeWindowInfo &info)
{
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);

View File

@ -29,42 +29,50 @@ bool InputMethodEngineListenerImpl::isEnable_{ false };
bool InputMethodEngineListenerImpl::isInputFinish_ { false };
std::unordered_map<std::string, PrivateDataValue> InputMethodEngineListenerImpl::privateCommand_ {};
constexpr int32_t TIMEOUT_SECONDS = 2;
void InputMethodEngineListenerImpl::OnKeyboardStatus(bool isShow)
{
IMSA_HILOGI("InputMethodEngineListenerImpl::OnKeyboardStatus %{public}s", isShow ? "show" : "hide");
keyboardState_ = isShow;
}
void InputMethodEngineListenerImpl::OnSecurityChange(int32_t security)
{
IMSA_HILOGI("InputMethodEngineListenerImpl::OnSecurityChange %{public}d", security);
}
void InputMethodEngineListenerImpl::OnInputStart()
{
IMSA_HILOGI("InputMethodEngineListenerImpl::OnInputStart");
isInputStart_ = true;
imeListenerCv_.notify_one();
}
int32_t InputMethodEngineListenerImpl::OnInputStop()
{
IMSA_HILOGI("InputMethodEngineListenerImpl::OnInputStop");
return ErrorCode::NO_ERROR;
}
void InputMethodEngineListenerImpl::OnSetCallingWindow(uint32_t windowId)
{
IMSA_HILOGI("InputMethodEngineListenerImpl::OnSetCallingWindow %{public}d", windowId);
windowId_ = windowId;
imeListenerCv_.notify_one();
}
void InputMethodEngineListenerImpl::OnSetSubtype(const SubProperty &property)
{
IMSA_HILOGI("InputMethodEngineListenerImpl::OnSetSubtype");
}
void InputMethodEngineListenerImpl::OnInputFinish()
{
IMSA_HILOGI("InputMethodEngineListenerImpl");
isInputFinish_ = true;
imeListenerCv_.notify_one();
}
void InputMethodEngineListenerImpl::ReceivePrivateCommand(
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
{
@ -72,11 +80,13 @@ void InputMethodEngineListenerImpl::ReceivePrivateCommand(
privateCommand_ = privateCommand;
imeListenerCv_.notify_one();
}
bool InputMethodEngineListenerImpl::IsEnable()
{
IMSA_HILOGI("InputMethodEngineListenerImpl isEnable: %{public}d", isEnable_);
return isEnable_;
}
void InputMethodEngineListenerImpl::ResetParam()
{
isInputStart_ = false;
@ -84,33 +94,45 @@ void InputMethodEngineListenerImpl::ResetParam()
windowId_ = 0;
privateCommand_.clear();
}
bool InputMethodEngineListenerImpl::WaitInputStart()
{
std::unique_lock<std::mutex> lock(imeListenerMutex_);
imeListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS), []() { return isInputStart_; });
imeListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS), []() {
return isInputStart_;
});
return isInputStart_;
}
bool InputMethodEngineListenerImpl::WaitInputFinish()
{
std::unique_lock<std::mutex> lock(imeListenerMutex_);
imeListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS), []() { return isInputFinish_; });
imeListenerCv_.wait_for(lock, std::chrono::seconds(TIMEOUT_SECONDS), []() {
return isInputFinish_;
});
return isInputFinish_;
}
bool InputMethodEngineListenerImpl::WaitSetCallingWindow(uint32_t windowId)
{
std::unique_lock<std::mutex> lock(imeListenerMutex_);
imeListenerCv_.wait_for(lock, std::chrono::seconds(1), [&windowId]() { return windowId_ == windowId; });
imeListenerCv_.wait_for(lock, std::chrono::seconds(1), [&windowId]() {
return windowId_ == windowId;
});
return windowId_ == windowId;
}
bool InputMethodEngineListenerImpl::WaitSendPrivateCommand(
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
{
std::unique_lock<std::mutex> lock(imeListenerMutex_);
imeListenerCv_.wait_for(lock, std::chrono::seconds(1),
[&privateCommand]() { return privateCommand_ == privateCommand; });
imeListenerCv_.wait_for(lock, std::chrono::seconds(1), [&privateCommand]() {
return privateCommand_ == privateCommand;
});
return privateCommand_ == privateCommand;
}
bool InputMethodEngineListenerImpl::WaitKeyboardStatus(bool state)
{
std::unique_lock<std::mutex> lock(imeListenerMutex_);
@ -119,6 +141,7 @@ bool InputMethodEngineListenerImpl::WaitKeyboardStatus(bool state)
});
return keyboardState_ == state;
}
bool InputMethodEngineListenerImpl::PostTaskToEventHandler(std::function<void()> task, const std::string &taskName)
{
if (eventHandler_ == nullptr) {

View File

@ -35,8 +35,8 @@ bool KeyboardListenerTestImpl::OnKeyEvent(int32_t keyCode, int32_t keyStatus, sp
return true;
}
bool KeyboardListenerTestImpl::OnDealKeyEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent,
sptr<KeyEventConsumerProxy> &consumer)
bool KeyboardListenerTestImpl::OnDealKeyEvent(
const std::shared_ptr<MMI::KeyEvent> &keyEvent, sptr<KeyEventConsumerProxy> &consumer)
{
bool isKeyCodeConsume = OnKeyEvent(keyEvent->GetKeyCode(), keyEvent->GetKeyAction(), consumer);
bool isKeyEventConsume = OnKeyEvent(keyEvent, consumer);
@ -51,21 +51,25 @@ void KeyboardListenerTestImpl::OnCursorUpdate(int32_t positionX, int32_t positio
cursorHeight_ = height;
kdListenerCv_.notify_one();
}
void KeyboardListenerTestImpl::OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd)
{
newBegin_ = newBegin;
kdListenerCv_.notify_one();
}
void KeyboardListenerTestImpl::OnTextChange(const std::string &text)
{
text_ = text;
kdListenerCv_.notify_one();
}
void KeyboardListenerTestImpl::OnEditorAttributeChange(const InputAttribute &inputAttribute)
{
inputAttribute_ = inputAttribute;
kdListenerCv_.notify_one();
}
void KeyboardListenerTestImpl::ResetParam()
{
keyCode_ = -1;
@ -76,35 +80,49 @@ void KeyboardListenerTestImpl::ResetParam()
inputAttribute_.enterKeyType = 0;
inputAttribute_.inputOption = 0;
}
bool KeyboardListenerTestImpl::WaitKeyEvent(int32_t keyCode)
{
std::unique_lock<std::mutex> lock(kdListenerLock_);
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&keyCode]() { return keyCode == keyCode_; });
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&keyCode]() {
return keyCode == keyCode_;
});
return keyCode == keyCode_;
}
bool KeyboardListenerTestImpl::WaitCursorUpdate()
{
std::unique_lock<std::mutex> lock(kdListenerLock_);
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), []() { return cursorHeight_ > 0; });
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), []() {
return cursorHeight_ > 0;
});
return cursorHeight_ > 0;
}
bool KeyboardListenerTestImpl::WaitSelectionChange(int32_t newBegin)
{
std::unique_lock<std::mutex> lock(kdListenerLock_);
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&newBegin]() { return newBegin == newBegin_; });
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&newBegin]() {
return newBegin == newBegin_;
});
return newBegin == newBegin_;
}
bool KeyboardListenerTestImpl::WaitTextChange(const std::string &text)
{
std::unique_lock<std::mutex> lock(kdListenerLock_);
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&text]() { return text == text_; });
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&text]() {
return text == text_;
});
return text == text_;
}
bool KeyboardListenerTestImpl::WaitEditorAttributeChange(const InputAttribute &inputAttribute)
{
std::unique_lock<std::mutex> lock(kdListenerLock_);
kdListenerCv_.wait_for(lock, std::chrono::seconds(1),
[&inputAttribute]() { return inputAttribute == inputAttribute_; });
kdListenerCv_.wait_for(lock, std::chrono::seconds(1), [&inputAttribute]() {
return inputAttribute == inputAttribute_;
});
return inputAttribute == inputAttribute_;
}
} // namespace MiscServices

View File

@ -46,9 +46,7 @@ TextListener::TextListener()
serviceHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
}
TextListener::~TextListener()
{
}
TextListener::~TextListener() { }
void TextListener::InsertText(const std::u16string &text)
{
@ -74,9 +72,7 @@ void TextListener::DeleteBackward(int32_t length)
IMSA_HILOGI("TextListener: DeleteBackward, direction is: %{public}d", length);
}
void TextListener::SendKeyEventFromInputMethod(const KeyEvent &event)
{
}
void TextListener::SendKeyEventFromInputMethod(const KeyEvent &event) { }
void TextListener::SendKeyboardStatus(const KeyboardStatus &keyboardStatus)
{
@ -215,79 +211,106 @@ void TextListener::ResetParam()
bool TextListener::WaitSendKeyboardStatusCallback(const KeyboardStatus &keyboardStatus)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(KEYBOARD_STATUS_WAIT_TIME_OUT),
[&keyboardStatus]() { return keyboardStatus == keyboardStatus_; });
textListenerCv_.wait_for(lock, std::chrono::seconds(KEYBOARD_STATUS_WAIT_TIME_OUT), [&keyboardStatus]() {
return keyboardStatus == keyboardStatus_;
});
return keyboardStatus == keyboardStatus_;
}
bool TextListener::WaitNotifyPanelStatusInfoCallback(const PanelStatusInfo &info)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [info]() { return info == info_; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [info]() {
return info == info_;
});
return info == info_;
}
bool TextListener::WaitNotifyKeyboardHeightCallback(uint32_t height)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [height]() { return height_ == height; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [height]() {
return height_ == height;
});
return height_ == height;
}
bool TextListener::WaitSendPrivateCommandCallback(std::unordered_map<std::string, PrivateDataValue> &privateCommand)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1),
[privateCommand]() { return privateCommand_ == privateCommand; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [privateCommand]() {
return privateCommand_ == privateCommand;
});
return privateCommand_ == privateCommand;
}
bool TextListener::WaitInsertText(const std::u16string &insertText)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [insertText]() { return insertText_ == insertText; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [insertText]() {
return insertText_ == insertText;
});
return insertText_ == insertText;
}
bool TextListener::WaitMoveCursor(int32_t direction)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [direction]() { return direction_ == direction; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [direction]() {
return direction_ == direction;
});
return direction_ == direction;
}
bool TextListener::WaitDeleteForward(int32_t length)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [length]() { return deleteForwardLength_ == length; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [length]() {
return deleteForwardLength_ == length;
});
return deleteForwardLength_ == length;
}
bool TextListener::WaitDeleteBackward(int32_t length)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [length]() { return deleteBackwardLength_ == length; });
return deleteBackwardLength_ == length;
}
bool TextListener::WaitSendFunctionKey(int32_t functionKey)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [functionKey]() { return key_ == functionKey; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [functionKey]() {
return key_ == functionKey;
});
return key_ == functionKey;
}
bool TextListener::WaitHandleExtendAction(int32_t action)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [action]() { return action_ == action; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [action]() {
return action_ == action;
});
return action_ == action;
}
bool TextListener::WaitHandleSetSelection(int32_t start, int32_t end)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1),
[start, end]() { return selectionStart_ == start && selectionEnd_ == end; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [start, end]() {
return selectionStart_ == start && selectionEnd_ == end;
});
return selectionStart_ == start && selectionEnd_ == end;
}
bool TextListener::WaitHandleSelect(int32_t keyCode, int32_t cursorMoveSkip)
{
std::unique_lock<std::mutex> lock(textListenerCallbackLock_);
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [keyCode]() { return selectionDirection_ == keyCode; });
textListenerCv_.wait_for(lock, std::chrono::seconds(1), [keyCode]() {
return selectionDirection_ == keyCode;
});
return selectionDirection_ == keyCode;
}
} // namespace MiscServices

View File

@ -35,6 +35,7 @@ uint32_t ConvertToUint32(const uint8_t *ptr)
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
return bigVar;
}
bool FuzzAgentStub(const uint8_t *rawData, size_t size)
{
uint32_t code = ConvertToUint32(rawData);

View File

@ -36,6 +36,7 @@ uint32_t ConvertToUint32(const uint8_t *ptr)
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
return bigVar;
}
bool FuzzControlChannel(const uint8_t *rawData, size_t size)
{
constexpr int32_t MAIN_USER_ID = 100;

View File

@ -35,6 +35,7 @@ uint32_t ConvertToUint32(const uint8_t *ptr)
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
return bigVar;
}
bool FuzzCoreStub(const uint8_t *rawData, size_t size)
{
uint32_t code = ConvertToUint32(rawData);

View File

@ -36,6 +36,7 @@ uint32_t ConvertToUint32(const uint8_t *ptr)
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
return bigVar;
}
bool FuzzDataChannelStub(const uint8_t *rawData, size_t size)
{
uint32_t code = ConvertToUint32(rawData);

View File

@ -54,8 +54,8 @@ void FuzzParseEnableKeyboard(const std::string &valueStr, int32_t userId, std::v
EnableImeDataParser::GetInstance()->ParseEnableKeyboard(valueStr, userId, enableVec);
}
void FuzzCheckTargetEnableName(const std::string &key, const std::string &targetName, std::string &nextIme,
const int32_t userId)
void FuzzCheckTargetEnableName(
const std::string &key, const std::string &targetName, std::string &nextIme, const int32_t userId)
{
EnableImeDataParser::GetInstance()->CheckTargetEnableName(key, targetName, nextIme, userId);
}

View File

@ -35,18 +35,10 @@ class KeyboardListenerImpl : public KeyboardListener {
{
return true;
}
void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height)
{
}
void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd)
{
}
void OnTextChange(const std::string &text)
{
}
void OnEditorAttributeChange(const InputAttribute &inputAttribute)
{
}
void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height) { }
void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) { }
void OnTextChange(const std::string &text) { }
void OnEditorAttributeChange(const InputAttribute &inputAttribute) { }
};
void TestInsertText(const std::string &fuzzedString)

View File

@ -27,11 +27,11 @@
#include "global.h"
#include "ime_cfg_manager.h"
#include "input_method_controller.h"
#include "inputmethodsystemability_fuzzer.h"
#include "iservice_registry.h"
#include "message_parcel.h"
#include "nativetoken_kit.h"
#include "system_ability_definition.h"
#include "inputmethodsystemability_fuzzer.h"
#include "text_listener.h"
#include "token_setproc.h"

View File

@ -34,6 +34,7 @@ uint32_t ConvertToUint32(const uint8_t *ptr)
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
return bigVar;
}
bool FuzzKeyEventConsumerStub(const uint8_t *rawData, size_t size)
{
bool isConsumed = static_cast<bool>(rawData[0] % 2);

View File

@ -37,9 +37,9 @@
#include "input_method_core_stub.h"
#include "input_method_info.h"
#include "input_method_property.h"
#include "input_method_types.h"
#include "iremote_broker.h"
#include "message_parcel.h"
#include "input_method_types.h"
using namespace OHOS::MiscServices;
namespace OHOS {

View File

@ -69,8 +69,8 @@ bool ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(const uint8_t *rawData, siz
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<InputMethodSystemAbility>::GetInstance()->OnRemoteRequest(static_cast<int32_t>(code), datas,
reply, option);
DelayedSingleton<InputMethodSystemAbility>::GetInstance()->OnRemoteRequest(
static_cast<int32_t>(code), datas, reply, option);
return true;
}

View File

@ -25,7 +25,7 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::DISPLAY_OPTIONAL_INPUT_METHOD);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(
data, size, InputMethodInterfaceCode::DISPLAY_OPTIONAL_INPUT_METHOD);
return 0;
}

View File

@ -24,7 +24,6 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::EXIT_CURRENT_INPUT_TYPE);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::EXIT_CURRENT_INPUT_TYPE);
return 0;
}

View File

@ -25,7 +25,7 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::GET_CURRENT_INPUT_METHOD_SUBTYPE);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(
data, size, InputMethodInterfaceCode::GET_CURRENT_INPUT_METHOD_SUBTYPE);
return 0;
}

View File

@ -24,7 +24,6 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::GET_DEFAULT_INPUT_METHOD);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::GET_DEFAULT_INPUT_METHOD);
return 0;
}

View File

@ -24,7 +24,6 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::GET_INPUT_METHOD_SETTINGS);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::GET_INPUT_METHOD_SETTINGS);
return 0;
}

View File

@ -25,7 +25,7 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::SHOW_CURRENT_INPUT_DEPRECATED);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(
data, size, InputMethodInterfaceCode::SHOW_CURRENT_INPUT_DEPRECATED);
return 0;
}

View File

@ -24,7 +24,6 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::START_INPUT_TYPE);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::START_INPUT_TYPE);
return 0;
}

View File

@ -24,7 +24,6 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size,
InputMethodInterfaceCode::UNREGISTERED_PROXY_IME);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::UNREGISTERED_PROXY_IME);
return 0;
}

View File

@ -387,14 +387,15 @@ void TddUtil::InitCurrentImePermissionInfo()
}
currentBundleNameMock_ = property->name;
session->InitImeData({ property->name, property->id });
ImeCfgManager::GetInstance().imeConfigs_ = { { userId, property->name + "/" + property->id, "", false } };
ImeCfgManager::GetInstance().imeConfigs_ = {
{ userId, property->name + "/" + property->id, "", false }
};
}
void TddUtil::WindowManager::CreateWindow()
{
if (windowTokenId_ == 0) {
windowTokenId_ = AllocTestTokenID(true, "TestWindow",
{ "ohos.permission.SYSTEM_FLOAT_WINDOW" });
windowTokenId_ = AllocTestTokenID(true, "TestWindow", { "ohos.permission.SYSTEM_FLOAT_WINDOW" });
}
TokenScope scope(windowTokenId_);
std::string windowName = "inputmethod_test_window";

View File

@ -47,21 +47,13 @@ private:
};
BlockQueue<std::chrono::system_clock::time_point> ImfBlockQueueTest::timeQueue_ { MAX_WAIT_TIME };
bool ImfBlockQueueTest::timeout_ { false };
void ImfBlockQueueTest::SetUpTestCase(void)
{
}
void ImfBlockQueueTest::SetUpTestCase(void) { }
void ImfBlockQueueTest::TearDownTestCase(void)
{
}
void ImfBlockQueueTest::TearDownTestCase(void) { }
void ImfBlockQueueTest::SetUp()
{
}
void ImfBlockQueueTest::SetUp() { }
void ImfBlockQueueTest::TearDown()
{
}
void ImfBlockQueueTest::TearDown() { }
int64_t ImfBlockQueueTest::GetThreadId()
{

View File

@ -56,9 +56,7 @@ void EnableImeDataParseTest::SetUpTestCase(void)
ImeInfoInquirer::GetInstance().GetDefaultImeCfgProp()->id = "defaultImeId";
}
void EnableImeDataParseTest::TearDownTestCase(void)
{
}
void EnableImeDataParseTest::TearDownTestCase(void) { }
void EnableImeDataParseTest::SetUp()
{
@ -70,9 +68,7 @@ void EnableImeDataParseTest::SetUp()
EnableImeDataParser::GetInstance()->enableList_.clear();
}
void EnableImeDataParseTest::TearDown()
{
}
void EnableImeDataParseTest::TearDown() { }
/**
* @tc.name: testGetEnableData_001

View File

@ -100,7 +100,9 @@ void IdentityCheckerTest::SetUpTestCase(void)
return;
}
service_->OnStart();
ImeCfgManager::GetInstance().imeConfigs_ = { { MAIN_USER_ID, CURRENT_IME, CURRENT_SUBNAME, false} };
ImeCfgManager::GetInstance().imeConfigs_ = {
{ MAIN_USER_ID, CURRENT_IME, CURRENT_SUBNAME, false }
};
identityCheckerImpl_ = std::make_shared<IdentityCheckerImpl>();
}

View File

@ -27,10 +27,10 @@
#include "input_method_ability_interface.h"
#include "input_method_controller.h"
#include "input_method_engine_listener_impl.h"
#include "input_method_types.h"
#include "keyboard_listener_test_impl.h"
#include "tdd_util.h"
#include "text_listener.h"
#include "input_method_types.h"
using namespace testing::ext;
namespace OHOS {
namespace MiscServices {
@ -94,8 +94,9 @@ public:
std::string result;
auto ret = TddUtil::ExecuteCmd(cmd, result);
EXPECT_TRUE(ret);
BlockRetry(RETRY_INTERVAL, RETRY_TIME,
[]() { return AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility().GetBundleName() == BUNDLENAME; });
BlockRetry(RETRY_INTERVAL, RETRY_TIME, []() {
return AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility().GetBundleName() == BUNDLENAME;
});
IMSA_HILOGI("start app success");
sleep(WAIT_APP_START_COMPLETE); // ensure app start complete
}
@ -116,8 +117,9 @@ public:
std::string result;
auto ret = TddUtil::ExecuteCmd(cmd, result);
EXPECT_TRUE(ret);
BlockRetry(RETRY_INTERVAL, RETRY_TIME,
[]() { return AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility().GetBundleName() != BUNDLENAME; });
BlockRetry(RETRY_INTERVAL, RETRY_TIME, []() {
return AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility().GetBundleName() != BUNDLENAME;
});
IMSA_HILOGI("stop app success");
}

View File

@ -26,12 +26,8 @@ using namespace testing::ext;
namespace OHOS {
namespace MiscServices {
class OnSystemCmdListenerImpl : public OnSystemCmdListener {
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override
{
}
void NotifyPanelStatus(const SysPanelStatus &sysPanelStatus) override
{
}
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override { }
void NotifyPanelStatus(const SysPanelStatus &sysPanelStatus) override { }
};
class ImeSystemChannelTest : public testing::Test {
public:

View File

@ -39,12 +39,8 @@ public:
{
IMSA_HILOGI("InputMethodAbilityExceptionTest::TearDownTestCase");
}
void SetUp()
{
}
void TearDown()
{
}
void SetUp() { }
void TearDown() { }
static void ResetMemberVar()
{
inputMethodAbility_->dataChannelProxy_ = nullptr;

View File

@ -16,9 +16,9 @@
#define protected public
#include "input_method_controller.h"
#include "input_data_channel_stub.h"
#include "input_method_ability.h"
#include "input_method_system_ability.h"
#include "input_data_channel_stub.h"
#include "task_manager.h"
#undef private
@ -42,6 +42,7 @@
#include "global.h"
#include "i_input_method_agent.h"
#include "i_input_method_system_ability.h"
#include "identity_checker_mock.h"
#include "if_system_ability_manager.h"
#include "input_client_stub.h"
#include "input_death_recipient.h"
@ -58,7 +59,6 @@
#include "system_ability_definition.h"
#include "tdd_util.h"
#include "text_listener.h"
#include "identity_checker_mock.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
@ -208,8 +208,8 @@ public:
}
void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) override
{
IMSA_HILOGI("KeyboardListenerImpl %{public}d %{public}d %{public}d %{public}d", oldBegin, oldEnd, newBegin,
newEnd);
IMSA_HILOGI(
"KeyboardListenerImpl %{public}d %{public}d %{public}d %{public}d", oldBegin, oldEnd, newBegin, newEnd);
oldBegin_ = oldBegin;
oldEnd_ = oldEnd;
newBegin_ = newBegin;
@ -347,7 +347,9 @@ void InputMethodControllerTest::SetInputDeathRecipient()
IMSA_HILOGE("InputMethodControllerTest, new death recipient failed");
return;
}
deathRecipient_->SetDeathRecipient([](const wptr<IRemoteObject> &remote) { OnRemoteSaDied(remote); });
deathRecipient_->SetDeathRecipient([](const wptr<IRemoteObject> &remote) {
OnRemoteSaDied(remote);
});
if ((systemAbility->IsProxyObject()) && (!systemAbility->AddDeathRecipient(deathRecipient_))) {
IMSA_HILOGE("InputMethodControllerTest, failed to add death recipient.");
return;
@ -396,14 +398,14 @@ void InputMethodControllerTest::CheckKeyEvent(std::shared_ptr<MMI::KeyEvent> key
ret = keyEvent->GetKeyIntention() == keyEvent_->GetKeyIntention();
EXPECT_TRUE(ret);
// check function key state
ret = keyEvent->GetFunctionKey(MMI::KeyEvent::NUM_LOCK_FUNCTION_KEY)
== keyEvent_->GetFunctionKey(MMI::KeyEvent::NUM_LOCK_FUNCTION_KEY);
ret = keyEvent->GetFunctionKey(MMI::KeyEvent::NUM_LOCK_FUNCTION_KEY) ==
keyEvent_->GetFunctionKey(MMI::KeyEvent::NUM_LOCK_FUNCTION_KEY);
EXPECT_TRUE(ret);
ret = keyEvent->GetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY)
== keyEvent_->GetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY);
ret = keyEvent->GetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY) ==
keyEvent_->GetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY);
EXPECT_TRUE(ret);
ret = keyEvent->GetFunctionKey(MMI::KeyEvent::SCROLL_LOCK_FUNCTION_KEY)
== keyEvent_->GetFunctionKey(MMI::KeyEvent::SCROLL_LOCK_FUNCTION_KEY);
ret = keyEvent->GetFunctionKey(MMI::KeyEvent::SCROLL_LOCK_FUNCTION_KEY) ==
keyEvent_->GetFunctionKey(MMI::KeyEvent::SCROLL_LOCK_FUNCTION_KEY);
EXPECT_TRUE(ret);
// check KeyItem
ret = keyEvent->GetKeyItems().size() == keyEvent_->GetKeyItems().size();
@ -428,17 +430,18 @@ bool InputMethodControllerTest::WaitKeyboardStatus(bool keyboardState)
void InputMethodControllerTest::TriggerConfigurationChangeCallback(Configuration &info)
{
textConfigHandler_->PostTask(
[info]() { inputMethodController_->OnConfigurationChange(info); }, InputMethodControllerTest::TASK_DELAY_TIME);
[info]() {
inputMethodController_->OnConfigurationChange(info);
},
InputMethodControllerTest::TASK_DELAY_TIME);
{
std::unique_lock<std::mutex> lock(InputMethodControllerTest::keyboardListenerMutex_);
InputMethodControllerTest::keyboardListenerCv_.wait_for(
lock, std::chrono::seconds(InputMethodControllerTest::DELAY_TIME), [&info] {
return (static_cast<OHOS::MiscServices::TextInputType>(
InputMethodControllerTest::inputAttribute_.inputPattern)
== info.GetTextInputType())
&& (static_cast<OHOS::MiscServices::EnterKeyType>(
InputMethodControllerTest::inputAttribute_.enterKeyType)
== info.GetEnterKeyType());
InputMethodControllerTest::inputAttribute_.inputPattern) == info.GetTextInputType()) &&
(static_cast<OHOS::MiscServices::EnterKeyType>(
InputMethodControllerTest::inputAttribute_.enterKeyType) == info.GetEnterKeyType());
});
}
}
@ -446,26 +449,33 @@ void InputMethodControllerTest::TriggerConfigurationChangeCallback(Configuration
void InputMethodControllerTest::TriggerCursorUpdateCallback(CursorInfo &info)
{
textConfigHandler_->PostTask(
[info]() { inputMethodController_->OnCursorUpdate(info); }, InputMethodControllerTest::TASK_DELAY_TIME);
[info]() {
inputMethodController_->OnCursorUpdate(info);
},
InputMethodControllerTest::TASK_DELAY_TIME);
{
std::unique_lock<std::mutex> lock(InputMethodControllerTest::keyboardListenerMutex_);
InputMethodControllerTest::keyboardListenerCv_.wait_for(lock,
std::chrono::seconds(InputMethodControllerTest::DELAY_TIME),
[&info] { return InputMethodControllerTest::cursorInfo_ == info; });
InputMethodControllerTest::keyboardListenerCv_.wait_for(
lock, std::chrono::seconds(InputMethodControllerTest::DELAY_TIME), [&info] {
return InputMethodControllerTest::cursorInfo_ == info;
});
}
}
void InputMethodControllerTest::TriggerSelectionChangeCallback(std::u16string &text, int start, int end)
{
IMSA_HILOGI("InputMethodControllerTest run in");
textConfigHandler_->PostTask([text, start, end]() { inputMethodController_->OnSelectionChange(text, start, end); },
textConfigHandler_->PostTask(
[text, start, end]() {
inputMethodController_->OnSelectionChange(text, start, end);
},
InputMethodControllerTest::TASK_DELAY_TIME);
{
std::unique_lock<std::mutex> lock(InputMethodControllerTest::keyboardListenerMutex_);
InputMethodControllerTest::keyboardListenerCv_.wait_for(
lock, std::chrono::seconds(InputMethodControllerTest::DELAY_TIME), [&text, start, end] {
return InputMethodControllerTest::text_ == Str16ToStr8(text)
&& InputMethodControllerTest::newBegin_ == start && InputMethodControllerTest::newEnd_ == end;
return InputMethodControllerTest::text_ == Str16ToStr8(text) &&
InputMethodControllerTest::newBegin_ == start && InputMethodControllerTest::newEnd_ == end;
});
}
IMSA_HILOGI("InputMethodControllerTest end");
@ -494,7 +504,9 @@ void InputMethodControllerTest::DispatchKeyEventCallback(std::shared_ptr<MMI::Ke
bool InputMethodControllerTest::WaitKeyEventCallback()
{
std::unique_lock<std::mutex> lock(keyEventLock_);
keyEventCv_.wait_for(lock, std::chrono::seconds(DELAY_TIME), [] { return consumeResult_; });
keyEventCv_.wait_for(lock, std::chrono::seconds(DELAY_TIME), [] {
return consumeResult_;
});
return consumeResult_;
}
@ -1018,8 +1030,8 @@ HWTEST_F(InputMethodControllerTest, testIMCGetEnterKeyType, TestSize.Level0)
IMSA_HILOGI("IMC GetEnterKeyType Test START");
int32_t keyType;
inputMethodController_->GetEnterKeyType(keyType);
EXPECT_TRUE(keyType >= static_cast<int32_t>(EnterKeyType::UNSPECIFIED)
&& keyType <= static_cast<int32_t>(EnterKeyType::PREVIOUS));
EXPECT_TRUE(keyType >= static_cast<int32_t>(EnterKeyType::UNSPECIFIED) &&
keyType <= static_cast<int32_t>(EnterKeyType::PREVIOUS));
}
/**
@ -1033,8 +1045,8 @@ HWTEST_F(InputMethodControllerTest, testIMCGetInputPattern, TestSize.Level0)
IMSA_HILOGI("IMC GetInputPattern Test START");
int32_t inputPattern;
inputMethodController_->GetInputPattern(inputPattern);
EXPECT_TRUE(inputPattern >= static_cast<int32_t>(TextInputType::NONE)
&& inputPattern <= static_cast<int32_t>(TextInputType::VISIBLE_PASSWORD));
EXPECT_TRUE(inputPattern >= static_cast<int32_t>(TextInputType::NONE) &&
inputPattern <= static_cast<int32_t>(TextInputType::VISIBLE_PASSWORD));
}
/**
@ -1520,12 +1532,15 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_008, TestSize.Level0)
auto ret = inputMethodController_->Attach(textListener_, false);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
TextListener::ResetParam();
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') } };
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 = inputMethodController_->SendPrivateCommand(privateCommand1);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
ret = inputMethodController_->SendPrivateCommand(privateCommand2);

View File

@ -61,12 +61,8 @@ constexpr const char *IME_STATE_CHANGED_EVENT_NAME = "IME_STATE_CHANGED";
class Watcher : public HiSysEventListener {
public:
explicit Watcher(const std::string &operateInfo) : operateInfo_(operateInfo)
{
}
virtual ~Watcher()
{
}
explicit Watcher(const std::string &operateInfo) : operateInfo_(operateInfo) { }
virtual ~Watcher() { }
void OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent) final
{
if (sysEvent == nullptr) {
@ -100,9 +96,7 @@ public:
: state_(state), pid_(pid), bundleName_(bundleName)
{
}
virtual ~WatcherImeChange()
{
}
virtual ~WatcherImeChange() { }
void OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent) final
{
if (sysEvent == nullptr) {
@ -313,7 +307,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Attach, TestSize.Leve
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Attach");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_ATTACH)));
auto attach = []() { inputMethodController_->Attach(textListener_, true); };
auto attach = []() {
inputMethodController_->Attach(textListener_, true);
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, attach));
}
@ -329,7 +325,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideTextInput, TestSi
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
auto watcher = std::make_shared<Watcher>(InputMethodSysEvent::GetInstance().GetOperateInfo(
static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_UNEDITABLE)));
auto hideTextInput = []() { inputMethodController_->HideTextInput(); };
auto hideTextInput = []() {
inputMethodController_->HideTextInput();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideTextInput));
}
@ -343,7 +341,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowTextInput, TestSi
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowTextInput");
auto watcher = std::make_shared<Watcher>(InputMethodSysEvent::GetInstance().GetOperateInfo(
static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_ENEDITABLE)));
auto showTextInput = []() { inputMethodController_->ShowTextInput(); };
auto showTextInput = []() {
inputMethodController_->ShowTextInput();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showTextInput));
}
@ -357,7 +357,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideCurrentInput, Tes
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideCurrentInput");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_NORMAL)));
auto hideCurrentInput = []() { inputMethodController_->HideCurrentInput(); };
auto hideCurrentInput = []() {
inputMethodController_->HideCurrentInput();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideCurrentInput));
}
@ -371,7 +373,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowCurrentInput, Tes
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowCurrentInput");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_NORMAL)));
auto showCurrentInput = []() { inputMethodController_->ShowCurrentInput(); };
auto showCurrentInput = []() {
inputMethodController_->ShowCurrentInput();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showCurrentInput));
}
@ -385,7 +389,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideSoftKeyboard, Tes
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideSoftKeyboard");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_NORMAL)));
auto hideSoftKeyboard = []() { inputMethodController_->HideSoftKeyboard(); };
auto hideSoftKeyboard = []() {
inputMethodController_->HideSoftKeyboard();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideSoftKeyboard));
}
@ -399,7 +405,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowSoftKeyboard, Tes
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowSoftKeyboard");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_NORMAL)));
auto showSoftKeyboard = []() { inputMethodController_->ShowSoftKeyboard(); };
auto showSoftKeyboard = []() {
inputMethodController_->ShowSoftKeyboard();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showSoftKeyboard));
}
@ -413,7 +421,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideKeyboardSelf, Tes
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideKeyboardSelf");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_SELF)));
auto hideKeyboardSelf = []() { inputMethodAbility_->HideKeyboardSelf(); };
auto hideKeyboardSelf = []() {
inputMethodAbility_->HideKeyboardSelf();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideKeyboardSelf));
}
@ -427,7 +437,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Close, TestSize.Level
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Close");
auto watcher = std::make_shared<Watcher>(
InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_UNBIND)));
auto close = []() { inputMethodController_->Close(); };
auto close = []() {
inputMethodController_->Close();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, close));
}
@ -458,7 +470,9 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Bind, TestSize.Level0
IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Bind");
auto watcherImeChange = std::make_shared<WatcherImeChange>(std::to_string(static_cast<int32_t>(ImeState::BIND)),
std::to_string(static_cast<int32_t>(getpid())), TddUtil::currentBundleNameMock_);
auto imeStateBind = []() { inputMethodController_->RequestShowInput(); };
auto imeStateBind = []() {
inputMethodController_->RequestShowInput();
};
EXPECT_TRUE(InputMethodDfxTest::WriteAndWatchImeChange(watcherImeChange, imeStateBind));
}

View File

@ -59,8 +59,7 @@ public:
static int32_t keyCode_;
static int32_t keyStatus_;
static CursorInfo cursorInfo_;
bool OnDealKeyEvent(
const std::shared_ptr<MMI::KeyEvent> &keyEvent, sptr<KeyEventConsumerProxy> &consumer) override;
bool OnDealKeyEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent, sptr<KeyEventConsumerProxy> &consumer) override;
bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr<KeyEventConsumerProxy> &consumer) override;
bool OnKeyEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent, sptr<KeyEventConsumerProxy> &consumer) override;
void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height) override;
@ -98,15 +97,9 @@ void KeyboardListenerImpl::OnCursorUpdate(int32_t positionX, int32_t positionY,
IMSA_HILOGD("KeyboardListenerImpl::OnCursorUpdate %{public}d %{public}d %{public}d", positionX, positionY, height);
cursorInfo_ = { static_cast<double>(positionX), static_cast<double>(positionY), 0, static_cast<double>(height) };
}
void KeyboardListenerImpl::OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd)
{
}
void KeyboardListenerImpl::OnTextChange(const std::string &text)
{
}
void KeyboardListenerImpl::OnEditorAttributeChange(const InputAttribute &inputAttribute)
{
}
void KeyboardListenerImpl::OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) { }
void KeyboardListenerImpl::OnTextChange(const std::string &text) { }
void KeyboardListenerImpl::OnEditorAttributeChange(const InputAttribute &inputAttribute) { }
class InputMethodEditorTest : public testing::Test {
public:
@ -434,8 +427,8 @@ HWTEST_F(InputMethodEditorTest, testShowTextInput, TestSize.Level0)
ret = InputMethodEditorTest::inputMethodController_->DispatchKeyEvent(InputMethodEditorTest::keyEvent_,
[&consumeResult](std::shared_ptr<MMI::KeyEvent> &keyEvent, bool isConsumed) { consumeResult = isConsumed; });
usleep(1000);
ret = ret && kbListener_->keyCode_ == keyEvent_->GetKeyCode()
&& kbListener_->keyStatus_ == keyEvent_->GetKeyAction();
ret =
ret && kbListener_->keyCode_ == keyEvent_->GetKeyCode() && kbListener_->keyStatus_ == keyEvent_->GetKeyAction();
EXPECT_TRUE(consumeResult);
InputMethodEditorTest::inputMethodController_->Close();
IdentityCheckerMock::SetFocused(false);

View File

@ -30,6 +30,8 @@
#include <vector>
#include "application_info.h"
#include "combination_key.h"
#include "focus_change_listener.h"
#include "global.h"
#include "i_input_method_agent.h"
#include "i_input_method_core.h"
@ -41,8 +43,6 @@
#include "os_account_manager.h"
#include "tdd_util.h"
#include "user_session_manager.h"
#include "combination_key.h"
#include "focus_change_listener.h"
using namespace testing::ext;
namespace OHOS {
@ -116,8 +116,13 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_GetExtends, TestSize.Level0)
constexpr int32_t metaDataNums = 5;
ImeInfoInquirer inquirer;
std::vector<Metadata> metaData;
Metadata metadata[metaDataNums] = { { "language", "english", "" }, { "mode", "mode", "" },
{ "locale", "local", "" }, { "icon", "icon", "" }, { "", "", "" } };
Metadata metadata[metaDataNums] = {
{ "language", "english", "" },
{ "mode", "mode", "" },
{ "locale", "local", "" },
{ "icon", "icon", "" },
{ "", "", "" }
};
for (auto const &data : metadata) {
metaData.emplace_back(data);
}
@ -325,7 +330,10 @@ HWTEST_F(InputMethodPrivateMemberTest, PerUserSessionParameterNullptr003, TestSi
userSession->OnClientDied(nullptr);
userSession->OnImeDied(nullptr, ImeType::IME);
bool isShowKeyboard = false;
userSession->UpdateClientInfo(nullptr, { { UpdateFlag::ISSHOWKEYBOARD, isShowKeyboard } });
userSession->UpdateClientInfo(nullptr,
{
{ UpdateFlag::ISSHOWKEYBOARD, isShowKeyboard }
});
int32_t ret = userSession->RemoveIme(nullptr, ImeType::IME);
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
}
@ -394,8 +402,8 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_SwitchByCombinationKey_003, TestSize.L
info.prop = { .name = "testBundleName" };
info.subProps = { { .id = "testSubName" } };
FullImeInfoManager::GetInstance().fullImeInfos_.insert({ MAIN_USER_ID, { info } });
ImeCfgManager::GetInstance().imeConfigs_.push_back({ MAIN_USER_ID, "testBundleName/testExtName", "testSubName",
false });
ImeCfgManager::GetInstance().imeConfigs_.push_back(
{ MAIN_USER_ID, "testBundleName/testExtName", "testSubName", false });
auto ret = service_->SwitchByCombinationKey(KeyboardEvent::SHIFT_RIGHT_MASK);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
ret = service_->SwitchByCombinationKey(KeyboardEvent::CAPS_MASK);
@ -414,10 +422,12 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_SwitchByCombinationKey_004, TestSize.L
IMSA_HILOGI("InputMethodPrivateMemberTest SA_SwitchByCombinationKey_004 TEST START");
FullImeInfo info;
info.prop = { .name = "testBundleName", .id = "testExtName" };
info.subProps = { { .name = "testBundleName", .id = "testSubName", .language = "French" } };
info.subProps = {
{ .name = "testBundleName", .id = "testSubName", .language = "French" }
};
FullImeInfoManager::GetInstance().fullImeInfos_.insert({ MAIN_USER_ID, { info } });
ImeCfgManager::GetInstance().imeConfigs_.push_back({ MAIN_USER_ID, "testBundleName/testExtName", "testSubName",
false });
ImeCfgManager::GetInstance().imeConfigs_.push_back(
{ MAIN_USER_ID, "testBundleName/testExtName", "testSubName", false });
auto ret = service_->SwitchByCombinationKey(KeyboardEvent::SHIFT_RIGHT_MASK);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
}
@ -434,10 +444,12 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_SwitchByCombinationKey_005, TestSize.L
IMSA_HILOGI("InputMethodPrivateMemberTest SA_SwitchByCombinationKey_005 TEST START");
FullImeInfo info;
info.prop = { .name = "testBundleName", .id = "testExtName" };
info.subProps = { { .name = "testBundleName", .id = "testSubName", .mode = "upper", .language = "english" } };
info.subProps = {
{ .name = "testBundleName", .id = "testSubName", .mode = "upper", .language = "english" }
};
FullImeInfoManager::GetInstance().fullImeInfos_.insert({ MAIN_USER_ID, { info } });
ImeCfgManager::GetInstance().imeConfigs_.push_back({ MAIN_USER_ID, "testBundleName/testExtName", "testSubName",
false });
ImeCfgManager::GetInstance().imeConfigs_.push_back(
{ MAIN_USER_ID, "testBundleName/testExtName", "testSubName", false });
auto ret = service_->SwitchByCombinationKey(KeyboardEvent::SHIFT_RIGHT_MASK);
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
ret = service_->SwitchByCombinationKey(KeyboardEvent::CAPS_MASK);
@ -456,12 +468,14 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_SwitchByCombinationKey_006, TestSize.L
IMSA_HILOGI("InputMethodPrivateMemberTest SA_SwitchByCombinationKey_006 TEST START");
FullImeInfo info;
info.prop = { .name = "testBundleName", .id = "testExtName" };
info.subProps = { { .name = "testBundleName", .id = "testSubName", .mode = "upper", .language = "english" },
{ .name = "testBundleName", .id = "testSubName1", .mode = "lower", .language = "chinese" } };
info.subProps = {
{ .name = "testBundleName", .id = "testSubName", .mode = "upper", .language = "english" },
{ .name = "testBundleName", .id = "testSubName1", .mode = "lower", .language = "chinese" }
};
FullImeInfoManager::GetInstance().fullImeInfos_.insert({ MAIN_USER_ID, { info } });
ImeCfgManager::GetInstance().imeConfigs_.push_back({ MAIN_USER_ID, "testBundleName/testExtName", "testSubName",
false});
ImeCfgManager::GetInstance().imeConfigs_.push_back(
{ MAIN_USER_ID, "testBundleName/testExtName", "testSubName", false });
// english->chinese
auto ret = service_->SwitchByCombinationKey(KeyboardEvent::SHIFT_RIGHT_MASK);
EXPECT_EQ(ret, ErrorCode::ERROR_IME_START_FAILED);
@ -1134,7 +1148,7 @@ HWTEST_F(InputMethodPrivateMemberTest, test_OnFocusedAndOnUnfocused001, TestSize
HWTEST_F(InputMethodPrivateMemberTest, test_OnFocusedAndOnUnfocused002, TestSize.Level0)
{
IMSA_HILOGI("test_OnFocusedAndOnUnfocused002 TEST START");
const sptr<Rosen::FocusChangeInfo> focusChangeInfo = new Rosen::FocusChangeInfo();;
const sptr<Rosen::FocusChangeInfo> focusChangeInfo = new Rosen::FocusChangeInfo();
FocusHandle handle = nullptr;
FocusChangedListener focusChangedListener(handle);
focusChangedListener.OnFocused(focusChangeInfo);

View File

@ -1513,4 +1513,4 @@ HWTEST_F(InputMethodControllerCapiTest, TestAttachWithNorrmalParam_001, TestSize
OH_AttachOptions_Destroy(options);
OH_TextEditorProxy_Destroy(textEditorProxy);
}
}
} // namespace

View File

@ -17,22 +17,20 @@
#include "itypes_util.h"
#undef private
#include <gtest/gtest.h>
#include <cstdint>
#include <gtest/gtest.h>
#include <string>
#include "global.h"
#include "tdd_util.h"
#include "itypes_util.h"
#include "inputmethod_sysevent.h"
#include "itypes_util.h"
#include "tdd_util.h"
using namespace testing::ext;
namespace OHOS {
namespace MiscServices {
class ITypesUtilTest : public testing::Test {
public:
class InputMethodEngineListenerImpl : public InputMethodEngineListener {
public:
InputMethodEngineListenerImpl() = default;

View File

@ -16,9 +16,9 @@
#define private public
#define protected public
#include "input_method_system_ability.h"
#include "security_mode_parser.h"
#include "settings_data_utils.h"
#include "input_method_system_ability.h"
#undef private
@ -151,8 +151,7 @@ HWTEST_F(SecurityModeParserTest, testGetSecurityMode_002, TestSize.Level0)
IMSA_HILOGI("SecurityModeParserTest testGetSecurityMode_002 START");
int32_t ret = SecurityModeParser::GetInstance()->UpdateFullModeList(SecurityModeParserTest::USER_ID);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
SecurityMode security =
SecurityModeParser::GetInstance()->GetSecurityMode("test", SecurityModeParserTest::USER_ID);
SecurityMode security = SecurityModeParser::GetInstance()->GetSecurityMode("test", SecurityModeParserTest::USER_ID);
EXPECT_EQ(static_cast<int32_t>(security), 0);
}
@ -263,8 +262,10 @@ HWTEST_F(SecurityModeParserTest, testParseSecurityMode_001, TestSize.Level0)
HWTEST_F(SecurityModeParserTest, testParseSecurityMode_002, TestSize.Level0)
{
IMSA_HILOGI("SecurityModeParserTest testParseSecurityMode_002 START");
auto ret = SecurityModeParser::GetInstance()->ParseSecurityMode("{\"fullExperienceList\" : {\"100\" : ["
"\"xiaoyiIme\", \"baiduIme\", \"sougouIme\"],\"101\" : [\"sougouIme\"]}}", SecurityModeParserTest::USER_ID);
auto ret = SecurityModeParser::GetInstance()->ParseSecurityMode(
"{\"fullExperienceList\" : {\"100\" : ["
"\"xiaoyiIme\", \"baiduIme\", \"sougouIme\"],\"101\" : [\"sougouIme\"]}}",
SecurityModeParserTest::USER_ID);
EXPECT_TRUE(ret);
}
} // namespace MiscServices

View File

@ -35,39 +35,17 @@ namespace MiscServices {
*/
class TextListenerImpl : public OnTextChangedListener {
public:
void InsertText(const std::u16string &text) override
{
}
void DeleteForward(int32_t length) override
{
}
void DeleteBackward(int32_t length) override
{
}
void SendKeyEventFromInputMethod(const KeyEvent &event) override
{
}
void SendKeyboardStatus(const KeyboardStatus &keyboardStatus) override
{
}
void SendFunctionKey(const FunctionKey &functionKey) override
{
}
void SetKeyboardStatus(bool status) override
{
}
void MoveCursor(const Direction direction) override
{
}
void HandleSetSelection(int32_t start, int32_t end) override
{
}
void HandleExtendAction(int32_t action) override
{
}
void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override
{
}
void InsertText(const std::u16string &text) override { }
void DeleteForward(int32_t length) override { }
void DeleteBackward(int32_t length) override { }
void SendKeyEventFromInputMethod(const KeyEvent &event) override { }
void SendKeyboardStatus(const KeyboardStatus &keyboardStatus) override { }
void SendFunctionKey(const FunctionKey &functionKey) override { }
void SetKeyboardStatus(bool status) override { }
void MoveCursor(const Direction direction) override { }
void HandleSetSelection(int32_t start, int32_t end) override { }
void HandleExtendAction(int32_t action) override { }
void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override { }
std::u16string GetLeftTextOfCursor(int32_t number) override
{
return Str8ToStr16("test");
@ -86,39 +64,25 @@ public:
*/
class EngineListenerImpl : public InputMethodEngineListener {
public:
void OnKeyboardStatus(bool isShow) override
{
}
void OnInputStart() override
{
}
void OnKeyboardStatus(bool isShow) override { }
void OnInputStart() override { }
int32_t OnInputStop() override
{
return ErrorCode::NO_ERROR;
}
void OnSecurityChange(int32_t security) override
{
}
void OnSetCallingWindow(uint32_t windowId) override
{
}
void OnSetSubtype(const SubProperty &property) override
{
}
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override
{
}
void OnSecurityChange(int32_t security) override { }
void OnSetCallingWindow(uint32_t windowId) override { }
void OnSetSubtype(const SubProperty &property) override { }
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override { }
};
/**
* @brief Only pure virtual functions are implemented.
*/
class EventListenerImpl : public ImeEventListener {
};
class EventListenerImpl : public ImeEventListener { };
/**
* @brief Only pure virtual functions are implemented.
*/
class SystemCmdChannelImpl : public OnSystemCmdListener {
};
class SystemCmdChannelImpl : public OnSystemCmdListener { };
class SystemCmdChannelListenerImpl : public OnSystemCmdListener {
public:

View File

@ -67,8 +67,7 @@ describe('InputMethodTest', function () {
expect(subProp.language).assertEqual(language[index]);
}
function checkNewImeSubProps(subProps)
{
function checkNewImeSubProps(subProps) {
expect(subProps.length).assertEqual(NEW_IME_SUBTYPE_NUM);
for (let i = 0; i < subProps.length; i++) {
expect(subProps[i].name).assertEqual(bundleName);
@ -78,24 +77,21 @@ describe('InputMethodTest', function () {
}
}
function checkImeCurrentProp(property, index)
{
function checkImeCurrentProp(property, index) {
expect(property.name).assertEqual(bundleName1);
expect(property.id).assertEqual(extName1[index]);
expect(property.packageName).assertEqual(bundleName1);
expect(property.methodId).assertEqual(extName1[index]);
}
function checkImeCurrentSubProp(subProp, index)
{
function checkImeCurrentSubProp(subProp, index) {
expect(subProp.name).assertEqual(bundleName1);
expect(subProp.id).assertEqual(extName1[index]);
expect(subProp.locale).assertEqual(locale1[index]);
expect(subProp.language).assertEqual(language1[index]);
}
function checkImeSubProps(subProps)
{
function checkImeSubProps(subProps) {
expect(subProps.length).assertEqual(OLD_IME_SUBTYPE_NUM);
for (let i = 0; i < subProps.length; i++) {
expect(subProps[i].name).assertEqual(bundleName1);

View File

@ -169,7 +169,6 @@ describe('InputMethodWithAttachTest', function () {
});
});
/*
* @tc.number inputmethod_with_attach_test_hideTextInput_002
* @tc.name Test whether the keyboard is hide successfully.