mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2025-03-01 11:35:58 +00:00
Merge branch 'master' of gitee.com:openharmony/inputmethod_imf into master
Signed-off-by: 赵凌岚 <zhaolinglan1@huawei.com>
This commit is contained in:
commit
430e1e01d8
@ -128,7 +128,8 @@ napi_value JsPanel::SetUiContent(napi_env env, napi_callback_info info)
|
||||
CHECK_RETURN(ctxt->inputMethodPanel != nullptr, "inputMethodPanel is nullptr!", napi_generic_failure);
|
||||
auto code = ctxt->inputMethodPanel->SetUiContent(ctxt->path, env, ctxt->contentStorage);
|
||||
if (code == ErrorCode::ERROR_PARAMETER_CHECK_FAILED) {
|
||||
PARAM_CHECK_RETURN(env, code == ErrorCode::NO_ERROR, "path is invalid!", TYPE_NONE, napi_generic_failure);
|
||||
ctxt->SetErrorCode(code);
|
||||
return napi_generic_failure;
|
||||
}
|
||||
return napi_ok;
|
||||
};
|
||||
|
@ -589,7 +589,7 @@ void JSInputMethodExtensionConnection::HandleOnAbilityDisconnectDone(
|
||||
}
|
||||
IMSA_HILOGI("OnAbilityDisconnectDone CallFunction success");
|
||||
napi_value callResult = nullptr;
|
||||
napi_call_function(env_, obj, method, ARGC_TWO, argv, &callResult);
|
||||
napi_call_function(env_, obj, method, ARGC_ONE, argv, &callResult);
|
||||
}
|
||||
|
||||
void JSInputMethodExtensionConnection::SetJsConnectionObject(napi_value jsConnectionObject)
|
||||
|
@ -378,10 +378,10 @@ int32_t InputMethodPanel::SetUiContent(
|
||||
void InputMethodPanel::SetPanelStatusListener(
|
||||
std::shared_ptr<PanelStatusListener> statusListener, const std::string &type)
|
||||
{
|
||||
IMSA_HILOGD("SetPanelStatusListener start.");
|
||||
if (!MarkListener(type, true)) {
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGD("type: %{public}s", type.c_str());
|
||||
if (panelStatusListener_ != nullptr) {
|
||||
IMSA_HILOGD("PanelStatusListener already set.");
|
||||
return;
|
||||
@ -397,6 +397,7 @@ void InputMethodPanel::ClearPanelListener(const std::string &type)
|
||||
if (!MarkListener(type, false)) {
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGD("type: %{public}s", type.c_str());
|
||||
if (panelStatusListener_ == nullptr) {
|
||||
IMSA_HILOGD("PanelStatusListener not set, don't need to remove.");
|
||||
return;
|
||||
|
@ -26,9 +26,9 @@ namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class ImeEventMonitorManagerImpl {
|
||||
public:
|
||||
static ImeEventMonitorManagerImpl &GetInstance();
|
||||
int32_t RegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
int32_t UnRegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
IMF_API static ImeEventMonitorManagerImpl &GetInstance();
|
||||
IMF_API int32_t RegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
IMF_API int32_t UnRegisterImeEventListener(uint32_t eventFlag, const std::shared_ptr<ImeEventListener> &listener);
|
||||
int32_t OnImeChange(const Property &property, const SubProperty &subProperty);
|
||||
int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info);
|
||||
|
||||
|
@ -142,9 +142,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
|
||||
}
|
||||
|
||||
public async releaseContext(): Promise<void> {
|
||||
if (this.mContext && this.extensionWin) {
|
||||
await this.extensionWin.destroyWindow();
|
||||
await this.mContext.terminateSelf();
|
||||
}
|
||||
await this.extensionWin?.destroyWindow();
|
||||
await this.mContext?.terminateSelf();
|
||||
}
|
||||
};
|
@ -91,7 +91,7 @@ struct Index {
|
||||
message: 'switch success', duration: 200
|
||||
});
|
||||
setTimeout(() => {
|
||||
context!.terminateSelf();
|
||||
context?.terminateSelf();
|
||||
}, EXIT_TIME);
|
||||
}).catch((err: BusinessError) => {
|
||||
if (!err) {
|
||||
|
83
test/unittest/cpp_test/common/include/scope_utils.h
Normal file
83
test/unittest/cpp_test/common/include/scope_utils.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef INPUTMETHOD_IMF_TEST_UNITTEST_COMMON_SCOPE_UTILS_H
|
||||
#define INPUTMETHOD_IMF_TEST_UNITTEST_COMMON_SCOPE_UTILS_H
|
||||
|
||||
#include "global.h"
|
||||
#include "tdd_util.h"
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
constexpr int32_t ROOT_UID = 0;
|
||||
class AccessScope {
|
||||
public:
|
||||
AccessScope(uint64_t tokenId, int32_t uid)
|
||||
{
|
||||
IMSA_HILOGI("enter");
|
||||
if (tokenId > 0) {
|
||||
originalTokenId_ = TddUtil::GetCurrentTokenID();
|
||||
TddUtil::SetTestTokenID(tokenId);
|
||||
}
|
||||
if (uid > 0) {
|
||||
TddUtil::SetSelfUid(uid);
|
||||
}
|
||||
}
|
||||
~AccessScope()
|
||||
{
|
||||
if (originalTokenId_ > 0) {
|
||||
TddUtil::SetTestTokenID(originalTokenId_);
|
||||
}
|
||||
TddUtil::SetSelfUid(ROOT_UID);
|
||||
IMSA_HILOGI("exit");
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t originalTokenId_{ 0 };
|
||||
};
|
||||
|
||||
class TokenScope {
|
||||
public:
|
||||
explicit TokenScope(uint64_t tokenId)
|
||||
{
|
||||
IMSA_HILOGI("enter");
|
||||
originalTokenId_ = TddUtil::GetCurrentTokenID();
|
||||
TddUtil::SetTestTokenID(tokenId);
|
||||
}
|
||||
~TokenScope()
|
||||
{
|
||||
TddUtil::SetTestTokenID(originalTokenId_);
|
||||
IMSA_HILOGI("exit");
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t originalTokenId_{ 0 };
|
||||
};
|
||||
|
||||
class UidScope {
|
||||
public:
|
||||
explicit UidScope(int32_t uid)
|
||||
{
|
||||
IMSA_HILOGI("enter, uid: %{public}d", uid);
|
||||
TddUtil::SetSelfUid(uid);
|
||||
}
|
||||
~UidScope()
|
||||
{
|
||||
TddUtil::SetSelfUid(ROOT_UID);
|
||||
IMSA_HILOGI("exit");
|
||||
}
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
#endif // INPUTMETHOD_IMF_TEST_UNITTEST_COMMON_SCOPE_UTILS_H
|
@ -47,6 +47,9 @@ public:
|
||||
static void DeleteTestTokenID(uint64_t tokenId);
|
||||
static void SetTestTokenID(uint64_t tokenId);
|
||||
static void RestoreSelfTokenID();
|
||||
static uint64_t GetCurrentTokenID();
|
||||
static int32_t GetUid(const std::string &bundleName);
|
||||
static void SetSelfUid(int32_t uid);
|
||||
static bool ExecuteCmd(const std::string &cmd, std::string &result);
|
||||
static pid_t GetImsaPid();
|
||||
static bool KillImsaProcess();
|
||||
@ -68,6 +71,7 @@ public:
|
||||
|
||||
private:
|
||||
static sptr<Rosen::Window> window_;
|
||||
static uint64_t windowTokenId_;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "nativetoken_kit.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "scope_utils.h"
|
||||
#include "system_ability.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "tdd_util.h"
|
||||
@ -54,6 +55,7 @@ uint64_t TddUtil::selfTokenID_ = 0;
|
||||
int32_t TddUtil::userID_ = INVALID_USER_ID;
|
||||
sptr<Window> TddUtil::WindowManager::window_ = nullptr;
|
||||
int32_t TddUtil::WindowManager::currentWindowId_ = 0;
|
||||
uint64_t TddUtil::WindowManager::windowTokenId_ = 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_ =
|
||||
@ -151,6 +153,33 @@ void TddUtil::RestoreSelfTokenID()
|
||||
IMSA_HILOGI("SetSelfTokenID ret = %{public}d", ret);
|
||||
}
|
||||
|
||||
uint64_t TddUtil::GetCurrentTokenID()
|
||||
{
|
||||
return GetSelfTokenID();
|
||||
}
|
||||
|
||||
int32_t TddUtil::GetUid(const std::string &bundleName)
|
||||
{
|
||||
auto bundleMgr = GetBundleMgr();
|
||||
if (bundleMgr == nullptr) {
|
||||
IMSA_HILOGE("bundleMgr nullptr");
|
||||
return -1;
|
||||
}
|
||||
auto uid = bundleMgr->GetUidByBundleName(bundleName, GetCurrentUserId());
|
||||
if (uid == -1) {
|
||||
IMSA_HILOGE("failed to get information and the parameters may be wrong.");
|
||||
return -1;
|
||||
}
|
||||
IMSA_HILOGI("bundleName: %{public}s, uid: %{public}d", bundleName.c_str(), uid);
|
||||
return uid;
|
||||
}
|
||||
|
||||
void TddUtil::SetSelfUid(int32_t uid)
|
||||
{
|
||||
setuid(uid);
|
||||
IMSA_HILOGI("set uid to: %{public}d", uid);
|
||||
}
|
||||
|
||||
bool TddUtil::ExecuteCmd(const std::string &cmd, std::string &result)
|
||||
{
|
||||
char buff[EACH_LINE_LENGTH] = { 0x00 };
|
||||
@ -321,6 +350,10 @@ bool TddUtil::GetUnfocused()
|
||||
|
||||
void TddUtil::WindowManager::CreateWindow()
|
||||
{
|
||||
if (windowTokenId_ == 0) {
|
||||
windowTokenId_ = AllocTestTokenID(true, "TestWindow", {});
|
||||
}
|
||||
TokenScope scope(windowTokenId_);
|
||||
std::string windowName = "inputmethod_test_window";
|
||||
sptr<WindowOption> winOption = new OHOS::Rosen::WindowOption();
|
||||
winOption->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
|
||||
@ -348,6 +381,7 @@ void TddUtil::WindowManager::HideWindow()
|
||||
IMSA_HILOGE("window is not exist.");
|
||||
return;
|
||||
}
|
||||
TokenScope scope(windowTokenId_);
|
||||
auto ret = window_->Hide();
|
||||
IMSA_HILOGI("Hide window end, ret = %{public}d", ret);
|
||||
}
|
||||
@ -355,6 +389,7 @@ void TddUtil::WindowManager::HideWindow()
|
||||
void TddUtil::WindowManager::DestroyWindow()
|
||||
{
|
||||
if (window_ != nullptr) {
|
||||
TokenScope scope(windowTokenId_);
|
||||
window_->Destroy();
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "input_method_core_stub.h"
|
||||
#include "input_method_panel.h"
|
||||
#include "message_handler.h"
|
||||
#include "scope_utils.h"
|
||||
#include "tdd_util.h"
|
||||
#include "text_listener.h"
|
||||
|
||||
@ -55,6 +56,9 @@ public:
|
||||
static sptr<InputMethodAbility> inputMethodAbility_;
|
||||
static uint32_t windowId_;
|
||||
static int32_t security_;
|
||||
static uint64_t currentImeTokenId_;
|
||||
static uint64_t defaultImeTokenId_;
|
||||
static int32_t currentImeUid_;
|
||||
|
||||
class InputMethodEngineListenerImpl : public InputMethodEngineListener {
|
||||
public:
|
||||
@ -101,26 +105,22 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static void StubSelfAsDefault()
|
||||
{
|
||||
std::shared_ptr<Property> property = std::make_shared<Property>();
|
||||
auto ret = InputMethodController::GetInstance()->GetDefaultInputMethod(property);
|
||||
std::string bundleName = ret == ErrorCode::NO_ERROR ? property->name : "default.inputmethod.unittest";
|
||||
TddUtil::SetTestTokenID(TddUtil::GetTestTokenID(bundleName));
|
||||
inputMethodAbility_ = InputMethodAbility::GetInstance();
|
||||
inputMethodAbility_->SetCoreAndAgent();
|
||||
}
|
||||
|
||||
static void SetUpTestCase(void)
|
||||
{
|
||||
// Set the tokenID to the tokenID of the current ime
|
||||
TddUtil::StorageSelfTokenID();
|
||||
std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
|
||||
std::string bundleName = property != nullptr ? property->name : "default.inputmethod.unittest";
|
||||
TddUtil::SetTestTokenID(TddUtil::GetTestTokenID(bundleName));
|
||||
inputMethodAbility_ = InputMethodAbility::GetInstance();
|
||||
inputMethodAbility_->SetCoreAndAgent();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
auto currentIme = property != nullptr ? property->name : "default.inputmethod.unittest";
|
||||
currentImeTokenId_ = TddUtil::GetTestTokenID(currentIme);
|
||||
currentImeUid_ = TddUtil::GetUid(currentIme);
|
||||
auto ret = InputMethodController::GetInstance()->GetDefaultInputMethod(property);
|
||||
auto defaultIme = ret == ErrorCode::NO_ERROR ? property->name : "default.inputmethod.unittest";
|
||||
defaultImeTokenId_ = TddUtil::GetTestTokenID(defaultIme);
|
||||
{
|
||||
TokenScope scope(currentImeTokenId_);
|
||||
inputMethodAbility_ = InputMethodAbility::GetInstance();
|
||||
inputMethodAbility_->SetCoreAndAgent();
|
||||
}
|
||||
TextListener::ResetParam();
|
||||
TddUtil::InitWindow(true);
|
||||
imc_ = InputMethodController::GetInstance();
|
||||
@ -132,6 +132,7 @@ public:
|
||||
imc_->Close();
|
||||
TextListener::ResetParam();
|
||||
TddUtil::DestroyWindow();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
}
|
||||
void SetUp()
|
||||
{
|
||||
@ -166,6 +167,7 @@ public:
|
||||
}
|
||||
void CheckPanelInfoInHide(const std::shared_ptr<InputMethodPanel> &panel, const PanelStatusInfo &info)
|
||||
{
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = inputMethodAbility_->HidePanel(panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
if (info.panelInfo.panelFlag != FLG_CANDIDATE_COLUMN) {
|
||||
@ -192,6 +194,9 @@ sptr<OnTextChangedListener> InputMethodAbilityTest::textListener_;
|
||||
sptr<InputMethodAbility> InputMethodAbilityTest::inputMethodAbility_;
|
||||
uint32_t InputMethodAbilityTest::windowId_ = 0;
|
||||
int32_t InputMethodAbilityTest::security_ = -1;
|
||||
uint64_t InputMethodAbilityTest::currentImeTokenId_ = 0;
|
||||
uint64_t InputMethodAbilityTest::defaultImeTokenId_ = 0;
|
||||
int32_t InputMethodAbilityTest::currentImeUid_ = 0;
|
||||
|
||||
/**
|
||||
* @tc.name: testSerializedInputAttribute
|
||||
@ -571,7 +576,7 @@ HWTEST_F(InputMethodAbilityTest, testGetTextIndexAtCursor, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testCreatePanel001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest testCreatePanel001 START. You can not create two SOFT_KEYBOARD panel.");
|
||||
TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, "undefine"));
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
std::shared_ptr<InputMethodPanel> softKeyboardPanel1 = nullptr;
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, panelInfo, softKeyboardPanel1);
|
||||
@ -599,6 +604,7 @@ HWTEST_F(InputMethodAbilityTest, testCreatePanel001, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testCreatePanel002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest testCreatePanel002 START. You can not create two STATUS_BAR panel.");
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
std::shared_ptr<InputMethodPanel> statusBar1 = nullptr;
|
||||
PanelInfo panelInfo = { .panelType = STATUS_BAR };
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, panelInfo, statusBar1);
|
||||
@ -627,6 +633,7 @@ HWTEST_F(InputMethodAbilityTest, testCreatePanel003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest testCreatePanel006 START. Allowed to create one SOFT_KEYBOARD panel and "
|
||||
"one STATUS_BAR panel.");
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
std::shared_ptr<InputMethodPanel> softKeyboardPanel = nullptr;
|
||||
PanelInfo panelInfo1 = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, panelInfo1, softKeyboardPanel);
|
||||
@ -656,6 +663,7 @@ HWTEST_F(InputMethodAbilityTest, testCreatePanel004, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest testCreatePanel006 START. Allowed to create one SOFT_KEYBOARD panel and "
|
||||
"one STATUS_BAR panel.");
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
std::shared_ptr<InputMethodPanel> inputMethodPanel = nullptr;
|
||||
PanelInfo panelInfo1 = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, panelInfo1, inputMethodPanel);
|
||||
@ -691,7 +699,7 @@ HWTEST_F(InputMethodAbilityTest, testCreatePanel004, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testCreatePanel005, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest testCreatePanel005 START.");
|
||||
TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, "undefine"));
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
std::shared_ptr<InputMethodPanel> softKeyboardPanel1 = nullptr;
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, panelInfo, softKeyboardPanel1);
|
||||
@ -719,7 +727,7 @@ HWTEST_F(InputMethodAbilityTest, testCreatePanel005, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testCreatePanel006, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest testCreatePanel006 START.");
|
||||
TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, "undefine"));
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
std::shared_ptr<InputMethodPanel> softKeyboardPanel1 = nullptr;
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, panelInfo, softKeyboardPanel1);
|
||||
@ -780,6 +788,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyPanelStatusInfo_001, TestSize.Level0)
|
||||
imc_->Attach(textListener_);
|
||||
PanelInfo info = { .panelType = STATUS_BAR };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
auto panel1 = std::make_shared<InputMethodPanel>();
|
||||
@ -817,6 +826,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyPanelStatusInfo_002, TestSize.Level0)
|
||||
IMSA_HILOGI("InputMethodAbility testNotifyPanelStatusInfo_002 START");
|
||||
imc_->Attach(textListener_);
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -843,6 +853,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyPanelStatusInfo_003, TestSize.Level0)
|
||||
imc_->Attach(textListener_);
|
||||
PanelInfo info = { .panelType = STATUS_BAR };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
@ -868,6 +879,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyPanelStatusInfo_004, TestSize.Level0)
|
||||
imc_->Attach(textListener_);
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_CANDIDATE_COLUMN };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
@ -900,6 +912,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyPanelStatusInfo_005, TestSize.Level0)
|
||||
EXPECT_TRUE(TextListener::WaitSendKeyboardStatusCallback(KeyboardStatus::HIDE));
|
||||
EXPECT_FALSE(TextListener::WaitNotifyPanelStatusInfoCallback({ info, false, Trigger::IME_APP }));
|
||||
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -928,6 +941,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyKeyboardHeight_001, TestSize.Level0)
|
||||
IMSA_HILOGI("InputMethodAbility testNotifyKeyboardHeight_001 START");
|
||||
TextListener::ResetParam();
|
||||
imc_->Attach(textListener_);
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
@ -952,6 +966,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyKeyboardHeight_002, TestSize.Level0)
|
||||
IMSA_HILOGI("InputMethodAbility testNotifyKeyboardHeight_002 START");
|
||||
TextListener::ResetParam();
|
||||
imc_->Attach(textListener_);
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo info = { .panelType = STATUS_BAR, .panelFlag = FLG_FIXED };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
@ -976,6 +991,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyKeyboardHeight_003, TestSize.Level0)
|
||||
IMSA_HILOGI("InputMethodAbility testNotifyKeyboardHeight_003 START");
|
||||
TextListener::ResetParam();
|
||||
imc_->Attach(textListener_);
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_CANDIDATE_COLUMN };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
@ -999,6 +1015,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyKeyboardHeight_004, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testNotifyKeyboardHeight_004 START");
|
||||
TextListener::ResetParam();
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_CANDIDATE_COLUMN };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
@ -1021,6 +1038,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyKeyboardHeight_005, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testNotifyKeyboardHeight_005 START");
|
||||
TextListener::ResetParam();
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
auto ret = inputMethodAbility_->CreatePanel(nullptr, info, panel);
|
||||
@ -1060,8 +1078,8 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_001 Test START");
|
||||
TextListener::ResetParam();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
imc_->Close();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
auto ret = inputMethodAbility_->SendPrivateCommand(privateCommand);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NOT_DEFAULT_IME);
|
||||
@ -1078,8 +1096,7 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_002 Test START");
|
||||
TextListener::ResetParam();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
InputMethodAbilityTest::StubSelfAsDefault();
|
||||
TokenScope tokenScope(InputMethodAbilityTest::defaultImeTokenId_);
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = std::string("stringValue");
|
||||
privateCommand.insert({ "value1", privateDataValue1 });
|
||||
@ -1098,10 +1115,9 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSendPrivateCommand_003 Test START");
|
||||
TextListener::ResetParam();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
auto ret = imc_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodAbilityTest::StubSelfAsDefault();
|
||||
TokenScope tokenScope(InputMethodAbilityTest::defaultImeTokenId_);
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = std::string("stringValue");
|
||||
PrivateDataValue privateDataValue2 = true;
|
||||
@ -1112,7 +1128,6 @@ HWTEST_F(InputMethodAbilityTest, testSendPrivateCommand_003, TestSize.Level0)
|
||||
ret = inputMethodAbility_->SendPrivateCommand(privateCommand);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(TextListener::WaitSendPrivateCommandCallback(privateCommand));
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
imc_->Close();
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "key_event_util.h"
|
||||
#include "keyboard_listener.h"
|
||||
#include "message_parcel.h"
|
||||
#include "scope_utils.h"
|
||||
#include "system_ability.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "tdd_util.h"
|
||||
@ -117,7 +118,6 @@ public:
|
||||
static void CheckProxyObject();
|
||||
static void DispatchKeyEventCallback(std::shared_ptr<MMI::KeyEvent> &keyEvent, bool isConsumed);
|
||||
static bool WaitKeyEventCallback();
|
||||
static void SetDefaultIme();
|
||||
static void CheckTextConfig(const TextConfig &config);
|
||||
static sptr<InputMethodController> inputMethodController_;
|
||||
static sptr<InputMethodAbility> inputMethodAbility_;
|
||||
@ -148,6 +148,8 @@ public:
|
||||
static constexpr uint32_t DELAY_TIME = 1;
|
||||
static constexpr uint32_t KEY_EVENT_DELAY_TIME = 100;
|
||||
static constexpr int32_t TASK_DELAY_TIME = 10;
|
||||
static uint64_t defaultImeTokenId_;
|
||||
static uint64_t permissionTokenId_;
|
||||
|
||||
class KeyboardListenerImpl : public KeyboardListener {
|
||||
public:
|
||||
@ -251,6 +253,8 @@ std::condition_variable InputMethodControllerTest::keyEventCv_;
|
||||
std::mutex InputMethodControllerTest::keyEventLock_;
|
||||
bool InputMethodControllerTest::consumeResult_{ false };
|
||||
std::shared_ptr<AppExecFwk::EventHandler> InputMethodControllerTest::textConfigHandler_{ nullptr };
|
||||
uint64_t InputMethodControllerTest::defaultImeTokenId_ = 0;
|
||||
uint64_t InputMethodControllerTest::permissionTokenId_ = 0;
|
||||
|
||||
void InputMethodControllerTest::SetUpTestCase(void)
|
||||
{
|
||||
@ -259,9 +263,11 @@ void InputMethodControllerTest::SetUpTestCase(void)
|
||||
// Set the tokenID to the tokenID of the current ime
|
||||
std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
|
||||
std::string bundleName = property != nullptr ? property->name : "default.inputmethod.unittest";
|
||||
TddUtil::SetTestTokenID(TddUtil::GetTestTokenID(bundleName));
|
||||
inputMethodAbility_ = InputMethodAbility::GetInstance();
|
||||
inputMethodAbility_->SetCoreAndAgent();
|
||||
{
|
||||
TokenScope tokenScope(TddUtil::GetTestTokenID(bundleName));
|
||||
inputMethodAbility_ = InputMethodAbility::GetInstance();
|
||||
inputMethodAbility_->SetCoreAndAgent();
|
||||
}
|
||||
imeListener_ = std::make_shared<InputMethodEngineListenerImpl>();
|
||||
controllerListener_ = std::make_shared<SelectListenerMock>();
|
||||
textListener_ = new TextListener();
|
||||
@ -273,20 +279,24 @@ 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(true, "undefine", { "ohos.permission.CONNECT_IME_ABILITY" }));
|
||||
|
||||
TddUtil::InitWindow(true);
|
||||
SetInputDeathRecipient();
|
||||
TextListener::ResetParam();
|
||||
|
||||
auto ret = InputMethodController::GetInstance()->GetDefaultInputMethod(property);
|
||||
auto defaultIme = ret == ErrorCode::NO_ERROR ? property->name : "default.inputmethod.unittest";
|
||||
defaultImeTokenId_ = TddUtil::GetTestTokenID(defaultIme);
|
||||
permissionTokenId_ = TddUtil::AllocTestTokenID(false, "undefine", { "ohos.permission.CONNECT_IME_ABILITY" });
|
||||
}
|
||||
|
||||
void InputMethodControllerTest::TearDownTestCase(void)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodControllerTest::TearDownTestCase");
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
TextListener::ResetParam();
|
||||
TddUtil::DestroyWindow();
|
||||
inputMethodController_->SetControllerListener(nullptr);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
}
|
||||
|
||||
void InputMethodControllerTest::SetUp(void)
|
||||
@ -466,15 +476,6 @@ bool InputMethodControllerTest::WaitKeyEventCallback()
|
||||
return consumeResult_;
|
||||
}
|
||||
|
||||
void InputMethodControllerTest::SetDefaultIme()
|
||||
{
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
std::shared_ptr<Property> defaultImeProperty = std::make_shared<Property>();
|
||||
auto ret = InputMethodController::GetInstance()->GetDefaultInputMethod(defaultImeProperty);
|
||||
auto bundleName = ret == ErrorCode::NO_ERROR ? defaultImeProperty->name : "undefined";
|
||||
TddUtil::SetTestTokenID(TddUtil::AllocTestTokenID(true, bundleName, { "ohos.permission.CONNECT_IME_ABILITY" }));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testIMCAttach001
|
||||
* @tc.desc: IMC Attach.
|
||||
@ -784,6 +785,7 @@ HWTEST_F(InputMethodControllerTest, testShowTextInput, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testShowSoftKeyboard, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC ShowSoftKeyboard Test START");
|
||||
TokenScope scope(InputMethodControllerTest::permissionTokenId_);
|
||||
imeListener_->keyboardState_ = false;
|
||||
TextListener::ResetParam();
|
||||
int32_t ret = inputMethodController_->ShowSoftKeyboard();
|
||||
@ -863,6 +865,7 @@ HWTEST_F(InputMethodControllerTest, testOnEditorAttributeChanged, TestSize.Level
|
||||
HWTEST_F(InputMethodControllerTest, testHideSoftKeyboard, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC HideSoftKeyboard Test START");
|
||||
TokenScope scope(InputMethodControllerTest::permissionTokenId_);
|
||||
imeListener_->keyboardState_ = true;
|
||||
TextListener::ResetParam();
|
||||
int32_t ret = inputMethodController_->HideSoftKeyboard();
|
||||
@ -1131,7 +1134,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_001, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_002 Test START");
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
InputMethodEngineListenerImpl::ResetParam();
|
||||
inputMethodController_->Close();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
@ -1155,7 +1158,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_002, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_003 Test START");
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
InputMethodEngineListenerImpl::ResetParam();
|
||||
auto ret = inputMethodController_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -1177,7 +1180,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_003, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_004, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_004 Test START");
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
InputMethodEngineListenerImpl::ResetParam();
|
||||
auto ret = inputMethodController_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -1204,7 +1207,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_004, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_005, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_005 Test START");
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
InputMethodEngineListenerImpl::ResetParam();
|
||||
auto ret = inputMethodController_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -1231,7 +1234,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_005, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_006, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_006 Test START");
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
InputMethodEngineListenerImpl::ResetParam();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand;
|
||||
PrivateDataValue privateDataValue1 = std::string("stringValue");
|
||||
@ -1259,7 +1262,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_006, TestSize.Level0)
|
||||
HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_007, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_007 Test START");
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
TextListener::ResetParam();
|
||||
auto ret = inputMethodController_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -1284,7 +1287,7 @@ HWTEST_F(InputMethodControllerTest, testSendPrivateCommand_008, TestSize.Level0)
|
||||
IMSA_HILOGI("IMC testSendPrivateCommand_008 Test START");
|
||||
auto ret = inputMethodController_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodControllerTest::SetDefaultIme();
|
||||
TokenScope scope(InputMethodControllerTest::defaultImeTokenId_);
|
||||
TextListener::ResetParam();
|
||||
std::unordered_map<std::string, PrivateDataValue> privateCommand1{ { "v",
|
||||
string(PRIVATE_COMMAND_SIZE_MAX - 2, 'a') } };
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "input_method_controller.h"
|
||||
#include "input_method_engine_listener_impl.h"
|
||||
#include "panel_status_listener.h"
|
||||
#include "scope_utils.h"
|
||||
#include "tdd_util.h"
|
||||
#include "text_listener.h"
|
||||
|
||||
@ -48,15 +49,22 @@ public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
static std::shared_ptr<InputMethodPanel> CreatePanel();
|
||||
static void DestroyPanel(const std::shared_ptr<InputMethodPanel> &panel);
|
||||
static void Attach();
|
||||
static void InitPanel();
|
||||
static void ClearPanel();
|
||||
static void TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
static void TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
static bool TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
static bool TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
static void ImaCreatePanel(const PanelInfo &info, std::shared_ptr<InputMethodPanel> &panel);
|
||||
static void ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> &panel);
|
||||
static void ImcPanelListeningTestRestore();
|
||||
static void ImcPanelShowNumCheck(uint32_t num);
|
||||
static void ImcPanelHideNumCheck(uint32_t num);
|
||||
static void ImcPanelShowInfoCheck(const InputWindowInfo &windowInfo);
|
||||
static void ImcPanelHideInfoCheck(const InputWindowInfo &windowInfo);
|
||||
static void TestShowPanel(const std::shared_ptr<InputMethodPanel> &panel);
|
||||
static void TestHidePanel(const std::shared_ptr<InputMethodPanel> &panel);
|
||||
static void TestIsPanelShown(const PanelInfo &info, bool expectedResult);
|
||||
class PanelStatusListenerImpl : public PanelStatusListener {
|
||||
public:
|
||||
PanelStatusListenerImpl()
|
||||
@ -67,8 +75,14 @@ public:
|
||||
~PanelStatusListenerImpl() = default;
|
||||
void OnPanelStatus(uint32_t windowId, bool isShow)
|
||||
{
|
||||
showPanel_ = isShow;
|
||||
hidePanel_ = !isShow;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(InputMethodPanelTest::panelListenerLock_);
|
||||
if (isShow) {
|
||||
InputMethodPanelTest::status_ = InputWindowStatus::SHOW;
|
||||
} else {
|
||||
InputMethodPanelTest::status_ = InputWindowStatus::HIDE;
|
||||
}
|
||||
}
|
||||
InputMethodPanelTest::panelListenerCv_.notify_one();
|
||||
IMSA_HILOGI("PanelStatusListenerImpl OnPanelStatus in, isShow is %{public}s", isShow ? "true" : "false");
|
||||
}
|
||||
@ -84,14 +98,14 @@ public:
|
||||
static sptr<InputMethodAbility> ima_;
|
||||
static uint32_t windowWidth_;
|
||||
static uint32_t windowHeight_;
|
||||
static bool showPanel_;
|
||||
static bool hidePanel_;
|
||||
static std::condition_variable panelListenerCv_;
|
||||
static std::mutex panelListenerLock_;
|
||||
static constexpr uint32_t DELAY_TIME = 100;
|
||||
static constexpr int32_t INTERVAL = 10;
|
||||
static std::shared_ptr<AppExecFwk::EventHandler> panelHandler_;
|
||||
static uint64_t testTokenId_;
|
||||
static uint64_t sysTokenId_;
|
||||
static int32_t currentImeUid_;
|
||||
static uint64_t currentImeTokenId_;
|
||||
static sptr<OnTextChangedListener> textListener_;
|
||||
static std::shared_ptr<InputMethodEngineListener> imeListener_;
|
||||
static std::shared_ptr<InputMethodPanel> inputMethodPanel_;
|
||||
@ -120,8 +134,6 @@ public:
|
||||
InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
|
||||
}
|
||||
};
|
||||
bool InputMethodPanelTest::showPanel_ = false;
|
||||
bool InputMethodPanelTest::hidePanel_ = false;
|
||||
std::condition_variable InputMethodPanelTest::panelListenerCv_;
|
||||
std::mutex InputMethodPanelTest::panelListenerLock_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> InputMethodPanelTest::panelHandler_{ nullptr };
|
||||
@ -135,7 +147,9 @@ sptr<InputMethodController> InputMethodPanelTest::imc_{ nullptr };
|
||||
sptr<InputMethodAbility> InputMethodPanelTest::ima_{ nullptr };
|
||||
uint32_t InputMethodPanelTest::windowWidth_ = 0;
|
||||
uint32_t InputMethodPanelTest::windowHeight_ = 0;
|
||||
uint64_t InputMethodPanelTest::testTokenId_ = 0;
|
||||
uint64_t InputMethodPanelTest::sysTokenId_ = 0;
|
||||
uint64_t InputMethodPanelTest::currentImeTokenId_ = 0;
|
||||
int32_t InputMethodPanelTest::currentImeUid_ = 0;
|
||||
sptr<OnTextChangedListener> InputMethodPanelTest::textListener_{ nullptr };
|
||||
std::shared_ptr<InputMethodEngineListener> InputMethodPanelTest::imeListener_{ nullptr };
|
||||
std::shared_ptr<InputMethodPanel> InputMethodPanelTest::inputMethodPanel_{ nullptr };
|
||||
@ -145,7 +159,6 @@ void InputMethodPanelTest::SetUpTestCase(void)
|
||||
IMSA_HILOGI("InputMethodPanelTest::SetUpTestCase");
|
||||
// storage current token id
|
||||
TddUtil::StorageSelfTokenID();
|
||||
ima_ = InputMethodAbility::GetInstance();
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
imc_ = InputMethodController::GetInstance();
|
||||
textListener_ = new (std::nothrow) TextListener();
|
||||
@ -153,7 +166,15 @@ void InputMethodPanelTest::SetUpTestCase(void)
|
||||
// set token as current input method
|
||||
std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
|
||||
std::string bundleName = property != nullptr ? property->name : "default.inputmethod.unittest";
|
||||
testTokenId_ = TddUtil::AllocTestTokenID(true, bundleName, {});
|
||||
currentImeTokenId_ = TddUtil::GetTestTokenID(bundleName);
|
||||
currentImeUid_ = TddUtil::GetUid(bundleName);
|
||||
sysTokenId_ = TddUtil::AllocTestTokenID(true, "undefined", {});
|
||||
{
|
||||
TokenScope tokenScope(currentImeTokenId_);
|
||||
ima_ = InputMethodAbility::GetInstance();
|
||||
ima_->SetCoreAndAgent();
|
||||
InputMethodPanelTest::ima_->SetImeListener(imeListener_);
|
||||
}
|
||||
InitPanel();
|
||||
}
|
||||
|
||||
@ -161,6 +182,8 @@ void InputMethodPanelTest::TearDownTestCase(void)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::TearDownTestCase");
|
||||
ClearPanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
TddUtil::KillImsaProcess();
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::SetUp(void)
|
||||
@ -176,6 +199,7 @@ void InputMethodPanelTest::TearDown(void)
|
||||
|
||||
std::shared_ptr<InputMethodPanel> InputMethodPanelTest::CreatePanel()
|
||||
{
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
@ -183,10 +207,39 @@ std::shared_ptr<InputMethodPanel> InputMethodPanelTest::CreatePanel()
|
||||
return inputMethodPanel;
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::DestroyPanel(const std::shared_ptr<InputMethodPanel> &panel)
|
||||
{
|
||||
ASSERT_NE(panel, nullptr);
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = panel->DestroyPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::ImaCreatePanel(const PanelInfo &info, std::shared_ptr<InputMethodPanel> &panel)
|
||||
{
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = ima_->CreatePanel(nullptr, info, panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> &panel)
|
||||
{
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = ima_->DestroyPanel(panel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::Attach()
|
||||
{
|
||||
TddUtil::InitWindow(true);
|
||||
auto ret = imc_->Attach(textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::InitPanel()
|
||||
{
|
||||
IMSA_HILOGI("start");
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
inputMethodPanel_ = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo info = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodPanel_->CreatePanel(nullptr, info);
|
||||
@ -202,8 +255,6 @@ void InputMethodPanelTest::InitPanel()
|
||||
info = { .panelType = STATUS_BAR };
|
||||
ret = inputMethodStatusBar_->CreatePanel(nullptr, info);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
IMSA_HILOGI("end");
|
||||
}
|
||||
|
||||
@ -213,28 +264,31 @@ void InputMethodPanelTest::ClearPanel()
|
||||
IMSA_HILOGD("nullptr");
|
||||
return;
|
||||
}
|
||||
AccessScope(currentImeTokenId_, currentImeUid_);
|
||||
inputMethodPanel_->DestroyPanel();
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
bool InputMethodPanelTest::TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
{
|
||||
panelHandler_->PostTask([&inputMethodPanel]() { inputMethodPanel->ShowPanel(); }, InputMethodPanelTest::INTERVAL);
|
||||
IMSA_HILOGI("start");
|
||||
status_ = InputWindowStatus::NONE;
|
||||
panelHandler_->PostTask([&inputMethodPanel]() { TestShowPanel(inputMethodPanel); }, InputMethodPanelTest::INTERVAL);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(InputMethodPanelTest::panelListenerLock_);
|
||||
InputMethodPanelTest::panelListenerCv_.wait_for(lock,
|
||||
std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME),
|
||||
[] { return InputMethodPanelTest::showPanel_; });
|
||||
std::unique_lock<std::mutex> lock(panelListenerLock_);
|
||||
return panelListenerCv_.wait_for(lock, std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME),
|
||||
[] { return status_ == InputWindowStatus::SHOW; });
|
||||
}
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
bool InputMethodPanelTest::TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
{
|
||||
panelHandler_->PostTask([&inputMethodPanel]() { inputMethodPanel->HidePanel(); }, InputMethodPanelTest::INTERVAL);
|
||||
IMSA_HILOGI("start");
|
||||
status_ = InputWindowStatus::NONE;
|
||||
panelHandler_->PostTask([&inputMethodPanel]() { TestHidePanel(inputMethodPanel); }, InputMethodPanelTest::INTERVAL);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(InputMethodPanelTest::panelListenerLock_);
|
||||
InputMethodPanelTest::panelListenerCv_.wait_for(lock,
|
||||
std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME),
|
||||
[] { return InputMethodPanelTest::hidePanel_; });
|
||||
std::unique_lock<std::mutex> lock(panelListenerLock_);
|
||||
return panelListenerCv_.wait_for(lock, std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME),
|
||||
[] { return status_ == InputWindowStatus::HIDE; });
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,6 +354,34 @@ void InputMethodPanelTest::ImcPanelListeningTestRestore()
|
||||
imeHideCallbackNum_ = 0;
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::TestShowPanel(const std::shared_ptr<InputMethodPanel> &panel)
|
||||
{
|
||||
ASSERT_NE(panel, nullptr);
|
||||
// set tokenId as current ime
|
||||
TokenScope scope(currentImeTokenId_);
|
||||
auto ret = panel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::TestHidePanel(const std::shared_ptr<InputMethodPanel> &panel)
|
||||
{
|
||||
ASSERT_NE(panel, nullptr);
|
||||
// set tokenId and uid as current ime
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto ret = panel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::TestIsPanelShown(const PanelInfo &info, bool expectedResult)
|
||||
{
|
||||
// set tokenId as system app
|
||||
TokenScope scope(sysTokenId_);
|
||||
bool result = !expectedResult;
|
||||
auto ret = imc_->IsPanelShown(info, result);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(result, expectedResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testCreatePanel
|
||||
* @tc.desc: Test CreatePanel.
|
||||
@ -308,6 +390,7 @@ void InputMethodPanelTest::ImcPanelListeningTestRestore()
|
||||
HWTEST_F(InputMethodPanelTest, testCreatePanel, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testCreatePanel start.");
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
@ -343,6 +426,7 @@ HWTEST_F(InputMethodPanelTest, testResizePanel001, TestSize.Level0)
|
||||
auto ret = inputMethodPanel->Resize(1, 1);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -384,6 +468,7 @@ HWTEST_F(InputMethodPanelTest, testResizePanel002, TestSize.Level0)
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
@ -423,6 +508,7 @@ HWTEST_F(InputMethodPanelTest, testMovePanel, TestSize.Level0)
|
||||
auto ret = inputMethodPanel->MoveTo(10, 100);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -460,6 +546,9 @@ HWTEST_F(InputMethodPanelTest, testShowPanel, TestSize.Level0)
|
||||
// 0、not create panel, show panel failed.
|
||||
auto ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
// 1 create panel, show success
|
||||
AccessScope scope(currentImeTokenId_, currentImeUid_);
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = inputMethodPanel->ShowPanel();
|
||||
@ -501,35 +590,20 @@ HWTEST_F(InputMethodPanelTest, testShowPanel, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testIsPanelShown_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_001 start.");
|
||||
TddUtil::SetTestTokenID(InputMethodPanelTest::testTokenId_);
|
||||
TddUtil::InitWindow(true);
|
||||
InputMethodPanelTest::ima_->SetImeListener(InputMethodPanelTest::imeListener_);
|
||||
int32_t ret = ima_->SetCoreAndAgent();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = InputMethodPanelTest::imc_->Attach(InputMethodPanelTest::textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
bool isShown = false;
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
InputMethodPanelTest::Attach();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
ret = ima_->CreatePanel(nullptr, panelInfo, inputMethodPanel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
|
||||
|
||||
// query when fixed soft keyboard is showing
|
||||
ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = imc_->IsPanelShown(panelInfo, isShown);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(isShown);
|
||||
InputMethodPanelTest::TestShowPanel(inputMethodPanel);
|
||||
InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
|
||||
|
||||
// query when fixed soft keyboard is hidden
|
||||
ret = inputMethodPanel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = imc_->IsPanelShown(panelInfo, isShown);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_FALSE(isShown);
|
||||
InputMethodPanelTest::TestHidePanel(inputMethodPanel);
|
||||
InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
|
||||
|
||||
ret = ima_->DestroyPanel(inputMethodPanel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
|
||||
InputMethodPanelTest::imc_->Close();
|
||||
TddUtil::DestroyWindow();
|
||||
}
|
||||
@ -542,36 +616,22 @@ HWTEST_F(InputMethodPanelTest, testIsPanelShown_001, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testIsPanelShown_002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_002 start.");
|
||||
TddUtil::SetTestTokenID(InputMethodPanelTest::testTokenId_);
|
||||
TddUtil::InitWindow(true);
|
||||
InputMethodPanelTest::ima_->SetImeListener(InputMethodPanelTest::imeListener_);
|
||||
int32_t ret = ima_->SetCoreAndAgent();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = InputMethodPanelTest::imc_->Attach(InputMethodPanelTest::textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
bool isShown = false;
|
||||
InputMethodPanelTest::Attach();
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
ret = ima_->CreatePanel(nullptr, panelInfo, inputMethodPanel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
|
||||
|
||||
// query panel with old info when panel changes its flag.
|
||||
ret = imc_->IsPanelShown(panelInfo, isShown);
|
||||
auto ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_FALSE(isShown);
|
||||
InputMethodPanelTest::TestShowPanel(inputMethodPanel);
|
||||
InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
|
||||
|
||||
// query panel with updated shown one's info when panel changes its flag.
|
||||
panelInfo.panelFlag = PanelFlag::FLG_FLOATING;
|
||||
ret = imc_->IsPanelShown(panelInfo, isShown);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(isShown);
|
||||
InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
|
||||
|
||||
ret = ima_->DestroyPanel(inputMethodPanel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
|
||||
InputMethodPanelTest::imc_->Close();
|
||||
TddUtil::DestroyWindow();
|
||||
}
|
||||
@ -584,35 +644,20 @@ HWTEST_F(InputMethodPanelTest, testIsPanelShown_002, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testIsPanelShown_003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_003 start.");
|
||||
TddUtil::SetTestTokenID(InputMethodPanelTest::testTokenId_);
|
||||
TddUtil::InitWindow(true);
|
||||
InputMethodPanelTest::ima_->SetImeListener(InputMethodPanelTest::imeListener_);
|
||||
int32_t ret = ima_->SetCoreAndAgent();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = InputMethodPanelTest::imc_->Attach(InputMethodPanelTest::textListener_, false);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
bool isShown = false;
|
||||
InputMethodPanelTest::Attach();
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = STATUS_BAR };
|
||||
ret = ima_->CreatePanel(nullptr, panelInfo, inputMethodPanel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
|
||||
|
||||
// query status bar's status when it is showing
|
||||
ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = imc_->IsPanelShown(panelInfo, isShown);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_TRUE(isShown);
|
||||
InputMethodPanelTest::TestShowPanel(inputMethodPanel);
|
||||
InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
|
||||
|
||||
// query status bar's status when it is hidden
|
||||
ret = inputMethodPanel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
ret = imc_->IsPanelShown(panelInfo, isShown);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_FALSE(isShown);
|
||||
InputMethodPanelTest::TestHidePanel(inputMethodPanel);
|
||||
InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
|
||||
|
||||
ret = ima_->DestroyPanel(inputMethodPanel);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
|
||||
InputMethodPanelTest::imc_->Close();
|
||||
TddUtil::DestroyWindow();
|
||||
}
|
||||
@ -628,22 +673,18 @@ HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener, TestSize.Level0)
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
|
||||
// on('show')->on('hide')->show->hide
|
||||
std::string type = "show";
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, type);
|
||||
type = "hide";
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, type);
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "show");
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
|
||||
|
||||
AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
InputMethodPanelTest::TriggerShowCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(InputMethodPanelTest::showPanel_);
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
|
||||
|
||||
InputMethodPanelTest::TriggerHideCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(InputMethodPanelTest::hidePanel_);
|
||||
ret = inputMethodPanel->DestroyPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -654,6 +695,7 @@ HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testGetPanelType, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testGetPanelType start.");
|
||||
AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
@ -672,6 +714,7 @@ HWTEST_F(InputMethodPanelTest, testGetPanelType, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testGetPanelFlag, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testGetPanelFlag start.");
|
||||
AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
@ -696,6 +739,7 @@ HWTEST_F(InputMethodPanelTest, testGetPanelFlag, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testChangePanelFlag, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testChangePanelFlag start.");
|
||||
AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelFlag flag = FLG_FLOATING;
|
||||
|
||||
@ -737,25 +781,19 @@ HWTEST_F(InputMethodPanelTest, testClearPanelListener, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testClearPanelListener start.");
|
||||
auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
|
||||
auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "show");
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
|
||||
|
||||
std::string subscribeType = "show";
|
||||
inputMethodPanel->ClearPanelListener(subscribeType);
|
||||
InputMethodPanelTest::TriggerShowCallback(inputMethodPanel);
|
||||
EXPECT_EQ(InputMethodPanelTest::showPanel_, false);
|
||||
InputMethodPanelTest::TriggerHideCallback(inputMethodPanel);
|
||||
EXPECT_EQ(InputMethodPanelTest::hidePanel_, true);
|
||||
InputMethodPanelTest::hidePanel_ = false;
|
||||
inputMethodPanel->ClearPanelListener("show");
|
||||
EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
|
||||
|
||||
subscribeType = "hide";
|
||||
inputMethodPanel->ClearPanelListener(subscribeType);
|
||||
inputMethodPanel->ClearPanelListener("hide");
|
||||
EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
|
||||
EXPECT_FALSE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
|
||||
|
||||
InputMethodPanelTest::TriggerShowCallback(inputMethodPanel);
|
||||
EXPECT_EQ(InputMethodPanelTest::showPanel_, false);
|
||||
InputMethodPanelTest::TriggerHideCallback(inputMethodPanel);
|
||||
EXPECT_EQ(InputMethodPanelTest::hidePanel_, false);
|
||||
|
||||
auto ret = inputMethodPanel->DestroyPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::DestroyPanel(inputMethodPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -770,33 +808,19 @@ HWTEST_F(InputMethodPanelTest, testRegisterListener, TestSize.Level0)
|
||||
auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
|
||||
|
||||
auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
|
||||
std::string type = "show";
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, type);
|
||||
type = "hide";
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, type);
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "show");
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
|
||||
|
||||
InputMethodPanelTest::TriggerShowCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(InputMethodPanelTest::showPanel_);
|
||||
inputMethodPanel->ClearPanelListener("show");
|
||||
EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
|
||||
|
||||
InputMethodPanelTest::TriggerHideCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(InputMethodPanelTest::hidePanel_);
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, "show");
|
||||
EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
|
||||
|
||||
type = "show";
|
||||
inputMethodPanel->ClearPanelListener(type);
|
||||
|
||||
InputMethodPanelTest::TriggerShowCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(!InputMethodPanelTest::showPanel_);
|
||||
|
||||
InputMethodPanelTest::TriggerHideCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(InputMethodPanelTest::hidePanel_);
|
||||
|
||||
inputMethodPanel->SetPanelStatusListener(statusListener, type);
|
||||
|
||||
InputMethodPanelTest::TriggerShowCallback(inputMethodPanel);
|
||||
EXPECT_TRUE(InputMethodPanelTest::showPanel_);
|
||||
|
||||
auto ret = inputMethodPanel->DestroyPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::DestroyPanel(inputMethodPanel);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -807,35 +831,29 @@ HWTEST_F(InputMethodPanelTest, testRegisterListener, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_001 start.");
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
InputWindowInfo info{ "", 0, 0, InputMethodPanelTest::windowWidth_, InputMethodPanelTest::windowHeight_ };
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(1);
|
||||
InputMethodPanelTest::ImcPanelShowInfoCheck(info);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(1);
|
||||
InputMethodPanelTest::ImcPanelHideInfoCheck(info);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -846,36 +864,30 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_002 start.");
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
InputWindowInfo info{ "", 0, 0, InputMethodPanelTest::windowWidth_, InputMethodPanelTest::windowHeight_ };
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_FLOATING;
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(1);
|
||||
InputMethodPanelTest::ImcPanelShowInfoCheck(info);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(1);
|
||||
InputMethodPanelTest::ImcPanelHideInfoCheck(info);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_FIXED;
|
||||
}
|
||||
|
||||
@ -887,33 +899,27 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_003 start.");
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_CANDIDATE_COLUMN;
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(0);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(0);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
InputMethodPanelTest::inputMethodPanel_->panelFlag_ = FLG_FIXED;
|
||||
}
|
||||
|
||||
@ -925,32 +931,26 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_004 start.");
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto ret = InputMethodPanelTest::inputMethodStatusBar_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodStatusBar_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(0);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodStatusBar_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodStatusBar_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(0);
|
||||
// set system app
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel system app
|
||||
{
|
||||
// set system app
|
||||
TokenScope tokenScope(InputMethodPanelTest::sysTokenId_);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener);
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -973,18 +973,13 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_005, TestSize.Level0)
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener3);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
auto ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(3);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(2);
|
||||
|
||||
// set native sa
|
||||
@ -1015,22 +1010,17 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_006, TestSize.Level0)
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_HIDE_MASK, listener1);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener2);
|
||||
ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK, listener3);
|
||||
// UnRegister one IME_SHOW listener
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_SHOW_MASK, listener1);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
// UnRegister one IME_SHOW listener
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(2);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(1);
|
||||
|
||||
// UnRegister all listener
|
||||
@ -1041,18 +1031,13 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_006, TestSize.Level0)
|
||||
ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(EVENT_IME_HIDE_MASK, listener1);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(0);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(0);
|
||||
}
|
||||
|
||||
@ -1071,17 +1056,11 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_007, TestSize.Level0)
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
auto ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(1);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(1);
|
||||
|
||||
// UnRegister all listener
|
||||
@ -1091,18 +1070,13 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_007, TestSize.Level0)
|
||||
EVENT_IME_HIDE_MASK | EVENT_IME_SHOW_MASK, listener);
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel native sa
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestShowPanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelShowNumCheck(0);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore();
|
||||
// set current ime
|
||||
TddUtil::SetTestTokenID(testTokenId_);
|
||||
ret = InputMethodPanelTest::inputMethodPanel_->HidePanel();
|
||||
TddUtil::RestoreSelfTokenID();
|
||||
// cancel current ime
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::TestHidePanel(InputMethodPanelTest::inputMethodPanel_);
|
||||
InputMethodPanelTest::ImcPanelHideNumCheck(0);
|
||||
}
|
||||
|
||||
@ -1114,6 +1088,7 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_007, TestSize.Level0)
|
||||
HWTEST_F(InputMethodPanelTest, testSetCallingWindow, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testSetCallingWindow start.");
|
||||
AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
// not CreatePanel, SetCallingWindow failed
|
||||
uint32_t windowId = 8;
|
||||
@ -1126,6 +1101,9 @@ HWTEST_F(InputMethodPanelTest, testSetCallingWindow, TestSize.Level0)
|
||||
|
||||
ret = inputMethodPanel->SetCallingWindow(windowId);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
ret = inputMethodPanel->DestroyPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
Loading…
x
Reference in New Issue
Block a user