mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-24 07:09:58 +00:00
!727 增加服务侧接口PanelStatusChange调用权限校验+新增tdd用例
Merge pull request !727 from cy7717/master
This commit is contained in:
commit
ea7f0bc57a
@ -113,14 +113,14 @@ int32_t InputMethodPanel::Resize(uint32_t width, uint32_t height)
|
||||
|
||||
int32_t InputMethodPanel::MoveTo(int32_t x, int32_t y)
|
||||
{
|
||||
if (panelType_ == SOFT_KEYBOARD && panelFlag_ == FLG_FIXED) {
|
||||
IMSA_HILOGE("FLG_FIXED panel can not moveTo.");
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
if (window_ == nullptr) {
|
||||
IMSA_HILOGE("window_ is nullptr.");
|
||||
return ErrorCode::ERROR_NULL_POINTER;
|
||||
}
|
||||
if (panelType_ == SOFT_KEYBOARD && panelFlag_ == FLG_FIXED) {
|
||||
IMSA_HILOGE("FLG_FIXED panel can not moveTo.");
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
auto ret = window_->MoveTo(x, y);
|
||||
if (ret != WMError::WM_OK) {
|
||||
return ErrorCode::ERROR_OPERATE_PANEL;
|
||||
|
@ -320,6 +320,15 @@ int32_t InputMethodSystemAbility::ShowCurrentInput()
|
||||
|
||||
int32_t InputMethodSystemAbility::PanelStatusChange(const InputWindowStatus &status, const InputWindowInfo &windowInfo)
|
||||
{
|
||||
auto currentImeCfg = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId_);
|
||||
if (currentImeCfg == nullptr) {
|
||||
IMSA_HILOGE("failed to get current ime");
|
||||
return ErrorCode::ERROR_NULL_POINTER;
|
||||
}
|
||||
if (!BundleChecker::IsCurrentIme(IPCSkeleton::GetCallingTokenID(), currentImeCfg->bundleName)) {
|
||||
IMSA_HILOGE("not current ime");
|
||||
return ErrorCode::ERROR_NOT_CURRENT_IME;
|
||||
}
|
||||
return userSession_->OnPanelStatusChange(status, windowInfo);
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,7 @@ ohos_unittest("InputMethodPanelTest") {
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"input:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
"os_account:os_account_innerkits",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
@ -134,6 +134,52 @@ HWTEST_F(InputMethodAbilityExceptionTest, testSendFunctionKeyException, TestSize
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSendExtendActionException
|
||||
* @tc.desc: InputMethodAbility SendExtendAction
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityExceptionTest, testSendExtendActionException, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityExceptionTest SendExtendAction Test START");
|
||||
constexpr int32_t action = 1;
|
||||
auto ret = inputMethodAbility_->SendExtendAction(action);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSelectByRangeException
|
||||
* @tc.desc: InputMethodAbility SelectByRange
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityExceptionTest, testSelectByRangeException, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityExceptionTest testSelectByRange START");
|
||||
constexpr int32_t start = 1;
|
||||
constexpr int32_t end = 2;
|
||||
auto ret = inputMethodAbility_->SelectByRange(start, end);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSelectByMovementException
|
||||
* @tc.desc: InputMethodAbility SelectByMovement
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityExceptionTest, testSelectByMovementException, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityExceptionTest testSelectByMovement START");
|
||||
constexpr int32_t direction = 1;
|
||||
auto ret = inputMethodAbility_->SelectByMovement(direction);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testDeleteExceptionText
|
||||
* @tc.desc: InputMethodAbility DeleteForward & DeleteBackward
|
||||
@ -189,5 +235,21 @@ HWTEST_F(InputMethodAbilityExceptionTest, testGetEnterKeyTypeException, TestSize
|
||||
ret = inputMethodAbility_->GetInputPattern(inputPattern);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_CLIENT_NULL_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testDispatchKeyEventException
|
||||
* @tc.desc: DispatchKeyEvent Exception
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityExceptionTest, testDispatchKeyEventException, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityExceptionTest DispatchKeyEvent START");
|
||||
int32_t keyCode = 2011;
|
||||
int32_t keyStatus = 2;
|
||||
auto ret = inputMethodAbility_->DispatchKeyEvent(keyCode, keyStatus);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
static int selectionStart_;
|
||||
static int selectionEnd_;
|
||||
static int selectionDirection_;
|
||||
static int32_t action_;
|
||||
static constexpr int CURSOR_DIRECTION_BASE_VALUE = 2011;
|
||||
static sptr<InputMethodController> imc_;
|
||||
static sptr<InputMethodAbility> inputMethodAbility_;
|
||||
@ -165,6 +166,9 @@ public:
|
||||
|
||||
void HandleExtendAction(int32_t action) override
|
||||
{
|
||||
action_ = action;
|
||||
InputMethodAbilityTest::textListenerCv_.notify_one();
|
||||
IMSA_HILOGI("HandleExtendAction, action_: %{public}d", action_);
|
||||
}
|
||||
|
||||
void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override
|
||||
@ -266,6 +270,7 @@ bool InputMethodAbilityTest::status_;
|
||||
int InputMethodAbilityTest::selectionStart_ = -1;
|
||||
int InputMethodAbilityTest::selectionEnd_ = -1;
|
||||
int InputMethodAbilityTest::selectionDirection_ = 0;
|
||||
int32_t InputMethodAbilityTest::action_ = 0;
|
||||
sptr<InputMethodController> InputMethodAbilityTest::imc_;
|
||||
sptr<InputMethodAbility> InputMethodAbilityTest::inputMethodAbility_;
|
||||
uint64_t InputMethodAbilityTest::selfTokenID_ = 0;
|
||||
@ -415,6 +420,25 @@ HWTEST_F(InputMethodAbilityTest, testSendFunctionKey, TestSize.Level0)
|
||||
EXPECT_EQ(InputMethodAbilityTest::key_, funcKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSendExtendAction
|
||||
* @tc.desc: InputMethodAbility SendExtendAction
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, testSendExtendAction, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility SendExtendAction Test START");
|
||||
constexpr int32_t action = 1;
|
||||
auto ret = inputMethodAbility_->SendExtendAction(action);
|
||||
std::unique_lock<std::mutex> lock(InputMethodAbilityTest::textListenerCallbackLock_);
|
||||
InputMethodAbilityTest::textListenerCv_.wait_for(
|
||||
lock, std::chrono::seconds(DEALY_TIME), [] { return InputMethodAbilityTest::action_ == action; });
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
EXPECT_EQ(InputMethodAbilityTest::action_, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testDeleteText
|
||||
* @tc.desc: InputMethodAbility DeleteForward & DeleteBackward
|
||||
@ -468,15 +492,15 @@ HWTEST_F(InputMethodAbilityTest, testGetEnterKeyType, TestSize.Level0)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSelectByRange
|
||||
* @tc.name: testSelectByRange_001
|
||||
* @tc.desc: InputMethodAbility SelectByRange
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: Zhaolinglan
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, testSelectByRange, TestSize.Level0)
|
||||
HWTEST_F(InputMethodAbilityTest, testSelectByRange_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSelectByRange START");
|
||||
IMSA_HILOGI("InputMethodAbility testSelectByRange_001 START");
|
||||
constexpr int32_t start = 1;
|
||||
constexpr int32_t end = 2;
|
||||
auto ret = inputMethodAbility_->SelectByRange(start, end);
|
||||
@ -489,6 +513,27 @@ HWTEST_F(InputMethodAbilityTest, testSelectByRange, TestSize.Level0)
|
||||
EXPECT_EQ(InputMethodAbilityTest::selectionEnd_, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSelectByRange_002
|
||||
* @tc.desc: InputMethodAbility SelectByRange
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, testSelectByRange_002, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility testSelectByRange_002 START");
|
||||
int32_t start = -2;
|
||||
int32_t end = 2;
|
||||
auto ret = inputMethodAbility_->SelectByRange(start, end);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
start = 2;
|
||||
end = -2;
|
||||
ret = inputMethodAbility_->SelectByRange(start, end);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSelectByMovement
|
||||
* @tc.desc: InputMethodAbility SelectByMovement
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "display_manager.h"
|
||||
#include "global.h"
|
||||
#include "input_method_controller.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "panel_status_listener.h"
|
||||
#include "token_setproc.h"
|
||||
|
||||
@ -32,7 +33,9 @@ using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::AccountSA;
|
||||
constexpr uint32_t IMC_WAIT_PANEL_STATUS_LISTEN_TIME = 200;
|
||||
constexpr int32_t MAIN_USER_ID = 100;
|
||||
enum ListeningStatus : uint32_t { ON, OFF, NONE };
|
||||
class InputMethodPanelTest : public testing::Test {
|
||||
public:
|
||||
@ -44,14 +47,15 @@ public:
|
||||
static void TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
static void TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
static void RestoreSelfTokenID();
|
||||
static void AllocTestTokenID();
|
||||
static void AllocTestTokenID(const std::string &bundleName);
|
||||
static void SetTestTokenID();
|
||||
static void ImcPanelListeningTestCheck(
|
||||
InputWindowStatus realStatus, InputWindowStatus waitStatus, const InputWindowInfo &windowInfo);
|
||||
static void ImcPanelListeningTestCheck(InputWindowStatus realStatus, InputWindowStatus waitStatus);
|
||||
static void ImcPanelListeningTestPrepare(
|
||||
std::shared_ptr<InputMethodPanel> inputMethodPanel, const PanelInfo &info, ListeningStatus status);
|
||||
const std::shared_ptr<InputMethodPanel> &inputMethodPanel, const PanelInfo &info, ListeningStatus status);
|
||||
static void ImcPanelListeningTestRestore(InputWindowStatus status);
|
||||
static void ImcPanelListeningTestClear(const std::shared_ptr<InputMethodPanel> &inputMethodPanel);
|
||||
class PanelStatusListenerImpl : public PanelStatusListener {
|
||||
public:
|
||||
PanelStatusListenerImpl()
|
||||
@ -120,7 +124,10 @@ uint64_t InputMethodPanelTest::testTokenIdEx_ = 0;
|
||||
void InputMethodPanelTest::SetUpTestCase(void)
|
||||
{
|
||||
selfTokenId_ = GetSelfTokenID();
|
||||
AllocTestTokenID();
|
||||
std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
|
||||
std::string bundleName = property != nullptr ? property->name : "default.inputmethod.unittest";
|
||||
AllocTestTokenID(bundleName);
|
||||
|
||||
auto listener = std::make_shared<InputMethodSettingListenerImpl>();
|
||||
imc_ = InputMethodController::GetInstance();
|
||||
imc_->SetSettingListener(listener);
|
||||
@ -142,12 +149,23 @@ void InputMethodPanelTest::TearDown(void)
|
||||
IMSA_HILOGI("InputMethodPanelTest::TearDown");
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::AllocTestTokenID()
|
||||
void InputMethodPanelTest::AllocTestTokenID(const std::string &bundleName)
|
||||
{
|
||||
HapInfoParams infoParams = {
|
||||
.userID = 1, .bundleName = "imf_panel_test", .instIndex = 0, .appIDDesc = "imf_test", .isSystemApp = true
|
||||
IMSA_HILOGI("bundleName: %{public}s", bundleName.c_str());
|
||||
std::vector<int32_t> userIds;
|
||||
auto ret = OsAccountManager::QueryActiveOsAccountIds(userIds);
|
||||
if (ret != ErrorCode::NO_ERROR || userIds.empty()) {
|
||||
IMSA_HILOGE("query active os account id failed");
|
||||
userIds[0] = MAIN_USER_ID;
|
||||
}
|
||||
HapInfoParams infoParams = { .userID = userIds[0],
|
||||
.bundleName = bundleName,
|
||||
.instIndex = 0,
|
||||
.appIDDesc = "ohos.inputmethod_test.demo",
|
||||
.isSystemApp = true };
|
||||
HapPolicyParams policyParams = {
|
||||
.apl = APL_NORMAL, .domain = "test.domain.inputmethod", .permList = {}, .permStateList = {}
|
||||
};
|
||||
HapPolicyParams policyParams = { .apl = APL_NORMAL, .domain = "test.domain", .permList = {}, .permStateList = {} };
|
||||
auto tokenInfo = AccessTokenKit::AllocHapToken(infoParams, policyParams);
|
||||
testTokenIdEx_ = tokenInfo.tokenIDEx;
|
||||
}
|
||||
@ -155,7 +173,7 @@ void InputMethodPanelTest::AllocTestTokenID()
|
||||
void InputMethodPanelTest::SetTestTokenID()
|
||||
{
|
||||
auto ret = SetSelfTokenID(testTokenIdEx_);
|
||||
IMSA_HILOGD("SetSelfTokenID ret: %{public}d", ret);
|
||||
IMSA_HILOGD("ret = %{public}d", ret);
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::RestoreSelfTokenID()
|
||||
@ -220,7 +238,7 @@ void InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus realStat
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::ImcPanelListeningTestPrepare(
|
||||
std::shared_ptr<InputMethodPanel> inputMethodPanel, const PanelInfo &info, ListeningStatus status)
|
||||
const std::shared_ptr<InputMethodPanel> &inputMethodPanel, const PanelInfo &info, ListeningStatus status)
|
||||
{
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, info);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
@ -255,9 +273,14 @@ void InputMethodPanelTest::ImcPanelListeningTestRestore(InputWindowStatus status
|
||||
windowInfo_.clear();
|
||||
}
|
||||
|
||||
void InputMethodPanelTest::ImcPanelListeningTestClear(const std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
{
|
||||
inputMethodPanel->DestroyPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSetUiContent
|
||||
* @tc.desc: Test SetUiContent.
|
||||
* @tc.name: testCreatePanel
|
||||
* @tc.desc: Test CreatePanel.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testCreatePanel, TestSize.Level0)
|
||||
@ -271,6 +294,20 @@ HWTEST_F(InputMethodPanelTest, testCreatePanel, TestSize.Level0)
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testDestroyPanel
|
||||
* @tc.desc: Test DestroyPanel.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testDestroyPanel, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testDestroyPanel start.");
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
// not CreatePanel, DestroyPanel failed
|
||||
auto ret = inputMethodPanel->DestroyPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testResizePanel
|
||||
* @tc.desc: Test Resize panel. All panels can be resized.
|
||||
@ -280,8 +317,12 @@ HWTEST_F(InputMethodPanelTest, testResizePanel, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testResizePanel start.");
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
// not CreatePanel, Resize failed
|
||||
auto ret = inputMethodPanel->Resize(1, 1);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
EXPECT_TRUE(defaultDisplay != nullptr);
|
||||
@ -312,8 +353,12 @@ HWTEST_F(InputMethodPanelTest, testMovePanel, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testMovePanel start.");
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
// not CreatePanel, MoveTo failed
|
||||
auto ret = inputMethodPanel->MoveTo(10, 100);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
ret = inputMethodPanel->MoveTo(10, 100);
|
||||
@ -418,7 +463,7 @@ HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testGetPanelType, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testSetUiContent start.");
|
||||
IMSA_HILOGI("InputMethodPanelTest::testGetPanelType start.");
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
@ -429,6 +474,46 @@ HWTEST_F(InputMethodPanelTest, testGetPanelType, TestSize.Level0)
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testChangePanelFlag
|
||||
* @tc.desc: Test ChangePanelFlag.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testChangePanelFlag, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testChangePanelFlag start.");
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelFlag flag = FLG_FLOATING;
|
||||
|
||||
// not CreatePanel, ChangePanelFlag failed
|
||||
auto ret = inputMethodPanel->ChangePanelFlag(flag);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
|
||||
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
// panelFlag is same with the original
|
||||
ret = inputMethodPanel->ChangePanelFlag(flag);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
// panelFlag modify to FLG_FIXED
|
||||
flag = FLG_FIXED;
|
||||
ret = inputMethodPanel->ChangePanelFlag(flag);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
inputMethodPanel->DestroyPanel();
|
||||
|
||||
panelInfo = { .panelType = STATUS_BAR, .panelFlag = FLG_FLOATING };
|
||||
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
// panelType is STATUS_BAR, not allow ChangePanelFlag
|
||||
ret = inputMethodPanel->ChangePanelFlag(flag);
|
||||
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
|
||||
|
||||
inputMethodPanel->DestroyPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testClearPanelListener
|
||||
* @tc.desc: Test ClearPanelListener.
|
||||
@ -502,7 +587,7 @@ HWTEST_F(InputMethodPanelTest, testRegisterListener, TestSize.Level0)
|
||||
|
||||
/*
|
||||
* @tc.name: testImcPanelListening_001
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED no listening set up
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED no listening set up systemApp currentIme
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
@ -513,6 +598,7 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
InputMethodPanelTest::ImcPanelListeningTestPrepare(inputMethodPanel, panelInfo, NONE);
|
||||
|
||||
auto ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::HIDE, InputWindowStatus::SHOW);
|
||||
@ -521,12 +607,13 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
|
||||
ret = inputMethodPanel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::SHOW, InputWindowStatus::HIDE);
|
||||
InputMethodPanelTest::ImcPanelListeningTestClear(inputMethodPanel);
|
||||
RestoreSelfTokenID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testImcPanelListening_002
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Set up listening
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Set up listening systemApp currentIme
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
|
||||
@ -548,12 +635,13 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::HIDE, InputWindowStatus::HIDE,
|
||||
{ "", 0, 0, InputMethodPanelTest::windowWidth_, InputMethodPanelTest::windowHeight_ });
|
||||
InputMethodPanelTest::ImcPanelListeningTestClear(inputMethodPanel);
|
||||
RestoreSelfTokenID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testImcPanelListening_003
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Cancel listening
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Cancel listening systemApp currentIme
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
|
||||
@ -573,12 +661,13 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
|
||||
ret = inputMethodPanel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::SHOW, InputWindowStatus::HIDE);
|
||||
InputMethodPanelTest::ImcPanelListeningTestClear(inputMethodPanel);
|
||||
RestoreSelfTokenID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testImcPanelListening_004
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Set up listening NO PERMISSION
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Set up listening not systemApp currentIme
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
|
||||
@ -589,6 +678,7 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
InputMethodPanelTest::ImcPanelListeningTestPrepare(inputMethodPanel, panelInfo, ON);
|
||||
|
||||
SetTestTokenID();
|
||||
auto ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::HIDE, InputWindowStatus::SHOW);
|
||||
@ -597,6 +687,34 @@ HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
|
||||
ret = inputMethodPanel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::SHOW, InputWindowStatus::HIDE);
|
||||
InputMethodPanelTest::ImcPanelListeningTestClear(inputMethodPanel);
|
||||
RestoreSelfTokenID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testImcPanelListening_005
|
||||
* @tc.desc: SOFT_KEYBOARD FLG_FIXED Set up listening systemApp not currentIme
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodPanelTest, testImcPanelListening_005, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_005 start.");
|
||||
SetTestTokenID();
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore(InputWindowStatus::HIDE);
|
||||
auto inputMethodPanel = std::make_shared<InputMethodPanel>();
|
||||
PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
|
||||
InputMethodPanelTest::ImcPanelListeningTestPrepare(inputMethodPanel, panelInfo, ON);
|
||||
|
||||
RestoreSelfTokenID();
|
||||
auto ret = inputMethodPanel->ShowPanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::HIDE, InputWindowStatus::SHOW);
|
||||
|
||||
InputMethodPanelTest::ImcPanelListeningTestRestore(InputWindowStatus::SHOW);
|
||||
ret = inputMethodPanel->HidePanel();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
InputMethodPanelTest::ImcPanelListeningTestCheck(InputWindowStatus::SHOW, InputWindowStatus::HIDE);
|
||||
InputMethodPanelTest::ImcPanelListeningTestClear(inputMethodPanel);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user