mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 00:41:04 +00:00
mod
Signed-off-by: cy7717 <chenyu301@huawei.com>
This commit is contained in:
parent
7afd80730c
commit
64313e6069
@ -37,8 +37,8 @@ constexpr size_t ARGC_TWO = 2;
|
||||
constexpr size_t ARGC_MAX = 6;
|
||||
thread_local napi_ref JsGetInputMethodSetting::IMSRef_ = nullptr;
|
||||
const std::string JsGetInputMethodSetting::IMS_CLASS_NAME = "InputMethodSetting";
|
||||
const std::unordered_map<std::string, EventType> EVENT_TYPE{ { "imeChange", IME_CHANGE }, { "imeShow", IME_SHOW },
|
||||
{ "imeHide", IME_HIDE } };
|
||||
const std::unordered_map<std::string, uint32_t> EVENT_TYPE{ { "imeChange", EVENT_IME_CHANGE_MASK },
|
||||
{ "imeShow", EVENT_IME_SHOW_MASK }, { "imeHide", EVENT_IME_HIDE_MASK } };
|
||||
std::mutex JsGetInputMethodSetting::msMutex_;
|
||||
std::shared_ptr<JsGetInputMethodSetting> JsGetInputMethodSetting::inputMethod_{ nullptr };
|
||||
napi_value JsGetInputMethodSetting::Init(napi_env env, napi_value exports)
|
||||
@ -491,7 +491,7 @@ napi_value JsGetInputMethodSetting::Subscribe(napi_env env, napi_callback_info i
|
||||
}
|
||||
std::shared_ptr<JSCallbackObject> callback =
|
||||
std::make_shared<JSCallbackObject>(env, argv[ARGC_ONE], std::this_thread::get_id());
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ iter->second }, inputMethod_);
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(iter->second, inputMethod_);
|
||||
if (ret == ErrorCode::NO_ERROR) {
|
||||
engine->RegisterListener(argv[ARGC_ONE], type, callback);
|
||||
} else {
|
||||
@ -572,7 +572,7 @@ napi_value JsGetInputMethodSetting::UnSubscribe(napi_env env, napi_callback_info
|
||||
return nullptr;
|
||||
}
|
||||
if (isUpdateFlag) {
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().UnRegisterImeEventListener({ iter->second }, inputMethod_);
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().UnRegisterImeEventListener(iter->second, inputMethod_);
|
||||
IMSA_HILOGI("UpdateListenEventFlag, ret: %{public}d, type: %{public}s", ret, type.c_str());
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
|
@ -24,15 +24,15 @@ class EventStatusManager {
|
||||
public:
|
||||
inline static bool IsImeShowOn(uint32_t eventFlag)
|
||||
{
|
||||
return (eventFlag & (1u << EventType::IME_SHOW)) == (1u << EventType::IME_SHOW);
|
||||
return (eventFlag & EVENT_IME_SHOW_MASK) == EVENT_IME_SHOW_MASK;
|
||||
}
|
||||
inline static bool IsImeChangeOn(uint32_t eventFlag)
|
||||
{
|
||||
return (eventFlag & (1u << EventType::IME_CHANGE)) == (1u << EventType::IME_CHANGE);
|
||||
return (eventFlag & EVENT_IME_CHANGE_MASK) == EVENT_IME_CHANGE_MASK;
|
||||
}
|
||||
inline static bool IsImeHideOn(uint32_t eventFlag)
|
||||
{
|
||||
return (eventFlag & (1u << EventType::IME_HIDE)) == (1u << EventType::IME_HIDE);
|
||||
return (eventFlag & EVENT_IME_HIDE_MASK) == EVENT_IME_HIDE_MASK;
|
||||
}
|
||||
};
|
||||
} // namespace MiscServices
|
||||
|
@ -27,20 +27,20 @@ namespace MiscServices {
|
||||
class ImeEventMonitorManagerImpl {
|
||||
public:
|
||||
static ImeEventMonitorManagerImpl &GetInstance();
|
||||
int32_t RegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener);
|
||||
int32_t UnRegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener);
|
||||
int32_t RegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
int32_t UnRegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
int32_t OnImeChange(const Property &property, const SubProperty &subProperty);
|
||||
int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info);
|
||||
|
||||
private:
|
||||
ImeEventMonitorManagerImpl();
|
||||
~ImeEventMonitorManagerImpl();
|
||||
|
||||
std::set<std::shared_ptr<ImeEventListener>> GetListeners(EventType type);
|
||||
static constexpr uint32_t MAX_EVENT_NUM = 3;
|
||||
int32_t OnImeShow(const ImeWindowInfo &info);
|
||||
int32_t OnImeHide(const ImeWindowInfo &info);
|
||||
std::set<std::shared_ptr<ImeEventListener>> GetListeners(uint32_t eventMask);
|
||||
std::mutex lock_;
|
||||
std::map<EventType, std::set<std::shared_ptr<ImeEventListener>>> listeners_{};
|
||||
std::map<uint32_t, std::set<std::shared_ptr<ImeEventListener>>> listeners_{};
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
int32_t ListCurrentInputMethodSubtype(std::vector<SubProperty> &subProps) override;
|
||||
int32_t ListInputMethodSubtype(const std::string &name, std::vector<SubProperty> &subProps) override;
|
||||
int32_t PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override;
|
||||
int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, EventType eventType) override;
|
||||
int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) override;
|
||||
bool IsCurrentIme() override;
|
||||
bool IsInputTypeSupported(InputType type) override;
|
||||
int32_t StartInputType(InputType type) override;
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
const std::set<EventType> ImeEventMonitorManager::EVENT_TYPE{ IME_SHOW, IME_HIDE };
|
||||
ImeEventMonitorManager::ImeEventMonitorManager()
|
||||
{
|
||||
}
|
||||
@ -38,41 +37,31 @@ ImeEventMonitorManager &ImeEventMonitorManager::GetInstance()
|
||||
}
|
||||
|
||||
int32_t ImeEventMonitorManager::RegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener)
|
||||
uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener)
|
||||
{
|
||||
if (!IsParamValid(types, listener)) {
|
||||
if (!IsParamValid(eventFlag, listener)) {
|
||||
IMSA_HILOGE("param is invalid");
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
return ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(types, listener);
|
||||
return ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(eventFlag & ALL_EVENT_MASK, listener);
|
||||
}
|
||||
|
||||
int32_t ImeEventMonitorManager::UnRegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener)
|
||||
uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener)
|
||||
{
|
||||
if (!IsParamValid(types, listener)) {
|
||||
if (!IsParamValid(eventFlag, listener)) {
|
||||
IMSA_HILOGE("param is invalid");
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
return ImeEventMonitorManagerImpl::GetInstance().UnRegisterImeEventListener(types, listener);
|
||||
return ImeEventMonitorManagerImpl::GetInstance().UnRegisterImeEventListener(eventFlag & ALL_EVENT_MASK, listener);
|
||||
}
|
||||
|
||||
bool ImeEventMonitorManager::IsParamValid(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener)
|
||||
bool ImeEventMonitorManager::IsParamValid(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
IMSA_HILOGE("listener is nullptr");
|
||||
if (eventFlag == 0) {
|
||||
IMSA_HILOGE("eventFlag is 0");
|
||||
return false;
|
||||
}
|
||||
if (types.empty()) {
|
||||
IMSA_HILOGE("no eventType");
|
||||
return false;
|
||||
}
|
||||
if (types.size() > EVENT_NUM) {
|
||||
IMSA_HILOGE("over eventNum");
|
||||
return false;
|
||||
}
|
||||
auto it = std::find_if(
|
||||
types.begin(), types.end(), [](EventType type) { return EVENT_TYPE.find(type) == EVENT_TYPE.end(); });
|
||||
return it == types.end();
|
||||
return listener != nullptr;
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -36,32 +36,45 @@ ImeEventMonitorManagerImpl &ImeEventMonitorManagerImpl::GetInstance()
|
||||
}
|
||||
|
||||
int32_t ImeEventMonitorManagerImpl::RegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener)
|
||||
uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
for (const auto &type : types) {
|
||||
auto it = listeners_.find(type);
|
||||
if (it == listeners_.end()) {
|
||||
auto ret = InputMethodController::GetInstance()->UpdateListenEventFlag(type, true);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("UpdateListenEventFlag failed: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
listeners_.insert({ type, { listener } });
|
||||
} else {
|
||||
it->second.insert(listener);
|
||||
uint32_t currentEventFlag = 0;
|
||||
for (const auto &listenerTemp : listeners_) {
|
||||
currentEventFlag |= listenerTemp.first;
|
||||
}
|
||||
auto finalEventFlag = currentEventFlag | eventFlag;
|
||||
auto ret = InputMethodController::GetInstance()->UpdateListenEventFlag(finalEventFlag, eventFlag, true);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("UpdateListenEventFlag failed: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
for (uint32_t i = 0; i < MAX_EVENT_NUM; i++) {
|
||||
auto eventMask = eventFlag & (1u << (MAX_EVENT_NUM - (i + 1)));
|
||||
if (eventMask == 0) {
|
||||
continue;
|
||||
}
|
||||
auto it = listeners_.find(eventMask);
|
||||
if (it == listeners_.end()) {
|
||||
listeners_.insert({ eventMask, { listener } });
|
||||
continue;
|
||||
}
|
||||
it->second.insert(listener);
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t ImeEventMonitorManagerImpl::UnRegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener)
|
||||
uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener)
|
||||
{
|
||||
bool isAbsentParam = false;
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
for (const auto &type : types) {
|
||||
auto it = listeners_.find(type);
|
||||
bool isAbsentParam = false;
|
||||
for (uint32_t i = 0; i < MAX_EVENT_NUM; i++) {
|
||||
auto eventMask = eventFlag & (1u << (MAX_EVENT_NUM - (i + 1)));
|
||||
if (eventMask == 0) {
|
||||
continue;
|
||||
}
|
||||
auto it = listeners_.find(eventMask);
|
||||
if (it == listeners_.end()) {
|
||||
isAbsentParam = true;
|
||||
continue;
|
||||
@ -73,19 +86,24 @@ int32_t ImeEventMonitorManagerImpl::UnRegisterImeEventListener(
|
||||
}
|
||||
it->second.erase(iter);
|
||||
if (it->second.empty()) {
|
||||
auto ret = InputMethodController::GetInstance()->UpdateListenEventFlag(type, false);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("UpdateListenEventFlag failed: %{public}d", ret);
|
||||
}
|
||||
listeners_.erase(it);
|
||||
}
|
||||
}
|
||||
uint32_t finalEventFlag = 0;
|
||||
for (const auto &listenerTemp : listeners_) {
|
||||
finalEventFlag |= listenerTemp.first;
|
||||
}
|
||||
auto ret = InputMethodController::GetInstance()->UpdateListenEventFlag(finalEventFlag, eventFlag, false);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("UpdateListenEventFlag failed: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
return isAbsentParam ? ErrorCode::ERROR_BAD_PARAMETERS : ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t ImeEventMonitorManagerImpl::OnImeChange(const Property &property, const SubProperty &subProperty)
|
||||
{
|
||||
auto listeners = GetListeners(EventType::IME_CHANGE);
|
||||
auto listeners = GetListeners(EVENT_IME_CHANGE_MASK);
|
||||
for (const auto &listener : listeners) {
|
||||
listener->OnImeChange(property, subProperty);
|
||||
}
|
||||
@ -94,22 +112,37 @@ int32_t ImeEventMonitorManagerImpl::OnImeChange(const Property &property, const
|
||||
|
||||
int32_t ImeEventMonitorManagerImpl::OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info)
|
||||
{
|
||||
auto type = status == InputWindowStatus::HIDE ? EventType::IME_HIDE : EventType::IME_SHOW;
|
||||
auto listeners = GetListeners(type);
|
||||
if (status == InputWindowStatus::HIDE) {
|
||||
return OnImeHide(info);
|
||||
}
|
||||
if (status == InputWindowStatus::SHOW) {
|
||||
return OnImeShow(info);
|
||||
}
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
int32_t ImeEventMonitorManagerImpl::OnImeShow(const ImeWindowInfo &info)
|
||||
{
|
||||
auto listeners = GetListeners(EVENT_IME_SHOW_MASK);
|
||||
for (const auto &listener : listeners) {
|
||||
if (type == EventType::IME_HIDE) {
|
||||
listener->OnImeHide(info);
|
||||
} else {
|
||||
listener->OnImeShow(info);
|
||||
}
|
||||
listener->OnImeShow(info);
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
std::set<std::shared_ptr<ImeEventListener>> ImeEventMonitorManagerImpl::GetListeners(EventType type)
|
||||
int32_t ImeEventMonitorManagerImpl::OnImeHide(const ImeWindowInfo &info)
|
||||
{
|
||||
auto listeners = GetListeners(EVENT_IME_HIDE_MASK);
|
||||
for (const auto &listener : listeners) {
|
||||
listener->OnImeHide(info);
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
std::set<std::shared_ptr<ImeEventListener>> ImeEventMonitorManagerImpl::GetListeners(uint32_t eventMask)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
auto it = listeners_.find(type);
|
||||
auto it = listeners_.find(eventMask);
|
||||
if (it == listeners_.end()) {
|
||||
return {};
|
||||
}
|
||||
|
@ -44,8 +44,6 @@ std::mutex InputMethodController::instanceLock_;
|
||||
constexpr int32_t LOOP_COUNT = 5;
|
||||
constexpr int64_t DELAY_TIME = 100;
|
||||
constexpr int32_t ACE_DEAL_TIME_OUT = 200;
|
||||
const std::unordered_map<std::string, EventType> EVENT_TYPE{ { "imeChange", IME_CHANGE }, { "imeShow", IME_SHOW },
|
||||
{ "imeHide", IME_HIDE } };
|
||||
InputMethodController::InputMethodController()
|
||||
{
|
||||
IMSA_HILOGD("IMC structure");
|
||||
@ -82,27 +80,21 @@ int32_t InputMethodController::RestoreListenEventFlag()
|
||||
IMSA_HILOGE("proxy is nullptr");
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
}
|
||||
return proxy->UpdateListenEventFlag(clientInfo_, IME_NONE);
|
||||
// 0 represent no need to check permission
|
||||
return proxy->UpdateListenEventFlag(clientInfo_, 0);
|
||||
}
|
||||
|
||||
int32_t InputMethodController::UpdateListenEventFlag(EventType eventType, bool isOn)
|
||||
int32_t InputMethodController::UpdateListenEventFlag(uint32_t finalEventFlag, uint32_t eventFlag, bool isOn)
|
||||
{
|
||||
auto oldEventFlag = clientInfo_.eventFlag;
|
||||
if (isOn) {
|
||||
clientInfo_.eventFlag |= (1u << eventType);
|
||||
} else {
|
||||
clientInfo_.eventFlag &= (~(1u << eventType));
|
||||
}
|
||||
if (oldEventFlag == clientInfo_.eventFlag) {
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
clientInfo_.eventFlag = finalEventFlag;
|
||||
auto proxy = GetSystemAbilityProxy();
|
||||
if (proxy == nullptr && isOn) {
|
||||
IMSA_HILOGE("proxy is nullptr");
|
||||
clientInfo_.eventFlag = oldEventFlag;
|
||||
return ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
}
|
||||
auto ret = proxy->UpdateListenEventFlag(clientInfo_, eventType);
|
||||
auto ret = proxy->UpdateListenEventFlag(clientInfo_, eventFlag);
|
||||
if (ret != ErrorCode::NO_ERROR && isOn) {
|
||||
clientInfo_.eventFlag = oldEventFlag;
|
||||
}
|
||||
|
@ -201,11 +201,10 @@ int32_t InputMethodSystemAbilityProxy::PanelStatusChange(const InputWindowStatus
|
||||
});
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbilityProxy::UpdateListenEventFlag(InputClientInfo &clientInfo, EventType eventType)
|
||||
int32_t InputMethodSystemAbilityProxy::UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag)
|
||||
{
|
||||
return SendRequest(static_cast<uint32_t>(InputMethodInterfaceCode::UPDATE_LISTEN_EVENT_FLAG),
|
||||
[&clientInfo, eventType](
|
||||
MessageParcel &data) { return ITypesUtil::Marshal(data, clientInfo, static_cast<uint32_t>(eventType)); });
|
||||
[&clientInfo, eventFlag](MessageParcel &data) { return ITypesUtil::Marshal(data, clientInfo, eventFlag); });
|
||||
}
|
||||
|
||||
bool InputMethodSystemAbilityProxy::IsCurrentIme()
|
||||
|
@ -21,7 +21,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum EventType : uint32_t { IME_CHANGE = 0, IME_SHOW = 1, IME_HIDE = 2, IME_NONE };
|
||||
constexpr uint32_t EVENT_IME_CHANGE_MASK = 1u;
|
||||
constexpr uint32_t EVENT_IME_SHOW_MASK = 1u << 1u;
|
||||
constexpr uint32_t EVENT_IME_HIDE_MASK = 1u << 2u;
|
||||
class ImeEventListener {
|
||||
public:
|
||||
virtual ~ImeEventListener() = default;
|
||||
|
@ -40,33 +40,30 @@ public:
|
||||
*
|
||||
* This function is used to Register Ime Event Listener, only IME_SHOW and IME_HIDE supported at present
|
||||
*
|
||||
* @param types Indicates the event type.
|
||||
* @param eventFlag Indicates the flag of the ime event to be registered
|
||||
* @param listener Indicates the the listener to be registered.
|
||||
* @return Returns 0 for success, others for failure.
|
||||
* @since 12
|
||||
*/
|
||||
IMF_API int32_t RegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener);
|
||||
IMF_API int32_t RegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
|
||||
/**
|
||||
* @brief UnRegister Ime Event Listener.
|
||||
*
|
||||
* This function is used to UnRegister Ime Event Listener, only IME_SHOW and IME_HIDE supported at present
|
||||
*
|
||||
* @param types Indicates the event type.
|
||||
* @param types Indicates the flag of the ime event to be unRegistered
|
||||
* @param listener Indicates the the listener to be unregistered.
|
||||
* @return Returns 0 for success, others for failure.
|
||||
* @since 12
|
||||
*/
|
||||
IMF_API int32_t UnRegisterImeEventListener(
|
||||
const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener);
|
||||
IMF_API int32_t UnRegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
|
||||
private:
|
||||
static constexpr uint32_t EVENT_NUM = 2;
|
||||
static const std::set<EventType> EVENT_TYPE;
|
||||
static constexpr uint32_t ALL_EVENT_MASK = EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK;
|
||||
ImeEventMonitorManager();
|
||||
~ImeEventMonitorManager();
|
||||
bool IsParamValid(const std::set<EventType> &types, const std::shared_ptr<ImeEventListener> &listener);
|
||||
bool IsParamValid(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -684,7 +684,7 @@ public:
|
||||
* @since 11
|
||||
*/
|
||||
IMF_API int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown);
|
||||
int32_t UpdateListenEventFlag(EventType eventType, bool isOn);
|
||||
int32_t UpdateListenEventFlag(uint32_t finalEventFlag, uint32_t eventFlag, bool isOn);
|
||||
|
||||
private:
|
||||
InputMethodController();
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
virtual int32_t SwitchInputMethod(
|
||||
const std::string &bundleName, const std::string &name, SwitchTrigger trigger) = 0;
|
||||
virtual int32_t PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) = 0;
|
||||
virtual int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, EventType eventType) = 0;
|
||||
virtual int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) = 0;
|
||||
virtual bool IsCurrentIme() = 0;
|
||||
virtual bool IsInputTypeSupported(InputType type) = 0;
|
||||
virtual int32_t StartInputType(InputType type) = 0;
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent) override;
|
||||
int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core) override;
|
||||
int32_t PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override;
|
||||
int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, EventType eventType) override;
|
||||
int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) override;
|
||||
bool IsCurrentIme() override;
|
||||
bool IsInputTypeSupported(InputType type) override;
|
||||
int32_t StartInputType(InputType type) override;
|
||||
|
@ -445,10 +445,10 @@ int32_t InputMethodSystemAbility::PanelStatusChange(const InputWindowStatus &sta
|
||||
return userSession_->OnPanelStatusChange(status, info);
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbility::UpdateListenEventFlag(InputClientInfo &clientInfo, EventType eventType)
|
||||
int32_t InputMethodSystemAbility::UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag)
|
||||
{
|
||||
IMSA_HILOGI("eventType: %{public}u, eventFlag: %{public}u", eventType, clientInfo.eventFlag);
|
||||
if (eventType == IME_SHOW || eventType == IME_HIDE) {
|
||||
IMSA_HILOGI("finalEventFlag: %{public}u, eventFlag: %{public}u", clientInfo.eventFlag, eventFlag);
|
||||
if (EventStatusManager::IsImeHideOn(eventFlag) || EventStatusManager::IsImeShowOn(eventFlag)) {
|
||||
if (!identityChecker_->IsSystemApp(IPCSkeleton::GetCallingFullTokenID())
|
||||
&& !identityChecker_->IsNativeSa(IPCSkeleton::GetCallingTokenID())) {
|
||||
IMSA_HILOGE("not system application");
|
||||
|
@ -267,12 +267,12 @@ int32_t InputMethodSystemAbilityStub::PanelStatusChangeOnRemote(MessageParcel &d
|
||||
int32_t InputMethodSystemAbilityStub::UpdateListenEventFlagOnRemote(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
InputClientInfo clientInfo;
|
||||
uint32_t type = 0;
|
||||
if (!ITypesUtil::Unmarshal(data, clientInfo, type)) {
|
||||
uint32_t eventFlag = 0;
|
||||
if (!ITypesUtil::Unmarshal(data, clientInfo, eventFlag)) {
|
||||
IMSA_HILOGE("Unmarshal failed");
|
||||
return ErrorCode::ERROR_EX_PARCELABLE;
|
||||
}
|
||||
int32_t ret = UpdateListenEventFlag(clientInfo, static_cast<EventType>(type));
|
||||
int32_t ret = UpdateListenEventFlag(clientInfo, eventFlag);
|
||||
return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
|
||||
}
|
||||
|
||||
|
@ -24,15 +24,15 @@ constexpr size_t THRESHOLD = 10;
|
||||
void FuzzRegisterImeEventListener(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ static_cast<EventType>(size) }, nullptr);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ static_cast<EventType>(size) }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(static_cast<uint32_t>(size), nullptr);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(static_cast<uint32_t>(size), listener);
|
||||
}
|
||||
|
||||
void FuzzUnRegisterImeEventListener(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ static_cast<EventType>(size) }, nullptr);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ static_cast<EventType>(size) }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(static_cast<uint32_t>(size), nullptr);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(static_cast<uint32_t>(size), listener);
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
|
@ -92,7 +92,8 @@ void TestOnConfigurationChange(sptr<InputMethodController> imc)
|
||||
imc->GetInputPattern(inputPattern);
|
||||
}
|
||||
|
||||
void TestSwitchInputMethod(SwitchTrigger fuzzedTrigger, sptr<InputMethodController> imc, const std::string& fuzzedString)
|
||||
void TestSwitchInputMethod(
|
||||
SwitchTrigger fuzzedTrigger, sptr<InputMethodController> imc, const std::string &fuzzedString)
|
||||
{
|
||||
imc->SwitchInputMethod(fuzzedTrigger, fuzzedString, fuzzedString);
|
||||
imc->ShowOptionalInputMethod();
|
||||
@ -127,8 +128,8 @@ void TestShowSomething(sptr<InputMethodController> imc)
|
||||
|
||||
void TestUpdateListenEventFlag(sptr<InputMethodController> imc, uint32_t fuzzedUint32)
|
||||
{
|
||||
imc->UpdateListenEventFlag(static_cast<EventType>(fuzzedUint32), true);
|
||||
imc->UpdateListenEventFlag(static_cast<EventType>(fuzzedUint32), false);
|
||||
imc->UpdateListenEventFlag(static_cast<uint32_t>(fuzzedUint32), static_cast<uint32_t>(fuzzedUint32), true);
|
||||
imc->UpdateListenEventFlag(static_cast<uint32_t>(fuzzedUint32), static_cast<uint32_t>(fuzzedUint32), false);
|
||||
}
|
||||
|
||||
void TestAttach(sptr<InputMethodController> imc, int32_t fuzzedInt32)
|
||||
|
@ -575,16 +575,13 @@ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_001, TestSize.Level0)
|
||||
IMSA_HILOGI("IdentityCheckerTest testUpdateListenEventFlag_001 start");
|
||||
service_->identityChecker_ = identityCheckerImpl_;
|
||||
InputClientInfo clientInfo{};
|
||||
EventType eventType = IME_SHOW;
|
||||
int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_SHOW_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION);
|
||||
|
||||
eventType = IME_HIDE;
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_HIDE_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION);
|
||||
|
||||
eventType = IME_CHANGE;
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_CHANGE_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
}
|
||||
|
||||
@ -601,16 +598,13 @@ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_002, TestSize.Level0)
|
||||
IdentityCheckerTest::IdentityCheckerMock::isSystemApp_ = true;
|
||||
IdentityCheckerTest::IdentityCheckerMock::isNativeSa_ = false;
|
||||
InputClientInfo clientInfo{};
|
||||
EventType eventType = IME_SHOW;
|
||||
int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_SHOW_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
eventType = IME_HIDE;
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_HIDE_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
eventType = IME_CHANGE;
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_CHANGE_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
}
|
||||
|
||||
@ -627,16 +621,13 @@ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_003, TestSize.Level0)
|
||||
IdentityCheckerTest::IdentityCheckerMock::isSystemApp_ = false;
|
||||
IdentityCheckerTest::IdentityCheckerMock::isNativeSa_ = true;
|
||||
InputClientInfo clientInfo{};
|
||||
EventType eventType = IME_SHOW;
|
||||
int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_SHOW_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
eventType = IME_HIDE;
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_HIDE_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
eventType = IME_CHANGE;
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, eventType);
|
||||
ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_CHANGE_MASK);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
}
|
||||
|
||||
|
@ -65,61 +65,65 @@ void ImeEventMonitorManagerTest::TearDown()
|
||||
|
||||
/**
|
||||
* @tc.name: testRegisterImeEventListener_001
|
||||
* @tc.desc: type size over max
|
||||
* @tc.desc: eventType is 0
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("testRegisterImeEventListener_001 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_HIDE, EventType::IME_SHOW, EventType::IME_CHANGE, static_cast<EventType>(10) }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(0, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testUnRegisterImeEventListener_002
|
||||
* @tc.desc: type size over max
|
||||
* @tc.desc: eventFlag is 0
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_002 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
|
||||
{ EventType::IME_HIDE, EventType::IME_SHOW, EventType::IME_CHANGE, static_cast<EventType>(10) }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(0, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testRegisterImeEventListener_003
|
||||
* @tc.desc: type is error
|
||||
* @tc.desc: eventFlag is 15
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("testRegisterImeEventListener_003 start.");
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_003 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_CHANGE }, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(15, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_HIDE_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testUnRegisterImeEventListener_004
|
||||
* @tc.desc: type is error
|
||||
* @tc.name: testRegisterImeEventListener_004
|
||||
* @tc.desc: eventFlag is 5
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_004, TestSize.Level0)
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_004, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_004 start.");
|
||||
IMSA_HILOGI("testRegisterImeEventListener_004 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
|
||||
{ EventType::IME_HIDE, EventType::IME_CHANGE }, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(5, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_HIDE_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
EXPECT_EQ(it->second.size(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +134,7 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_004, TestSiz
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_005, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("testRegisterImeEventListener_005 start.");
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, nullptr);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, nullptr);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
}
|
||||
@ -143,7 +147,7 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_005, TestSize.
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_006, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_006 start.");
|
||||
auto ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, nullptr);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, nullptr);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
}
|
||||
@ -158,7 +162,7 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_007, TestSize.
|
||||
IMSA_HILOGI("testRegisterImeEventListener_007 start.");
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
}
|
||||
@ -172,13 +176,13 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_008, TestSiz
|
||||
{
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_008 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 4);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 0);
|
||||
}
|
||||
@ -192,11 +196,11 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_009, TestSize.
|
||||
{
|
||||
IMSA_HILOGI("testRegisterImeEventListener_009 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 4);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_HIDE);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_HIDE_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 1);
|
||||
auto iter = it->second.find(listener);
|
||||
@ -205,7 +209,7 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_009, TestSize.
|
||||
|
||||
/**
|
||||
* @tc.name: testRegisterImeEventListener_010
|
||||
* @tc.desc: one listener register all event
|
||||
* @tc.desc: one listener register EVENT_IME_HIDE_MASK|EVENT_IME_SHOW_MASK
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_010, TestSize.Level0)
|
||||
@ -213,17 +217,17 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_010, TestSize.
|
||||
IMSA_HILOGI("testRegisterImeEventListener_010 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_HIDE, EventType::IME_SHOW }, listener);
|
||||
EVENT_IME_HIDE_MASK | EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_HIDE);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_HIDE_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 1);
|
||||
auto iter = it->second.find(listener);
|
||||
EXPECT_NE(iter, it->second.end());
|
||||
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 1);
|
||||
iter = it->second.find(listener);
|
||||
@ -232,7 +236,7 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_010, TestSize.
|
||||
|
||||
/**
|
||||
* @tc.name: testRegisterImeEventListener_011
|
||||
* @tc.desc: one listener register three same event
|
||||
* @tc.desc: one listener register EVENT_IME_SHOW_MASK|EVENT_IME_HIDE_MASK|EVENT_IME_CHANGE_MASK
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_011, TestSize.Level0)
|
||||
@ -240,15 +244,12 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_011, TestSize.
|
||||
IMSA_HILOGI("testRegisterImeEventListener_011 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_SHOW, EventType::IME_SHOW }, listener);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK | EVENT_IME_CHANGE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 1);
|
||||
auto iter = it->second.find(listener);
|
||||
EXPECT_NE(iter, it->second.end());
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_CHANGE_MASK);
|
||||
ASSERT_EQ(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,21 +263,21 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_012, TestSize.
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener1);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_HIDE);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_HIDE_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 2);
|
||||
auto iter = it->second.find(listener);
|
||||
EXPECT_NE(iter, it->second.end());
|
||||
iter = it->second.find(listener1);
|
||||
EXPECT_NE(iter, it->second.end());
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 2);
|
||||
iter = it->second.find(listener);
|
||||
@ -295,23 +296,22 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_013, TestSize.
|
||||
IMSA_HILOGI("testRegisterImeEventListener_013 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_SHOW }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener1);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 2);
|
||||
auto iter = it->second.find(listener);
|
||||
EXPECT_NE(iter, it->second.end());
|
||||
iter = it->second.find(listener1);
|
||||
EXPECT_NE(iter, it->second.end());
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_HIDE);
|
||||
it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_HIDE_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 1);
|
||||
iter = it->second.find(listener1);
|
||||
@ -327,11 +327,11 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_014, TestSiz
|
||||
{
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_014 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 0);
|
||||
@ -347,11 +347,11 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_015, TestSiz
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_015 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
@ -367,12 +367,12 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_016, TestSiz
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_016 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener);
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(ImeEventMonitorManagerImpl::GetInstance().listeners_.empty());
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 0);
|
||||
@ -388,17 +388,17 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_017, TestSiz
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_017 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 1);
|
||||
auto iter = it->second.find(listener1);
|
||||
@ -415,17 +415,17 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_018, TestSiz
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_018 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 2);
|
||||
auto iter = it->second.find(listener);
|
||||
@ -444,17 +444,17 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_019, TestSiz
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener2 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
auto ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener2);
|
||||
ret = ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener2);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 2);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 1);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EventType::IME_SHOW);
|
||||
auto it = ImeEventMonitorManagerImpl::GetInstance().listeners_.find(EVENT_IME_SHOW_MASK);
|
||||
ASSERT_NE(it, ImeEventMonitorManagerImpl::GetInstance().listeners_.end());
|
||||
ASSERT_EQ(it->second.size(), 2);
|
||||
auto iter = it->second.find(listener);
|
||||
@ -473,9 +473,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_020, TestSize.
|
||||
IMSA_HILOGI("testRegisterImeEventListener_020 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ EventType::IME_CHANGE }, listener);
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_CHANGE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW, IME_HIDE }, listener1);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 7);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 3);
|
||||
@ -491,17 +492,18 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_021, TestSiz
|
||||
IMSA_HILOGI("testUnRegisterImeEventListener_021 start.");
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto listener1 = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ EventType::IME_CHANGE }, listener);
|
||||
auto ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_CHANGE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ret = ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW, IME_HIDE }, listener1);
|
||||
ret = ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener1);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 7);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 3);
|
||||
ret = ImeEventMonitorManagerImpl::GetInstance().UnRegisterImeEventListener({ EventType::IME_CHANGE }, listener);
|
||||
ret = ImeEventMonitorManagerImpl::GetInstance().UnRegisterImeEventListener(EVENT_IME_CHANGE_MASK, listener);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodController::GetInstance()->clientInfo_.eventFlag, 6);
|
||||
EXPECT_EQ(ImeEventMonitorManagerImpl::GetInstance().listeners_.size(), 2);
|
||||
|
@ -140,7 +140,7 @@ private:
|
||||
TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, "ImeProxyTest"));
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_CHANGE, EventType::IME_HIDE, EventType::IME_SHOW }, listener);
|
||||
EVENT_IME_HIDE_MASK | EVENT_IME_SHOW_MASK | EVENT_IME_CHANGE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
}
|
||||
};
|
||||
|
@ -810,8 +810,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
InputWindowInfo info{ "", 0, 0, InputMethodPanelTest::windowWidth_, InputMethodPanelTest::windowHeight_ };
|
||||
@ -832,8 +832,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
InputMethodPanelTest::ImcPanelHideInfoCheck(info);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
}
|
||||
@ -849,8 +849,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
InputWindowInfo info{ "", 0, 0, InputMethodPanelTest::windowWidth_, InputMethodPanelTest::windowHeight_ };
|
||||
@ -872,8 +872,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
|
||||
InputMethodPanelTest::ImcPanelHideInfoCheck(info);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_FIXED;
|
||||
@ -890,8 +890,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_CANDIDATE_COLUMN;
|
||||
@ -910,8 +910,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(0);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_FIXED;
|
||||
@ -928,8 +928,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
@ -947,8 +947,8 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(0);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
}
|
||||
@ -966,11 +966,11 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_005, TestSize.Level0)
|
||||
auto listener1 = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
auto listener2 = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
auto listener3 = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener3);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener3);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
// set current ime
|
||||
@ -989,11 +989,11 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_005, TestSize.Level0)
|
||||
|
||||
// set native sa
|
||||
TddUtil::GrantNativePermission();
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener2);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener2);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener3);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener3);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
}
|
||||
@ -1011,11 +1011,11 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_006, TestSize.Level0)
|
||||
auto listener1 = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
auto listener2 = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
auto listener3 = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_HIDE }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener({ EventType::IME_SHOW }, listener3);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener3);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
// UnRegister one IME_SHOW listener
|
||||
@ -1036,9 +1036,9 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_006, TestSize.Level0)
|
||||
// UnRegister all listener
|
||||
// set native sa
|
||||
TddUtil::GrantNativePermission();
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener2);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_SHOW }, listener3);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener({ EventType::IME_HIDE }, listener1);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener3);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener1);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
@ -1067,8 +1067,7 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_007, TestSize.Level0)
|
||||
// set native sa
|
||||
TddUtil::GrantNativePermission();
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK | EVENT_IME_SHOW_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
@ -1089,7 +1088,7 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_007, TestSize.Level0)
|
||||
// set native sa
|
||||
TddUtil::GrantNativePermission();
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
|
||||
{ EventType::IME_SHOW, EventType::IME_HIDE }, listener);
|
||||
EVENT_IME_HIDE_MASK | EVENT_IME_SHOW_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
|
@ -86,7 +86,7 @@ void InputMethodSwitchTest::SetUpTestCase(void)
|
||||
TddUtil::AllocTestTokenID(true, "ohos.inputMethod.test", { "ohos.permission.CONNECT_IME_ABILITY" }));
|
||||
imc_ = InputMethodController::GetInstance();
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ EventType::IME_CHANGE }, listener);
|
||||
ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_CHANGE_MASK, listener);
|
||||
}
|
||||
|
||||
void InputMethodSwitchTest::TearDownTestCase(void)
|
||||
|
@ -79,7 +79,7 @@ void NewImeSwitchTest::SetUpTestCase(void)
|
||||
TddUtil::AllocTestTokenID(true, "ohos.inputMethod.test", { "ohos.permission.CONNECT_IME_ABILITY" }));
|
||||
imc_ = InputMethodController::GetInstance();
|
||||
auto listener = std::make_shared<ImeSettingListenerTestImpl>();
|
||||
ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener({ EventType::IME_CHANGE }, listener);
|
||||
ImeEventMonitorManagerImpl::GetInstance().RegisterImeEventListener(EVENT_IME_CHANGE_MASK, listener);
|
||||
}
|
||||
|
||||
void NewImeSwitchTest::TearDownTestCase(void)
|
||||
|
Loading…
Reference in New Issue
Block a user