• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 TEST_WUKONG_FOCUS_SCENE_DELEGATE_H
17 #define TEST_WUKONG_FOCUS_SCENE_DELEGATE_H
18 
19 #include "singleton.h"
20 #include "tree_manager.h"
21 #include "wukong_define.h"
22 
23 namespace OHOS {
24 namespace WuKong {
25 class FocusSceneDelegate : public DelayedSingleton<FocusSceneDelegate> {
26 public:
27     FocusSceneDelegate();
28     ~FocusSceneDelegate();
29 
30     /**
31      * @brief judge the scene
32      * @param isRandom whether it is a random test
33      * @return ERR_OK is success,other is fail
34      */
35     ErrCode ChooseScene(bool isRandom);
36 
37     /**
38      * @brief judge whether to back to the previous page
39      * @return true is back,false is not back
40      */
IsBackToPrePage()41     bool IsBackToPrePage()
42     {
43         return isBack_;
44     }
45 
GetComponentTypeList()46     std::vector<std::string> GetComponentTypeList()
47     {
48         return componentType_;
49     }
50 
GetCurrentPageId()51     uint64_t GetCurrentPageId()
52     {
53         return pageId_;
54     }
55 
56     /**
57      * @brief judge whether page changed
58      * @return true if changed,false if not changed
59      */
60     bool IsPageChanged();
61 
62 private:
63     /**
64      * @brief compare two component tree
65      * @param componentinfo the information of a component tree
66      * @param othercomponentinfo the information of another component tree
67      * @return ERR_OK is success,other is fail
68      */
69     ErrCode CompareComponentInfos(std::shared_ptr<ComponentTree> &newcomponentinfo,
70                                   std::shared_ptr<ComponentTree> &oldcomponentinfo, bool isRandom);
71 
72     /**
73      * @brief get all componentinfo of active page
74      * @param componentinfo the root component node of active page
75      * @return ERR_OK is success,other is fail
76      */
77     ErrCode GetCurrentComponentInfo(std::shared_ptr<ComponentTree> componentinfo,
78                                     std::vector<std::shared_ptr<ComponentTree>> &componentlist);
79 
80     /**
81      * @brief set the available component
82      * @param componentinfo the root component node of active page
83      * @return ERR_OK is success,other is fail
84      */
85     ErrCode SetAvailableComponentList(std::shared_ptr<ComponentTree> componentinfo, bool isRandom);
86 
87     /**
88      * @brief find the same component in new component list and old component list
89      * @param newcomponentlist new component list
90      * @param oldcomponentlist old component list
91      * @return same count
92      */
93     uint32_t FindSame(const std::vector<std::shared_ptr<ComponentTree>> &newcomponentlist,
94                       const std::vector<std::shared_ptr<ComponentTree>> &oldcomponentlist);
95 
96     /**
97      * @brief set the available component
98      * @param isFound whether newcomponentinfos is same with its parent node
99      * @param isRandom whether it is a random test
100      * @return ERR_OK is success,other is fail
101      */
102     ErrCode FindSamePageInChildren(bool &isFound, bool isRandom);
103 
104     /**
105      * @brief set the available component
106      * @param isFound whether newcomponentinfos is same with its child node
107      * @param isRandom whether it is a random test
108      * @return ERR_OK is success,other is fail
109      */
110     ErrCode FindSamePageInParent(bool &isFound, bool isRandom);
111 
112     /**
113      * @brief check if the component is in screen
114      * @param componentinfo the component
115      * @return true is in screen,false is not in screen
116      */
117     bool IsComponentInScreen(const std::shared_ptr<ComponentTree> componentinfo);
118 
119     std::vector<std::shared_ptr<ComponentTree>> componentList_;
120     std::vector<std::string> componentType_;
121     bool isBack_ = false;
122     uint64_t pageId_ = 0;
123 };
124 }  // namespace WuKong
125 }  // namespace OHOS
126 #endif  // TEST_WUKONG_FOCUS_SCENE_DELEGATE_H
127