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 "marshalling_helper.h"
18 #include "window_manager_agent.h"
19 #include "window_manager_agent_stub.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23 namespace OHOS {
24 namespace Rosen {
25 class WindowManagerAgentStubTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp() override;
30 void TearDown() override;
31 sptr<WindowManagerAgentStub> stub_;
32 };
33
SetUpTestCase()34 void WindowManagerAgentStubTest::SetUpTestCase() {}
35
TearDownTestCase()36 void WindowManagerAgentStubTest::TearDownTestCase() {}
37
SetUp()38 void WindowManagerAgentStubTest::SetUp()
39 {
40 stub_ = new WindowManagerAgent();
41 }
42
TearDown()43 void WindowManagerAgentStubTest::TearDown() {}
44
45 namespace {
46 /**
47 * @tc.name: OnRemoteRequest01
48 * @tc.desc: test InterfaceToken check failed
49 * @tc.type: FUNC
50 */
51 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest01, TestSize.Level1)
52 {
53 MessageParcel data;
54 MessageParcel reply;
55 MessageOption option;
56
57 data.WriteInterfaceToken(u"error.GetDescriptor");
58
59 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS);
60
61 int res = stub_->OnRemoteRequest(code, data, reply, option);
62 EXPECT_EQ(res, static_cast<int>(ERR_TRANSACTION_FAILED));
63 }
64
65 /**
66 * @tc.name: OnRemoteRequest02
67 * @tc.desc: test TRANS_ID_UPDATE_FOCUS
68 * @tc.type: FUNC
69 */
70 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest02, TestSize.Level1)
71 {
72 MessageParcel data;
73 MessageParcel reply;
74 MessageOption option;
75
76 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
77
78 sptr<FocusChangeInfo> focusChangeInfo = new FocusChangeInfo();
79 data.WriteParcelable(focusChangeInfo);
80 data.WriteRemoteObject(focusChangeInfo->abilityToken_);
81 data.WriteBool(false);
82
83 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS);
84
85 int res = stub_->OnRemoteRequest(code, data, reply, option);
86 EXPECT_EQ(res, 0);
87 }
88
89 /**
90 * @tc.name: OnRemoteRequest03
91 * @tc.desc: test TRANS_ID_UPDATE_FOCUS failed
92 * @tc.type: FUNC
93 */
94 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest03, TestSize.Level1)
95 {
96 MessageParcel data;
97 MessageParcel reply;
98 MessageOption option;
99
100 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
101
102 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS);
103
104 int res = stub_->OnRemoteRequest(code, data, reply, option);
105 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
106 }
107
108 /**
109 * @tc.name: OnRemoteRequest04
110 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_STATUS success
111 * @tc.type: FUNC
112 */
113 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest04, TestSize.Level1)
114 {
115 MessageParcel data;
116 MessageParcel reply;
117 MessageOption option;
118
119 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
120
121 sptr<AccessibilityWindowInfo> info = new AccessibilityWindowInfo();
122 std::vector<sptr<AccessibilityWindowInfo>> infos;
123 infos.emplace_back(info);
124 MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(data, infos);
125
126 data.WriteUint32(static_cast<uint32_t>(WindowUpdateType::WINDOW_UPDATE_ADDED));
127
128 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS);
129
130 int res = stub_->OnRemoteRequest(code, data, reply, option);
131 EXPECT_EQ(res, 0);
132 }
133
134 /**
135 * @tc.name: OnRemoteRequest06
136 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_VISIBILITY success
137 * @tc.type: FUNC
138 */
139 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest06, TestSize.Level1)
140 {
141 MessageParcel data;
142 MessageParcel reply;
143 MessageOption option;
144
145 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
146
147 sptr<WindowVisibilityInfo> visibilityInfo = new WindowVisibilityInfo();
148 std::vector<sptr<WindowVisibilityInfo>> visibilityInfos;
149 visibilityInfos.emplace_back(visibilityInfo);
150 data.WriteUint32(static_cast<uint32_t>(visibilityInfos.size()));
151 for (auto& info : visibilityInfos) {
152 data.WriteParcelable(info);
153 }
154
155 auto code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_VISIBILITY);
156
157 int res = stub_->OnRemoteRequest(code, data, reply, option);
158 EXPECT_EQ(res, 0);
159 }
160
161 /**
162 * @tc.name: OnRemoteRequest08
163 * @tc.desc: test TRANS_ID_UPDATE_SYSTEM_BAR_PROPS success
164 * @tc.type: FUNC
165 */
166 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest08, TestSize.Level1)
167 {
168 MessageParcel data;
169 MessageParcel reply;
170 MessageOption option;
171
172 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
173
174 data.WriteUint64(0);
175
176 SystemBarRegionTints tints;
177 MarshallingHelper::MarshallingVectorObj<SystemBarRegionTint>(
__anon7b0e7ad70202(Parcel& parcel, const SystemBarRegionTint& tint) 178 data, tints, [](Parcel& parcel, const SystemBarRegionTint& tint) {
179 return parcel.WriteUint32(static_cast<uint32_t>(tint.type_)) && parcel.WriteBool(tint.prop_.enable_) &&
180 parcel.WriteUint32(tint.prop_.backgroundColor_) && parcel.WriteUint32(tint.prop_.contentColor_) &&
181 parcel.WriteInt32(tint.region_.posX_) && parcel.WriteInt32(tint.region_.posY_) &&
182 parcel.WriteInt32(tint.region_.width_) && parcel.WriteInt32(tint.region_.height_);
183 });
184
185 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS);
186
187 int res = stub_->OnRemoteRequest(code, data, reply, option);
188 EXPECT_EQ(res, 0);
189 }
190
191 /**
192 * @tc.name: OnRemoteRequest09
193 * @tc.desc: test TRANS_ID_UPDATE_SYSTEM_BAR_PROPS success
194 * @tc.type: FUNC
195 */
196 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest09, TestSize.Level1)
197 {
198 MessageParcel data;
199 MessageParcel reply;
200 MessageOption option;
201
202 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
203 data.WriteBool(true);
204 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WATER_MARK_FLAG);
205 int res = stub_->OnRemoteRequest(code, data, reply, option);
206 EXPECT_EQ(res, 0);
207 }
208
209 /**
210 * @tc.name: OnRemoteRequest10
211 * @tc.desc: test TRANS_ID_UPDATE_SYSTEM_BAR_PROPS success
212 * @tc.type: FUNC
213 */
214 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest10, TestSize.Level1)
215 {
216 MessageParcel data;
217 MessageParcel reply;
218 MessageOption option;
219
220 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
221 data.WriteBool(true);
222 uint32_t code =
223 static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_GESTURE_NAVIGATION_ENABLED);
224 int res = stub_->OnRemoteRequest(code, data, reply, option);
225 EXPECT_EQ(res, 0);
226 }
227
228 /**
229 * @tc.name: OnRemoteRequest11
230 * @tc.desc: test InterfaceToken check failed
231 * @tc.type: FUNC
232 */
233 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest11, TestSize.Level1)
234 {
235 MessageParcel data;
236 MessageParcel reply;
237 MessageOption option;
238
239 data.WriteInterfaceToken(u"error.GetDescriptor");
240
241 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE);
242 int res = stub_->OnRemoteRequest(code, data, reply, option);
243 EXPECT_EQ(res, static_cast<int>(ERR_TRANSACTION_FAILED));
244 }
245
246 /**
247 * @tc.name: OnRemoteRequest12
248 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_MODE_TYPE
249 * @tc.type: FUNC
250 */
251 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest12, TestSize.Level1)
252 {
253 MessageParcel data;
254 MessageParcel reply;
255 MessageOption option;
256
257 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
258 data.WriteUint8(static_cast<uint8_t>(WindowModeType::WINDOW_MODE_FLOATING));
259 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE);
260 int res = stub_->OnRemoteRequest(code, data, reply, option);
261 EXPECT_EQ(res, 0);
262 }
263
264 /**
265 * @tc.name: OnRemoteRequest13
266 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_MODE_TYPE success
267 * @tc.type: FUNC
268 */
269 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest13, TestSize.Level1)
270 {
271 MessageParcel data;
272 MessageParcel reply;
273 MessageOption option;
274
275 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
276 data.WriteUint8(static_cast<uint8_t>(WindowModeType::WINDOW_MODE_FLOATING));
277 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE);
278 int res = stub_->OnRemoteRequest(code, data, reply, option);
279 EXPECT_EQ(res, 0);
280 }
281
282 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest14, TestSize.Level1)
283 {
284 MessageParcel data;
285 MessageParcel reply;
286 MessageOption option;
287
288 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
289
290 VisibleWindowNumInfo oneNum;
291 oneNum.displayId = 0;
292 oneNum.visibleWindowNum = 3;
293 std::vector<VisibleWindowNumInfo> visibleWindowNumInfo;
294 visibleWindowNumInfo.push_back(oneNum);
295 MarshallingHelper::MarshallingVectorObj<VisibleWindowNumInfo>(
__anon7b0e7ad70302(Parcel& parcel, const VisibleWindowNumInfo& num) 296 data, visibleWindowNumInfo, [](Parcel& parcel, const VisibleWindowNumInfo& num) {
297 return parcel.WriteUint32(num.displayId) && parcel.WriteUint32(num.visibleWindowNum);
298 });
299
300 uint32_t code =
301 static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_VISIBLE_WINDOW_NUM);
302
303 int res = stub_->OnRemoteRequest(code, data, reply, option);
304 EXPECT_EQ(res, 0);
305 }
306
307 /**
308 * @tc.name: OnRemoteRequest15
309 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_DRAWING_STATE
310 * @tc.type: FUNC
311 */
312 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest15, TestSize.Level1)
313 {
314 MessageParcel data;
315 MessageParcel reply;
316 MessageOption option;
317
318 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
319 uint32_t code =
320 static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_DRAWING_STATE);
321 ASSERT_NE(stub_, nullptr);
322 int res = stub_->OnRemoteRequest(code, data, reply, option);
323 EXPECT_EQ(res, 0);
324 }
325
326 /**
327 * @tc.name: OnRemoteRequest16
328 * @tc.desc: test TRANS_ID_UPDATE_CAMERA_FLOAT
329 * @tc.type: FUNC
330 */
331 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest16, TestSize.Level1)
332 {
333 MessageParcel data;
334 MessageParcel reply;
335 MessageOption option;
336
337 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
338 data.WriteUint8(static_cast<uint8_t>(1));
339 data.WriteBool(true);
340 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT);
341 ASSERT_NE(stub_, nullptr);
342 int res = stub_->OnRemoteRequest(code, data, reply, option);
343 EXPECT_EQ(res, 0);
344 }
345
346 /**
347 * @tc.name: OnRemoteRequest17
348 * @tc.desc: test TRANS_ID_UPDATE_CAMERA_WINDOW_STATUS
349 * @tc.type: FUNC
350 */
351 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest17, TestSize.Level1)
352 {
353 MessageParcel data;
354 MessageParcel reply;
355 MessageOption option;
356
357 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
358 data.WriteUint8(static_cast<uint8_t>(1));
359 data.WriteBool(true);
360 uint32_t code =
361 static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_WINDOW_STATUS);
362 ASSERT_NE(stub_, nullptr);
363 int res = stub_->OnRemoteRequest(code, data, reply, option);
364 EXPECT_EQ(res, 0);
365 }
366
367 /**
368 * @tc.name: OnRemoteRequest18
369 * @tc.desc: test default
370 * @tc.type: FUNC
371 */
372 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest18, TestSize.Level1)
373 {
374 MessageParcel data;
375 MessageParcel reply;
376 MessageOption option;
377
378 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
379 data.WriteUint8(static_cast<uint8_t>(1));
380 uint32_t code = static_cast<uint32_t>(12);
381 ASSERT_NE(stub_, nullptr);
382 int res = stub_->OnRemoteRequest(code, data, reply, option);
383 EXPECT_EQ(res, static_cast<int>(ERR_NONE));
384 }
385
386 /**
387 * @tc.name: OnRemoteRequest19
388 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_STYLE_TYPE success
389 * @tc.type: FUNC
390 */
391 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest19, TestSize.Level1)
392 {
393 MessageParcel data;
394 MessageParcel reply;
395 MessageOption option;
396 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
397 data.WriteUint8(static_cast<uint8_t>(WindowStyleType::WINDOW_STYLE_DEFAULT));
398 uint32_t code =
399 static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STYLE_TYPE);
400 int res = stub_->OnRemoteRequest(code, data, reply, option);
401 EXPECT_EQ(res, 0);
402 }
403
404 /**
405 * @tc.name: OnRemoteRequest20
406 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_FOCUS error
407 * @tc.type: FUNC
408 */
409 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest20, TestSize.Level1)
410 {
411 MessageParcel data;
412 MessageParcel reply;
413 MessageOption option;
414
415 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
416
417 sptr<FocusChangeInfo> focusChangeInfo = sptr<FocusChangeInfo>::MakeSptr();
418 data.WriteParcelable(focusChangeInfo);
419 data.WriteRemoteObject(focusChangeInfo->abilityToken_);
420
421 uint32_t code = static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS);
422 int res = stub_->OnRemoteRequest(code, data, reply, option);
423 EXPECT_EQ(res, static_cast<int>(ERR_INVALID_DATA));
424 }
425
426 /**
427 * @tc.name: OnRemoteRequest21
428 * @tc.desc: test TRANS_ID_NOTIFY_WINDOW_PROPERTY_CHANGE success
429 */
430 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest21, TestSize.Level1)
431 {
432 MessageParcel data;
433 MessageParcel reply;
434 MessageOption option;
435
436 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
437 uint32_t propertyDirtyFlags = 0;
438 data.WriteUint32(propertyDirtyFlags);
439 data.WriteUint32(0);
440
441 uint32_t code =
442 static_cast<uint32_t>(IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_NOTIFY_WINDOW_PROPERTY_CHANGE);
443 int res = stub_->OnRemoteRequest(code, data, reply, option);
444 EXPECT_EQ(res, 0);
445 }
446
447 /**
448 * @tc.name: OnRemoteRequest22
449 * @tc.desc: test TRANS_ID_UPDATE_WINDOW_DRAWING_STATE
450 * @tc.type: FUNC
451 */
452 HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest22, TestSize.Level1)
453 {
454 MessageParcel data;
455 MessageParcel reply;
456 MessageOption option;
457
458 data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor());
459 uint32_t code = static_cast<uint32_t>(
460 IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_NOTIFY_WINDOW_SYSTEM_BAR_PROPERTY_CHANGE);
461 EXPECT_NE(stub_, nullptr);
462 int res = stub_->OnRemoteRequest(code, data, reply, option);
463 EXPECT_EQ(res, 5);
464 }
465
466 /**
467 * @tc.name: ReadWindowInfoList01
468 * @tc.desc: test ReadWindowInfoList
469 * @tc.type: FUNC
470 */
471 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfoList01, TestSize.Level1)
472 {
473 MessageParcel data;
474 std::vector<std::unordered_map<WindowInfoKey, WindowChangeInfoType>> windowInfoList;
475
476 data.WriteUint32(1);
477 EXPECT_FALSE(stub_->ReadWindowInfoList(data, windowInfoList));
478 data.WriteUint32(1);
479 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_ID));
480 EXPECT_FALSE(stub_->ReadWindowInfoList(data, windowInfoList));
481 data.WriteUint32(0);
482 EXPECT_TRUE(stub_->ReadWindowInfoList(data, windowInfoList));
483 }
484
485 /**
486 * @tc.name: ReadWindowInfo01
487 * @tc.desc: test WINDOW_ID
488 * @tc.type: FUNC
489 */
490 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo01, TestSize.Level1)
491 {
492 MessageParcel data;
493 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
494
495 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
496 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_ID));
497 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
498 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_ID));
499 data.WriteUint32(0);
500 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
501 }
502
503 /**
504 * @tc.name: ReadWindowInfo02
505 * @tc.desc: test BUNDLE_NAME
506 * @tc.type: FUNC
507 */
508 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo02, TestSize.Level1)
509 {
510 MessageParcel data;
511 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
512
513 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
514 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::BUNDLE_NAME));
515 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
516 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::BUNDLE_NAME));
517 data.WriteString("test");
518 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
519 }
520
521 /**
522 * @tc.name: ReadWindowInfo03
523 * @tc.desc: test ABILITY_NAME
524 * @tc.type: FUNC
525 */
526 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo03, TestSize.Level1)
527 {
528 MessageParcel data;
529 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
530
531 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
532 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::ABILITY_NAME));
533 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
534 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::ABILITY_NAME));
535 data.WriteString("test");
536 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
537 }
538
539 /**
540 * @tc.name: ReadWindowInfo04
541 * @tc.desc: test APP_INDEX
542 * @tc.type: FUNC
543 */
544 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo04, TestSize.Level1)
545 {
546 MessageParcel data;
547 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
548
549 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
550 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::APP_INDEX));
551 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
552 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::APP_INDEX));
553 data.WriteInt32(0);
554 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
555 }
556
557 /**
558 * @tc.name: ReadWindowInfo05
559 * @tc.desc: test VISIBILITY_STATE
560 * @tc.type: FUNC
561 */
562 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo05, TestSize.Level1)
563 {
564 MessageParcel data;
565 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
566
567 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
568 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::VISIBILITY_STATE));
569 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
570 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::VISIBILITY_STATE));
571 data.WriteUint32(0);
572 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
573 }
574
575 /**
576 * @tc.name: ReadWindowInfo06
577 * @tc.desc: test WINDOW_MODE
578 * @tc.type: FUNC
579 */
580 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo06, TestSize.Level1)
581 {
582 MessageParcel data;
583 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
584
585 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
586 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_MODE));
587 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
588 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_MODE));
589 data.WriteUint32(0);
590 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
591 }
592
593 /**
594 * @tc.name: ReadWindowInfo07
595 * @tc.desc: test DISPLAY_ID
596 * @tc.type: FUNC
597 */
598 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo07, TestSize.Level1)
599 {
600 MessageParcel data;
601 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
602
603 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
604 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::DISPLAY_ID));
605 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
606 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::DISPLAY_ID));
607 data.WriteUint64(0);
608 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
609 }
610
611 /**
612 * @tc.name: ReadWindowInfo08
613 * @tc.desc: test WINDOW_RECT
614 * @tc.type: FUNC
615 */
616 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo08, TestSize.Level1)
617 {
618 MessageParcel data;
619 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
620
621 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
622 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_RECT));
623 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
624 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::WINDOW_RECT));
625 data.WriteInt32(0);
626 data.WriteInt32(0);
627 data.WriteUint32(0);
628 data.WriteUint32(0);
629 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
630 }
631
632 /**
633 * @tc.name: ReadWindowInfo09
634 * @tc.desc: test FLOATING_SCALE
635 * @tc.type: FUNC
636 */
637 HWTEST_F(WindowManagerAgentStubTest, ReadWindowInfo09, TestSize.Level1)
638 {
639 MessageParcel data;
640 std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowInfo;
641
642 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
643 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::FLOATING_SCALE));
644 EXPECT_FALSE(stub_->ReadWindowInfo(data, windowInfo));
645 data.WriteInt32(static_cast<int32_t>(WindowInfoKey::FLOATING_SCALE));
646 data.WriteFloat(0.f);
647 EXPECT_TRUE(stub_->ReadWindowInfo(data, windowInfo));
648 }
649 } // namespace
650 } // namespace Rosen
651 } // namespace OHOS
652