From 8b362805b79e28e83aaae8e3b6017ae4aade589c Mon Sep 17 00:00:00 2001 From: Hollokin Date: Wed, 9 Aug 2023 17:39:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9TDD=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hollokin --- test/unittest/cpp_test/BUILD.gn | 4 ++ .../cpp_test/common/include/tdd_util.h | 14 ++++ .../unittest/cpp_test/common/src/tdd_util.cpp | 64 +++++++++++++++---- .../src/input_method_ability_test.cpp | 5 +- .../cpp_test/src/input_method_attach_test.cpp | 5 +- .../src/input_method_controller_test.cpp | 20 ++++-- .../cpp_test/src/input_method_dfx_test.cpp | 9 ++- .../cpp_test/src/input_method_editor_test.cpp | 25 +++++++- ...permission_verification_exception_test.cpp | 6 ++ 9 files changed, 125 insertions(+), 27 deletions(-) diff --git a/test/unittest/cpp_test/BUILD.gn b/test/unittest/cpp_test/BUILD.gn index ae0b8de1..ccc153ca 100644 --- a/test/unittest/cpp_test/BUILD.gn +++ b/test/unittest/cpp_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("InputMethodControllerTest") { "napi:ace_napi", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "window_manager:libwm", ] } @@ -82,6 +83,7 @@ ohos_unittest("InputMethodAttachTest") { "c_utils:utils", "hilog:libhilog", "napi:ace_napi", + "window_manager:libwm", ] } ohos_unittest("InputMethodAbilityTest") { @@ -193,6 +195,7 @@ ohos_unittest("InputMethodDfxTest") { "input:libmmi-client", "ipc:ipc_single", "napi:ace_napi", + "window_manager:libwm", ] } @@ -326,6 +329,7 @@ ohos_unittest("InputMethodEditorTest") { "input:libmmi-client", "ipc:ipc_single", "napi:ace_napi", + "window_manager:libwm", ] } diff --git a/test/unittest/cpp_test/common/include/tdd_util.h b/test/unittest/cpp_test/common/include/tdd_util.h index 3cb0506a..d55d522f 100644 --- a/test/unittest/cpp_test/common/include/tdd_util.h +++ b/test/unittest/cpp_test/common/include/tdd_util.h @@ -18,13 +18,25 @@ #include +#include "block_data.h" #include "bundle_mgr_interface.h" #include "window.h" +#include "window_manager.h" #include "window_option.h" #include "wm_common.h" namespace OHOS { namespace MiscServices { +class FocusChangedListenerTestImpl : public Rosen::IFocusChangedListener { +public: + FocusChangedListenerTestImpl() = default; + ~FocusChangedListenerTestImpl() = default; + void OnFocused(const sptr &focusChangeInfo) override; + void OnUnfocused(const sptr &focusChangeInfo) override; + bool getFocus_ = false; + static std::shared_ptr> isFocused_; + static std::shared_ptr> unFocused_; +}; class TddUtil { public: static void StorageSelfTokenID(); @@ -42,6 +54,8 @@ public: static void ShowWindow(); static void HideWindow(); static void DestroyWindow(); + static void RegisterFocusChangeListener(); + static int32_t currentWindowId_; private: static sptr window_; diff --git a/test/unittest/cpp_test/common/src/tdd_util.cpp b/test/unittest/cpp_test/common/src/tdd_util.cpp index 790d91b3..c2f58f73 100644 --- a/test/unittest/cpp_test/common/src/tdd_util.cpp +++ b/test/unittest/cpp_test/common/src/tdd_util.cpp @@ -31,7 +31,6 @@ #include "system_ability.h" #include "system_ability_definition.h" #include "token_setproc.h" -#include "window_manager.h" namespace OHOS { namespace MiscServices { @@ -43,9 +42,36 @@ constexpr int32_t MAIN_USER_ID = 100; constexpr const uint16_t EACH_LINE_LENGTH = 500; constexpr int32_t BUFF_LENGTH = 10; constexpr const char *CMD_PIDOF_IMS = "pidof inputmethod_ser"; +static constexpr int32_t MAX_TIMEOUT_WAIT_FOCUS = 2000; uint64_t TddUtil::selfTokenID_ = 0; int32_t TddUtil::userID_ = INVALID_USER_ID; sptr TddUtil::WindowManager::window_ = nullptr; +int32_t TddUtil::WindowManager::currentWindowId_ = 0; +std::shared_ptr> FocusChangedListenerTestImpl::isFocused_ = + std::make_shared>(MAX_TIMEOUT_WAIT_FOCUS, false); +std::shared_ptr> FocusChangedListenerTestImpl::unFocused_ = + std::make_shared>(MAX_TIMEOUT_WAIT_FOCUS, false); +void FocusChangedListenerTestImpl::OnFocused(const sptr &focusChangeInfo) +{ + IMSA_HILOGI("get onFocus information from window manager."); + if (focusChangeInfo->windowId_ == TddUtil::WindowManager::currentWindowId_) { + getFocus_ = true; + isFocused_->SetValue(getFocus_); + unFocused_->Clear(false); + } +} + +void FocusChangedListenerTestImpl::OnUnfocused(const sptr &focusChangeInfo) +{ + IMSA_HILOGI("get unfocus information from window manager."); + if (focusChangeInfo->windowId_ == TddUtil::WindowManager::currentWindowId_) { + getFocus_ = false; + isFocused_->Clear(false); + bool unFocus = !getFocus_; + unFocused_->SetValue(unFocus); + } +} + int32_t TddUtil::GetCurrentUserId() { if (userID_ != INVALID_USER_ID) { @@ -180,7 +206,12 @@ sptr TddUtil::GetBundleMgr() int TddUtil::GetUserIdByBundleName(const std::string &bundleName, const int currentUserId) { - auto uid = TddUtil::GetBundleMgr()->GetUidByBundleName(bundleName, currentUserId); + auto bundleMgr = TddUtil::GetBundleMgr(); + if (bundleMgr == nullptr) { + IMSA_HILOGE("Get bundleMgr failed."); + return -1; + } + auto uid = bundleMgr->GetUidByBundleName(bundleName, currentUserId); if (uid == -1) { IMSA_HILOGE("failed to get information and the parameters may be wrong."); return -1; @@ -193,31 +224,33 @@ void TddUtil::WindowManager::CreateWindow() { std::string windowName = "inputmethod_test_window"; sptr winOption = new OHOS::Rosen::WindowOption(); + winOption->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); winOption->SetFocusable(true); std::shared_ptr context = nullptr; WMError wmError = WMError::WM_OK; window_ = Window::Create(windowName, winOption, context, wmError); IMSA_HILOGI("Create window ret:%{public}d", wmError); + currentWindowId_ = window_->GetWindowId(); } void TddUtil::WindowManager::ShowWindow() { - if (window_ != nullptr) { - auto ret = window_->Show(); - if (ret != WMError::WM_OK) { - IMSA_HILOGE("Show window error, err = %{public}d", ret); - } + if (window_ == nullptr) { + IMSA_HILOGE("window is not exist."); + return; } + auto ret = window_->Show(); + IMSA_HILOGI("Show window end, ret = %{public}d", ret); } void TddUtil::WindowManager::HideWindow() { - if (window_ != nullptr) { - auto ret = window_->Hide(); - if (ret != WMError::WM_OK) { - IMSA_HILOGE("Hide window error, err = %{public}d", ret); - } + if (window_ == nullptr) { + IMSA_HILOGE("window is not exist."); + return; } + auto ret = window_->Hide(); + IMSA_HILOGI("Hide window end, ret = %{public}d", ret); } void TddUtil::WindowManager::DestroyWindow() @@ -226,5 +259,12 @@ void TddUtil::WindowManager::DestroyWindow() window_->Destroy(); } } + +void TddUtil::WindowManager::RegisterFocusChangeListener() +{ + auto listener = new (std::nothrow) FocusChangedListenerTestImpl(); + WMError ret = Rosen::WindowManager::GetInstance().RegisterFocusChangedListener(listener); + IMSA_HILOGI("register focus changed listener ret: %{public}d", ret); +} } // namespace MiscServices } // namespace OHOS diff --git a/test/unittest/cpp_test/src/input_method_ability_test.cpp b/test/unittest/cpp_test/src/input_method_ability_test.cpp index 71cc8aa7..a450cf4f 100644 --- a/test/unittest/cpp_test/src/input_method_ability_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ability_test.cpp @@ -102,12 +102,12 @@ public: inputMethodAbility_->SetCoreAndAgent(); TddUtil::RestoreSelfTokenID(); TextListener::ResetParam(); + TddUtil::WindowManager::RegisterFocusChangeListener(); } static void TearDownTestCase(void) { IMSA_HILOGI("InputMethodAbilityTest::TearDownTestCase"); imc_->Close(); - TddUtil::KillImsaProcess(); TextListener::ResetParam(); WindowMgr::HideWindow(); WindowMgr::DestroyWindow(); @@ -154,6 +154,7 @@ HWTEST_F(InputMethodAbilityTest, testSerializedInputAttribute, TestSize.Level0) */ HWTEST_F(InputMethodAbilityTest, testShowKeyboardInputMethodCoreProxy, TestSize.Level0) { + IMSA_HILOGI("testShowKeyboardInputMethodCoreProxy start."); sptr coreStub = new InputMethodCoreStub(0); sptr core = coreStub; auto msgHandler = new (std::nothrow) MessageHandler(); @@ -248,6 +249,8 @@ HWTEST_F(InputMethodAbilityTest, testHideKeyboardSelf, TestSize.Level0) IMSA_HILOGI("InputMethodAbility testHideKeyboardSelf START"); WindowMgr::CreateWindow(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("testHideKeyboardSelf getFocus end, isFocused = %{public}d", isFocused); sptr textListener = new TextListener(); imc_ = InputMethodController::GetInstance(); imc_->Attach(textListener); 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 7f9ba005..2a137af8 100644 --- a/test/unittest/cpp_test/src/input_method_attach_test.cpp +++ b/test/unittest/cpp_test/src/input_method_attach_test.cpp @@ -47,8 +47,11 @@ public: inputMethodAbility_->SetImeListener(std::make_shared()); TddUtil::RestoreSelfTokenID(); + TddUtil::WindowManager::RegisterFocusChangeListener(); WindowMgr::CreateWindow(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("getFocus end, isFocused = %{public}d", isFocused); inputMethodController_ = InputMethodController::GetInstance(); } static void TearDownTestCase(void) @@ -60,12 +63,10 @@ public: void SetUp() { IMSA_HILOGI("InputMethodAttachTest::SetUp"); - WindowMgr::ShowWindow(); } void TearDown() { IMSA_HILOGI("InputMethodAttachTest::TearDown"); - WindowMgr::HideWindow(); inputMethodController_->Close(); } }; 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 d4c59727..c6035f6c 100644 --- a/test/unittest/cpp_test/src/input_method_controller_test.cpp +++ b/test/unittest/cpp_test/src/input_method_controller_test.cpp @@ -225,10 +225,13 @@ void InputMethodControllerTest::SetUpTestCase(void) keyEvent_->SetFunctionKey(MMI::KeyEvent::NUM_LOCK_FUNCTION_KEY, 0); keyEvent_->SetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY, 1); keyEvent_->SetFunctionKey(MMI::KeyEvent::SCROLL_LOCK_FUNCTION_KEY, 1); - TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(false, true, "undefine")); + TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, true, "undefine")); + TddUtil::WindowManager::RegisterFocusChangeListener(); WindowMgr::CreateWindow(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("getFocus end, isFocused = %{public}d", isFocused); SetInputDeathRecipient(); TextListener::ResetParam(); } @@ -245,13 +248,11 @@ void InputMethodControllerTest::TearDownTestCase(void) void InputMethodControllerTest::SetUp(void) { IMSA_HILOGI("InputMethodControllerTest::SetUp"); - WindowMgr::ShowWindow(); } void InputMethodControllerTest::TearDown(void) { IMSA_HILOGI("InputMethodControllerTest::TearDown"); - WindowMgr::HideWindow(); } void InputMethodControllerTest::SetInputDeathRecipient() @@ -423,8 +424,11 @@ HWTEST_F(InputMethodControllerTest, testIMCAttach, TestSize.Level0) HWTEST_F(InputMethodControllerTest, testIMCSetCallingWindow, TestSize.Level0) { IMSA_HILOGD("IMC SetCallingWindow Test START"); + auto ret = inputMethodController_->Attach(textListener_); + EXPECT_EQ(ret, ErrorCode::NO_ERROR); uint32_t windowId = 3; - inputMethodController_->SetCallingWindow(windowId); + ret = inputMethodController_->SetCallingWindow(windowId); + EXPECT_EQ(ret, ErrorCode::NO_ERROR); EXPECT_EQ(windowId, imeListener_->windowId_); } @@ -485,12 +489,14 @@ HWTEST_F(InputMethodControllerTest, testIMCDispatchKeyEvent001, TestSize.Level0) doesKeyEventConsume_ = true; doesFUllKeyEventConsume_ = false; blockKeyEvent_.Clear(nullptr); + auto res = inputMethodController_->Attach(textListener_); + EXPECT_EQ(res, ErrorCode::NO_ERROR); bool ret = inputMethodController_->DispatchKeyEvent(keyEvent_); EXPECT_TRUE(ret); auto keyEvent = blockKeyEvent_.GetValue(); - EXPECT_NE(keyEvent, nullptr); - ret = keyEvent->GetKeyCode() == keyEvent_->GetKeyCode() && keyEvent->GetKeyAction() == keyEvent_->GetKeyAction(); - EXPECT_TRUE(ret); + ASSERT_NE(keyEvent, nullptr); + EXPECT_EQ(keyEvent->GetKeyCode(), keyEvent_->GetKeyCode()); + EXPECT_EQ(keyEvent->GetKeyAction(), keyEvent_->GetKeyAction()); } /** 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 b12920d0..5173906a 100644 --- a/test/unittest/cpp_test/src/input_method_dfx_test.cpp +++ b/test/unittest/cpp_test/src/input_method_dfx_test.cpp @@ -137,15 +137,18 @@ void InputMethodDfxTest::SetUpTestCase(void) inputMethodController_ = InputMethodController::GetInstance(); textListener_ = new TextListener(); + TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, false, "undefine")); + TddUtil::WindowManager::RegisterFocusChangeListener(); WindowMgr::CreateWindow(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("getFocus end, isFocused = %{public}d", isFocused); } void InputMethodDfxTest::TearDownTestCase(void) { IMSA_HILOGI("InputMethodDfxTest::TearDownTestCase"); TddUtil::RestoreSelfTokenID(); - TddUtil::KillImsaProcess(); WindowMgr::HideWindow(); WindowMgr::DestroyWindow(); } @@ -153,13 +156,11 @@ void InputMethodDfxTest::TearDownTestCase(void) void InputMethodDfxTest::SetUp(void) { IMSA_HILOGI("InputMethodDfxTest::SetUp"); - WindowMgr::ShowWindow(); } void InputMethodDfxTest::TearDown(void) { IMSA_HILOGI("InputMethodDfxTest::TearDown"); - WindowMgr::HideWindow(); } /** @@ -230,6 +231,8 @@ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Attach, TestSize.Leve */ HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideTextInput, TestSize.Level0) { + auto ret = inputMethodController_->Attach(textListener_, true); + EXPECT_EQ(ret, ErrorCode::NO_ERROR); auto watcher = std::make_shared(InputMethodSysEvent::GetInstance().GetOperateInfo( static_cast(OperateIMEInfoCode::IME_HIDE_UNEDITABLE))); auto hideTextInput = []() { inputMethodController_->HideTextInput(); }; 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 8579398b..c8235e08 100644 --- a/test/unittest/cpp_test/src/input_method_editor_test.cpp +++ b/test/unittest/cpp_test/src/input_method_editor_test.cpp @@ -131,6 +131,8 @@ void InputMethodEditorTest::SetUpTestCase(void) keyEvent_->SetKeyAction(keyAction); keyEvent_->SetKeyCode(keyCode); TextListener::ResetParam(); + TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, false, "undefine")); + TddUtil::WindowManager::RegisterFocusChangeListener(); WindowMgr::CreateWindow(); } @@ -138,7 +140,6 @@ void InputMethodEditorTest::TearDownTestCase(void) { IMSA_HILOGI("InputMethodEditorTest::TearDownTestCase"); TddUtil::RestoreSelfTokenID(); - TddUtil::KillImsaProcess(); TextListener::ResetParam(); WindowMgr::DestroyWindow(); } @@ -204,6 +205,8 @@ HWTEST_F(InputMethodEditorTest, testAttachFocused, TestSize.Level0) { IMSA_HILOGI("InputMethodEditorTest Attach Focused Test START"); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("testAttachFocused getFocus end, isFocused = %{public}d", isFocused); InputMethodEditorTest::imeListener_->isInputStart_ = false; InputMethodEditorTest::imeListener_->keyboardState_ = false; int32_t ret = InputMethodEditorTest::inputMethodController_->Attach(InputMethodEditorTest::textListener_, false); @@ -222,7 +225,10 @@ HWTEST_F(InputMethodEditorTest, testAttachFocused, TestSize.Level0) EXPECT_TRUE(TextListener::WaitIMACallback()); EXPECT_TRUE(imeListener_->isInputStart_ && imeListener_->keyboardState_); EXPECT_EQ(ret, ErrorCode::NO_ERROR); + InputMethodEditorTest::inputMethodController_->Close(); WindowMgr::HideWindow(); + bool unFocus = FocusChangedListenerTestImpl::unFocused_->GetValue(); + IMSA_HILOGI("testAttachFocused unFocus end, unFocus = %{public}d", unFocus); } /** @@ -233,9 +239,10 @@ HWTEST_F(InputMethodEditorTest, testAttachFocused, TestSize.Level0) HWTEST_F(InputMethodEditorTest, testShowSoftKeyboard, TestSize.Level0) { IMSA_HILOGI("InputMethodEditorTest ShowSoftKeyboard Test START"); - InputMethodEditorTest::inputMethodController_->Close(); TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, true, "undefined")); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("testShowSoftKeyboard getFocus end, isFocused = %{public}d", isFocused); InputMethodEditorTest::imeListener_->keyboardState_ = false; TextListener::keyboardStatus_ = KeyboardStatus::NONE; int32_t ret = InputMethodEditorTest::inputMethodController_->Attach(InputMethodEditorTest::textListener_, false); @@ -245,6 +252,8 @@ HWTEST_F(InputMethodEditorTest, testShowSoftKeyboard, TestSize.Level0) EXPECT_EQ(ret, ErrorCode::NO_ERROR); EXPECT_TRUE(imeListener_->keyboardState_ && TextListener::keyboardStatus_ == KeyboardStatus::SHOW); WindowMgr::HideWindow(); + bool unFocus = FocusChangedListenerTestImpl::unFocused_->GetValue(); + IMSA_HILOGI("testShowSoftKeyboard unFocus end, unFocus = %{public}d", unFocus); } /** @@ -257,6 +266,8 @@ HWTEST_F(InputMethodEditorTest, testIMCHideTextInput, TestSize.Level0) IMSA_HILOGI("InputMethodEditorTest HideTextInputAndShowTextInput Test START"); InputMethodEditorTest::inputMethodController_->Close(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("testIMCHideTextInput getFocus end, isFocused = %{public}d", isFocused); int32_t ret = InputMethodEditorTest::inputMethodController_->Attach(InputMethodEditorTest::textListener_, true); EXPECT_EQ(ret, ErrorCode::NO_ERROR); @@ -276,6 +287,8 @@ HWTEST_F(InputMethodEditorTest, testIMCHideTextInput, TestSize.Level0) ret = InputMethodEditorTest::inputMethodController_->HideCurrentInput(); EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NOT_EDITABLE); WindowMgr::HideWindow(); + bool unFocus = FocusChangedListenerTestImpl::unFocused_->GetValue(); + IMSA_HILOGI("testIMCHideTextInput unFocus end, unFocus = %{public}d", unFocus); } /** @@ -288,6 +301,8 @@ HWTEST_F(InputMethodEditorTest, testShowTextInput, TestSize.Level0) IMSA_HILOGI("InputMethodEditorTest ShowTextInput Test START"); InputMethodEditorTest::inputMethodController_->Close(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("testShowTextInput getFocus end, isFocused = %{public}d", isFocused); int32_t ret = InputMethodEditorTest::inputMethodController_->Attach(InputMethodEditorTest::textListener_, true); EXPECT_EQ(ret, ErrorCode::NO_ERROR); InputMethodEditorTest::inputMethodController_->HideTextInput(); @@ -300,6 +315,8 @@ HWTEST_F(InputMethodEditorTest, testShowTextInput, TestSize.Level0) && kbListener_->keyStatus_ == keyEvent_->GetKeyAction(); EXPECT_TRUE(result); WindowMgr::HideWindow(); + bool unFocus = FocusChangedListenerTestImpl::unFocused_->GetValue(); + IMSA_HILOGI("testShowTextInput unFocus end, unFocus = %{public}d", unFocus); } /** @@ -311,6 +328,8 @@ HWTEST_F(InputMethodEditorTest, testIMCClose, TestSize.Level0) { IMSA_HILOGI("IMC Close Test START"); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("testIMCClose getFocus end, isFocused = %{public}d", isFocused); int32_t ret = InputMethodEditorTest::inputMethodController_->Attach(InputMethodEditorTest::textListener_, true); EXPECT_EQ(ret, ErrorCode::NO_ERROR); InputMethodEditorTest::inputMethodController_->Close(); @@ -330,6 +349,8 @@ HWTEST_F(InputMethodEditorTest, testIMCClose, TestSize.Level0) ret = InputMethodEditorTest::inputMethodController_->HideCurrentInput(); EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NOT_EDITABLE); WindowMgr::HideWindow(); + bool unFocus = FocusChangedListenerTestImpl::unFocused_->GetValue(); + IMSA_HILOGI("testIMCClose unFocus end, unFocus = %{public}d", unFocus); } } // namespace MiscServices } // namespace OHOS diff --git a/test/unittest/cpp_test/src/permission_verification_exception_test.cpp b/test/unittest/cpp_test/src/permission_verification_exception_test.cpp index 1af1e7d3..0a3d2915 100644 --- a/test/unittest/cpp_test/src/permission_verification_exception_test.cpp +++ b/test/unittest/cpp_test/src/permission_verification_exception_test.cpp @@ -64,6 +64,8 @@ void PermissionVerificationExceptionTest::SetUpTestCase(void) auto property = InputMethodController::GetInstance()->GetCurrentInputMethod(); EXPECT_NE(property, nullptr); tokenId_ = TddUtil::GetTestTokenID(property->name); + + TddUtil::WindowManager::RegisterFocusChangeListener(); WindowMgr::CreateWindow(); } @@ -98,12 +100,16 @@ HWTEST_F(PermissionVerificationExceptionTest, ShowAndHideSoftKeyboard, TestSize. TddUtil::RestoreSelfTokenID(); WindowMgr::ShowWindow(); + bool isFocused = FocusChangedListenerTestImpl::isFocused_->GetValue(); + IMSA_HILOGI("ShowAndHideSoftKeyboard getFocus end, isFocused = %{public}d", isFocused); PermissionVerificationExceptionTest::imc_->Attach(PermissionVerificationExceptionTest::textListener_); int32_t ret = PermissionVerificationExceptionTest::imc_->ShowSoftKeyboard(); EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_PERMISSION_DENIED); ret = PermissionVerificationExceptionTest::imc_->HideSoftKeyboard(); EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_PERMISSION_DENIED); WindowMgr::HideWindow(); + bool unFocus = FocusChangedListenerTestImpl::unFocused_->GetValue(); + IMSA_HILOGI("ShowAndHideSoftKeyboard unFocus end, unFocus = %{public}d", unFocus); } /**