• 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 "window_proxy.h"
18 
19 #include "window_agent.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 namespace OHOS {
24 namespace Rosen {
25 class WindowProxyTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31     sptr<WindowAgent> mockWindowAgent_;
32     sptr<WindowProxy> windowProxy_;
33 };
34 
SetUpTestCase()35 void WindowProxyTest::SetUpTestCase()
36 {
37 }
38 
TearDownTestCase()39 void WindowProxyTest::TearDownTestCase()
40 {
41 }
42 
SetUp()43 void WindowProxyTest::SetUp()
44 {
45     sptr<WindowOption> option = new WindowOption();
46     sptr<WindowImpl> window = new WindowImpl(option);
47     mockWindowAgent_ = new WindowAgent(window);
48     windowProxy_ = new WindowProxy(mockWindowAgent_);
49 }
50 
TearDown()51 void WindowProxyTest::TearDown()
52 {
53 }
54 
55 namespace {
56 /**
57  * @tc.name: UpdateWindowRect01
58  * @tc.desc: normal function
59  * @tc.type: FUNC
60  */
61 HWTEST_F(WindowProxyTest, UpdateWindowRect01, Function | SmallTest | Level2)
62 {
63     WMError err = windowProxy_->UpdateWindowRect(Rect {0, 0, 0, 0}, false, WindowSizeChangeReason::HIDE);
64     ASSERT_EQ(err, WMError::WM_OK);
65 }
66 
67 /**
68  * @tc.name: UpdateWindowMode01
69  * @tc.desc: normal function
70  * @tc.type: FUNC
71  */
72 HWTEST_F(WindowProxyTest, UpdateWindowMode01, Function | SmallTest | Level2)
73 {
74     WMError err = windowProxy_->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
75     ASSERT_EQ(err, WMError::WM_OK);
76 }
77 
78 /**
79  * @tc.name: UpdateWindowModeSupportInfo01
80  * @tc.desc: normal function
81  * @tc.type: FUNC
82  */
83 HWTEST_F(WindowProxyTest, UpdateWindowModeSupportInfo01, Function | SmallTest | Level2)
84 {
85     WMError err = windowProxy_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY);
86     ASSERT_EQ(err, WMError::WM_OK);
87 }
88 
89 /**
90  * @tc.name: UpdateFocusStatus01
91  * @tc.desc: normal function
92  * @tc.type: FUNC
93  */
94 HWTEST_F(WindowProxyTest, UpdateFocusStatus01, Function | SmallTest | Level2)
95 {
96     WMError err = windowProxy_->UpdateFocusStatus(false);
97     ASSERT_EQ(err, WMError::WM_OK);
98 }
99 
100 /**
101  * @tc.name: UpdateAvoidArea01
102  * @tc.desc: normal function
103  * @tc.type: FUNC
104  */
105 HWTEST_F(WindowProxyTest, UpdateAvoidArea01, Function | SmallTest | Level2)
106 {
107     const sptr<AvoidArea>& avoidArea = new AvoidArea();
108     WMError err = windowProxy_->UpdateAvoidArea(avoidArea, AvoidAreaType::TYPE_SYSTEM);
109     ASSERT_EQ(err, WMError::WM_OK);
110 }
111 
112 /**
113  * @tc.name: UpdateWindowState01
114  * @tc.desc: normal function
115  * @tc.type: FUNC
116  */
117 HWTEST_F(WindowProxyTest, UpdateWindowState01, Function | SmallTest | Level2)
118 {
119     WMError err = windowProxy_->UpdateWindowState(WindowState::STATE_BOTTOM);
120     ASSERT_EQ(err, WMError::WM_OK);
121 }
122 
123 /**
124  * @tc.name: UpdateWindowDragInfo01
125  * @tc.desc: normal function
126  * @tc.type: FUNC
127  */
128 HWTEST_F(WindowProxyTest, UpdateWindowDragInfo01, Function | SmallTest | Level2)
129 {
130     PointInfo point;
131     point.x = 1;
132     point.y = 2;
133     WMError err = windowProxy_->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_MOVE);
134     ASSERT_EQ(err, WMError::WM_OK);
135 }
136 
137 /**
138  * @tc.name: UpdateDisplayId01
139  * @tc.desc: normal function
140  * @tc.type: FUNC
141  */
142 HWTEST_F(WindowProxyTest, UpdateDisplayId01, Function | SmallTest | Level2)
143 {
144     WMError err = windowProxy_->UpdateDisplayId(0, 1);
145     ASSERT_EQ(err, WMError::WM_OK);
146 }
147 
148 /**
149  * @tc.name: UpdateOccupiedAreaChangeInfo01
150  * @tc.desc: normal function
151  * @tc.type: FUNC
152  */
153 HWTEST_F(WindowProxyTest, UpdateOccupiedAreaChangeInfo01, Function | SmallTest | Level2)
154 {
155     Rect overlapRect = {0, 0, 0, 0};
156     sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, overlapRect);
157     WMError err = windowProxy_->UpdateOccupiedAreaChangeInfo(info);
158     ASSERT_EQ(err, WMError::WM_OK);
159 }
160 
161 /**
162  * @tc.name: UpdateActiveStatus01
163  * @tc.desc: normal function
164  * @tc.type: FUNC
165  */
166 HWTEST_F(WindowProxyTest, UpdateActiveStatus01, Function | SmallTest | Level2)
167 {
168     WMError err = windowProxy_->UpdateActiveStatus(false);
169     ASSERT_EQ(err, WMError::WM_OK);
170 }
171 
172 /**
173  * @tc.name: GetWindowProperty01
174  * @tc.desc: normal function
175  * @tc.type: FUNC
176  */
177 HWTEST_F(WindowProxyTest, GetWindowProperty01, Function | SmallTest | Level2)
178 {
179     ASSERT_TRUE(windowProxy_->GetWindowProperty() == nullptr);
180 }
181 
182 /**
183  * @tc.name: NotifyTouchOutside01
184  * @tc.desc: normal function
185  * @tc.type: FUNC
186  */
187 HWTEST_F(WindowProxyTest, NotifyTouchOutside01, Function | SmallTest | Level2)
188 {
189     WMError err = windowProxy_->NotifyTouchOutside();
190     ASSERT_EQ(err, WMError::WM_OK);
191 }
192 
193 /**
194  * @tc.name: DumpInfo01
195  * @tc.desc: normal function
196  * @tc.type: FUNC
197  */
198 HWTEST_F(WindowProxyTest, DumpInfo01, Function | SmallTest | Level2)
199 {
200     std::vector<std::string> params;
201     WMError err = windowProxy_->DumpInfo(params);
202     ASSERT_EQ(err, WMError::WM_OK);
203 }
204 
205 /**
206  * @tc.name: NotifyDestroy01
207  * @tc.desc: normal function
208  * @tc.type: FUNC
209  */
210 HWTEST_F(WindowProxyTest, NotifyDestroy01, Function | SmallTest | Level2)
211 {
212     WMError err = windowProxy_->NotifyDestroy();
213     ASSERT_EQ(err, WMError::WM_OK);
214 }
215 
216 
217 /**
218  * @tc.name: NotifyForeground01
219  * @tc.desc: normal function
220  * @tc.type: FUNC
221  */
222 HWTEST_F(WindowProxyTest, NotifyForeground01, Function | SmallTest | Level2)
223 {
224     WMError err = windowProxy_->NotifyForeground();
225     ASSERT_EQ(err, WMError::WM_OK);
226 }
227 
228 
229 /**
230  * @tc.name: NotifyBackground01
231  * @tc.desc: normal function
232  * @tc.type: FUNC
233  */
234 HWTEST_F(WindowProxyTest, NotifyBackground01, Function | SmallTest | Level2)
235 {
236     WMError err = windowProxy_->NotifyBackground();
237     ASSERT_EQ(err, WMError::WM_OK);
238 }
239 
240 /**
241  * @tc.name: NotifyWindowClientPointUp01
242  * @tc.desc: param is nullptr
243  * @tc.type: FUNC
244  */
245 HWTEST_F(WindowProxyTest, NotifyWindowClientPointUp01, Function | SmallTest | Level2)
246 {
247     WMError err = windowProxy_->NotifyWindowClientPointUp(nullptr);
248     ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR);
249 }
250 
251 /**
252  * @tc.name: NotifyWindowClientPointUp02
253  * @tc.desc: normal function
254  * @tc.type: FUNC
255  */
256 HWTEST_F(WindowProxyTest, NotifyWindowClientPointUp02, Function | SmallTest | Level2)
257 {
258     auto pointerEvent = MMI::PointerEvent::Create();
259     WMError err = windowProxy_->NotifyWindowClientPointUp(pointerEvent);
260     ASSERT_EQ(err, WMError::WM_OK);
261 }
262 
263 /**
264  * @tc.name: UpdateZoomTransform01
265  * @tc.desc: normal function
266  * @tc.type: FUNC
267  */
268 HWTEST_F(WindowProxyTest, UpdateZoomTransform01, Function | SmallTest | Level2)
269 {
270     Transform transform;
271     WMError err = windowProxy_->UpdateZoomTransform(transform, false);
272     ASSERT_EQ(err, WMError::WM_OK);
273 }
274 
275 /**
276  * @tc.name: RestoreSplitWindowMode01
277  * @tc.desc: normal function
278  * @tc.type: FUNC
279  */
280 HWTEST_F(WindowProxyTest, RestoreSplitWindowMode01, Function | SmallTest | Level2)
281 {
282     WMError err = windowProxy_->RestoreSplitWindowMode(200);
283     ASSERT_EQ(err, WMError::WM_OK);
284 }
285 
286 /**
287  * @tc.name: NotifyScreenshot
288  * @tc.desc: normal function
289  * @tc.type: FUNC
290  */
291 HWTEST_F(WindowProxyTest, NotifyScreenshot, Function | SmallTest | Level2)
292 {
293     WMError err = windowProxy_->NotifyScreenshot();
294     ASSERT_EQ(err, WMError::WM_OK);
295 }
296 
297 }
298 }
299 }
300