From 700ca9a109dc8d8dc009e4f8dca23b03c5ba9216 Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 19 Nov 2024 20:04:55 +0800 Subject: [PATCH] code check add Signed-off-by: wangdongqi --- services/src/peruser_session.cpp | 8 +- .../include/ime_setting_listener_test_impl.h | 4 +- .../include/keyboard_listener_test_impl.h | 4 +- .../src/ime_setting_listener_test_impl.cpp | 38 ++-- .../src/input_method_engine_listener_impl.cpp | 39 +++- .../src/keyboard_listener_test_impl.cpp | 42 ++-- test/common/src/text_listener.cpp | 71 ++++--- .../agentstub_fuzzer/agentstub_fuzzer.cpp | 1 + .../controlchannelstub_fuzzer.cpp | 1 + .../corestub_fuzzer/corestub_fuzzer.cpp | 1 + .../datachannelstub_fuzzer.cpp | 1 + .../enableimedataparse_fuzzer.cpp | 4 +- .../inputmethodability_fuzzer.cpp | 16 +- .../inputmethodsystemability_fuzzer.cpp | 10 +- .../keyeventconsumer_fuzzer.cpp | 3 +- .../perusersession_fuzzer.cpp | 2 +- .../common/imf_sa_stub_fuzz_util.cpp | 4 +- .../displayoptionalinputmethod_fuzzer.cpp | 4 +- .../exitcurrentinputtype_fuzzer.cpp | 3 +- .../getcurrentinputmethodsubtype_fuzzer.cpp | 4 +- .../getdefaultinputmethod_fuzzer.cpp | 3 +- .../getinputmethodconfig_fuzzer.cpp | 3 +- .../showcurrentinputdeprecated_fuzzer.cpp | 4 +- .../startinputtype_fuzzer.cpp | 3 +- .../unregisteredproxyime_fuzzer.cpp | 3 +- .../common/include/identity_checker_mock.h | 12 +- .../cpp_test/common/include/scope_utils.h | 4 +- .../unittest/cpp_test/common/src/tdd_util.cpp | 7 +- .../cpp_test/mock/datashare_helper.cpp | 2 +- .../unittest/cpp_test/mock/datashare_helper.h | 2 +- .../cpp_test/mock/full_ime_info_manager.h | 4 +- .../cpp_test/mock/ime_info_inquirer.h | 6 +- .../cpp_test/src/block_queue_test.cpp | 20 +- .../src/enable_ime_data_parse_test.cpp | 8 +- .../src/full_ime_info_manager_test.cpp | 10 +- .../cpp_test/src/identity_checker_test.cpp | 102 ++++----- .../src/ime_event_monitor_manager_test.cpp | 178 ++++++++-------- .../cpp_test/src/ime_freeze_manager_test.cpp | 4 +- test/unittest/cpp_test/src/ime_proxy_test.cpp | 182 ++++++++-------- .../cpp_test/src/ime_system_channel_test.cpp | 8 +- .../input_method_ability_exception_test.cpp | 10 +- .../cpp_test/src/input_method_attach_test.cpp | 6 +- .../src/input_method_controller_test.cpp | 101 +++++---- .../cpp_test/src/input_method_dfx_test.cpp | 196 ++++++++++-------- .../cpp_test/src/input_method_editor_test.cpp | 23 +- .../src/input_method_ext_seccomp_test.cpp | 12 +- .../src/input_method_private_member_test.cpp | 164 ++++++++------- .../src/inputmethod_controller_capi_test.cpp | 2 +- .../cpp_test/src/itypes_util_test.cpp | 12 +- test/unittest/cpp_test/src/js_util_test.cpp | 2 +- .../cpp_test/src/newIme_switch_test.cpp | 138 ++++++------ .../src/security_mode_parser_test.cpp | 13 +- .../cpp_test/src/virtual_listener_test.cpp | 88 +++----- .../unittest/napi_test/src/InputMethodTest.js | 14 +- .../src/InputMethodWithAttachTest.js | 21 +- 55 files changed, 835 insertions(+), 792 deletions(-) diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index ede99731..173a65bb 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -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 &eventHandler) : userId_(userId), eventHandler_(eventHandler) @@ -64,9 +62,7 @@ PerUserSession::PerUserSession(int32_t userId, const std::shared_ptr inputClient, const InputClientInfo &clientInfo, ClientAddEvent event) diff --git a/test/common/include/ime_setting_listener_test_impl.h b/test/common/include/ime_setting_listener_test_impl.h index 3b88881e..0226325d 100644 --- a/test/common/include/ime_setting_listener_test_impl.h +++ b/test/common/include/ime_setting_listener_test_impl.h @@ -24,8 +24,8 @@ namespace OHOS { namespace MiscServices { class ImeSettingListenerTestImpl : public ImeEventListener { public: - ImeSettingListenerTestImpl(){}; - ~ImeSettingListenerTestImpl(){}; + ImeSettingListenerTestImpl() {}; + ~ImeSettingListenerTestImpl() {}; void OnImeChange(const Property &property, const SubProperty &subProperty) override; void OnImeShow(const ImeWindowInfo &info) override; void OnImeHide(const ImeWindowInfo &info) override; diff --git a/test/common/include/keyboard_listener_test_impl.h b/test/common/include/keyboard_listener_test_impl.h index a7a9432d..5538aa35 100644 --- a/test/common/include/keyboard_listener_test_impl.h +++ b/test/common/include/keyboard_listener_test_impl.h @@ -25,8 +25,8 @@ namespace OHOS { namespace MiscServices { class KeyboardListenerTestImpl : public KeyboardListener { public: - KeyboardListenerTestImpl(){}; - ~KeyboardListenerTestImpl(){}; + KeyboardListenerTestImpl() {}; + ~KeyboardListenerTestImpl() {}; bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr &consumer) override; bool OnKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) override { diff --git a/test/common/src/ime_setting_listener_test_impl.cpp b/test/common/src/ime_setting_listener_test_impl.cpp index f9a24efb..6293549c 100644 --- a/test/common/src/ime_setting_listener_test_impl.cpp +++ b/test/common/src/ime_setting_listener_test_impl.cpp @@ -21,12 +21,13 @@ namespace OHOS { namespace MiscServices { constexpr int32_t SWITCH_IME_WAIT_TIME = 3; constexpr int32_t TIMEOUT_SECONDS = 2; -InputWindowStatus ImeSettingListenerTestImpl::status_{ InputWindowStatus::NONE }; -SubProperty ImeSettingListenerTestImpl::subProperty_{}; -Property ImeSettingListenerTestImpl::property_{}; +InputWindowStatus ImeSettingListenerTestImpl::status_ { InputWindowStatus::NONE }; +SubProperty ImeSettingListenerTestImpl::subProperty_ {}; +Property ImeSettingListenerTestImpl::property_ {}; std::mutex ImeSettingListenerTestImpl::imeSettingListenerLock_; -bool ImeSettingListenerTestImpl::isImeChange_{ false }; +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 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 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 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 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 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 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 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 lock(imeSettingListenerLock_); diff --git a/test/common/src/input_method_engine_listener_impl.cpp b/test/common/src/input_method_engine_listener_impl.cpp index cdec5cc1..4e8333ac 100644 --- a/test/common/src/input_method_engine_listener_impl.cpp +++ b/test/common/src/input_method_engine_listener_impl.cpp @@ -25,46 +25,54 @@ bool InputMethodEngineListenerImpl::isInputStart_ = false; uint32_t InputMethodEngineListenerImpl::windowId_ = 0; std::mutex InputMethodEngineListenerImpl::imeListenerMutex_; std::condition_variable InputMethodEngineListenerImpl::imeListenerCv_; -bool InputMethodEngineListenerImpl::isEnable_{ false }; -bool InputMethodEngineListenerImpl::isInputFinish_{ false }; -std::unordered_map InputMethodEngineListenerImpl::privateCommand_{}; +bool InputMethodEngineListenerImpl::isEnable_ { false }; +bool InputMethodEngineListenerImpl::isInputFinish_ { false }; +std::unordered_map 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 &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 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 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 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 &privateCommand) { std::unique_lock 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 lock(imeListenerMutex_); @@ -119,6 +141,7 @@ bool InputMethodEngineListenerImpl::WaitKeyboardStatus(bool state) }); return keyboardState_ == state; } + bool InputMethodEngineListenerImpl::PostTaskToEventHandler(std::function task, const std::string &taskName) { if (eventHandler_ == nullptr) { diff --git a/test/common/src/keyboard_listener_test_impl.cpp b/test/common/src/keyboard_listener_test_impl.cpp index ed07701d..3fd73f88 100644 --- a/test/common/src/keyboard_listener_test_impl.cpp +++ b/test/common/src/keyboard_listener_test_impl.cpp @@ -21,11 +21,11 @@ namespace OHOS { namespace MiscServices { std::mutex KeyboardListenerTestImpl::kdListenerLock_; std::condition_variable KeyboardListenerTestImpl::kdListenerCv_; -int32_t KeyboardListenerTestImpl::keyCode_{ -1 }; -int32_t KeyboardListenerTestImpl::cursorHeight_{ -1 }; -int32_t KeyboardListenerTestImpl::newBegin_{ -1 }; +int32_t KeyboardListenerTestImpl::keyCode_ { -1 }; +int32_t KeyboardListenerTestImpl::cursorHeight_ { -1 }; +int32_t KeyboardListenerTestImpl::newBegin_ { -1 }; std::string KeyboardListenerTestImpl::text_; -InputAttribute KeyboardListenerTestImpl::inputAttribute_{ 0, 0, 0 }; +InputAttribute KeyboardListenerTestImpl::inputAttribute_ { 0, 0, 0 }; bool KeyboardListenerTestImpl::OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr &consumer) { keyCode_ = keyCode; @@ -35,8 +35,8 @@ bool KeyboardListenerTestImpl::OnKeyEvent(int32_t keyCode, int32_t keyStatus, sp return true; } -bool KeyboardListenerTestImpl::OnDealKeyEvent(const std::shared_ptr &keyEvent, - sptr &consumer) +bool KeyboardListenerTestImpl::OnDealKeyEvent( + const std::shared_ptr &keyEvent, sptr &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 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 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 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 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 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 diff --git a/test/common/src/text_listener.cpp b/test/common/src/text_listener.cpp index 15d49eb9..768cdc81 100644 --- a/test/common/src/text_listener.cpp +++ b/test/common/src/text_listener.cpp @@ -35,20 +35,18 @@ int32_t TextListener::selectionSkip_ = -1; int32_t TextListener::action_ = -1; uint32_t TextListener::height_ = 0; KeyboardStatus TextListener::keyboardStatus_ = { KeyboardStatus::NONE }; -PanelStatusInfo TextListener::info_{}; -std::unordered_map TextListener::privateCommand_{}; +PanelStatusInfo TextListener::info_ {}; +std::unordered_map TextListener::privateCommand_ {}; std::string TextListener::previewText_; -Range TextListener::previewRange_{}; -bool TextListener::isFinishTextPreviewCalled_{ false }; +Range TextListener::previewRange_ {}; +bool TextListener::isFinishTextPreviewCalled_ { false }; TextListener::TextListener() { std::shared_ptr runner = AppExecFwk::EventRunner::Create("TextListenerNotifier"); serviceHandler_ = std::make_shared(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 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 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 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 &privateCommand) { std::unique_lock 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 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 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 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 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 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 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 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 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 diff --git a/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp b/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp index 11e2ae7a..c7a5f4aa 100644 --- a/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp +++ b/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp @@ -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); diff --git a/test/fuzztest/controlchannelstub_fuzzer/controlchannelstub_fuzzer.cpp b/test/fuzztest/controlchannelstub_fuzzer/controlchannelstub_fuzzer.cpp index 934d3660..862a1a5b 100644 --- a/test/fuzztest/controlchannelstub_fuzzer/controlchannelstub_fuzzer.cpp +++ b/test/fuzztest/controlchannelstub_fuzzer/controlchannelstub_fuzzer.cpp @@ -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; diff --git a/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp b/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp index b0c7a2d1..0af8dd42 100644 --- a/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp +++ b/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp @@ -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); diff --git a/test/fuzztest/datachannelstub_fuzzer/datachannelstub_fuzzer.cpp b/test/fuzztest/datachannelstub_fuzzer/datachannelstub_fuzzer.cpp index 416b9b9e..34ab7f73 100644 --- a/test/fuzztest/datachannelstub_fuzzer/datachannelstub_fuzzer.cpp +++ b/test/fuzztest/datachannelstub_fuzzer/datachannelstub_fuzzer.cpp @@ -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); diff --git a/test/fuzztest/enableimedataparse_fuzzer/enableimedataparse_fuzzer.cpp b/test/fuzztest/enableimedataparse_fuzzer/enableimedataparse_fuzzer.cpp index 12867b52..fcc066ef 100644 --- a/test/fuzztest/enableimedataparse_fuzzer/enableimedataparse_fuzzer.cpp +++ b/test/fuzztest/enableimedataparse_fuzzer/enableimedataparse_fuzzer.cpp @@ -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); } diff --git a/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp b/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp index be04239e..0b89b053 100644 --- a/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp +++ b/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp @@ -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) diff --git a/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp b/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp index 1ee8cefe..c5c1b859 100644 --- a/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp +++ b/test/fuzztest/inputmethodsystemability_fuzzer/inputmethodsystemability_fuzzer.cpp @@ -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" @@ -41,7 +41,7 @@ constexpr const int32_t MSG_ID_USER_ONE = 50; constexpr const int32_t MSG_ID_USER_TWO = 60; void FuzzOnUser(int32_t userId, const std::string &packageName) { - //onUserStarted + // onUserStarted MessageParcel *parcel = new MessageParcel(); DelayedSingleton::GetInstance()->isScbEnable_ = false; DelayedSingleton::GetInstance()->userId_ = MSG_ID_USER_ONE; @@ -49,13 +49,13 @@ void FuzzOnUser(int32_t userId, const std::string &packageName) auto msg = std::make_shared(MessageID::MSG_ID_USER_START, parcel); DelayedSingleton::GetInstance()->OnUserStarted(msg.get()); - //onUserRemoved + // onUserRemoved MessageParcel *parcel1 = new MessageParcel(); parcel1->WriteInt32(MSG_ID_USER_TWO); auto msg1 = std::make_shared(MessageID::MSG_ID_USER_REMOVED, parcel1); DelayedSingleton::GetInstance()->OnUserRemoved(msg1.get()); - //HandlePackageEvent + // HandlePackageEvent MessageParcel *parcel2 = new (std::nothrow) MessageParcel(); auto bundleName = "testBundleName1"; DelayedSingleton::GetInstance()->userId_ = MSG_ID_USER_TWO; @@ -64,7 +64,7 @@ void FuzzOnUser(int32_t userId, const std::string &packageName) auto msg2 = std::make_shared(MessageID::MSG_ID_PACKAGE_REMOVED, parcel2); DelayedSingleton::GetInstance()->HandlePackageEvent(msg2.get()); - //OnPackageRemoved + // OnPackageRemoved DelayedSingleton::GetInstance()->userId_ = userId; DelayedSingleton::GetInstance()->OnPackageRemoved(userId, bundleName); } diff --git a/test/fuzztest/keyeventconsumer_fuzzer/keyeventconsumer_fuzzer.cpp b/test/fuzztest/keyeventconsumer_fuzzer/keyeventconsumer_fuzzer.cpp index 804610e0..da038dc0 100644 --- a/test/fuzztest/keyeventconsumer_fuzzer/keyeventconsumer_fuzzer.cpp +++ b/test/fuzztest/keyeventconsumer_fuzzer/keyeventconsumer_fuzzer.cpp @@ -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(rawData[0] % 2); @@ -48,7 +49,7 @@ bool FuzzKeyEventConsumerStub(const uint8_t *rawData, size_t size) MessageParcel reply; MessageOption option; - std::shared_ptr keyEvent = MMI::KeyEvent::Create(); + std::shared_ptr keyEvent = MMI::KeyEvent::Create(); sptr stub = new KeyEventConsumerStub( [](std::shared_ptr &keyEvent, bool isConsumed) {}, keyEvent); diff --git a/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp b/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp index b9322ac8..c5dc34f0 100644 --- a/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp +++ b/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp @@ -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 { diff --git a/test/fuzztest/systemabilitystubfuzztest/common/imf_sa_stub_fuzz_util.cpp b/test/fuzztest/systemabilitystubfuzztest/common/imf_sa_stub_fuzz_util.cpp index 2bd8c2bc..b759cb61 100644 --- a/test/fuzztest/systemabilitystubfuzztest/common/imf_sa_stub_fuzz_util.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/common/imf_sa_stub_fuzz_util.cpp @@ -69,8 +69,8 @@ bool ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(const uint8_t *rawData, siz datas.RewindRead(0); MessageParcel reply; MessageOption option; - DelayedSingleton::GetInstance()->OnRemoteRequest(static_cast(code), datas, - reply, option); + DelayedSingleton::GetInstance()->OnRemoteRequest( + static_cast(code), datas, reply, option); return true; } diff --git a/test/fuzztest/systemabilitystubfuzztest/displayoptionalinputmethod_fuzzer/displayoptionalinputmethod_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/displayoptionalinputmethod_fuzzer/displayoptionalinputmethod_fuzzer.cpp index 816e3554..4626e06e 100644 --- a/test/fuzztest/systemabilitystubfuzztest/displayoptionalinputmethod_fuzzer/displayoptionalinputmethod_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/displayoptionalinputmethod_fuzzer/displayoptionalinputmethod_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/exitcurrentinputtype_fuzzer/exitcurrentinputtype_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/exitcurrentinputtype_fuzzer/exitcurrentinputtype_fuzzer.cpp index 8862ca6c..e936aa6e 100644 --- a/test/fuzztest/systemabilitystubfuzztest/exitcurrentinputtype_fuzzer/exitcurrentinputtype_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/exitcurrentinputtype_fuzzer/exitcurrentinputtype_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/getcurrentinputmethodsubtype_fuzzer/getcurrentinputmethodsubtype_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/getcurrentinputmethodsubtype_fuzzer/getcurrentinputmethodsubtype_fuzzer.cpp index 6edcada3..78f6c747 100644 --- a/test/fuzztest/systemabilitystubfuzztest/getcurrentinputmethodsubtype_fuzzer/getcurrentinputmethodsubtype_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/getcurrentinputmethodsubtype_fuzzer/getcurrentinputmethodsubtype_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/getdefaultinputmethod_fuzzer/getdefaultinputmethod_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/getdefaultinputmethod_fuzzer/getdefaultinputmethod_fuzzer.cpp index 43c8243b..8ff21303 100644 --- a/test/fuzztest/systemabilitystubfuzztest/getdefaultinputmethod_fuzzer/getdefaultinputmethod_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/getdefaultinputmethod_fuzzer/getdefaultinputmethod_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/getinputmethodconfig_fuzzer/getinputmethodconfig_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/getinputmethodconfig_fuzzer/getinputmethodconfig_fuzzer.cpp index 305746b3..d138dde5 100644 --- a/test/fuzztest/systemabilitystubfuzztest/getinputmethodconfig_fuzzer/getinputmethodconfig_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/getinputmethodconfig_fuzzer/getinputmethodconfig_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/showcurrentinputdeprecated_fuzzer/showcurrentinputdeprecated_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/showcurrentinputdeprecated_fuzzer/showcurrentinputdeprecated_fuzzer.cpp index 738a4501..97f03a3c 100644 --- a/test/fuzztest/systemabilitystubfuzztest/showcurrentinputdeprecated_fuzzer/showcurrentinputdeprecated_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/showcurrentinputdeprecated_fuzzer/showcurrentinputdeprecated_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/startinputtype_fuzzer/startinputtype_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/startinputtype_fuzzer/startinputtype_fuzzer.cpp index 0deeb3c2..8cbd837e 100644 --- a/test/fuzztest/systemabilitystubfuzztest/startinputtype_fuzzer/startinputtype_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/startinputtype_fuzzer/startinputtype_fuzzer.cpp @@ -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; } diff --git a/test/fuzztest/systemabilitystubfuzztest/unregisteredproxyime_fuzzer/unregisteredproxyime_fuzzer.cpp b/test/fuzztest/systemabilitystubfuzztest/unregisteredproxyime_fuzzer/unregisteredproxyime_fuzzer.cpp index 99f238b4..9ab2dd06 100644 --- a/test/fuzztest/systemabilitystubfuzztest/unregisteredproxyime_fuzzer/unregisteredproxyime_fuzzer.cpp +++ b/test/fuzztest/systemabilitystubfuzztest/unregisteredproxyime_fuzzer/unregisteredproxyime_fuzzer.cpp @@ -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; } diff --git a/test/unittest/cpp_test/common/include/identity_checker_mock.h b/test/unittest/cpp_test/common/include/identity_checker_mock.h index e16a8f1a..304f97c4 100644 --- a/test/unittest/cpp_test/common/include/identity_checker_mock.h +++ b/test/unittest/cpp_test/common/include/identity_checker_mock.h @@ -101,12 +101,12 @@ private: static bool isNativeSa_; static std::string bundleName_; }; -bool IdentityCheckerMock::isFocused_{ false }; -bool IdentityCheckerMock::isSystemApp_{ false }; -bool IdentityCheckerMock::isBundleNameValid_{ false }; -bool IdentityCheckerMock::hasPermission_{ false }; -bool IdentityCheckerMock::isBroker_{ false }; -bool IdentityCheckerMock::isNativeSa_{ false }; +bool IdentityCheckerMock::isFocused_ { false }; +bool IdentityCheckerMock::isSystemApp_ { false }; +bool IdentityCheckerMock::isBundleNameValid_ { false }; +bool IdentityCheckerMock::hasPermission_ { false }; +bool IdentityCheckerMock::isBroker_ { false }; +bool IdentityCheckerMock::isNativeSa_ { false }; std::string IdentityCheckerMock::bundleName_; } // namespace MiscServices } // namespace OHOS diff --git a/test/unittest/cpp_test/common/include/scope_utils.h b/test/unittest/cpp_test/common/include/scope_utils.h index dfdeb6cd..7b9ad9e8 100644 --- a/test/unittest/cpp_test/common/include/scope_utils.h +++ b/test/unittest/cpp_test/common/include/scope_utils.h @@ -44,7 +44,7 @@ public: } private: - uint64_t originalTokenId_{ 0 }; + uint64_t originalTokenId_ { 0 }; }; class TokenScope { @@ -62,7 +62,7 @@ public: } private: - uint64_t originalTokenId_{ 0 }; + uint64_t originalTokenId_ { 0 }; }; class UidScope { diff --git a/test/unittest/cpp_test/common/src/tdd_util.cpp b/test/unittest/cpp_test/common/src/tdd_util.cpp index 5a85aac3..0780046b 100644 --- a/test/unittest/cpp_test/common/src/tdd_util.cpp +++ b/test/unittest/cpp_test/common/src/tdd_util.cpp @@ -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"; diff --git a/test/unittest/cpp_test/mock/datashare_helper.cpp b/test/unittest/cpp_test/mock/datashare_helper.cpp index 57dcc123..08ff8a67 100644 --- a/test/unittest/cpp_test/mock/datashare_helper.cpp +++ b/test/unittest/cpp_test/mock/datashare_helper.cpp @@ -90,7 +90,7 @@ int DataShareHelper::Update(Uri &uri, const DataSharePredicates &predicates, con { return 0; } - + int DataShareHelper::Insert(Uri &uri, const DataShareValuesBucket &value) { return 0; diff --git a/test/unittest/cpp_test/mock/datashare_helper.h b/test/unittest/cpp_test/mock/datashare_helper.h index b2c6be70..4dc8dde3 100644 --- a/test/unittest/cpp_test/mock/datashare_helper.h +++ b/test/unittest/cpp_test/mock/datashare_helper.h @@ -31,7 +31,7 @@ class DataSharePredicates { public: DataSharePredicates *EqualTo(const std::string &field, const std::string &value); }; -class DatashareBusinessError {}; +class DatashareBusinessError { }; class DataShareResultSet { public: DataShareResultSet() = default; diff --git a/test/unittest/cpp_test/mock/full_ime_info_manager.h b/test/unittest/cpp_test/mock/full_ime_info_manager.h index 25d56a7f..e6cfb9c3 100644 --- a/test/unittest/cpp_test/mock/full_ime_info_manager.h +++ b/test/unittest/cpp_test/mock/full_ime_info_manager.h @@ -45,8 +45,8 @@ private: ~FullImeInfoManager(); std::mutex lock_; std::map> fullImeInfos_; - Utils::Timer timer_{ "imeInfoCacheInitTimer" }; - uint32_t timerId_{ 0 }; + Utils::Timer timer_ { "imeInfoCacheInitTimer" }; + uint32_t timerId_ { 0 }; }; } // namespace MiscServices } // namespace OHOS diff --git a/test/unittest/cpp_test/mock/ime_info_inquirer.h b/test/unittest/cpp_test/mock/ime_info_inquirer.h index a2560615..f637086a 100644 --- a/test/unittest/cpp_test/mock/ime_info_inquirer.h +++ b/test/unittest/cpp_test/mock/ime_info_inquirer.h @@ -45,11 +45,11 @@ private: static std::shared_ptr defaultIme_; static std::shared_ptr currentIme_; static std::shared_ptr defaultImeProperty_; - bool isQueryAllFullImeInfosOk_{ false }; + bool isQueryAllFullImeInfosOk_ { false }; std::vector>> allFullImeInfos_; - bool isQueryFullImeInfosOk_{ false }; + bool isQueryFullImeInfosOk_ { false }; std::vector fullImeInfos_; - bool isGetFullImeInfoOk_{ false }; + bool isGetFullImeInfoOk_ { false }; FullImeInfo fullImeInfo_; }; } // namespace MiscServices diff --git a/test/unittest/cpp_test/src/block_queue_test.cpp b/test/unittest/cpp_test/src/block_queue_test.cpp index 3a277bc7..0339736b 100644 --- a/test/unittest/cpp_test/src/block_queue_test.cpp +++ b/test/unittest/cpp_test/src/block_queue_test.cpp @@ -45,23 +45,15 @@ public: private: static BlockQueue timeQueue_; }; -BlockQueue ImfBlockQueueTest::timeQueue_{ MAX_WAIT_TIME }; -bool ImfBlockQueueTest::timeout_{ false }; -void ImfBlockQueueTest::SetUpTestCase(void) -{ -} +BlockQueue ImfBlockQueueTest::timeQueue_ { MAX_WAIT_TIME }; +bool ImfBlockQueueTest::timeout_ { false }; +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() { diff --git a/test/unittest/cpp_test/src/enable_ime_data_parse_test.cpp b/test/unittest/cpp_test/src/enable_ime_data_parse_test.cpp index 46073a52..15413d5d 100644 --- a/test/unittest/cpp_test/src/enable_ime_data_parse_test.cpp +++ b/test/unittest/cpp_test/src/enable_ime_data_parse_test.cpp @@ -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 diff --git a/test/unittest/cpp_test/src/full_ime_info_manager_test.cpp b/test/unittest/cpp_test/src/full_ime_info_manager_test.cpp index e10c93ac..adce2a6e 100644 --- a/test/unittest/cpp_test/src/full_ime_info_manager_test.cpp +++ b/test/unittest/cpp_test/src/full_ime_info_manager_test.cpp @@ -87,7 +87,7 @@ HWTEST_F(FullImeInfoManagerTest, test_Init_002, TestSize.Level0) uint32_t tokenId = 2; std::string appId = "appId"; uint32_t versionCode = 11; - Property prop{ "bundleName" }; + Property prop { "bundleName" }; std::vector imeInfos; imeInfos.push_back({ isNewIme, tokenId, appId, versionCode, prop }); std::vector>> fullImeInfos; @@ -153,12 +153,12 @@ HWTEST_F(FullImeInfoManagerTest, test_Add_003, TestSize.Level0) uint32_t tokenId = 2; std::string appId = "appId"; uint32_t versionCode = 11; - Property prop{ "bundleName" }; - FullImeInfo imeInfo{ isNewIme, tokenId, appId, versionCode, prop }; + Property prop { "bundleName" }; + FullImeInfo imeInfo { isNewIme, tokenId, appId, versionCode, prop }; uint32_t tokenId1 = 2; std::string appId1 = "appId1"; - Property prop1{ "bundleName1" }; - FullImeInfo imeInfo1{ isNewIme, tokenId1, appId1, versionCode, prop1 }; + Property prop1 { "bundleName1" }; + FullImeInfo imeInfo1 { isNewIme, tokenId1, appId1, versionCode, prop1 }; imeInfos.push_back(imeInfo); imeInfos.push_back(imeInfo1); ImeInfoInquirer::GetInstance().SetFullImeInfo(true, imeInfos); diff --git a/test/unittest/cpp_test/src/identity_checker_test.cpp b/test/unittest/cpp_test/src/identity_checker_test.cpp index c901f888..dcd356c1 100644 --- a/test/unittest/cpp_test/src/identity_checker_test.cpp +++ b/test/unittest/cpp_test/src/identity_checker_test.cpp @@ -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(); } @@ -134,7 +136,7 @@ std::shared_ptr IdentityCheckerTest::identityCheckerImpl_; * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStartInput_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStartInput_001 start"); @@ -151,7 +153,7 @@ HWTEST_F(IdentityCheckerTest, testStartInput_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStartInput_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStartInput_002 start"); @@ -169,7 +171,7 @@ HWTEST_F(IdentityCheckerTest, testStartInput_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStartInput_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStartInput_003 start"); @@ -187,7 +189,7 @@ HWTEST_F(IdentityCheckerTest, testStartInput_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStartInput_004, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStartInput_004 start"); @@ -205,7 +207,7 @@ HWTEST_F(IdentityCheckerTest, testStartInput_004, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInput_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInput_001 start"); @@ -220,7 +222,7 @@ HWTEST_F(IdentityCheckerTest, testStopInput_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInput_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInput_002 start"); @@ -236,13 +238,13 @@ HWTEST_F(IdentityCheckerTest, testStopInput_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInput_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInput_003 start"); IdentityCheckerTest::IdentityCheckerMock::isBroker_ = true; IdentityCheckerTest::IdentityCheckerMock::isFocused_ = true; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->HideInput(nullptr); EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER); } @@ -253,13 +255,13 @@ HWTEST_F(IdentityCheckerTest, testStopInput_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInput_004, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInput_004 start"); IdentityCheckerTest::IdentityCheckerMock::isBroker_ = false; IdentityCheckerTest::IdentityCheckerMock::isFocused_ = true; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->HideInput(nullptr); EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER); } @@ -270,7 +272,7 @@ HWTEST_F(IdentityCheckerTest, testStopInput_004, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInputSession_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInputSession_001 start"); @@ -285,7 +287,7 @@ HWTEST_F(IdentityCheckerTest, testStopInputSession_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInputSession_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInputSession_002 start"); @@ -301,13 +303,13 @@ HWTEST_F(IdentityCheckerTest, testStopInputSession_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInputSession_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInputSession_003 start"); IdentityCheckerTest::IdentityCheckerMock::isBroker_ = true; IdentityCheckerTest::IdentityCheckerMock::isFocused_ = true; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->StopInputSession(); EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NOT_FOUND); } @@ -318,13 +320,13 @@ HWTEST_F(IdentityCheckerTest, testStopInputSession_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testStopInputSession_004, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testStopInputSession_004 start"); IdentityCheckerTest::IdentityCheckerMock::isBroker_ = false; IdentityCheckerTest::IdentityCheckerMock::isFocused_ = true; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->StopInputSession(); EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NOT_FOUND); } @@ -335,7 +337,7 @@ HWTEST_F(IdentityCheckerTest, testStopInputSession_004, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testSetCoreAndAgent_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testSetCoreAndAgent_001 start"); @@ -350,7 +352,7 @@ HWTEST_F(IdentityCheckerTest, testSetCoreAndAgent_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testSetCoreAndAgent_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testSetCoreAndAgent_002 start"); @@ -365,7 +367,7 @@ HWTEST_F(IdentityCheckerTest, testSetCoreAndAgent_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testSetCoreAndAgent_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testSetCoreAndAgent_003 start"); @@ -381,7 +383,7 @@ HWTEST_F(IdentityCheckerTest, testSetCoreAndAgent_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testUnRegisteredProxyIme_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testUnRegisteredProxyIme_001 start"); @@ -396,7 +398,7 @@ HWTEST_F(IdentityCheckerTest, testUnRegisteredProxyIme_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testUnRegisteredProxyIme_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testUnRegisteredProxyIme_002 start"); @@ -411,7 +413,7 @@ HWTEST_F(IdentityCheckerTest, testUnRegisteredProxyIme_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testIsCurrentIme_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testIsCurrentIme_001 start"); @@ -426,7 +428,7 @@ HWTEST_F(IdentityCheckerTest, testIsCurrentIme_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testIsCurrentIme_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testIsCurrentIme_002 start"); @@ -441,7 +443,7 @@ HWTEST_F(IdentityCheckerTest, testIsCurrentIme_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testHideCurrentInput_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testHideCurrentInput_001 start"); @@ -456,7 +458,7 @@ HWTEST_F(IdentityCheckerTest, testHideCurrentInput_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testHideCurrentInput_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testHideCurrentInput_002 start"); @@ -472,7 +474,7 @@ HWTEST_F(IdentityCheckerTest, testHideCurrentInput_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testHideCurrentInput_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testHideCurrentInput_003 start"); @@ -489,7 +491,7 @@ HWTEST_F(IdentityCheckerTest, testHideCurrentInput_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testShowCurrentInput_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testShowCurrentInput_001 start"); @@ -504,7 +506,7 @@ HWTEST_F(IdentityCheckerTest, testShowCurrentInput_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testShowCurrentInput_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testShowCurrentInput_002 start"); @@ -520,7 +522,7 @@ HWTEST_F(IdentityCheckerTest, testShowCurrentInput_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testShowCurrentInput_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testShowCurrentInput_003 start"); @@ -537,13 +539,13 @@ HWTEST_F(IdentityCheckerTest, testShowCurrentInput_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testPanelStatusChange_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testPanelStatusChange_001 start"); service_->identityChecker_ = identityCheckerImpl_; InputWindowStatus status = InputWindowStatus::SHOW; - ImeWindowInfo info{}; + ImeWindowInfo info {}; int32_t ret = IdentityCheckerTest::service_->PanelStatusChange(status, info); EXPECT_EQ(ret, ErrorCode::ERROR_NOT_CURRENT_IME); } @@ -554,13 +556,13 @@ HWTEST_F(IdentityCheckerTest, testPanelStatusChange_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testPanelStatusChange_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testPanelStatusChange_002 start"); IdentityCheckerTest::IdentityCheckerMock::isBundleNameValid_ = true; InputWindowStatus status = InputWindowStatus::SHOW; - ImeWindowInfo info{}; + ImeWindowInfo info {}; int32_t ret = IdentityCheckerTest::service_->PanelStatusChange(status, info); EXPECT_EQ(ret, ErrorCode::ERROR_NOT_CURRENT_IME); } @@ -571,12 +573,12 @@ HWTEST_F(IdentityCheckerTest, testPanelStatusChange_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testUpdateListenEventFlag_001 start"); service_->identityChecker_ = identityCheckerImpl_; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_SHOW_MASK); EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION); @@ -593,13 +595,13 @@ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testUpdateListenEventFlag_002 start"); IdentityCheckerTest::IdentityCheckerMock::isSystemApp_ = true; IdentityCheckerTest::IdentityCheckerMock::isNativeSa_ = false; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_SHOW_MASK); EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER); @@ -616,13 +618,13 @@ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testUpdateListenEventFlag_003 start"); IdentityCheckerTest::IdentityCheckerMock::isSystemApp_ = false; IdentityCheckerTest::IdentityCheckerMock::isNativeSa_ = true; - InputClientInfo clientInfo{}; + InputClientInfo clientInfo {}; int32_t ret = IdentityCheckerTest::service_->UpdateListenEventFlag(clientInfo, EVENT_IME_SHOW_MASK); EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER); @@ -639,7 +641,7 @@ HWTEST_F(IdentityCheckerTest, testUpdateListenEventFlag_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testDisplayOptionalInputMethod_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testDisplayOptionalInputMethod_001 start"); @@ -654,7 +656,7 @@ HWTEST_F(IdentityCheckerTest, testDisplayOptionalInputMethod_001, TestSize.Level * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testSwitchInputMethod_001 start"); @@ -670,7 +672,7 @@ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testSwitchInputMethod_002 start"); @@ -687,7 +689,7 @@ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_002, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testSwitchInputMethod_003 start"); @@ -704,7 +706,7 @@ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_003, TestSize.Level0) * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testHideCurrentInputDeprecated_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testHideCurrentInputDeprecated_001 start"); @@ -719,7 +721,7 @@ HWTEST_F(IdentityCheckerTest, testHideCurrentInputDeprecated_001, TestSize.Level * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testHideCurrentInputDeprecated_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testHideCurrentInputDeprecated_002 start"); @@ -735,7 +737,7 @@ HWTEST_F(IdentityCheckerTest, testHideCurrentInputDeprecated_002, TestSize.Level * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testHideCurrentInputDeprecated_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testHideCurrentInputDeprecated_003 start"); @@ -751,7 +753,7 @@ HWTEST_F(IdentityCheckerTest, testHideCurrentInputDeprecated_003, TestSize.Level * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testShowCurrentInputDeprecated_001, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testShowCurrentInputDeprecated_001 start"); @@ -766,7 +768,7 @@ HWTEST_F(IdentityCheckerTest, testShowCurrentInputDeprecated_001, TestSize.Level * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testShowCurrentInputDeprecated_002, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testShowCurrentInputDeprecated_002 start"); @@ -782,7 +784,7 @@ HWTEST_F(IdentityCheckerTest, testShowCurrentInputDeprecated_002, TestSize.Level * @tc.type: FUNC * @tc.require: * @tc.author: -*/ + */ HWTEST_F(IdentityCheckerTest, testShowCurrentInputDeprecated_003, TestSize.Level0) { IMSA_HILOGI("IdentityCheckerTest testShowCurrentInputDeprecated_003 start"); diff --git a/test/unittest/cpp_test/src/ime_event_monitor_manager_test.cpp b/test/unittest/cpp_test/src/ime_event_monitor_manager_test.cpp index 15145671..7ad39558 100644 --- a/test/unittest/cpp_test/src/ime_event_monitor_manager_test.cpp +++ b/test/unittest/cpp_test/src/ime_event_monitor_manager_test.cpp @@ -64,10 +64,10 @@ void ImeEventMonitorManagerTest::TearDown() } /** -* @tc.name: testRegisterImeEventListener_001 -* @tc.desc: eventType is 0 -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_001 + * @tc.desc: eventType is 0 + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_001, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_001 start."); @@ -78,10 +78,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_001, TestSize. } /** -* @tc.name: testUnRegisterImeEventListener_002 -* @tc.desc: eventFlag is 0 -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_002 + * @tc.desc: eventFlag is 0 + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_002, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_002 start."); @@ -92,10 +92,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_002, TestSiz } /** -* @tc.name: testRegisterImeEventListener_003 -* @tc.desc: eventFlag is 15 -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_003 + * @tc.desc: eventFlag is 15 + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_003, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_003 start."); @@ -110,10 +110,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_003, TestSize. } /** -* @tc.name: testRegisterImeEventListener_004 -* @tc.desc: eventFlag is 5 -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_004 + * @tc.desc: eventFlag is 5 + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_004, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_004 start."); @@ -127,10 +127,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_004, TestSize. } /** -* @tc.name: testRegisterImeEventListener_005 -* @tc.desc: listener is nullptr -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_005 + * @tc.desc: listener is nullptr + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_005, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_005 start."); @@ -140,10 +140,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_005, TestSize. } /** -* @tc.name: testUnRegisterImeEventListener_006 -* @tc.desc: listener is nullptr -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_006 + * @tc.desc: listener is nullptr + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_006, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_006 start."); @@ -153,10 +153,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_006, TestSiz } /** -* @tc.name: testRegisterImeEventListener_007 -* @tc.desc: UpdateListenEventFlag filed -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_007 + * @tc.desc: UpdateListenEventFlag filed + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_007, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_007 start."); @@ -168,10 +168,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_007, TestSize. } /** -* @tc.name: testUnRegisterImeEventListener_008 -* @tc.desc: one listener register one event, unregister with UpdateListenEventFlag filed -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_008 + * @tc.desc: one listener register one event, unregister with UpdateListenEventFlag filed + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_008, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_008 start."); @@ -188,10 +188,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_008, TestSiz } /** -* @tc.name: testRegisterImeEventListener_009 -* @tc.desc: one listener register one event -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_009 + * @tc.desc: one listener register one event + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_009, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_009 start."); @@ -208,10 +208,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_009, TestSize. } /** -* @tc.name: testRegisterImeEventListener_010 -* @tc.desc: one listener register EVENT_IME_HIDE_MASK|EVENT_IME_SHOW_MASK -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_010 + * @tc.desc: one listener register EVENT_IME_HIDE_MASK|EVENT_IME_SHOW_MASK + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_010, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_010 start."); @@ -235,10 +235,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_010, TestSize. } /** -* @tc.name: testRegisterImeEventListener_011 -* @tc.desc: one listener register EVENT_IME_SHOW_MASK|EVENT_IME_HIDE_MASK|EVENT_IME_CHANGE_MASK -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_011 + * @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) { IMSA_HILOGI("testRegisterImeEventListener_011 start."); @@ -253,10 +253,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_011, TestSize. } /** -* @tc.name: testRegisterImeEventListener_012 -* @tc.desc: two listener register same event -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_012 + * @tc.desc: two listener register same event + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_012, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_012 start."); @@ -287,10 +287,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_012, TestSize. } /** -* @tc.name: testRegisterImeEventListener_013 -* @tc.desc: two listener register not same event -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_013 + * @tc.desc: two listener register not same event + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_013, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_013 start."); @@ -319,10 +319,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_013, TestSize. } /** -* @tc.name: testUnRegisterImeEventListener_014 -* @tc.desc: one listener register one event, unregister -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_014 + * @tc.desc: one listener register one event, unregister + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_014, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_014 start."); @@ -338,10 +338,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_014, TestSiz } /** -* @tc.name: testUnRegisterImeEventListener_015 -* @tc.desc: one listener register all events, unregister one events -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_015 + * @tc.desc: one listener register all events, unregister one events + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_015, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_015 start."); @@ -358,10 +358,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_015, TestSiz } /** -* @tc.name: testUnRegisterImeEventListener_016 -* @tc.desc: one listener register all events, unregister all events -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_016 + * @tc.desc: one listener register all events, unregister all events + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_016, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_016 start."); @@ -379,10 +379,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_016, TestSiz } /** -* @tc.name: testUnRegisterImeEventListener_017 -* @tc.desc: two listener register same event, unregister one listener -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_017 + * @tc.desc: two listener register same event, unregister one listener + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_017, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_017 start."); @@ -406,10 +406,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_017, TestSiz } /** -* @tc.name: testUnRegisterImeEventListener_018 -* @tc.desc: two listener register same event, unregister one listener with error event -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_018 + * @tc.desc: two listener register same event, unregister one listener with error event + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_018, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_018 start."); @@ -434,10 +434,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_018, TestSiz EXPECT_NE(iter, it->second.end()); } /** -* @tc.name: testUnRegisterImeEventListener_019 -* @tc.desc: two listener register same event, unregister one listener with error listener -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_019 + * @tc.desc: two listener register same event, unregister one listener with error listener + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_019, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_019 start."); @@ -464,11 +464,11 @@ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_019, TestSiz } /** -* @tc.name: testInputStatusChangedListener -* @tc.desc: register and unregister EVENT_INPUT_STATUS_CHANGED_MASK, -* there is no effect on EVENT_IME_SHOW_MASK and EVENT_HIDE_SHOW_MASK -* @tc.type: FUNC -*/ + * @tc.name: testInputStatusChangedListener + * @tc.desc: register and unregister EVENT_INPUT_STATUS_CHANGED_MASK, + * there is no effect on EVENT_IME_SHOW_MASK and EVENT_HIDE_SHOW_MASK + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testInputStatusChangedListener, TestSize.Level0) { IMSA_HILOGI("testInputStatusChangedListener start."); @@ -510,10 +510,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testInputStatusChangedListener, TestSize.Le /********************************* all test is for innerkit above ***************************************************/ /** -* @tc.name: testRegisterImeEventListener_020 -* @tc.desc: two listener, one is innerkit(register all event), one is js(register one event) -* @tc.type: FUNC -*/ + * @tc.name: testRegisterImeEventListener_020 + * @tc.desc: two listener, one is innerkit(register all event), one is js(register one event) + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_020, TestSize.Level0) { IMSA_HILOGI("testRegisterImeEventListener_020 start."); @@ -529,10 +529,10 @@ HWTEST_F(ImeEventMonitorManagerTest, testRegisterImeEventListener_020, TestSize. } /** -* @tc.name: testUnRegisterImeEventListener_021 -* @tc.desc: two listener, one is innerkit(register all event), one is js(register all event), js unregister IME_CHANGE -* @tc.type: FUNC -*/ + * @tc.name: testUnRegisterImeEventListener_021 + * @tc.desc: two listener, one is innerkit(register all event), one is js(register all event), js unregister IME_CHANGE + * @tc.type: FUNC + */ HWTEST_F(ImeEventMonitorManagerTest, testUnRegisterImeEventListener_021, TestSize.Level0) { IMSA_HILOGI("testUnRegisterImeEventListener_021 start."); diff --git a/test/unittest/cpp_test/src/ime_freeze_manager_test.cpp b/test/unittest/cpp_test/src/ime_freeze_manager_test.cpp index 605e33e9..5c84f0e9 100644 --- a/test/unittest/cpp_test/src/ime_freeze_manager_test.cpp +++ b/test/unittest/cpp_test/src/ime_freeze_manager_test.cpp @@ -174,9 +174,9 @@ private: EXPECT_EQ(freezeManager_->isFrozen_, freezable); } }; -std::shared_ptr ImeFreezeManagerTest::freezeManager_{ nullptr }; +std::shared_ptr ImeFreezeManagerTest::freezeManager_ { nullptr }; std::mutex ImeFreezeManagerTest::mtx_; -std::shared_ptr ImeFreezeManagerTest::eventHandler_{ nullptr }; +std::shared_ptr ImeFreezeManagerTest::eventHandler_ { nullptr }; /** * @tc.name: SingleThread_StartInput_001 diff --git a/test/unittest/cpp_test/src/ime_proxy_test.cpp b/test/unittest/cpp_test/src/ime_proxy_test.cpp index 0199b2b7..2de397a4 100644 --- a/test/unittest/cpp_test/src/ime_proxy_test.cpp +++ b/test/unittest/cpp_test/src/ime_proxy_test.cpp @@ -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"); } @@ -160,10 +162,10 @@ private: sptr ImeProxyTest::imc_; /** -* @tc.name: RegisteredProxyNotInEditor_001 -* @tc.desc: not in editor -* @tc.type: FUNC -*/ + * @tc.name: RegisteredProxyNotInEditor_001 + * @tc.desc: not in editor + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, RegisteredProxyNotInEditor_001, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::RegisteredProxyNotInEditor_001"); @@ -178,10 +180,10 @@ HWTEST_F(ImeProxyTest, RegisteredProxyNotInEditor_001, TestSize.Level0) } /** -* @tc.name: AttachInPcAfterRegisteredProxyNotInEditor_002 -* @tc.desc: not in editor -* @tc.type: FUNC -*/ + * @tc.name: AttachInPcAfterRegisteredProxyNotInEditor_002 + * @tc.desc: not in editor + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, AttachInPcAfterRegisteredProxyNotInEditor_002, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::AttachInPcAfterRegisteredProxyNotInEditor_002"); @@ -204,10 +206,10 @@ HWTEST_F(ImeProxyTest, AttachInPcAfterRegisteredProxyNotInEditor_002, TestSize.L } /** -* @tc.name: AttachInPeAfterRegisteredProxyNotInEditor_003 -* @tc.desc: not in editor -* @tc.type: FUNC -*/ + * @tc.name: AttachInPeAfterRegisteredProxyNotInEditor_003 + * @tc.desc: not in editor + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, AttachInPeAfterRegisteredProxyNotInEditor_003, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::AttachInPeAfterRegisteredProxyNotInEditor_003"); @@ -230,10 +232,10 @@ HWTEST_F(ImeProxyTest, AttachInPeAfterRegisteredProxyNotInEditor_003, TestSize.L } /** -* @tc.name: RegisteredProxyInImaEditor_004 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: RegisteredProxyInImaEditor_004 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, RegisteredProxyInImaEditor_004, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::RegisteredProxyInImaEditor_004"); @@ -260,10 +262,10 @@ HWTEST_F(ImeProxyTest, RegisteredProxyInImaEditor_004, TestSize.Level0) } /** -* @tc.name: UnRegisteredAndRegisteredProxyInProxyBind_005 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredAndRegisteredProxyInProxyBind_005 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredAndRegisteredProxyInProxyBind_005, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredAndRegisteredProxyInProxyBind_005"); @@ -297,10 +299,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredAndRegisteredProxyInProxyBind_005, TestSize.L } /** -* @tc.name: UnRegisteredProxyNotInBind_stop_006 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredProxyNotInBind_stop_006 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredProxyNotInBind_stop_006, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredProxyNotInBind_stop_006"); @@ -314,10 +316,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredProxyNotInBind_stop_006, TestSize.Level0) } /** -* @tc.name: UnRegisteredProxyInProxyBind_stop_007 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredProxyInProxyBind_stop_007 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredProxyInProxyBind_stop_007, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredProxyInProxyBind_stop_007"); @@ -344,10 +346,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredProxyInProxyBind_stop_007, TestSize.Level0) } /** -* @tc.name: UnRegisteredProxyInImaBind_stop_008 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredProxyInImaBind_stop_008 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredProxyInImaBind_stop_008, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredProxyInImaBind_stop_008"); @@ -373,10 +375,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredProxyInImaBind_stop_008, TestSize.Level0) } /** -* @tc.name: UnRegisteredProxyNotInBind_switch_009 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredProxyNotInBind_switch_009 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredProxyNotInBind_switch_009, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredProxyNotInBind_switch_009"); @@ -388,10 +390,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredProxyNotInBind_switch_009, TestSize.Level0) } /** -* @tc.name: UnRegisteredProxyInProxyBind_switch_010 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredProxyInProxyBind_switch_010 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredProxyInProxyBind_switch_010, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredProxyInProxyBind_switch_010"); @@ -417,10 +419,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredProxyInProxyBind_switch_010, TestSize.Level0) } /** -* @tc.name: UnRegisteredProxyWithErrorType_011 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: UnRegisteredProxyWithErrorType_011 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, UnRegisteredProxyWithErrorType_011, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::UnRegisteredProxyWithErrorType_011"); @@ -432,10 +434,10 @@ HWTEST_F(ImeProxyTest, UnRegisteredProxyWithErrorType_011, TestSize.Level0) } /** -* @tc.name: AppUnFocusInProxyBindInPe_012 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: AppUnFocusInProxyBindInPe_012 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, AppUnFocusInProxyBindInPe_012, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::AppUnFocusInProxyBindInPe_012"); @@ -460,10 +462,10 @@ HWTEST_F(ImeProxyTest, AppUnFocusInProxyBindInPe_012, TestSize.Level0) } /** -* @tc.name: AppUnFocusInProxyBindInPc_013 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: AppUnFocusInProxyBindInPc_013 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, AppUnFocusInProxyBindInPc_013, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::AppUnFocusInProxyBindInPc_013"); @@ -488,10 +490,10 @@ HWTEST_F(ImeProxyTest, AppUnFocusInProxyBindInPc_013, TestSize.Level0) } /** -* @tc.name: ProxyAndImaSwitchTest_014 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: ProxyAndImaSwitchTest_014 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, ProxyAndImaSwitchTest_014, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::ProxyAndImaSwitchTest_014"); @@ -527,10 +529,10 @@ HWTEST_F(ImeProxyTest, ProxyAndImaSwitchTest_014, TestSize.Level0) } /** -* @tc.name: KeyboardListenerTest_015 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: KeyboardListenerTest_015 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, KeyboardListenerTest_015, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::KeyboardListenerTest_015"); @@ -544,10 +546,10 @@ HWTEST_F(ImeProxyTest, KeyboardListenerTest_015, TestSize.Level0) } /** -* @tc.name: TextEditTest -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: TextEditTest + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, TextEditTest, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::TextEditTest"); @@ -579,10 +581,10 @@ HWTEST_F(ImeProxyTest, TextEditTest, TestSize.Level0) } /** -* @tc.name: ClientDiedInImaBind_016 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: ClientDiedInImaBind_016 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, ClientDiedInImaBind_016, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::ClientDiedInImaBind_016"); @@ -599,10 +601,10 @@ HWTEST_F(ImeProxyTest, ClientDiedInImaBind_016, TestSize.Level0) } /** -* @tc.name: ClientDiedInProxyBind_017 -* @tc.desc: -* @tc.type: FUNC -*/ + * @tc.name: ClientDiedInProxyBind_017 + * @tc.desc: + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, ClientDiedInProxyBind_017, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::ClientDiedInProxyBind_017"); @@ -624,10 +626,10 @@ HWTEST_F(ImeProxyTest, ClientDiedInProxyBind_017, TestSize.Level0) } /** -* @tc.name: onInputFinishTest_StopInput -* @tc.desc: close -* @tc.type: FUNC -*/ + * @tc.name: onInputFinishTest_StopInput + * @tc.desc: close + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, onInputFinishTest_StopInput, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::onInputFinishTest_StopInput"); @@ -635,10 +637,10 @@ HWTEST_F(ImeProxyTest, onInputFinishTest_StopInput, TestSize.Level0) EXPECT_TRUE(InputMethodEngineListenerImpl::WaitInputFinish()); } /** -* @tc.name: onInputFinishTest_OnClientInactive -* @tc.desc: OnClientInactive -* @tc.type: FUNC -*/ + * @tc.name: onInputFinishTest_OnClientInactive + * @tc.desc: OnClientInactive + * @tc.type: FUNC + */ HWTEST_F(ImeProxyTest, onInputFinishTest_OnClientInactive, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest::onInputFinishTest_OnClientInactive"); @@ -647,11 +649,11 @@ HWTEST_F(ImeProxyTest, onInputFinishTest_OnClientInactive, TestSize.Level0) } /** -* @tc.name: testIsFromTs -* @tc.desc: ImeProxyTest testIsFromTs -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: testIsFromTs + * @tc.desc: ImeProxyTest testIsFromTs + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(ImeProxyTest, testIsFromTs, TestSize.Level0) { IMSA_HILOGI("ImeProxyTest testIsFromTs Test START"); diff --git a/test/unittest/cpp_test/src/ime_system_channel_test.cpp b/test/unittest/cpp_test/src/ime_system_channel_test.cpp index 7357e1f8..b1660a0e 100644 --- a/test/unittest/cpp_test/src/ime_system_channel_test.cpp +++ b/test/unittest/cpp_test/src/ime_system_channel_test.cpp @@ -26,12 +26,8 @@ using namespace testing::ext; namespace OHOS { namespace MiscServices { class OnSystemCmdListenerImpl : public OnSystemCmdListener { - void ReceivePrivateCommand(const std::unordered_map &privateCommand) override - { - } - void NotifyPanelStatus(const SysPanelStatus &sysPanelStatus) override - { - } + void ReceivePrivateCommand(const std::unordered_map &privateCommand) override { } + void NotifyPanelStatus(const SysPanelStatus &sysPanelStatus) override { } }; class ImeSystemChannelTest : public testing::Test { public: diff --git a/test/unittest/cpp_test/src/input_method_ability_exception_test.cpp b/test/unittest/cpp_test/src/input_method_ability_exception_test.cpp index 7d021437..14fa96cd 100644 --- a/test/unittest/cpp_test/src/input_method_ability_exception_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ability_exception_test.cpp @@ -39,12 +39,8 @@ public: { IMSA_HILOGI("InputMethodAbilityExceptionTest::TearDownTestCase"); } - void SetUp() - { - } - void TearDown() - { - } + void SetUp() { } + void TearDown() { } static void ResetMemberVar() { inputMethodAbility_->dataChannelProxy_ = nullptr; @@ -133,7 +129,7 @@ HWTEST_F(InputMethodAbilityExceptionTest, testSelectByRangeException, TestSize.L end = 2; ret = inputMethodAbility_->SelectByRange(start, end); EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED); - //end < 0, start > 0 + // end < 0, start > 0 start = 1; end = -2; ret = inputMethodAbility_->SelectByRange(start, end); diff --git a/test/unittest/cpp_test/src/input_method_attach_test.cpp b/test/unittest/cpp_test/src/input_method_attach_test.cpp index 89f692b8..0a47a7d8 100644 --- a/test/unittest/cpp_test/src/input_method_attach_test.cpp +++ b/test/unittest/cpp_test/src/input_method_attach_test.cpp @@ -51,7 +51,7 @@ public: static constexpr int32_t MAX_WAIT_TIME = 5000; static bool timeout_; static std::shared_ptr textConfigHandler_; - + static void SetUpTestCase(void) { IMSA_HILOGI("InputMethodAttachTest::SetUpTestCase"); @@ -122,8 +122,8 @@ sptr InputMethodAttachTest::inputMethodController_; sptr InputMethodAttachTest::inputMethodAbility_; sptr InputMethodAttachTest::imsaProxy_; sptr InputMethodAttachTest::imsa_; -bool InputMethodAttachTest::timeout_{ false }; -std::shared_ptr InputMethodAttachTest::textConfigHandler_{ nullptr }; +bool InputMethodAttachTest::timeout_ { false }; +std::shared_ptr InputMethodAttachTest::textConfigHandler_ { nullptr }; /** * @tc.name: testAttach001 diff --git a/test/unittest/cpp_test/src/input_method_controller_test.cpp b/test/unittest/cpp_test/src/input_method_controller_test.cpp index 421771f2..9996505a 100644 --- a/test/unittest/cpp_test/src/input_method_controller_test.cpp +++ b/test/unittest/cpp_test/src/input_method_controller_test.cpp @@ -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 { @@ -164,7 +164,7 @@ public: "st"); textConfigHandler_ = std::make_shared(runner); }; - ~KeyboardListenerImpl(){}; + ~KeyboardListenerImpl() {}; bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr &consumer) override { if (!doesKeyEventConsume_) { @@ -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; @@ -252,18 +252,18 @@ std::condition_variable InputMethodControllerTest::keyboardListenerCv_; sptr InputMethodControllerTest::deathRecipient_; std::mutex InputMethodControllerTest::onRemoteSaDiedMutex_; std::condition_variable InputMethodControllerTest::onRemoteSaDiedCv_; -BlockData> InputMethodControllerTest::blockKeyEvent_{ +BlockData> InputMethodControllerTest::blockKeyEvent_ { InputMethodControllerTest::KEY_EVENT_DELAY_TIME, nullptr }; -BlockData> InputMethodControllerTest::blockFullKeyEvent_{ +BlockData> InputMethodControllerTest::blockFullKeyEvent_ { InputMethodControllerTest::KEY_EVENT_DELAY_TIME, nullptr }; -bool InputMethodControllerTest::doesKeyEventConsume_{ false }; -bool InputMethodControllerTest::doesFUllKeyEventConsume_{ false }; +bool InputMethodControllerTest::doesKeyEventConsume_ { false }; +bool InputMethodControllerTest::doesFUllKeyEventConsume_ { false }; std::condition_variable InputMethodControllerTest::keyEventCv_; std::mutex InputMethodControllerTest::keyEventLock_; -bool InputMethodControllerTest::consumeResult_{ false }; -std::shared_ptr InputMethodControllerTest::textConfigHandler_{ nullptr }; +bool InputMethodControllerTest::consumeResult_ { false }; +std::shared_ptr InputMethodControllerTest::textConfigHandler_ { nullptr }; void InputMethodControllerTest::SetUpTestCase(void) { @@ -347,7 +347,9 @@ void InputMethodControllerTest::SetInputDeathRecipient() IMSA_HILOGE("InputMethodControllerTest, new death recipient failed"); return; } - deathRecipient_->SetDeathRecipient([](const wptr &remote) { OnRemoteSaDied(remote); }); + deathRecipient_->SetDeathRecipient([](const wptr &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 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 lock(InputMethodControllerTest::keyboardListenerMutex_); InputMethodControllerTest::keyboardListenerCv_.wait_for( lock, std::chrono::seconds(InputMethodControllerTest::DELAY_TIME), [&info] { return (static_cast( - InputMethodControllerTest::inputAttribute_.inputPattern) - == info.GetTextInputType()) - && (static_cast( - InputMethodControllerTest::inputAttribute_.enterKeyType) - == info.GetEnterKeyType()); + InputMethodControllerTest::inputAttribute_.inputPattern) == info.GetTextInputType()) && + (static_cast( + 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 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 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 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(EnterKeyType::UNSPECIFIED) - && keyType <= static_cast(EnterKeyType::PREVIOUS)); + EXPECT_TRUE(keyType >= static_cast(EnterKeyType::UNSPECIFIED) && + keyType <= static_cast(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(TextInputType::NONE) - && inputPattern <= static_cast(TextInputType::VISIBLE_PASSWORD)); + EXPECT_TRUE(inputPattern >= static_cast(TextInputType::NONE) && + inputPattern <= static_cast(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 privateCommand1{ { "v", - string(PRIVATE_COMMAND_SIZE_MAX - 2, 'a') } }; - std::unordered_map privateCommand2{ { "v", - string(PRIVATE_COMMAND_SIZE_MAX - 1, 'a') } }; - std::unordered_map privateCommand3{ { "v", - string(PRIVATE_COMMAND_SIZE_MAX, 'a') } }; + std::unordered_map privateCommand1 { + { "v", string(PRIVATE_COMMAND_SIZE_MAX - 2, 'a') } + }; + std::unordered_map privateCommand2 { + { "v", string(PRIVATE_COMMAND_SIZE_MAX - 1, 'a') } + }; + std::unordered_map privateCommand3 { + { "v", string(PRIVATE_COMMAND_SIZE_MAX, 'a') } + }; ret = inputMethodController_->SendPrivateCommand(privateCommand1); EXPECT_EQ(ret, ErrorCode::NO_ERROR); ret = inputMethodController_->SendPrivateCommand(privateCommand2); @@ -1588,7 +1603,7 @@ HWTEST_F(InputMethodControllerTest, testOnInputReady, TestSize.Level0) EXPECT_FALSE(TextListener::isFinishTextPreviewCalled_); } - /** +/** * @tc.name: testIsPanelShown * @tc.desc: IMC testIsPanelShown * @tc.type: IMC diff --git a/test/unittest/cpp_test/src/input_method_dfx_test.cpp b/test/unittest/cpp_test/src/input_method_dfx_test.cpp index 4242a969..9c199509 100644 --- a/test/unittest/cpp_test/src/input_method_dfx_test.cpp +++ b/test/unittest/cpp_test/src/input_method_dfx_test.cpp @@ -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 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 sysEvent) final { if (sysEvent == nullptr) { @@ -253,12 +247,12 @@ void InputMethodDfxTest::TearDown(void) } /** -* @tc.name: InputMethodDfxTest_DumpAllMethod_001 -* @tc.desc: DumpAllMethod -* @tc.type: FUNC -* @tc.require: issueI61PMG -* @tc.author: chenyu -*/ + * @tc.name: InputMethodDfxTest_DumpAllMethod_001 + * @tc.desc: DumpAllMethod + * @tc.type: FUNC + * @tc.require: issueI61PMG + * @tc.author: chenyu + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_DumpAllMethod_001, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_DumpAllMethod_001"); @@ -270,12 +264,12 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_DumpAllMethod_001, TestSize.Leve } /** -* @tc.name: InputMethodDfxTest_Dump_ShowHelp_001 -* @tc.desc: Dump ShowHelp. -* @tc.type: FUNC -* @tc.require: issueI61PMG -* @tc.author: chenyu -*/ + * @tc.name: InputMethodDfxTest_Dump_ShowHelp_001 + * @tc.desc: Dump ShowHelp. + * @tc.type: FUNC + * @tc.require: issueI61PMG + * @tc.author: chenyu + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ShowHelp_001, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Dump_ShowHelp_001"); @@ -288,12 +282,12 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ShowHelp_001, TestSize.Leve } /** -* @tc.name: InputMethodDfxTest_Dump_ShowIllealInformation_001 -* @tc.desc: Dump ShowIllealInformation. -* @tc.type: FUNC -* @tc.require: issueI61PMG -* @tc.author: chenyu -*/ + * @tc.name: InputMethodDfxTest_Dump_ShowIllealInformation_001 + * @tc.desc: Dump ShowIllealInformation. + * @tc.type: FUNC + * @tc.require: issueI61PMG + * @tc.author: chenyu + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ShowIllealInformation_001, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Dump_ShowIllealInformation_001"); @@ -304,24 +298,26 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ShowIllealInformation_001, } /** -* @tc.name: InputMethodDfxTest_Hisysevent_Attach -* @tc.desc: Hisysevent attach. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_Attach + * @tc.desc: Hisysevent attach. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Attach, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Attach"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_SHOW_ATTACH))); - auto attach = []() { inputMethodController_->Attach(textListener_, true); }; + auto attach = []() { + inputMethodController_->Attach(textListener_, true); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, attach)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_HideTextInput -* @tc.desc: Hisysevent HideTextInput. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_HideTextInput + * @tc.desc: Hisysevent HideTextInput. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideTextInput, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideTextInput"); @@ -329,113 +325,129 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideTextInput, TestSi EXPECT_EQ(ret, ErrorCode::NO_ERROR); auto watcher = std::make_shared(InputMethodSysEvent::GetInstance().GetOperateInfo( static_cast(OperateIMEInfoCode::IME_HIDE_UNEDITABLE))); - auto hideTextInput = []() { inputMethodController_->HideTextInput(); }; + auto hideTextInput = []() { + inputMethodController_->HideTextInput(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideTextInput)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_ShowTextInput -* @tc.desc: Hisysevent ShowTextInput. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_ShowTextInput + * @tc.desc: Hisysevent ShowTextInput. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowTextInput, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowTextInput"); auto watcher = std::make_shared(InputMethodSysEvent::GetInstance().GetOperateInfo( static_cast(OperateIMEInfoCode::IME_SHOW_ENEDITABLE))); - auto showTextInput = []() { inputMethodController_->ShowTextInput(); }; + auto showTextInput = []() { + inputMethodController_->ShowTextInput(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showTextInput)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_HideCurrentInput -* @tc.desc: Hisysevent HideCurrentInput. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_HideCurrentInput + * @tc.desc: Hisysevent HideCurrentInput. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideCurrentInput, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideCurrentInput"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_HIDE_NORMAL))); - auto hideCurrentInput = []() { inputMethodController_->HideCurrentInput(); }; + auto hideCurrentInput = []() { + inputMethodController_->HideCurrentInput(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideCurrentInput)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_ShowCurrentInput -* @tc.desc: Hisysevent ShowCurrentInput. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_ShowCurrentInput + * @tc.desc: Hisysevent ShowCurrentInput. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowCurrentInput, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowCurrentInput"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_SHOW_NORMAL))); - auto showCurrentInput = []() { inputMethodController_->ShowCurrentInput(); }; + auto showCurrentInput = []() { + inputMethodController_->ShowCurrentInput(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showCurrentInput)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_HideSoftKeyboard -* @tc.desc: Hisysevent HideSoftKeyboard. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_HideSoftKeyboard + * @tc.desc: Hisysevent HideSoftKeyboard. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideSoftKeyboard, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideSoftKeyboard"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_HIDE_NORMAL))); - auto hideSoftKeyboard = []() { inputMethodController_->HideSoftKeyboard(); }; + auto hideSoftKeyboard = []() { + inputMethodController_->HideSoftKeyboard(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideSoftKeyboard)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_ShowSoftKeyboard -* @tc.desc: Hisysevent ShowSoftKeyboard. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_ShowSoftKeyboard + * @tc.desc: Hisysevent ShowSoftKeyboard. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowSoftKeyboard, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowSoftKeyboard"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_SHOW_NORMAL))); - auto showSoftKeyboard = []() { inputMethodController_->ShowSoftKeyboard(); }; + auto showSoftKeyboard = []() { + inputMethodController_->ShowSoftKeyboard(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showSoftKeyboard)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_HideKeyboardSelf -* @tc.desc: Hisysevent HideKeyboardSelf. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_HideKeyboardSelf + * @tc.desc: Hisysevent HideKeyboardSelf. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideKeyboardSelf, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideKeyboardSelf"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_HIDE_SELF))); - auto hideKeyboardSelf = []() { inputMethodAbility_->HideKeyboardSelf(); }; + auto hideKeyboardSelf = []() { + inputMethodAbility_->HideKeyboardSelf(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideKeyboardSelf)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_Close -* @tc.desc: Hisysevent Close. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_Close + * @tc.desc: Hisysevent Close. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Close, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Close"); auto watcher = std::make_shared( InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast(OperateIMEInfoCode::IME_UNBIND))); - auto close = []() { inputMethodController_->Close(); }; + auto close = []() { + inputMethodController_->Close(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, close)); } /** -* @tc.name: InputMethodDfxTest_Hisysevent_UnBind -* @tc.desc: Hisysevent UnBind. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_UnBind + * @tc.desc: Hisysevent UnBind. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_UnBind, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_UnBind"); @@ -449,41 +461,43 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_UnBind, TestSize.Leve } /** -* @tc.name: InputMethodDfxTest_Hisysevent_Bind -* @tc.desc: Hisysevent Bind. -* @tc.type: FUNC -*/ + * @tc.name: InputMethodDfxTest_Hisysevent_Bind + * @tc.desc: Hisysevent Bind. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Bind, TestSize.Level0) { IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Bind"); auto watcherImeChange = std::make_shared(std::to_string(static_cast(ImeState::BIND)), std::to_string(static_cast(getpid())), TddUtil::currentBundleNameMock_); - auto imeStateBind = []() { inputMethodController_->RequestShowInput(); }; + auto imeStateBind = []() { + inputMethodController_->RequestShowInput(); + }; EXPECT_TRUE(InputMethodDfxTest::WriteAndWatchImeChange(watcherImeChange, imeStateBind)); } /** -* @tc.name: InputMethod_Dump_HELP -* @tc.desc: InputMethodDump. -* @tc.type: FUNC -*/ + * @tc.name: InputMethod_Dump_HELP + * @tc.desc: InputMethodDump. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_HELP, TestSize.Level0) { IMSA_HILOGI("InputMethodDump::InputMethod_Dump_HELP"); - std::vector args = {"-h"}; + std::vector args = { "-h" }; int fd = 1; EXPECT_TRUE(InputmethodDump::GetInstance().Dump(fd, args)); } /** -* @tc.name: InputMethod_Dump_ALL -* @tc.desc: InputMethodDump. -* @tc.type: FUNC -*/ + * @tc.name: InputMethod_Dump_ALL + * @tc.desc: InputMethodDump. + * @tc.type: FUNC + */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ALL, TestSize.Level0) { IMSA_HILOGI("InputMethodDump::InputMethod_Dump_ALL"); - std::vector args = {"-a"}; + std::vector args = { "-a" }; int fd = 1; EXPECT_FALSE(!InputmethodDump::GetInstance().Dump(fd, args)); } diff --git a/test/unittest/cpp_test/src/input_method_editor_test.cpp b/test/unittest/cpp_test/src/input_method_editor_test.cpp index 133d709c..a34c53a5 100644 --- a/test/unittest/cpp_test/src/input_method_editor_test.cpp +++ b/test/unittest/cpp_test/src/input_method_editor_test.cpp @@ -54,13 +54,12 @@ namespace OHOS { namespace MiscServices { class KeyboardListenerImpl : public KeyboardListener { public: - KeyboardListenerImpl(){}; - ~KeyboardListenerImpl(){}; + KeyboardListenerImpl() {}; + ~KeyboardListenerImpl() {}; static int32_t keyCode_; static int32_t keyStatus_; static CursorInfo cursorInfo_; - bool OnDealKeyEvent( - const std::shared_ptr &keyEvent, sptr &consumer) override; + bool OnDealKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) override; bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr &consumer) override; bool OnKeyEvent(const std::shared_ptr &keyEvent, sptr &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(positionX), static_cast(positionY), 0, static_cast(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 &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); diff --git a/test/unittest/cpp_test/src/input_method_ext_seccomp_test.cpp b/test/unittest/cpp_test/src/input_method_ext_seccomp_test.cpp index d8066665..f34cbc61 100644 --- a/test/unittest/cpp_test/src/input_method_ext_seccomp_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ext_seccomp_test.cpp @@ -44,10 +44,10 @@ namespace OHOS { namespace MiscServices { class SeccompUnitTest : public testing::Test { public: - SeccompUnitTest(){}; - virtual ~SeccompUnitTest(){}; - static void SetUpTestCase(){}; - static void TearDownTestCase(){}; + SeccompUnitTest() {}; + virtual ~SeccompUnitTest() {}; + static void SetUpTestCase() {}; + static void TearDownTestCase() {}; void SetUp() { @@ -59,8 +59,8 @@ public: sleep(SLEEP_TIME_1S); }; - void TearDown(){}; - void TestBody(void){}; + void TearDown() {}; + void TestBody(void) {}; static pid_t StartChild(SeccompFilterType type, const char *filterName, SyscallFunc func) { diff --git a/test/unittest/cpp_test/src/input_method_private_member_test.cpp b/test/unittest/cpp_test/src/input_method_private_member_test.cpp index 13d965f9..f8ee889d 100644 --- a/test/unittest/cpp_test/src/input_method_private_member_test.cpp +++ b/test/unittest/cpp_test/src/input_method_private_member_test.cpp @@ -30,6 +30,8 @@ #include #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 { @@ -92,11 +92,11 @@ void InputMethodPrivateMemberTest::TearDown(void) sptr InputMethodPrivateMemberTest::service_; /** -* @tc.name: SA_TestOnStart -* @tc.desc: SA OnStart. -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: SA_TestOnStart + * @tc.desc: SA OnStart. + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(InputMethodPrivateMemberTest, SA_TestOnStart, TestSize.Level0) { InputMethodSystemAbility ability; @@ -106,18 +106,23 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_TestOnStart, TestSize.Level0) } /** -* @tc.name: SA_GetExtends -* @tc.desc: SA GetExtends. -* @tc.type: FUNC -* @tc.require: issuesI640YZ -*/ + * @tc.name: SA_GetExtends + * @tc.desc: SA GetExtends. + * @tc.type: FUNC + * @tc.require: issuesI640YZ + */ HWTEST_F(InputMethodPrivateMemberTest, SA_GetExtends, TestSize.Level0) { constexpr int32_t metaDataNums = 5; ImeInfoInquirer inquirer; std::vector 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); } @@ -129,11 +134,11 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_GetExtends, TestSize.Level0) } /** -* @tc.name: SA_TestOnUserStarted -* @tc.desc: SA_TestOnUserStarted. -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: SA_TestOnUserStarted + * @tc.desc: SA_TestOnUserStarted. + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(InputMethodPrivateMemberTest, SA_TestOnUserStarted, TestSize.Level0) { // isScbEnable_ is true @@ -179,11 +184,11 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_TestOnUserStarted, TestSize.Level0) } /** -* @tc.name: SA_TestOnUserRemoved -* @tc.desc: SA_TestOnUserRemoved. -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: SA_TestOnUserRemoved + * @tc.desc: SA_TestOnUserRemoved. + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(InputMethodPrivateMemberTest, SA_TestOnUserRemoved, TestSize.Level0) { // msg is nullptr @@ -201,11 +206,11 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_TestOnUserRemoved, TestSize.Level0) } /** -* @tc.name: SA_ListInputMethodInfoWithInexistentUserId -* @tc.desc: SA ListInputMethodInfo With Inexistent UserId. -* @tc.type: FUNC -* @tc.require: issuesI669E8 -*/ + * @tc.name: SA_ListInputMethodInfoWithInexistentUserId + * @tc.desc: SA ListInputMethodInfo With Inexistent UserId. + * @tc.type: FUNC + * @tc.require: issuesI669E8 + */ HWTEST_F(InputMethodPrivateMemberTest, SA_ListInputMethodInfoWithInexistentUserId, TestSize.Level0) { ImeInfoInquirer inquirer; @@ -215,11 +220,11 @@ HWTEST_F(InputMethodPrivateMemberTest, SA_ListInputMethodInfoWithInexistentUserI } /** -* @tc.name: IMC_ListInputMethodCommonWithErrorStatus -* @tc.desc: IMC ListInputMethodCommon With Error Status. -* @tc.type: FUNC -* @tc.require: issuesI669E8 -*/ + * @tc.name: IMC_ListInputMethodCommonWithErrorStatus + * @tc.desc: IMC ListInputMethodCommon With Error Status. + * @tc.type: FUNC + * @tc.require: issuesI669E8 + */ HWTEST_F(InputMethodPrivateMemberTest, IMC_ListInputMethodCommonWithErrorStatus, TestSize.Level0) { std::vector props; @@ -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); @@ -554,7 +568,7 @@ HWTEST_F(InputMethodPrivateMemberTest, III_TestGetCurrentSubtype_001, TestSize.L auto currentSubProp = InputMethodController::GetInstance()->GetCurrentInputMethodSubtype(); ImeCfgManager::GetInstance().imeConfigs_.clear(); ImeCfgManager::GetInstance().imeConfigs_.push_back( - { currentUserId, currentProp->name + "/" + currentProp->id, currentSubProp->id, false}); + { currentUserId, currentProp->name + "/" + currentProp->id, currentSubProp->id, false }); subProp = ImeInfoInquirer::GetInstance().GetCurrentSubtype(currentUserId); ASSERT_TRUE(subProp != nullptr); EXPECT_TRUE(subProp->id == currentSubProp->id); @@ -578,7 +592,7 @@ HWTEST_F(InputMethodPrivateMemberTest, III_TestGetCurrentIme_001, TestSize.Level // get correct prop auto currentProp = InputMethodController::GetInstance()->GetCurrentInputMethod(); ImeCfgManager::GetInstance().imeConfigs_.push_back( - { currentUserId, currentProp->name + "/" + currentProp->id, currentProp->id, false}); + { currentUserId, currentProp->name + "/" + currentProp->id, currentProp->id, false }); prop = ImeInfoInquirer::GetInstance().GetCurrentInputMethod(currentUserId); ASSERT_TRUE(prop != nullptr); EXPECT_TRUE(prop->id == currentProp->id); @@ -659,7 +673,7 @@ HWTEST_F(InputMethodPrivateMemberTest, III_TestIsNewExtInfos_001, TestSize.Level HWTEST_F(InputMethodPrivateMemberTest, ICM_TestDeleteImeCfg_001, TestSize.Level0) { IMSA_HILOGI("InputMethodPrivateMemberTest ICM_TestDeleteImeCfg_001 TEST START"); - ImeCfgManager::GetInstance().imeConfigs_.push_back({ 100, "testBundleName", "testSubName", false}); + ImeCfgManager::GetInstance().imeConfigs_.push_back({ 100, "testBundleName", "testSubName", false }); ImeCfgManager::GetInstance().DeleteImeCfg(100); EXPECT_TRUE(ImeCfgManager::GetInstance().imeConfigs_.empty()); } @@ -809,15 +823,15 @@ HWTEST_F(InputMethodPrivateMemberTest, TestIsInputMethod, TestSize.Level0) EXPECT_EQ(ret, ErrorCode::NO_ERROR); } - /** - @tc.name: TestHandlePackageEvent - @tc.desc: TestHandlePackageEvent - @tc.type: FUNC - @tc.require: - */ +/** +@tc.name: TestHandlePackageEvent +@tc.desc: TestHandlePackageEvent +@tc.type: FUNC +@tc.require: +*/ HWTEST_F(InputMethodPrivateMemberTest, TestHandlePackageEvent, TestSize.Level0) { -// msg is nullptr + // msg is nullptr auto *msg = new Message(MessageID::MSG_ID_PACKAGE_REMOVED, nullptr); auto ret = service_->HandlePackageEvent(msg); EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER); @@ -841,7 +855,7 @@ HWTEST_F(InputMethodPrivateMemberTest, TestHandlePackageEvent, TestSize.Level0) auto ret2 = service_->HandlePackageEvent(msg2.get()); EXPECT_EQ(ret2, ErrorCode::NO_ERROR); - //remove bundle not current ime + // remove bundle not current ime auto parcel3 = new (std::nothrow) MessageParcel(); service_->userId_ = userId; ImeCfgManager::GetInstance().imeConfigs_.push_back({ 60, "testBundleName/testExtName", "testSubName", false }); @@ -937,11 +951,11 @@ HWTEST_F(InputMethodPrivateMemberTest, TestOnSecurityChange, TestSize.Level0) } /** -* @tc.name: TestServiceStartInputType -* @tc.desc: Test ServiceStartInputType -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: TestServiceStartInputType + * @tc.desc: Test ServiceStartInputType + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(InputMethodPrivateMemberTest, TestServiceStartInputType, TestSize.Level0) { auto ret = service_->ExitCurrentInputType(); @@ -955,11 +969,11 @@ HWTEST_F(InputMethodPrivateMemberTest, TestServiceStartInputType, TestSize.Level } /** -* @tc.name: TestIsSupported -* @tc.desc: Test IsSupported -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: TestIsSupported + * @tc.desc: Test IsSupported + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(InputMethodPrivateMemberTest, TestIsSupported, TestSize.Level0) { auto ret = InputTypeManager::GetInstance().IsSupported(InputType::NONE); @@ -967,11 +981,11 @@ HWTEST_F(InputMethodPrivateMemberTest, TestIsSupported, TestSize.Level0) } /** -* @tc.name: TestGetImeByInputType -* @tc.desc: Test GetImeByInputType -* @tc.type: FUNC -* @tc.require: -*/ + * @tc.name: TestGetImeByInputType + * @tc.desc: Test GetImeByInputType + * @tc.type: FUNC + * @tc.require: + */ HWTEST_F(InputMethodPrivateMemberTest, TestGetImeByInputType, TestSize.Level0) { ImeIdentification ime; @@ -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 focusChangeInfo = new Rosen::FocusChangeInfo();; + const sptr focusChangeInfo = new Rosen::FocusChangeInfo(); FocusHandle handle = nullptr; FocusChangedListener focusChangedListener(handle); focusChangedListener.OnFocused(focusChangeInfo); @@ -1167,7 +1181,7 @@ HWTEST_F(InputMethodPrivateMemberTest, BranchCoverage001, TestSize.Level0) auto userSession = std::make_shared(MAIN_USER_ID); sptr core = nullptr; sptr agent = nullptr; - pid_t pid{ -1 }; + pid_t pid { -1 }; auto ret = userSession->UpdateImeData(core, agent, pid); EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER); diff --git a/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp b/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp index dba8e66a..a74ff2b2 100644 --- a/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp +++ b/test/unittest/cpp_test/src/inputmethod_controller_capi_test.cpp @@ -1513,4 +1513,4 @@ HWTEST_F(InputMethodControllerCapiTest, TestAttachWithNorrmalParam_001, TestSize OH_AttachOptions_Destroy(options); OH_TextEditorProxy_Destroy(textEditorProxy); } -} \ No newline at end of file +} // namespace \ No newline at end of file diff --git a/test/unittest/cpp_test/src/itypes_util_test.cpp b/test/unittest/cpp_test/src/itypes_util_test.cpp index 0f928854..e24668b0 100644 --- a/test/unittest/cpp_test/src/itypes_util_test.cpp +++ b/test/unittest/cpp_test/src/itypes_util_test.cpp @@ -17,22 +17,20 @@ #include "itypes_util.h" #undef private -#include #include +#include #include - #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; @@ -230,7 +228,7 @@ HWTEST_F(ITypesUtilTest, testMarshallAndUnMarshallInputClientInfo, TestSize.Leve IMSA_HILOGI("ITypesUtilTest testMarshallAndUnMarshallInputClientInfo Test START"); MessageParcel data; InputClientInfo input; - auto ret = ITypesUtil::Unmarshalling(input, data); + auto ret = ITypesUtil::Unmarshalling(input, data); EXPECT_FALSE(ret); ret = ITypesUtil::Marshalling(input, data); EXPECT_TRUE(ret); @@ -296,7 +294,7 @@ HWTEST_F(ITypesUtilTest, testMarshallAndUnMarshallInputType, TestSize.Level0) { IMSA_HILOGI("ITypesUtilTest testMarshallAndUnMarshallInputType Test START"); MessageParcel data; - InputType input{ InputType::NONE }; + InputType input { InputType::NONE }; auto ret = ITypesUtil::Unmarshalling(input, data); EXPECT_FALSE(ret); data.WriteInt32(1); diff --git a/test/unittest/cpp_test/src/js_util_test.cpp b/test/unittest/cpp_test/src/js_util_test.cpp index db5809d2..fd1b8b1c 100644 --- a/test/unittest/cpp_test/src/js_util_test.cpp +++ b/test/unittest/cpp_test/src/js_util_test.cpp @@ -109,7 +109,7 @@ static napi_value GetString(napi_env env, napi_callback_info info) static napi_value GetObject(napi_env env, napi_callback_info info) { return Handle(env, info, [env](napi_value in) -> napi_value { - Property prop{}; + Property prop {}; JsProperty::Read(env, in, prop); return JsProperty::Write(env, prop); }); diff --git a/test/unittest/cpp_test/src/newIme_switch_test.cpp b/test/unittest/cpp_test/src/newIme_switch_test.cpp index f0226603..5e3e3ba1 100644 --- a/test/unittest/cpp_test/src/newIme_switch_test.cpp +++ b/test/unittest/cpp_test/src/newIme_switch_test.cpp @@ -50,9 +50,9 @@ public: sptr NewImeSwitchTest::imc_; std::string NewImeSwitchTest::bundleName = "com.example.newTestIme"; std::string NewImeSwitchTest::extName = "InputMethodExtAbility"; -std::vector NewImeSwitchTest::subName{ "lowerInput", "upperInput", "chineseInput" }; -std::vector NewImeSwitchTest::locale{ "en-US", "en-US", "zh-CN" }; -std::vector NewImeSwitchTest::language{ "english", "english", "chinese" }; +std::vector NewImeSwitchTest::subName { "lowerInput", "upperInput", "chineseInput" }; +std::vector NewImeSwitchTest::locale { "en-US", "en-US", "zh-CN" }; +std::vector NewImeSwitchTest::language { "english", "english", "chinese" }; std::string NewImeSwitchTest::beforeValue; std::string NewImeSwitchTest::allEnableIme = "{\"enableImeList\" : {\"100\" : [ \"com.example.newTestIme\"]}}"; constexpr uint32_t IME_SUBTYPE_NUM = 3; @@ -143,12 +143,12 @@ HWTEST_F(NewImeSwitchTest, testNewImeSwitch, TestSize.Level0) } /** -* @tc.name: testSubTypeSwitch_001 -* @tc.desc: switch subtype with subName1. -* @tc.type: FUNC -* @tc.require: -* @tc.author: chenyu -*/ + * @tc.name: testSubTypeSwitch_001 + * @tc.desc: switch subtype with subName1. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenyu + */ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_001, TestSize.Level0) { IMSA_HILOGI("newIme testSubTypeSwitch_001 Test START"); @@ -162,12 +162,12 @@ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_001, TestSize.Level0) } /** -* @tc.name: testSubTypeSwitch_002 -* @tc.desc: switch subtype with subName2. -* @tc.type: FUNC -* @tc.require: -* @tc.author: chenyu -*/ + * @tc.name: testSubTypeSwitch_002 + * @tc.desc: switch subtype with subName2. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenyu + */ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_002, TestSize.Level0) { IMSA_HILOGI("newIme testSubTypeSwitch_002 Test START"); @@ -181,12 +181,12 @@ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_002, TestSize.Level0) } /** -* @tc.name: testSubTypeSwitch_003 -* @tc.desc: switch subtype with subName3. -* @tc.type: FUNC -* @tc.require: -* @tc.author: chenyu -*/ + * @tc.name: testSubTypeSwitch_003 + * @tc.desc: switch subtype with subName3. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenyu + */ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_003, TestSize.Level0) { IMSA_HILOGI("newIme testSubTypeSwitch_003 Test START"); @@ -200,12 +200,12 @@ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_003, TestSize.Level0) } /** -* @tc.name: testSubTypeSwitch_004 -* @tc.desc: switch subtype witch subName1. -* @tc.type: FUNC -* @tc.require: -* @tc.author: chenyu -*/ + * @tc.name: testSubTypeSwitch_004 + * @tc.desc: switch subtype witch subName1. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenyu + */ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_004, TestSize.Level0) { IMSA_HILOGI("newIme testSubTypeSwitch_004 Test START"); @@ -219,12 +219,12 @@ HWTEST_F(NewImeSwitchTest, testSubTypeSwitch_004, TestSize.Level0) } /** -* @tc.name: testSubTypeSwitchWithErrorSubName -* @tc.desc: switch subtype with error subName. -* @tc.type: FUNC -* @tc.require: -* @tc.author: chenyu -*/ + * @tc.name: testSubTypeSwitchWithErrorSubName + * @tc.desc: switch subtype with error subName. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenyu + */ HWTEST_F(NewImeSwitchTest, testSubTypeSwitchWithErrorSubName, TestSize.Level0) { IMSA_HILOGI("newIme testSubTypeSwitchWithErrorSubName Test START"); @@ -236,12 +236,12 @@ HWTEST_F(NewImeSwitchTest, testSubTypeSwitchWithErrorSubName, TestSize.Level0) } /** -* @tc.name: testSwitchToCurrentImeWithEmptySubName -* @tc.desc: switch to currentIme witch empty subName. -* @tc.type: FUNC -* @tc.require: -* @tc.author: chenyu -*/ + * @tc.name: testSwitchToCurrentImeWithEmptySubName + * @tc.desc: switch to currentIme witch empty subName. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenyu + */ HWTEST_F(NewImeSwitchTest, testSwitchToCurrentImeWithEmptySubName, TestSize.Level0) { IMSA_HILOGI("newIme testSwitchToCurrentImeWithEmptySubName Test START"); @@ -255,12 +255,12 @@ HWTEST_F(NewImeSwitchTest, testSwitchToCurrentImeWithEmptySubName, TestSize.Leve } /** -* @tc.name: testSwitchInputMethod_001 -* @tc.desc: switch ime to newTestIme and switch the subtype to subName1. -* @tc.type: FUNC -* @tc.require: -* @tc.author: weishaoxiong -*/ + * @tc.name: testSwitchInputMethod_001 + * @tc.desc: switch ime to newTestIme and switch the subtype to subName1. + * @tc.type: FUNC + * @tc.require: + * @tc.author: weishaoxiong + */ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_001, TestSize.Level0) { IMSA_HILOGI("newIme testSwitchInputMethod_001 Test START"); @@ -274,12 +274,12 @@ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_001, TestSize.Level0) } /** -* @tc.name: testSwitchInputMethod_002 -* @tc.desc: switch the subtype to subName0. -* @tc.type: FUNC -* @tc.require: -* @tc.author: weishaoxiong -*/ + * @tc.name: testSwitchInputMethod_002 + * @tc.desc: switch the subtype to subName0. + * @tc.type: FUNC + * @tc.require: + * @tc.author: weishaoxiong + */ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_002, TestSize.Level0) { IMSA_HILOGI("newIme testSwitchInputMethod_002 Test START"); @@ -293,12 +293,12 @@ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_002, TestSize.Level0) } /** -* @tc.name: testSwitchInputMethod_003 -* @tc.desc: switch ime to newTestIme. -* @tc.type: FUNC -* @tc.require: -* @tc.author: weishaoxiong -*/ + * @tc.name: testSwitchInputMethod_003 + * @tc.desc: switch ime to newTestIme. + * @tc.type: FUNC + * @tc.require: + * @tc.author: weishaoxiong + */ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_003, TestSize.Level0) { IMSA_HILOGI("newIme testSwitchInputMethod_003 Test START"); @@ -310,12 +310,12 @@ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_003, TestSize.Level0) } /** -* @tc.name: testSwitchInputMethod_004 -* @tc.desc: The caller is not a system app. -* @tc.type: FUNC -* @tc.require: -* @tc.author: weishaoxiong -*/ + * @tc.name: testSwitchInputMethod_004 + * @tc.desc: The caller is not a system app. + * @tc.type: FUNC + * @tc.require: + * @tc.author: weishaoxiong + */ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_004, TestSize.Level0) { TddUtil::SetTestTokenID( @@ -326,12 +326,12 @@ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_004, TestSize.Level0) } /** -* @tc.name: testSwitchInputMethod_005 -* @tc.desc: The caller has no permissions. -* @tc.type: FUNC -* @tc.require: -* @tc.author: weishaoxiong -*/ + * @tc.name: testSwitchInputMethod_005 + * @tc.desc: The caller has no permissions. + * @tc.type: FUNC + * @tc.require: + * @tc.author: weishaoxiong + */ HWTEST_F(NewImeSwitchTest, testSwitchInputMethod_005, TestSize.Level0) { TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, "ohos.inputMethod.test", {})); diff --git a/test/unittest/cpp_test/src/security_mode_parser_test.cpp b/test/unittest/cpp_test/src/security_mode_parser_test.cpp index 9659ae4b..a579cfcf 100644 --- a/test/unittest/cpp_test/src/security_mode_parser_test.cpp +++ b/test/unittest/cpp_test/src/security_mode_parser_test.cpp @@ -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 @@ -44,7 +44,7 @@ public: }; std::shared_ptr SecurityModeParserTest::helper_; std::shared_ptr SecurityModeParserTest::resultSet_; -sptr SecurityModeParserTest::service_{ nullptr }; +sptr SecurityModeParserTest::service_ { nullptr }; void SecurityModeParserTest::SetUpTestCase(void) { IMSA_HILOGI("SecurityModeParserTest::SetUpTestCase"); @@ -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(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 diff --git a/test/unittest/cpp_test/src/virtual_listener_test.cpp b/test/unittest/cpp_test/src/virtual_listener_test.cpp index 71b45768..7cc286d1 100644 --- a/test/unittest/cpp_test/src/virtual_listener_test.cpp +++ b/test/unittest/cpp_test/src/virtual_listener_test.cpp @@ -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 &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 &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: @@ -126,7 +90,7 @@ public: { isReceivePrivateCommand_ = true; } - void NotifyPanelStatus(const SysPanelStatus &sysPanelStatus)override + void NotifyPanelStatus(const SysPanelStatus &sysPanelStatus) override { isNotifyIsShowSysPanel_ = true; } @@ -138,8 +102,8 @@ public: static bool isReceivePrivateCommand_; static bool isNotifyIsShowSysPanel_; }; -bool SystemCmdChannelListenerImpl::isReceivePrivateCommand_{ false }; -bool SystemCmdChannelListenerImpl::isNotifyIsShowSysPanel_{ false }; +bool SystemCmdChannelListenerImpl::isReceivePrivateCommand_ { false }; +bool SystemCmdChannelListenerImpl::isNotifyIsShowSysPanel_ { false }; class VirtualListenerTest : public testing::Test { public: @@ -168,10 +132,10 @@ public: static std::shared_ptr engineListener_; static sptr systemCmdListener_; }; -sptr VirtualListenerTest::textListener_{ nullptr }; -std::shared_ptr VirtualListenerTest::eventListener_{ nullptr }; -std::shared_ptr VirtualListenerTest::engineListener_{ nullptr }; -sptr VirtualListenerTest::systemCmdListener_{ nullptr }; +sptr VirtualListenerTest::textListener_ { nullptr }; +std::shared_ptr VirtualListenerTest::eventListener_ { nullptr }; +std::shared_ptr VirtualListenerTest::engineListener_ { nullptr }; +sptr VirtualListenerTest::systemCmdListener_ { nullptr }; /** * @tc.name: testOnTextChangedListener_001 diff --git a/test/unittest/napi_test/src/InputMethodTest.js b/test/unittest/napi_test/src/InputMethodTest.js index ba87ab68..39cda870 100644 --- a/test/unittest/napi_test/src/InputMethodTest.js +++ b/test/unittest/napi_test/src/InputMethodTest.js @@ -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); @@ -107,7 +103,7 @@ describe('InputMethodTest', function () { function wait(delay) { let start = new Date().getTime(); - while (new Date().getTime() - start < delay){ + while (new Date().getTime() - start < delay) { } } diff --git a/test/unittest/napi_test/src/InputMethodWithAttachTest.js b/test/unittest/napi_test/src/InputMethodWithAttachTest.js index df4397da..978f239d 100644 --- a/test/unittest/napi_test/src/InputMethodWithAttachTest.js +++ b/test/unittest/napi_test/src/InputMethodWithAttachTest.js @@ -21,7 +21,7 @@ import { PanelInfo, PanelFlag, PanelType } from '@ohos.inputMethod.Panel'; describe('InputMethodWithAttachTest', function () { const WAIT_DEAL_OK = 500; const TEST_RESULT_CODE = 0; - const TEST_FUNCTION = { + const TEST_FUNCTION = { INSERT_TEXT_SYNC: 0, MOVE_CURSOR_SYNC: 1, GET_ATTRIBUTE_SYNC: 2, @@ -41,11 +41,11 @@ describe('InputMethodWithAttachTest', function () { beforeAll(async function (done) { console.info('beforeAll called'); let inputMethodProperty = { - name:'com.example.testIme', - id:'InputMethodExtAbility' + name: 'com.example.testIme', + id: 'InputMethodExtAbility' }; await inputMethod.switchInputMethod(inputMethodProperty); - setTimeout(()=>{ + setTimeout(() => { done(); }, WAIT_DEAL_OK); }); @@ -56,9 +56,9 @@ describe('InputMethodWithAttachTest', function () { let props = await inputMethodSetting.listInputMethod(); let bundleName = 'com.example.newTestIme'; let bundleName1 = 'com.example.testIme'; - for(let i = 0;i< props.length; i++) { + for (let i = 0; i < props.length; i++) { let prop = props[i]; - if(prop.name !== bundleName && prop.name !== bundleName1){ + if (prop.name !== bundleName && prop.name !== bundleName1) { await inputMethod.switchInputMethod(prop); } } @@ -91,13 +91,13 @@ describe('InputMethodWithAttachTest', function () { } function subscribe(subscribeInfo, functionCode, done) { - commonEventManager.createSubscriber(subscribeInfo).then((data)=>{ + commonEventManager.createSubscriber(subscribeInfo).then((data) => { let subscriber = data; - commonEventManager.subscribe(subscriber, (err, eventData)=>{ + commonEventManager.subscribe(subscriber, (err, eventData) => { console.info("inputMethod subscribe"); - if(eventData.code === TEST_RESULT_CODE) { + if (eventData.code === TEST_RESULT_CODE) { expect(true).assertTrue(); - }else{ + } else { expect().assertFail(); } commonEventManager.unsubscribe(subscriber); @@ -169,7 +169,6 @@ describe('InputMethodWithAttachTest', function () { }); }); - /* * @tc.number inputmethod_with_attach_test_hideTextInput_002 * @tc.name Test whether the keyboard is hide successfully.