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: UpdateWindowModeSupportType01
80 * @tc.desc: normal function
81 * @tc.type: FUNC
82 */
83 HWTEST_F(WindowProxyTest, UpdateWindowModeSupportType01, Function | SmallTest | Level2)
84 {
85 WMError err = windowProxy_->UpdateWindowModeSupportType(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: NotifyTouchOutside01
174 * @tc.desc: normal function
175 * @tc.type: FUNC
176 */
177 HWTEST_F(WindowProxyTest, NotifyTouchOutside01, Function | SmallTest | Level2)
178 {
179 WMError err = windowProxy_->NotifyTouchOutside();
180 ASSERT_EQ(err, WMError::WM_OK);
181 }
182
183 /**
184 * @tc.name: DumpInfo01
185 * @tc.desc: normal function
186 * @tc.type: FUNC
187 */
188 HWTEST_F(WindowProxyTest, DumpInfo01, Function | SmallTest | Level2)
189 {
190 std::vector<std::string> params;
191 WMError err = windowProxy_->DumpInfo(params);
192 ASSERT_EQ(err, WMError::WM_OK);
193 }
194
195 /**
196 * @tc.name: NotifyDestroy01
197 * @tc.desc: normal function
198 * @tc.type: FUNC
199 */
200 HWTEST_F(WindowProxyTest, NotifyDestroy01, Function | SmallTest | Level2)
201 {
202 WMError err = windowProxy_->NotifyDestroy();
203 ASSERT_EQ(err, WMError::WM_OK);
204 }
205
206
207 /**
208 * @tc.name: NotifyForeground01
209 * @tc.desc: normal function
210 * @tc.type: FUNC
211 */
212 HWTEST_F(WindowProxyTest, NotifyForeground01, Function | SmallTest | Level2)
213 {
214 WMError err = windowProxy_->NotifyForeground();
215 ASSERT_EQ(err, WMError::WM_OK);
216 }
217
218
219 /**
220 * @tc.name: NotifyBackground01
221 * @tc.desc: normal function
222 * @tc.type: FUNC
223 */
224 HWTEST_F(WindowProxyTest, NotifyBackground01, Function | SmallTest | Level2)
225 {
226 WMError err = windowProxy_->NotifyBackground();
227 ASSERT_EQ(err, WMError::WM_OK);
228 }
229
230 /**
231 * @tc.name: NotifyWindowClientPointUp01
232 * @tc.desc: param is nullptr
233 * @tc.type: FUNC
234 */
235 HWTEST_F(WindowProxyTest, NotifyWindowClientPointUp01, Function | SmallTest | Level2)
236 {
237 WMError err = windowProxy_->NotifyWindowClientPointUp(nullptr);
238 ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR);
239 }
240
241 /**
242 * @tc.name: NotifyWindowClientPointUp02
243 * @tc.desc: normal function
244 * @tc.type: FUNC
245 */
246 HWTEST_F(WindowProxyTest, NotifyWindowClientPointUp02, Function | SmallTest | Level2)
247 {
248 auto pointerEvent = MMI::PointerEvent::Create();
249 WMError err = windowProxy_->NotifyWindowClientPointUp(pointerEvent);
250 ASSERT_EQ(err, WMError::WM_OK);
251 }
252
253 /**
254 * @tc.name: UpdateZoomTransform01
255 * @tc.desc: normal function
256 * @tc.type: FUNC
257 */
258 HWTEST_F(WindowProxyTest, UpdateZoomTransform01, Function | SmallTest | Level2)
259 {
260 Transform transform;
261 WMError err = windowProxy_->UpdateZoomTransform(transform, false);
262 ASSERT_EQ(err, WMError::WM_OK);
263 }
264
265 /**
266 * @tc.name: RestoreSplitWindowMode01
267 * @tc.desc: normal function
268 * @tc.type: FUNC
269 */
270 HWTEST_F(WindowProxyTest, RestoreSplitWindowMode01, Function | SmallTest | Level2)
271 {
272 WMError err = windowProxy_->RestoreSplitWindowMode(200);
273 ASSERT_EQ(err, WMError::WM_OK);
274 }
275
276 /**
277 * @tc.name: NotifyScreenshot
278 * @tc.desc: normal function
279 * @tc.type: FUNC
280 */
281 HWTEST_F(WindowProxyTest, NotifyScreenshot, Function | SmallTest | Level2)
282 {
283 WMError err = windowProxy_->NotifyScreenshot();
284 ASSERT_EQ(err, WMError::WM_OK);
285 }
286
287 /**
288 * @tc.name: NotifyForegroundInteractiveStatus
289 * @tc.desc: normal function
290 * @tc.type: FUNC
291 */
292 HWTEST_F(WindowProxyTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2)
293 {
294 ASSERT_NE(windowProxy_, nullptr);
295 WMError err = WMError::WM_OK;
296 bool interactive = false;
297 windowProxy_->NotifyForegroundInteractiveStatus(interactive);
298 ASSERT_EQ(err, WMError::WM_OK);
299 }
300
301 }
302 }
303 }
304