• 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 #include <gtest/gtest.h>
17 #include "display_manager_adapter.h"
18 #include <functional>
19 #include "window_manager_agent_proxy.h"
20 #include "window_manager_agent.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 namespace OHOS {
25 namespace Rosen {
26 class WindowManagerAgentProxyTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 };
33 
SetUpTestCase()34 void WindowManagerAgentProxyTest::SetUpTestCase()
35 {
36 }
37 
TearDownTestCase()38 void WindowManagerAgentProxyTest::TearDownTestCase()
39 {
40 }
41 
SetUp()42 void WindowManagerAgentProxyTest::SetUp()
43 {
44 }
45 
TearDown()46 void WindowManagerAgentProxyTest::TearDown()
47 {
48 }
49 
50 namespace {
51 /**
52  * @tc.name: UpdateFocusChangeInfo
53  * @tc.desc: test InterfaceToken check failed
54  * @tc.type: FUNC
55  */
56 HWTEST_F(WindowManagerAgentProxyTest, UpdateFocusChangeInfo, Function | SmallTest | Level2)
57 {
58     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
59     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
60     sptr<FocusChangeInfo> focusChangeInfo = new FocusChangeInfo();
61     bool focused = true;
62 
63     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
64 
65     int resultValue = 0;
66     std::function<void()> func = [&]()
__anonfc601b7a0202() 67     {
68         windowManagerAgentProxy->UpdateFocusChangeInfo(focusChangeInfo, focused);
69         resultValue = 1;
70     };
71     func();
72     ASSERT_EQ(resultValue, 1);
73 }
74 
75 /**
76  * @tc.name: UpdateSystemBarRegionTints
77  * @tc.desc: test InterfaceToken check failed
78  * @tc.type: FUNC
79  */
80 HWTEST_F(WindowManagerAgentProxyTest, UpdateSystemBarRegionTints, Function | SmallTest | Level2)
81 {
82     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
83     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
84     DisplayId displayId = 0;
85     SystemBarRegionTints tints = {};
86 
87     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
88 
89     int resultValue = 0;
90     std::function<void()> func = [&]()
__anonfc601b7a0302() 91     {
92         windowManagerAgentProxy->UpdateSystemBarRegionTints(displayId, tints);
93         resultValue = 1;
94     };
95     func();
96     ASSERT_EQ(resultValue, 1);
97 }
98 
99 /**
100  * @tc.name: NotifyAccessibilityWindowInfo
101  * @tc.desc: test InterfaceToken check failed
102  * @tc.type: FUNC
103  */
104 HWTEST_F(WindowManagerAgentProxyTest, NotifyAccessibilityWindowInfo, Function | SmallTest | Level2)
105 {
106     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
107     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
108     std::vector<sptr<AccessibilityWindowInfo>> infos = {};
109     WindowUpdateType type = WindowUpdateType::WINDOW_UPDATE_REMOVED;
110 
111     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
112 
113     int resultValue = 0;
114     std::function<void()> func = [&]()
__anonfc601b7a0402() 115     {
116         windowManagerAgentProxy->NotifyAccessibilityWindowInfo(infos, type);
117         resultValue = 1;
118     };
119     func();
120     ASSERT_EQ(resultValue, 1);
121 }
122 
123 /**
124  * @tc.name: UpdateWindowVisibilityInfo
125  * @tc.desc: test InterfaceToken check failed
126  * @tc.type: FUNC
127  */
128 HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowVisibilityInfo, Function | SmallTest | Level2)
129 {
130     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
131     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
132     std::vector<sptr<WindowVisibilityInfo>> visibilityInfos = {};
133 
134     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
135 
136     int resultValue = 0;
137     std::function<void()> func = [&]()
__anonfc601b7a0502() 138     {
139         windowManagerAgentProxy->UpdateWindowVisibilityInfo(visibilityInfos);
140         resultValue = 1;
141     };
142     func();
143     ASSERT_EQ(resultValue, 1);
144 }
145 
146 /**
147  * @tc.name: UpdateWindowDrawingContentInfo
148  * @tc.desc: test InterfaceToken check failed
149  * @tc.type: FUNC
150  */
151 HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowDrawingContentInfo, Function | SmallTest | Level2)
152 {
153     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
154     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
155     std::vector<sptr<WindowDrawingContentInfo>> windowDrawingContentInfos = {};
156 
157     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
158 
159     int resultValue = 0;
160     std::function<void()> func = [&]()
__anonfc601b7a0602() 161     {
162         windowManagerAgentProxy->UpdateWindowDrawingContentInfo(windowDrawingContentInfos);
163         resultValue = 1;
164     };
165     func();
166     ASSERT_EQ(resultValue, 1);
167 }
168 
169 /**
170  * @tc.name: UpdateCameraFloatWindowStatus
171  * @tc.desc: test InterfaceToken check failed
172  * @tc.type: FUNC
173  */
174 HWTEST_F(WindowManagerAgentProxyTest, UpdateCameraFloatWindowStatus, Function | SmallTest | Level2)
175 {
176     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
177     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
178     uint32_t accessTokenId = 0;
179     bool isShowing = true;
180 
181     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
182 
183     int resultValue = 0;
184     std::function<void()> func = [&]()
__anonfc601b7a0702() 185     {
186         windowManagerAgentProxy->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
187         resultValue = 1;
188     };
189     func();
190     ASSERT_EQ(resultValue, 1);
191 }
192 
193 /**
194  * @tc.name: NotifyWaterMarkFlagChangedResult
195  * @tc.desc: test InterfaceToken check failed
196  * @tc.type: FUNC
197  */
198 HWTEST_F(WindowManagerAgentProxyTest, NotifyWaterMarkFlagChangedResult, Function | SmallTest | Level2)
199 {
200     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
201     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
202     bool showWaterMark = true;
203 
204     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
205 
206     int resultValue = 0;
207     std::function<void()> func = [&]()
__anonfc601b7a0802() 208     {
209         windowManagerAgentProxy->NotifyWaterMarkFlagChangedResult(showWaterMark);
210         resultValue = 1;
211     };
212     func();
213     ASSERT_EQ(resultValue, 1);
214 }
215 
216 /**
217  * @tc.name: NotifyGestureNavigationEnabledResult
218  * @tc.desc: test InterfaceToken check failed
219  * @tc.type: FUNC
220  */
221 HWTEST_F(WindowManagerAgentProxyTest, NotifyGestureNavigationEnabledResult, Function | SmallTest | Level2)
222 {
223     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
224     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
225     bool enable = true;
226 
227     sptr<WindowManagerAgentProxy> windowManagerAgentProxy = new WindowManagerAgentProxy(impl);
228 
229     int resultValue = 0;
230     std::function<void()> func = [&]()
__anonfc601b7a0902() 231     {
232         windowManagerAgentProxy->NotifyGestureNavigationEnabledResult(enable);
233         resultValue = 1;
234     };
235     func();
236     ASSERT_EQ(resultValue, 1);
237 }
238 }
239 }
240 }