mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-30 10:20:49 +00:00
修改TDD失败
Signed-off-by: Hollokin <taoyuxin2@huawei.com>
This commit is contained in:
parent
b62bea1cfd
commit
8b362805b7
@ -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",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -18,13 +18,25 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#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<Rosen::FocusChangeInfo> &focusChangeInfo) override;
|
||||
void OnUnfocused(const sptr<Rosen::FocusChangeInfo> &focusChangeInfo) override;
|
||||
bool getFocus_ = false;
|
||||
static std::shared_ptr<BlockData<bool>> isFocused_;
|
||||
static std::shared_ptr<BlockData<bool>> 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<Rosen::Window> window_;
|
||||
|
@ -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<Window> TddUtil::WindowManager::window_ = nullptr;
|
||||
int32_t TddUtil::WindowManager::currentWindowId_ = 0;
|
||||
std::shared_ptr<BlockData<bool>> FocusChangedListenerTestImpl::isFocused_ =
|
||||
std::make_shared<BlockData<bool>>(MAX_TIMEOUT_WAIT_FOCUS, false);
|
||||
std::shared_ptr<BlockData<bool>> FocusChangedListenerTestImpl::unFocused_ =
|
||||
std::make_shared<BlockData<bool>>(MAX_TIMEOUT_WAIT_FOCUS, false);
|
||||
void FocusChangedListenerTestImpl::OnFocused(const sptr<Rosen::FocusChangeInfo> &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<Rosen::FocusChangeInfo> &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<OHOS::AppExecFwk::IBundleMgr> 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<WindowOption> winOption = new OHOS::Rosen::WindowOption();
|
||||
winOption->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
|
||||
winOption->SetFocusable(true);
|
||||
std::shared_ptr<AbilityRuntime::Context> 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
|
||||
|
@ -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<InputMethodCoreStub> coreStub = new InputMethodCoreStub(0);
|
||||
sptr<IInputMethodCore> 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<OnTextChangedListener> textListener = new TextListener();
|
||||
imc_ = InputMethodController::GetInstance();
|
||||
imc_->Attach(textListener);
|
||||
|
@ -47,8 +47,11 @@ public:
|
||||
inputMethodAbility_->SetImeListener(std::make_shared<InputMethodEngineListenerImpl>());
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<Watcher>(InputMethodSysEvent::GetInstance().GetOperateInfo(
|
||||
static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_UNEDITABLE)));
|
||||
auto hideTextInput = []() { inputMethodController_->HideTextInput(); };
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user