• 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         explicit SysUiController(std::string_view name);
26 
27         ~SysUiController() override;
28 
29         void GetUiHierarchy(std::vector<std::pair<Window, nlohmann::json>>& out) override;
30 
31         bool WaitForUiSteady(uint32_t idleThresholdMs, uint32_t timeoutMs) const override;
32 
33         void InjectTouchEventSequence(const PointerMatrix &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         void SetDisplayRotation(DisplayRotation rotation) const override;
52 
53         DisplayRotation GetDisplayRotation() const override;
54 
55         void SetDisplayRotationEnabled(bool enabled) const override;
56 
57         Point GetDisplaySize() const override;
58 
59         Point GetDisplayDensity() const override;
60 
61         bool IsScreenOn() const override;
62 
63     private:
64         bool connected_ = false;
65     };
66 }
67 
68 #endif