1a69a01cdSopenharmony_ci/*
2a69a01cdSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3a69a01cdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4a69a01cdSopenharmony_ci * you may not use this file except in compliance with the License.
5a69a01cdSopenharmony_ci * You may obtain a copy of the License at
6a69a01cdSopenharmony_ci *
7a69a01cdSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8a69a01cdSopenharmony_ci *
9a69a01cdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10a69a01cdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11a69a01cdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12a69a01cdSopenharmony_ci * See the License for the specific language governing permissions and
13a69a01cdSopenharmony_ci * limitations under the License.
14a69a01cdSopenharmony_ci */
15a69a01cdSopenharmony_ci
16a69a01cdSopenharmony_ci#ifndef TEST_WUKONG_FOCUS_SCENE_DELEGATE_H
17a69a01cdSopenharmony_ci#define TEST_WUKONG_FOCUS_SCENE_DELEGATE_H
18a69a01cdSopenharmony_ci
19a69a01cdSopenharmony_ci#include "singleton.h"
20a69a01cdSopenharmony_ci#include "tree_manager.h"
21a69a01cdSopenharmony_ci#include "wukong_define.h"
22a69a01cdSopenharmony_ci
23a69a01cdSopenharmony_cinamespace OHOS {
24a69a01cdSopenharmony_cinamespace WuKong {
25a69a01cdSopenharmony_ciclass FocusSceneDelegate : public DelayedSingleton<FocusSceneDelegate> {
26a69a01cdSopenharmony_cipublic:
27a69a01cdSopenharmony_ci    FocusSceneDelegate();
28a69a01cdSopenharmony_ci    ~FocusSceneDelegate();
29a69a01cdSopenharmony_ci
30a69a01cdSopenharmony_ci    /**
31a69a01cdSopenharmony_ci     * @brief judge the scene
32a69a01cdSopenharmony_ci     * @param isRandom whether it is a random test
33a69a01cdSopenharmony_ci     * @return ERR_OK is success,other is fail
34a69a01cdSopenharmony_ci     */
35a69a01cdSopenharmony_ci    ErrCode ChooseScene(bool isRandom);
36a69a01cdSopenharmony_ci
37a69a01cdSopenharmony_ci    /**
38a69a01cdSopenharmony_ci     * @brief judge whether to back to the previous page
39a69a01cdSopenharmony_ci     * @return true is back,false is not back
40a69a01cdSopenharmony_ci     */
41a69a01cdSopenharmony_ci    bool IsBackToPrePage()
42a69a01cdSopenharmony_ci    {
43a69a01cdSopenharmony_ci        return isBack_;
44a69a01cdSopenharmony_ci    }
45a69a01cdSopenharmony_ci
46a69a01cdSopenharmony_ci    std::vector<std::string> GetComponentTypeList()
47a69a01cdSopenharmony_ci    {
48a69a01cdSopenharmony_ci        return componentType_;
49a69a01cdSopenharmony_ci    }
50a69a01cdSopenharmony_ci
51a69a01cdSopenharmony_ci    uint64_t GetCurrentPageId()
52a69a01cdSopenharmony_ci    {
53a69a01cdSopenharmony_ci        return pageId_;
54a69a01cdSopenharmony_ci    }
55a69a01cdSopenharmony_ci
56a69a01cdSopenharmony_ci    /**
57a69a01cdSopenharmony_ci     * @brief judge whether page changed
58a69a01cdSopenharmony_ci     * @return true if changed,false if not changed
59a69a01cdSopenharmony_ci     */
60a69a01cdSopenharmony_ci    bool IsPageChanged();
61a69a01cdSopenharmony_ci
62a69a01cdSopenharmony_ciprivate:
63a69a01cdSopenharmony_ci    /**
64a69a01cdSopenharmony_ci     * @brief compare two component tree
65a69a01cdSopenharmony_ci     * @param componentinfo the information of a component tree
66a69a01cdSopenharmony_ci     * @param othercomponentinfo the information of another component tree
67a69a01cdSopenharmony_ci     * @return ERR_OK is success,other is fail
68a69a01cdSopenharmony_ci     */
69a69a01cdSopenharmony_ci    ErrCode CompareComponentInfos(std::shared_ptr<ComponentTree> &newcomponentinfo,
70a69a01cdSopenharmony_ci                                  std::shared_ptr<ComponentTree> &oldcomponentinfo, bool isRandom);
71a69a01cdSopenharmony_ci
72a69a01cdSopenharmony_ci    /**
73a69a01cdSopenharmony_ci     * @brief get all componentinfo of active page
74a69a01cdSopenharmony_ci     * @param componentinfo the root component node of active page
75a69a01cdSopenharmony_ci     * @return ERR_OK is success,other is fail
76a69a01cdSopenharmony_ci     */
77a69a01cdSopenharmony_ci    ErrCode GetCurrentComponentInfo(std::shared_ptr<ComponentTree> componentinfo,
78a69a01cdSopenharmony_ci                                    std::vector<std::shared_ptr<ComponentTree>> &componentlist);
79a69a01cdSopenharmony_ci
80a69a01cdSopenharmony_ci    /**
81a69a01cdSopenharmony_ci     * @brief set the available component
82a69a01cdSopenharmony_ci     * @param componentinfo the root component node of active page
83a69a01cdSopenharmony_ci     * @return ERR_OK is success,other is fail
84a69a01cdSopenharmony_ci     */
85a69a01cdSopenharmony_ci    ErrCode SetAvailableComponentList(std::shared_ptr<ComponentTree> componentinfo, bool isRandom);
86a69a01cdSopenharmony_ci
87a69a01cdSopenharmony_ci    /**
88a69a01cdSopenharmony_ci     * @brief find the same component in new component list and old component list
89a69a01cdSopenharmony_ci     * @param newcomponentlist new component list
90a69a01cdSopenharmony_ci     * @param oldcomponentlist old component list
91a69a01cdSopenharmony_ci     * @return same count
92a69a01cdSopenharmony_ci     */
93a69a01cdSopenharmony_ci    uint32_t FindSame(const std::vector<std::shared_ptr<ComponentTree>> &newcomponentlist,
94a69a01cdSopenharmony_ci                      const std::vector<std::shared_ptr<ComponentTree>> &oldcomponentlist);
95a69a01cdSopenharmony_ci
96a69a01cdSopenharmony_ci    /**
97a69a01cdSopenharmony_ci     * @brief set the available component
98a69a01cdSopenharmony_ci     * @param isFound whether newcomponentinfos is same with its parent node
99a69a01cdSopenharmony_ci     * @param isRandom whether it is a random test
100a69a01cdSopenharmony_ci     * @return ERR_OK is success,other is fail
101a69a01cdSopenharmony_ci     */
102a69a01cdSopenharmony_ci    ErrCode FindSamePageInChildren(bool &isFound, bool isRandom);
103a69a01cdSopenharmony_ci
104a69a01cdSopenharmony_ci    /**
105a69a01cdSopenharmony_ci     * @brief set the available component
106a69a01cdSopenharmony_ci     * @param isFound whether newcomponentinfos is same with its child node
107a69a01cdSopenharmony_ci     * @param isRandom whether it is a random test
108a69a01cdSopenharmony_ci     * @return ERR_OK is success,other is fail
109a69a01cdSopenharmony_ci     */
110a69a01cdSopenharmony_ci    ErrCode FindSamePageInParent(bool &isFound, bool isRandom);
111a69a01cdSopenharmony_ci
112a69a01cdSopenharmony_ci    /**
113a69a01cdSopenharmony_ci     * @brief check if the component is in screen
114a69a01cdSopenharmony_ci     * @param componentinfo the component
115a69a01cdSopenharmony_ci     * @return true is in screen,false is not in screen
116a69a01cdSopenharmony_ci     */
117a69a01cdSopenharmony_ci    bool IsComponentInScreen(const std::shared_ptr<ComponentTree> componentinfo);
118a69a01cdSopenharmony_ci
119a69a01cdSopenharmony_ci    std::vector<std::shared_ptr<ComponentTree>> componentList_;
120a69a01cdSopenharmony_ci    std::vector<std::string> componentType_;
121a69a01cdSopenharmony_ci    bool isBack_ = false;
122a69a01cdSopenharmony_ci    uint64_t pageId_ = 0;
123a69a01cdSopenharmony_ci};
124a69a01cdSopenharmony_ci}  // namespace WuKong
125a69a01cdSopenharmony_ci}  // namespace OHOS
126a69a01cdSopenharmony_ci#endif  // TEST_WUKONG_FOCUS_SCENE_DELEGATE_H
127