• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 SYSTEM_UI_CONTROLLER_H
17 #define SYSTEM_UI_CONTROLLER_H
18 
19 #include "ui_controller.h"
20 
21 namespace OHOS::uitest {
22     /**The default UiController of ohos, which is effective for all apps.*/
23     class SysUiController final : public UiController {
24     public:
25         SysUiController(std::string_view name, std::string_view device);
26 
27         ~SysUiController();
28 
29         void GetCurrentUiDom(nlohmann::json& out) const override;
30 
31         void WaitForUiSteady(uint32_t idleThresholdMs, uint32_t timeoutMs) const override;
32 
33         void InjectTouchEventSequence(const std::vector<TouchEvent> &events) const override;
34 
35         void InjectKeyEventSequence(const std::vector<KeyEvent> &events) const override;
36 
37         void PutTextToClipboard(std::string_view text) const override;
38 
39         bool TakeScreenCap(std::string_view savePath, std::stringstream &errReceiver) const override;
40 
41         bool GetCharKeyCode(char ch, int32_t& code, int32_t& ctrlCode) const override;
42 
43         bool IsWorkable() const override;
44 
45         // setup method, connect to system ability AAMS
46         bool ConnectToSysAbility();
47 
48         // teardown method, disconnect from system ability AAMS
49         void DisConnectFromSysAbility();
50 
51     private:
52         bool connected_ = false;
53     };
54 }
55 
56 #endif