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_agent.h"
18 #include "window_stub.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22 namespace OHOS {
23 namespace Rosen {
24 class WindowStubTest : public testing::Test {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 void SetUp() override;
29 void TearDown() override;
30 sptr<WindowStub> windowStub_;
31 };
32
SetUpTestCase()33 void WindowStubTest::SetUpTestCase() {}
34
TearDownTestCase()35 void WindowStubTest::TearDownTestCase() {}
36
SetUp()37 void WindowStubTest::SetUp()
38 {
39 sptr<WindowOption> option = new WindowOption();
40 sptr<WindowImpl> window = new WindowImpl(option);
41 windowStub_ = new WindowAgent(window);
42 }
43
TearDown()44 void WindowStubTest::TearDown() {}
45
46 namespace {
47 /**
48 * @tc.name: OnRemoteRequest01
49 * @tc.desc: test InterfaceToken check failed
50 * @tc.type: FUNC
51 */
52 HWTEST_F(WindowStubTest, OnRemoteRequest01, Function | SmallTest | Level2)
53 {
54 MessageParcel data;
55 MessageParcel reply;
56 MessageOption option;
57
58 data.WriteInterfaceToken(u"error.GetDescriptor");
59
60 data.WriteInt32(0);
61 data.WriteInt32(0);
62 data.WriteUint32(100);
63 data.WriteUint32(100);
64
65 data.WriteBool(false);
66
67 data.WriteUint32(static_cast<uint32_t>(WindowSizeChangeReason::DRAG_START));
68
69 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT);
70
71 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
72 EXPECT_EQ(res, static_cast<int>(ERR_TRANSACTION_FAILED));
73 }
74
75 /**
76 * @tc.name: OnRemoteRequest02
77 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_RECT
78 * @tc.type: FUNC
79 */
80 HWTEST_F(WindowStubTest, OnRemoteRequest02, Function | SmallTest | Level2)
81 {
82 MessageParcel data;
83 MessageParcel reply;
84 MessageOption option;
85
86 data.WriteInterfaceToken(WindowStub::GetDescriptor());
87
88 data.WriteInt32(0);
89 data.WriteInt32(0);
90 data.WriteUint32(100);
91 data.WriteUint32(100);
92
93 data.WriteBool(false);
94
95 data.WriteUint32(static_cast<uint32_t>(WindowSizeChangeReason::DRAG_START));
96
97 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT);
98
99 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
100 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
101 }
102
103 /**
104 * @tc.name: OnRemoteRequest03
105 * @tc.desc: test TRANS_ID_UPDATE_AVOID_AREA success
106 * @tc.type: FUNC
107 */
108 HWTEST_F(WindowStubTest, OnRemoteRequest03, Function | SmallTest | Level2)
109 {
110 MessageParcel data;
111 MessageParcel reply;
112 MessageOption option;
113
114 data.WriteInterfaceToken(WindowStub::GetDescriptor());
115
116 sptr<AvoidArea> avoidArea = new AvoidArea();
117 data.WriteStrongParcelable(avoidArea);
118
119 data.WriteUint32(static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM));
120
121 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_AVOID_AREA);
122
123 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
124 EXPECT_EQ(res, 0);
125 }
126
127 /**
128 * @tc.name: OnRemoteRequest04
129 * @tc.desc: test TRANS_ID_UPDATE_AVOID_AREA success
130 * @tc.type: FUNC
131 */
132 HWTEST_F(WindowStubTest, OnRemoteRequest04, Function | SmallTest | Level2)
133 {
134 MessageParcel data;
135 MessageParcel reply;
136 MessageOption option;
137
138 data.WriteInterfaceToken(WindowStub::GetDescriptor());
139
140 sptr<AvoidArea> avoidArea = new AvoidArea();
141 data.WriteStrongParcelable(avoidArea);
142
143 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_AVOID_AREA);
144
145 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
146 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
147 }
148
149 /**
150 * @tc.name: OnRemoteRequest05
151 * @tc.desc: test TRANS_ID_DUMP_INFO success
152 * @tc.type: FUNC
153 */
154 HWTEST_F(WindowStubTest, OnRemoteRequest05, Function | SmallTest | Level2)
155 {
156 MessageParcel data;
157 MessageParcel reply;
158 MessageOption option;
159
160 data.WriteInterfaceToken(WindowStub::GetDescriptor());
161
162 std::vector<std::string> params;
163 params.push_back("-a");
164 data.WriteStringVector(params);
165
166 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_DUMP_INFO);
167
168 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
169 EXPECT_EQ(res, 0);
170 }
171
172 /**
173 * @tc.name: OnRemoteRequest06
174 * @tc.desc: test TRANS_ID_DUMP_INFO failed
175 * @tc.type: FUNC
176 */
177 HWTEST_F(WindowStubTest, OnRemoteRequest06, Function | SmallTest | Level2)
178 {
179 MessageParcel data;
180 MessageParcel reply;
181 MessageOption option;
182
183 data.WriteInterfaceToken(WindowStub::GetDescriptor());
184 data.WriteRawData(nullptr, 0);
185
186 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_DUMP_INFO);
187
188 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
189 EXPECT_EQ(res, 0);
190 }
191
192 /**
193 * @tc.name: OnRemoteRequest07
194 * @tc.desc: test TRANS_ID_NOTIFY_CLIENT_POINT_UP success
195 * @tc.type: FUNC
196 */
197 HWTEST_F(WindowStubTest, OnRemoteRequest07, Function | SmallTest | Level2)
198 {
199 MessageParcel data;
200 MessageParcel reply;
201 MessageOption option;
202
203 data.WriteInterfaceToken(WindowStub::GetDescriptor());
204
205 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
206 pointerEvent->WriteToParcel(data);
207
208 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP);
209
210 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
211 EXPECT_EQ(res, 0);
212 }
213
214 /**
215 * @tc.name: OnRemoteRequest08
216 * @tc.desc: test TRANS_ID_NOTIFY_CLIENT_POINT_UP success
217 * @tc.type: FUNC
218 */
219 HWTEST_F(WindowStubTest, OnRemoteRequest08, Function | SmallTest | Level2)
220 {
221 MessageParcel data;
222 MessageParcel reply;
223 MessageOption option;
224
225 data.WriteInterfaceToken(WindowStub::GetDescriptor());
226
227 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP);
228
229 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
230 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
231 }
232
233 /**
234 * @tc.name: OnRemoteRequest09
235 * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS success
236 * @tc.type: FUNC
237 */
238 HWTEST_F(WindowStubTest, OnRemoteRequest09, Function | SmallTest | Level2)
239 {
240 MessageParcel data;
241 MessageParcel reply;
242 MessageOption option(MessageOption::TF_ASYNC);
243
244 data.WriteInterfaceToken(WindowStub::GetDescriptor());
245 data.WriteBool(false);
246 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS);
247 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
248 EXPECT_EQ(res, 0);
249 }
250
251 /**
252 * @tc.name: OnRemoteRequest10
253 * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS success
254 * @tc.type: FUNC
255 */
256 HWTEST_F(WindowStubTest, OnRemoteRequest10, Function | SmallTest | Level2)
257 {
258 MessageParcel data;
259 MessageParcel reply;
260 MessageOption option(MessageOption::TF_ASYNC);
261 uint32_t code = 0;
262
263 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
264 EXPECT_EQ(res, static_cast<int>(ERR_TRANSACTION_FAILED));
265 }
266
267 /**
268 * @tc.name: OnRemoteRequest11
269 * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS success
270 * @tc.type: FUNC
271 */
272 HWTEST_F(WindowStubTest, OnRemoteRequest11, Function | SmallTest | Level2)
273 {
274 MessageParcel data;
275 MessageParcel reply;
276 MessageOption option(MessageOption::TF_ASYNC);
277 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT);
278 data.WriteBool(false);
279 data.WriteInterfaceToken(WindowStub::GetDescriptor());
280
281 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_MODE);
282 windowStub_->OnRemoteRequest(code, data, reply, option);
283 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO);
284 windowStub_->OnRemoteRequest(code, data, reply, option);
285 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS);
286 windowStub_->OnRemoteRequest(code, data, reply, option);
287 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_AVOID_AREA);
288 windowStub_->OnRemoteRequest(code, data, reply, option);
289 uint32_t type = 1;
290 data.ReadUint32(type);
291 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE);
292 windowStub_->OnRemoteRequest(code, data, reply, option);
293 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT);
294 windowStub_->OnRemoteRequest(code, data, reply, option);
295 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DISPLAY_ID);
296 windowStub_->OnRemoteRequest(code, data, reply, option);
297 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA);
298 windowStub_->OnRemoteRequest(code, data, reply, option);
299 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT);
300 windowStub_->OnRemoteRequest(code, data, reply, option);
301 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS);
302
303 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
304 EXPECT_NE(res, 10);
305 }
306
307 /**
308 * @tc.name: OnRemoteRequest12
309 * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS success
310 * @tc.type: FUNC
311 */
312 HWTEST_F(WindowStubTest, OnRemoteRequest12, Function | SmallTest | Level2)
313 {
314 MessageParcel data;
315 MessageParcel reply;
316 MessageOption option(MessageOption::TF_ASYNC);
317 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT);
318 data.WriteBool(false);
319 data.WriteInterfaceToken(WindowStub::GetDescriptor());
320
321 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY);
322 windowStub_->OnRemoteRequest(code, data, reply, option);
323 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED);
324 windowStub_->OnRemoteRequest(code, data, reply, option);
325 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_SCREEN_SHOT);
326 windowStub_->OnRemoteRequest(code, data, reply, option);
327 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_DESTROY);
328 windowStub_->OnRemoteRequest(code, data, reply, option);
329 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND);
330 windowStub_->OnRemoteRequest(code, data, reply, option);
331 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_BACKGROUND);
332 windowStub_->OnRemoteRequest(code, data, reply, option);
333 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_DUMP_INFO);
334 windowStub_->OnRemoteRequest(code, data, reply, option);
335 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP);
336 windowStub_->OnRemoteRequest(code, data, reply, option);
337 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_ZOOM_TRANSFORM);
338 windowStub_->OnRemoteRequest(code, data, reply, option);
339 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_RESTORE_SPLIT_WINDOW_MODE);
340 windowStub_->OnRemoteRequest(code, data, reply, option);
341 code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS);
342
343 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
344 EXPECT_NE(res, 10);
345 }
346
347 /**
348 * @tc.name: OnRemoteRequest13
349 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_RECT success
350 * @tc.type: FUNC
351 */
352 HWTEST_F(WindowStubTest, OnRemoteRequest13, Function | SmallTest | Level2)
353 {
354 MessageParcel data;
355 MessageParcel reply;
356 MessageOption option(MessageOption::TF_ASYNC);
357
358 data.WriteInterfaceToken(WindowStub::GetDescriptor());
359
360 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT);
361 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
362 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
363 }
364
365 /**
366 * @tc.name: OnRemoteRequest14
367 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_MODE success
368 * @tc.type: FUNC
369 */
370 HWTEST_F(WindowStubTest, OnRemoteRequest14, Function | SmallTest | Level2)
371 {
372 MessageParcel data;
373 MessageParcel reply;
374 MessageOption option(MessageOption::TF_ASYNC);
375
376 data.WriteInterfaceToken(WindowStub::GetDescriptor());
377
378 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_MODE);
379 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
380 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
381 }
382
383 /**
384 * @tc.name: OnRemoteRequest15
385 * @tc.desc: test TRANS_ID_UPDATE_MODE_SUPPORT_INFO success
386 * @tc.type: FUNC
387 */
388 HWTEST_F(WindowStubTest, OnRemoteRequest15, Function | SmallTest | Level2)
389 {
390 MessageParcel data;
391 MessageParcel reply;
392 MessageOption option(MessageOption::TF_ASYNC);
393
394 data.WriteInterfaceToken(WindowStub::GetDescriptor());
395
396 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO);
397 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
398 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
399 }
400
401 /**
402 * @tc.name: OnRemoteRequest16
403 * @tc.desc: test TRANS_ID_UPDATE_FOCUS_STATUS success
404 * @tc.type: FUNC
405 */
406 HWTEST_F(WindowStubTest, OnRemoteRequest16, Function | SmallTest | Level2)
407 {
408 MessageParcel data;
409 MessageParcel reply;
410 MessageOption option(MessageOption::TF_ASYNC);
411
412 data.WriteInterfaceToken(WindowStub::GetDescriptor());
413
414 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS);
415 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
416 EXPECT_EQ(res, 0);
417 }
418
419 /**
420 * @tc.name: OnRemoteRequest17
421 * @tc.desc: test TRANS_ID_UPDATE_AVOID_AREA success
422 * @tc.type: FUNC
423 */
424 HWTEST_F(WindowStubTest, OnRemoteRequest17, Function | SmallTest | Level2)
425 {
426 MessageParcel data;
427 MessageParcel reply;
428 MessageOption option(MessageOption::TF_ASYNC);
429
430 data.WriteInterfaceToken(WindowStub::GetDescriptor());
431
432 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_AVOID_AREA);
433 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
434 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
435 }
436
437 /**
438 * @tc.name: OnRemoteRequest18
439 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_STATE success
440 * @tc.type: FUNC
441 */
442 HWTEST_F(WindowStubTest, OnRemoteRequest18, Function | SmallTest | Level2)
443 {
444 MessageParcel data;
445 MessageParcel reply;
446 MessageOption option(MessageOption::TF_ASYNC);
447
448 data.WriteInterfaceToken(WindowStub::GetDescriptor());
449 data.WriteUint32(1);
450
451 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE);
452 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
453 EXPECT_EQ(res, static_cast<int>(ERR_NONE));
454 }
455
456 /**
457 * @tc.name: OnRemoteRequest19
458 * @tc.desc: test TRANS_ID_UPDATE_DRAG_EVENT success
459 * @tc.type: FUNC
460 */
461 HWTEST_F(WindowStubTest, OnRemoteRequest19, Function | SmallTest | Level2)
462 {
463 MessageParcel data;
464 MessageParcel reply;
465 MessageOption option(MessageOption::TF_ASYNC);
466
467 data.WriteInterfaceToken(WindowStub::GetDescriptor());
468 data.WriteInt32(0);
469 data.WriteInt32(0);
470 data.WriteUint32(1);
471
472 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT);
473 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
474 EXPECT_EQ(res, 0);
475 }
476
477 /**
478 * @tc.name: OnRemoteRequest20
479 * @tc.desc: test TRANS_ID_UPDATE_DISPLAY_ID success
480 * @tc.type: FUNC
481 */
482 HWTEST_F(WindowStubTest, OnRemoteRequest20, Function | SmallTest | Level2)
483 {
484 MessageParcel data;
485 MessageParcel reply;
486 MessageOption option(MessageOption::TF_ASYNC);
487
488 data.WriteInterfaceToken(WindowStub::GetDescriptor());
489
490 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DISPLAY_ID);
491 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
492 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
493 }
494
495 /**
496 * @tc.name: OnRemoteRequest21
497 * @tc.desc: test TRANS_ID_UPDATE_OCCUPIED_AREA success
498 * @tc.type: FUNC
499 */
500 HWTEST_F(WindowStubTest, OnRemoteRequest21, Function | SmallTest | Level2)
501 {
502 MessageParcel data;
503 MessageParcel reply;
504 MessageOption option(MessageOption::TF_ASYNC);
505
506 data.WriteInterfaceToken(WindowStub::GetDescriptor());
507
508 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA);
509 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
510 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
511 }
512
513 /**
514 * @tc.name: OnRemoteRequest22
515 * @tc.desc: test TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT success
516 * @tc.type: FUNC
517 */
518 HWTEST_F(WindowStubTest, OnRemoteRequest22, Function | SmallTest | Level2)
519 {
520 MessageParcel data;
521 MessageParcel reply;
522 MessageOption option(MessageOption::TF_ASYNC);
523
524 data.WriteInterfaceToken(WindowStub::GetDescriptor());
525
526 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT);
527 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
528 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
529 }
530
531 /**
532 * @tc.name: OnRemoteRequest23
533 * @tc.desc: test TRANS_ID_UPDATE_ACTIVE_STATUS success
534 * @tc.type: FUNC
535 */
536 HWTEST_F(WindowStubTest, OnRemoteRequest23, Function | SmallTest | Level2)
537 {
538 MessageParcel data;
539 MessageParcel reply;
540 MessageOption option(MessageOption::TF_ASYNC);
541
542 data.WriteInterfaceToken(WindowStub::GetDescriptor());
543
544 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS);
545 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
546 EXPECT_EQ(res, 0);
547 }
548
549 /**
550 * @tc.name: OnRemoteRequest24
551 * @tc.desc: test TRANS_ID_GET_WINDOW_PROPERTY success
552 * @tc.type: FUNC
553 */
554 HWTEST_F(WindowStubTest, OnRemoteRequest24, Function | SmallTest | Level2)
555 {
556 MessageParcel data;
557 MessageParcel reply;
558 MessageOption option(MessageOption::TF_ASYNC);
559
560 data.WriteInterfaceToken(WindowStub::GetDescriptor());
561
562 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY);
563 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
564 EXPECT_EQ(res, 0);
565 }
566
567 /**
568 * @tc.name: OnRemoteRequest25
569 * @tc.desc: test TRANS_ID_NOTIFY_OUTSIDE_PRESSED success
570 * @tc.type: FUNC
571 */
572 HWTEST_F(WindowStubTest, OnRemoteRequest25, Function | SmallTest | Level2)
573 {
574 MessageParcel data;
575 MessageParcel reply;
576 MessageOption option(MessageOption::TF_ASYNC);
577
578 data.WriteInterfaceToken(WindowStub::GetDescriptor());
579
580 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED);
581 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
582 EXPECT_EQ(res, 0);
583 }
584
585 /**
586 * @tc.name: OnRemoteRequest26
587 * @tc.desc: test TRANS_ID_NOTIFY_SCREEN_SHOT success
588 * @tc.type: FUNC
589 */
590 HWTEST_F(WindowStubTest, OnRemoteRequest26, Function | SmallTest | Level2)
591 {
592 MessageParcel data;
593 MessageParcel reply;
594 MessageOption option(MessageOption::TF_ASYNC);
595
596 data.WriteInterfaceToken(WindowStub::GetDescriptor());
597
598 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_SCREEN_SHOT);
599 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
600 EXPECT_EQ(res, 0);
601 }
602
603 /**
604 * @tc.name: OnRemoteRequest27
605 * @tc.desc: test TRANS_ID_NOTIFY_DESTROY success
606 * @tc.type: FUNC
607 */
608 HWTEST_F(WindowStubTest, OnRemoteRequest27, Function | SmallTest | Level2)
609 {
610 MessageParcel data;
611 MessageParcel reply;
612 MessageOption option(MessageOption::TF_ASYNC);
613
614 data.WriteInterfaceToken(WindowStub::GetDescriptor());
615
616 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_DESTROY);
617 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
618 EXPECT_EQ(res, 0);
619 }
620
621 /**
622 * @tc.name: OnRemoteRequest28
623 * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND success
624 * @tc.type: FUNC
625 */
626 HWTEST_F(WindowStubTest, OnRemoteRequest28, Function | SmallTest | Level2)
627 {
628 MessageParcel data;
629 MessageParcel reply;
630 MessageOption option(MessageOption::TF_ASYNC);
631
632 data.WriteInterfaceToken(WindowStub::GetDescriptor());
633
634 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND);
635 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
636 EXPECT_EQ(res, 0);
637 }
638
639 /**
640 * @tc.name: OnRemoteRequest29
641 * @tc.desc: test TRANS_ID_NOTIFY_BACKGROUND success
642 * @tc.type: FUNC
643 */
644 HWTEST_F(WindowStubTest, OnRemoteRequest29, Function | SmallTest | Level2)
645 {
646 MessageParcel data;
647 MessageParcel reply;
648 MessageOption option(MessageOption::TF_ASYNC);
649
650 data.WriteInterfaceToken(WindowStub::GetDescriptor());
651
652 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_BACKGROUND);
653 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
654 EXPECT_EQ(res, 0);
655 }
656
657 /**
658 * @tc.name: OnRemoteRequest30
659 * @tc.desc: test TRANS_ID_DUMP_INFO success
660 * @tc.type: FUNC
661 */
662 HWTEST_F(WindowStubTest, OnRemoteRequest30, Function | SmallTest | Level2)
663 {
664 MessageParcel data;
665 MessageParcel reply;
666 MessageOption option(MessageOption::TF_ASYNC);
667
668 data.WriteInterfaceToken(WindowStub::GetDescriptor());
669
670 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_DUMP_INFO);
671 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
672 EXPECT_EQ(res, 0);
673 }
674
675 /**
676 * @tc.name: OnRemoteRequest31
677 * @tc.desc: test TRANS_ID_NOTIFY_CLIENT_POINT_UP success
678 * @tc.type: FUNC
679 */
680 HWTEST_F(WindowStubTest, OnRemoteRequest31, Function | SmallTest | Level2)
681 {
682 MessageParcel data;
683 MessageParcel reply;
684 MessageOption option(MessageOption::TF_ASYNC);
685
686 data.WriteInterfaceToken(WindowStub::GetDescriptor());
687
688 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP);
689 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
690 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
691 }
692
693 /**
694 * @tc.name: OnRemoteRequest32
695 * @tc.desc: test TRANS_ID_UPDATE_ZOOM_TRANSFORM success
696 * @tc.type: FUNC
697 */
698 HWTEST_F(WindowStubTest, OnRemoteRequest32, Function | SmallTest | Level2)
699 {
700 MessageParcel data;
701 MessageParcel reply;
702 MessageOption option(MessageOption::TF_ASYNC);
703
704 data.WriteInterfaceToken(WindowStub::GetDescriptor());
705
706 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_ZOOM_TRANSFORM);
707 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
708 EXPECT_EQ(res, 0);
709 }
710
711 /**
712 * @tc.name: OnRemoteRequest33
713 * @tc.desc: test TRANS_ID_RESTORE_SPLIT_WINDOW_MODE success
714 * @tc.type: FUNC
715 */
716 HWTEST_F(WindowStubTest, OnRemoteRequest33, Function | SmallTest | Level2)
717 {
718 MessageParcel data;
719 MessageParcel reply;
720 MessageOption option(MessageOption::TF_ASYNC);
721
722 data.WriteInterfaceToken(WindowStub::GetDescriptor());
723
724 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_RESTORE_SPLIT_WINDOW_MODE);
725 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
726 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
727 }
728
729 /**
730 * @tc.name: OnRemoteRequest34
731 * @tc.desc: test TRANS_ID_CONSUME_KEY_EVENT success
732 * @tc.type: FUNC
733 */
734 HWTEST_F(WindowStubTest, OnRemoteRequest34, Function | SmallTest | Level2)
735 {
736 MessageParcel data;
737 MessageParcel reply;
738 MessageOption option(MessageOption::TF_ASYNC);
739
740 data.WriteInterfaceToken(WindowStub::GetDescriptor());
741
742 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_CONSUME_KEY_EVENT);
743 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
744 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
745 }
746
747 /**
748 * @tc.name: OnRemoteRequest35
749 * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS success
750 * @tc.type: FUNC
751 */
752 HWTEST_F(WindowStubTest, OnRemoteRequest35, Function | SmallTest | Level2)
753 {
754 MessageParcel data;
755 MessageParcel reply;
756 MessageOption option(MessageOption::TF_ASYNC);
757
758 data.WriteInterfaceToken(WindowStub::GetDescriptor());
759
760 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS);
761 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
762 EXPECT_EQ(res, 0);
763 }
764
765 /**
766 * @tc.name: OnRemoteRequest36
767 * @tc.desc: test TRANS_ID_UPDATE_DRAG_EVENT fail
768 * @tc.type: FUNC
769 */
770 HWTEST_F(WindowStubTest, OnRemoteRequest36, Function | SmallTest | Level2)
771 {
772 MessageParcel data;
773 MessageParcel reply;
774 MessageOption option(MessageOption::TF_ASYNC);
775
776 data.WriteInterfaceToken(WindowStub::GetDescriptor());
777 data.WriteInt32(0);
778 data.WriteInt32(0);
779 data.WriteUint32(100);
780
781 uint32_t code = static_cast<uint32_t>(IWindow::WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT);
782 int res = windowStub_->OnRemoteRequest(code, data, reply, option);
783 EXPECT_EQ(res, 5);
784 }
785 } // namespace
786 } // namespace Rosen
787 } // namespace OHOS
788