• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INPUTMETHOD_IMF_KEYBOARD_LISTENER_TEST_IMPL_H
17 #define INPUTMETHOD_IMF_KEYBOARD_LISTENER_TEST_IMPL_H
18 
19 #include <condition_variable>
20 #include <mutex>
21 
22 #include "keyboard_listener.h"
23 
24 namespace OHOS {
25 namespace MiscServices {
26 class KeyboardListenerTestImpl : public KeyboardListener {
27 public:
KeyboardListenerTestImpl()28     KeyboardListenerTestImpl() {};
~KeyboardListenerTestImpl()29     ~KeyboardListenerTestImpl() {};
30     bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr<KeyEventConsumerProxy> &consumer) override;
OnKeyEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent,sptr<KeyEventConsumerProxy> & consumer)31     bool OnKeyEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent, sptr<KeyEventConsumerProxy> &consumer) override
32     {
33         return false;
34     }
35     bool OnDealKeyEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent, uint64_t cbId,
36         const sptr<IRemoteObject> &channelObject) override;
37     void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height) override;
38     void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) override;
39     void OnTextChange(const std::string &text) override;
40     void OnEditorAttributeChange(const InputAttribute &inputAttribute) override;
41     void OnFunctionKey(int32_t funcKey) override;
42     static void ResetParam();
43     static bool WaitKeyEvent(int32_t keyCode);
44     static bool WaitCursorUpdate();
45     static bool WaitSelectionChange(int32_t newBegin);
46     static bool WaitTextChange(const std::string &text);
47     static bool WaitEditorAttributeChange(const InputAttribute &inputAttribute);
48     static bool WaitFunctionKey(int32_t funcKey);
49 
50 public:
51     static std::mutex kdListenerLock_;
52     static std::condition_variable kdListenerCv_;
53     static int32_t keyCode_;
54     static int32_t cursorHeight_;
55     static int32_t newBegin_;
56     static std::string text_;
57     static InputAttribute inputAttribute_;
58     static int32_t funcKey_;
59 };
60 } // namespace MiscServices
61 } // namespace OHOS
62 
63 #endif //INPUTMETHOD_IMF_KEYBOARD_LISTENER_TEST_IMPL_H
64