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
18 #include <iremote_broker.h>
19 #include <iremote_object.h>
20 #include "display_manager_agent_default.h"
21 #include "display_manager_proxy.h"
22 #include "iremote_object_mocker.h"
23
24 #include "iconsumer_surface.h"
25 #include <surface.h>
26
27 using namespace testing;
28 using namespace testing::ext;
29
30 namespace OHOS {
31 namespace Rosen {
32 using RemoteMocker = MockIRemoteObject;
33 class DisplayManagerProxyTest : public testing::Test {
34 public:
35 static void SetUpTestCase();
36 static void TearDownTestCase();
37 void SetUp() override;
38 void TearDown() override;
39 };
40
SetUpTestCase()41 void DisplayManagerProxyTest::SetUpTestCase()
42 {
43 }
44
TearDownTestCase()45 void DisplayManagerProxyTest::TearDownTestCase()
46 {
47 }
48
SetUp()49 void DisplayManagerProxyTest::SetUp()
50 {
51 }
52
TearDown()53 void DisplayManagerProxyTest::TearDown()
54 {
55 }
56
57 namespace {
58 /**
59 * @tc.name: GetDefaultDisplayInfo
60 * @tc.desc: test DisplayManagerProxy::GetDefaultDisplayInfo
61 * @tc.type: FUNC
62 */
63 HWTEST_F(DisplayManagerProxyTest, GetDefaultDisplayInfo01, Function | SmallTest | Level1)
64 {
65 DisplayManagerProxy proxy1(nullptr);
66 ASSERT_EQ(nullptr, proxy1.remoteObject_);
67 auto displayInfo1 = proxy1.GetDefaultDisplayInfo();
68 ASSERT_EQ(nullptr, displayInfo1);
69
70 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
71 DisplayManagerProxy proxy2(remoteMocker);
72 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
73 auto displayInfo2 = proxy2.GetDefaultDisplayInfo();
74 ASSERT_EQ(nullptr, displayInfo2);
75
76 remoteMocker->sendRequestResult_ = 1;
77 auto displayInfo3 = proxy2.GetDefaultDisplayInfo();
78 ASSERT_EQ(nullptr, displayInfo3);
79 }
80
81 /**
82 * @tc.name: GetDisplayInfoById01
83 * @tc.desc: test DisplayManagerProxy::GetDisplayInfoById
84 * @tc.type: FUNC
85 */
86 HWTEST_F(DisplayManagerProxyTest, GetDisplayInfoById01, Function | SmallTest | Level1)
87 {
88 DisplayManagerProxy proxy1(nullptr);
89 ASSERT_EQ(nullptr, proxy1.remoteObject_);
90 auto displayInfo1 = proxy1.GetDisplayInfoById(0);
91 ASSERT_EQ(nullptr, displayInfo1);
92
93 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
94 DisplayManagerProxy proxy2(remoteMocker);
95 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
96
97 auto displayInfo2 = proxy2.GetDisplayInfoById(0);
98 ASSERT_EQ(nullptr, displayInfo2);
99
100 remoteMocker->sendRequestResult_ = 1;
101 auto displayInfo3 = proxy2.GetDisplayInfoById(0);
102 ASSERT_EQ(nullptr, displayInfo3);
103 }
104
105 /**
106 * @tc.name: GetDisplayInfoByScreen01
107 * @tc.desc: test DisplayManagerProxy::GetDisplayInfoByScreen
108 * @tc.type: FUNC
109 */
110 HWTEST_F(DisplayManagerProxyTest, GetDisplayInfoByScreen01, Function | SmallTest | Level1)
111 {
112 DisplayManagerProxy proxy1(nullptr);
113 ASSERT_EQ(nullptr, proxy1.remoteObject_);
114 auto displayInfo1 = proxy1.GetDisplayInfoByScreen(0);
115 ASSERT_EQ(nullptr, displayInfo1);
116
117 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
118 DisplayManagerProxy proxy2(remoteMocker);
119 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
120
121 auto displayInfo2 = proxy2.GetDisplayInfoByScreen(0);
122 ASSERT_EQ(nullptr, displayInfo2);
123
124 remoteMocker->sendRequestResult_ = 1;
125 auto displayInfo3 = proxy2.GetDisplayInfoByScreen(0);
126 ASSERT_EQ(nullptr, displayInfo3);
127 }
128
129 /**
130 * @tc.name: CreateVirtualScreen01
131 * @tc.desc: test DisplayManagerProxy::CreateVirtualScreen
132 * @tc.type: FUNC
133 */
134 HWTEST_F(DisplayManagerProxyTest, CreateVirtualScreen01, Function | SmallTest | Level1)
135 {
136 DisplayManagerProxy proxy1(nullptr);
137 ASSERT_EQ(nullptr, proxy1.remoteObject_);
138 VirtualScreenOption virtualOption1;
139 virtualOption1.name_ = "testVirtualOption";
140 sptr<IRemoteObject> displayManagerAgent1 = new RemoteMocker();
141 auto screenId1 = proxy1.CreateVirtualScreen(virtualOption1, displayManagerAgent1);
142 ASSERT_EQ(SCREEN_ID_INVALID, screenId1);
143
144 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
145 DisplayManagerProxy proxy2(remoteMocker);
146 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
147
148 VirtualScreenOption virtualOption2;
149 virtualOption2.name_ = "testVirtualOption";
150 sptr<IRemoteObject> displayManagerAgent2 = new RemoteMocker();
151 auto screenId2 = proxy2.CreateVirtualScreen(virtualOption2, displayManagerAgent2);
152 ASSERT_EQ(0, screenId2);
153
154 remoteMocker->sendRequestResult_ = 1;
155 auto screenId3 = proxy2.CreateVirtualScreen(virtualOption2, displayManagerAgent2);
156 ASSERT_EQ(SCREEN_ID_INVALID, screenId3);
157 }
158
159 /**
160 * @tc.name: DestroyVirtualScreen01
161 * @tc.desc: test DisplayManagerProxy::DestroyVirtualScreen
162 * @tc.type: FUNC
163 */
164 HWTEST_F(DisplayManagerProxyTest, DestroyVirtualScreen01, Function | SmallTest | Level1)
165 {
166 DisplayManagerProxy proxy1(nullptr);
167 ASSERT_EQ(nullptr, proxy1.remoteObject_);
168 auto result1 = proxy1.DestroyVirtualScreen(0);
169 ASSERT_EQ(DMError::DM_ERROR_REMOTE_CREATE_FAILED, result1);
170
171 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
172 DisplayManagerProxy proxy2(remoteMocker);
173 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
174
175 auto result2 = proxy2.DestroyVirtualScreen(0);
176 ASSERT_EQ(DMError::DM_OK, result2);
177
178 remoteMocker->sendRequestResult_ = 1;
179 auto result3 = proxy2.DestroyVirtualScreen(0);
180 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
181 }
182
183 /**
184 * @tc.name: SetVirtualScreenSurface01
185 * @tc.desc: test DisplayManagerProxy::SetVirtualScreenSurface
186 * @tc.type: FUNC
187 */
188 HWTEST_F(DisplayManagerProxyTest, SetVirtualScreenSurface01, Function | SmallTest | Level1)
189 {
190 DisplayManagerProxy proxy1(nullptr);
191 ASSERT_EQ(nullptr, proxy1.remoteObject_);
192 auto result1 = proxy1.SetVirtualScreenSurface(0, nullptr);
193 ASSERT_EQ(DMError::DM_ERROR_REMOTE_CREATE_FAILED, result1);
194
195 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
196 DisplayManagerProxy proxy2(remoteMocker);
197 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
198
199 auto result2 = proxy2.SetVirtualScreenSurface(0, nullptr);
200 ASSERT_EQ(DMError::DM_OK, result2);
201 sptr<IConsumerSurface> surface = OHOS::IConsumerSurface::Create();
202 auto result3 = proxy2.SetVirtualScreenSurface(0, surface->GetProducer());
203 ASSERT_EQ(DMError::DM_OK, result3);
204
205 remoteMocker->sendRequestResult_ = 1;
206 auto result4 = proxy2.SetVirtualScreenSurface(0, surface->GetProducer());
207 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result4);
208 }
209
210 /**
211 * @tc.name: SetOrientation01
212 * @tc.desc: test DisplayManagerProxy::SetOrientation
213 * @tc.type: FUNC
214 */
215 HWTEST_F(DisplayManagerProxyTest, SetOrientation01, Function | SmallTest | Level1)
216 {
217 DisplayManagerProxy proxy1(nullptr);
218 ASSERT_EQ(nullptr, proxy1.remoteObject_);
219 auto result1 = proxy1.SetOrientation(0, Orientation::VERTICAL);
220 ASSERT_TRUE(DMError::DM_OK != result1);
221
222 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
223 DisplayManagerProxy proxy2(remoteMocker);
224 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
225
226 auto result2 = proxy2.SetOrientation(0, Orientation::VERTICAL);
227 ASSERT_TRUE(DMError::DM_OK == result2);
228
229 remoteMocker->sendRequestResult_ = 1;
230 auto result3 = proxy2.SetOrientation(0, Orientation::VERTICAL);
231 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
232 }
233
234 /**
235 * @tc.name: GetDisplaySnapshot01
236 * @tc.desc: test DisplayManagerProxy::GetDisplaySnapshot
237 * @tc.type: FUNC
238 */
239 HWTEST_F(DisplayManagerProxyTest, GetDisplaySnapshot01, Function | SmallTest | Level1)
240 {
241 DisplayManagerProxy proxy1(nullptr);
242 ASSERT_EQ(nullptr, proxy1.remoteObject_);
243 auto result1 = proxy1.GetDisplaySnapshot(0);
244 ASSERT_EQ(nullptr, result1);
245
246 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
247 DisplayManagerProxy proxy2(remoteMocker);
248 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
249
250 auto result2 = proxy2.GetDisplaySnapshot(0);
251 ASSERT_EQ(nullptr, result2);
252 remoteMocker->sendRequestResult_ = 1;
253 auto result3 = proxy2.GetDisplaySnapshot(0);
254 ASSERT_EQ(nullptr, result3);
255 }
256
257 /**
258 * @tc.name: GetScreenSupportedColorGamuts01
259 * @tc.desc: test DisplayManagerProxy::GetScreenSupportedColorGamuts
260 * @tc.type: FUNC
261 */
262 HWTEST_F(DisplayManagerProxyTest, GetScreenSupportedColorGamuts01, Function | SmallTest | Level1)
263 {
264 std::vector<ScreenColorGamut> gamutVector;
265 DisplayManagerProxy proxy1(nullptr);
266 ASSERT_EQ(nullptr, proxy1.remoteObject_);
267 auto result1 = proxy1.GetScreenSupportedColorGamuts(0, gamutVector);
268 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, result1);
269 gamutVector.clear();
270
271 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
272 DisplayManagerProxy proxy2(remoteMocker);
273 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
274 auto result2 = proxy2.GetScreenSupportedColorGamuts(0, gamutVector);
275 ASSERT_EQ(DMError::DM_OK, result2);
276 remoteMocker->sendRequestResult_ = 1;
277 auto result3 = proxy2.GetScreenSupportedColorGamuts(0, gamutVector);
278 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
279 }
280
281 /**
282 * @tc.name: GetScreenColorGamut01
283 * @tc.desc: test DisplayManagerProxy::GetScreenColorGamut
284 * @tc.type: FUNC
285 */
286 HWTEST_F(DisplayManagerProxyTest, GetScreenColorGamut01, Function | SmallTest | Level1)
287 {
288 DisplayManagerProxy proxy1(nullptr);
289 ASSERT_EQ(nullptr, proxy1.remoteObject_);
290 ScreenColorGamut screenColorGamut;
291 auto result1 = proxy1.GetScreenColorGamut(0, screenColorGamut);
292 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, result1);
293
294 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
295 DisplayManagerProxy proxy2(remoteMocker);
296 ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
297 screenColorGamut = ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB;
298 auto result2 = proxy2.GetScreenColorGamut(0, screenColorGamut);
299 ASSERT_EQ(DMError::DM_OK, result2);
300 ASSERT_EQ(ScreenColorGamut::COLOR_GAMUT_NATIVE, screenColorGamut);
301
302 screenColorGamut = ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB;
303 remoteMocker->sendRequestResult_ = 1;
304 auto result3 = proxy2.GetScreenColorGamut(0, screenColorGamut);
305 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
306 ASSERT_EQ(ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB, screenColorGamut);
307 }
308
309 /**
310 * @tc.name: SetScreenColorGamut01
311 * @tc.desc: test DisplayManagerProxy::SetScreenColorGamut
312 * @tc.type: FUNC
313 */
314 HWTEST_F(DisplayManagerProxyTest, SetScreenColorGamut01, Function | SmallTest | Level1)
315 {
316 DisplayManagerProxy proxy1(nullptr);
317 EXPECT_EQ(nullptr, proxy1.remoteObject_);
318 auto result1 = proxy1.SetScreenColorGamut(0, 3);
319 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
320
321 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
322 DisplayManagerProxy proxy2(remoteMocker);
323 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
324 auto result2 = proxy2.SetScreenColorGamut(0, 3);
325 EXPECT_EQ(DMError::DM_OK, result2);
326
327 remoteMocker->sendRequestResult_ = 1;
328 auto result3 = proxy2.SetScreenColorGamut(0, 3);
329 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
330 }
331
332 /**
333 * @tc.name: GetScreenGamutMap01
334 * @tc.desc: test DisplayManagerProxy::GetScreenGamutMap
335 * @tc.type: FUNC
336 */
337 HWTEST_F(DisplayManagerProxyTest, GetScreenGamutMap01, Function | SmallTest | Level1)
338 {
339 DisplayManagerProxy proxy1(nullptr);
340 EXPECT_EQ(nullptr, proxy1.remoteObject_);
341 ScreenGamutMap gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION;
342 auto result1 = proxy1.GetScreenGamutMap(0, gamutMap);
343 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
344
345 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
346 DisplayManagerProxy proxy2(remoteMocker);
347 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
348 gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION;
349 auto result2 = proxy2.GetScreenGamutMap(0, gamutMap);
350 EXPECT_EQ(DMError::DM_OK, result2);
351 EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_CONSTANT, gamutMap);
352
353 gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION;
354 remoteMocker->sendRequestResult_ = 1;
355 auto result3 = proxy2.GetScreenGamutMap(0, gamutMap);
356 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
357 EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION, gamutMap);
358 }
359
360 /**
361 * @tc.name: SetScreenGamutMap01
362 * @tc.desc: test DisplayManagerProxy::SetScreenGamutMap
363 * @tc.type: FUNC
364 */
365 HWTEST_F(DisplayManagerProxyTest, SetScreenGamutMap01, Function | SmallTest | Level1)
366 {
367 DisplayManagerProxy proxy1(nullptr);
368 EXPECT_EQ(nullptr, proxy1.remoteObject_);
369 ScreenGamutMap gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION;
370 auto result1 = proxy1.SetScreenGamutMap(0, gamutMap);
371 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
372
373 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
374 DisplayManagerProxy proxy2(remoteMocker);
375 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
376 gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION;
377 auto result2 = proxy2.SetScreenGamutMap(0, gamutMap);
378 EXPECT_EQ(DMError::DM_OK, result2);
379 EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION, gamutMap);
380
381 gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION;
382 remoteMocker->sendRequestResult_ = 1;
383 auto result3 = proxy2.SetScreenGamutMap(0, gamutMap);
384 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
385 EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION, gamutMap);
386 }
387
388 /**
389 * @tc.name: SetScreenColorTransform01
390 * @tc.desc: test DisplayManagerProxy::SetScreenColorTransform
391 * @tc.type: FUNC
392 */
393 HWTEST_F(DisplayManagerProxyTest, SetScreenColorTransform01, Function | SmallTest | Level1)
394 {
395 DisplayManagerProxy proxy1(nullptr);
396 EXPECT_EQ(nullptr, proxy1.remoteObject_);
397 auto result1 = proxy1.SetScreenColorTransform(0);
398 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
399
400 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
401 DisplayManagerProxy proxy2(remoteMocker);
402 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
403
404 auto result2 = proxy2.SetScreenColorTransform(0);
405 EXPECT_EQ(DMError::DM_OK, result2);
406
407 remoteMocker->sendRequestResult_ = 1;
408 auto result3 = proxy2.SetScreenColorTransform(0);
409 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
410 }
411
412 /**
413 * @tc.name: RegisterDisplayManagerAgent01
414 * @tc.desc: test DisplayManagerProxy::RegisterDisplayManagerAgent
415 * @tc.type: FUNC
416 */
417 HWTEST_F(DisplayManagerProxyTest, RegisterDisplayManagerAgent01, Function | SmallTest | Level1)
418 {
419 sptr<IRemoteObject> iRemoteObject = new IRemoteObjectMocker();
420 DisplayManagerProxy proxy1(iRemoteObject);
421 EXPECT_NE(nullptr, proxy1.remoteObject_);
422 sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
423 DisplayManagerAgentType type = DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER;
424 DMError result01 = proxy1.RegisterDisplayManagerAgent(displayManagerAgent, type);
425 EXPECT_EQ(result01, DMError::DM_OK);
426 }
427
428 /**
429 * @tc.name: UnregisterDisplayManagerAgent01
430 * @tc.desc: test DisplayManagerProxy::UnregisterDisplayManagerAgent
431 * @tc.type: FUNC
432 */
433 HWTEST_F(DisplayManagerProxyTest, UnregisterDisplayManagerAgent01, Function | SmallTest | Level1)
434 {
435 sptr<IRemoteObject> iRemoteObject = new IRemoteObjectMocker();
436 DisplayManagerProxy proxy1(iRemoteObject);
437 EXPECT_NE(nullptr, proxy1.remoteObject_);
438 sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
439 DisplayManagerAgentType type = DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER;
440 DMError result01 = proxy1.UnregisterDisplayManagerAgent(displayManagerAgent, type);
441 EXPECT_EQ(result01, DMError::DM_OK);
442 }
443
444 /**
445 * @tc.name: WakeUpBegin01
446 * @tc.desc: test DisplayManagerProxy::WakeUpBegin
447 * @tc.type: FUNC
448 */
449 HWTEST_F(DisplayManagerProxyTest, WakeUpBegin01, Function | SmallTest | Level1)
450 {
451 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
452 DisplayManagerProxy proxy1(remoteMocker);
453 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
454
455 PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON;
456 auto result1 = proxy1.WakeUpBegin(reason);
457 EXPECT_EQ(result1, false);
458
459 remoteMocker->sendRequestResult_ = 1;
460 auto result2 = proxy1.WakeUpBegin(reason);
461 EXPECT_EQ(result2, false);
462 }
463
464 /**
465 * @tc.name: WakeUpEnd01
466 * @tc.desc: test DisplayManagerProxy::WakeUpEnd
467 * @tc.type: FUNC
468 */
469 HWTEST_F(DisplayManagerProxyTest, WakeUpEnd01, Function | SmallTest | Level1)
470 {
471 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
472 DisplayManagerProxy proxy1(remoteMocker);
473 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
474
475 auto result1 = proxy1.WakeUpEnd();
476 EXPECT_EQ(result1, false);
477
478 remoteMocker->sendRequestResult_ = 1;
479 auto result2 = proxy1.WakeUpEnd();
480 EXPECT_EQ(result2, false);
481 }
482
483 /**
484 * @tc.name: GetPixelFormat
485 * @tc.desc: test DisplayManagerProxy::GetPixelFormat
486 * @tc.type: FUNC
487 */
488 HWTEST_F(DisplayManagerProxyTest, GetPixelFormat, Function | SmallTest | Level1)
489 {
490 GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT1};
491 DisplayManagerProxy proxy1(nullptr);
492 EXPECT_EQ(nullptr, proxy1.remoteObject_);
493 auto result1 = proxy1.GetPixelFormat(0, pixelFormat);
494 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
495
496 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
497 DisplayManagerProxy proxy2(remoteMocker);
498 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
499
500 auto result2 = proxy2.GetPixelFormat(0, pixelFormat);
501 EXPECT_EQ(DMError::DM_OK, result2);
502
503 remoteMocker->sendRequestResult_ = 1;
504 auto result3 = proxy2.GetPixelFormat(0, pixelFormat);
505 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
506 }
507
508 /**
509 * @tc.name: SetPixelFormat
510 * @tc.desc: test DisplayManagerProxy::SetPixelFormat
511 * @tc.type: FUNC
512 */
513 HWTEST_F(DisplayManagerProxyTest, SetPixelFormat, Function | SmallTest | Level1)
514 {
515 GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT1};
516 DisplayManagerProxy proxy1(nullptr);
517 EXPECT_EQ(nullptr, proxy1.remoteObject_);
518 auto result1 = proxy1.SetPixelFormat(0, pixelFormat);
519 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
520
521 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
522 DisplayManagerProxy proxy2(remoteMocker);
523 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
524
525 auto result2 = proxy2.SetPixelFormat(0, pixelFormat);
526 EXPECT_EQ(DMError::DM_OK, result2);
527
528 remoteMocker->sendRequestResult_ = 1;
529 auto result3 = proxy2.SetPixelFormat(0, pixelFormat);
530 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
531 }
532
533 /**
534 * @tc.name: GetSupportedHDRFormats
535 * @tc.desc: test DisplayManagerProxy::GetSupportedHDRFormats
536 * @tc.type: FUNC
537 */
538 HWTEST_F(DisplayManagerProxyTest, GetSupportedHDRFormats, Function | SmallTest | Level1)
539 {
540 std::vector<ScreenHDRFormat> hdrFormats;
541 DisplayManagerProxy proxy1(nullptr);
542 EXPECT_EQ(nullptr, proxy1.remoteObject_);
543 auto result1 = proxy1.GetSupportedHDRFormats(0, hdrFormats);
544 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
545
546 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
547 DisplayManagerProxy proxy2(remoteMocker);
548 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
549
550 auto result2 = proxy2.GetSupportedHDRFormats(0, hdrFormats);
551 EXPECT_EQ(DMError::DM_OK, result2);
552
553 remoteMocker->sendRequestResult_ = 1;
554 auto result3 = proxy2.GetSupportedHDRFormats(0, hdrFormats);
555 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
556 }
557
558 /**
559 * @tc.name: SetScreenHDRFormat
560 * @tc.desc: test DisplayManagerProxy::SetScreenHDRFormat
561 * @tc.type: FUNC
562 */
563 HWTEST_F(DisplayManagerProxyTest, SetScreenHDRFormat, Function | SmallTest | Level1)
564 {
565 DisplayManagerProxy proxy1(nullptr);
566 EXPECT_EQ(nullptr, proxy1.remoteObject_);
567 auto result1 = proxy1.SetScreenHDRFormat(0, 0);
568 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
569
570 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
571 DisplayManagerProxy proxy2(remoteMocker);
572 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
573
574 auto result2 = proxy2.SetScreenHDRFormat(0, 0);
575 EXPECT_EQ(DMError::DM_OK, result2);
576
577 remoteMocker->sendRequestResult_ = 1;
578 auto result3 = proxy2.SetScreenHDRFormat(0, 0);
579 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
580 }
581
582 /**
583 * @tc.name: GetScreenHDRFormat
584 * @tc.desc: test DisplayManagerProxy::GetScreenHDRFormat
585 * @tc.type: FUNC
586 */
587 HWTEST_F(DisplayManagerProxyTest, GetScreenHDRFormat, Function | SmallTest | Level1)
588 {
589 ScreenHDRFormat hdrFormats = ScreenHDRFormat{VIDEO_HLG};
590 DisplayManagerProxy proxy1(nullptr);
591 EXPECT_EQ(nullptr, proxy1.remoteObject_);
592 auto result1 = proxy1.GetScreenHDRFormat(0, hdrFormats);
593 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
594
595 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
596 DisplayManagerProxy proxy2(remoteMocker);
597 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
598
599 auto result2 = proxy2.GetScreenHDRFormat(0, hdrFormats);
600 EXPECT_EQ(DMError::DM_OK, result2);
601
602 remoteMocker->sendRequestResult_ = 1;
603 auto result3 = proxy2.GetScreenHDRFormat(0, hdrFormats);
604 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
605 }
606
607 /**
608 * @tc.name: GetSupportedColorSpaces
609 * @tc.desc: test DisplayManagerProxy::GetSupportedColorSpaces
610 * @tc.type: FUNC
611 */
612 HWTEST_F(DisplayManagerProxyTest, GetSupportedColorSpaces, Function | SmallTest | Level1)
613 {
614 std::vector<GraphicCM_ColorSpaceType> colorSpaces;
615 DisplayManagerProxy proxy1(nullptr);
616 EXPECT_EQ(nullptr, proxy1.remoteObject_);
617 auto result1 = proxy1.GetSupportedColorSpaces(0, colorSpaces);
618 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
619
620 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
621 DisplayManagerProxy proxy2(remoteMocker);
622 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
623
624 auto result2 = proxy2.GetSupportedColorSpaces(0, colorSpaces);
625 EXPECT_EQ(DMError::DM_OK, result2);
626
627 remoteMocker->sendRequestResult_ = 1;
628 auto result3 = proxy2.GetSupportedColorSpaces(0, colorSpaces);
629 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
630 }
631
632 /**
633 * @tc.name: GetScreenColorSpace
634 * @tc.desc: test DisplayManagerProxy::GetScreenColorSpace
635 * @tc.type: FUNC
636 */
637 HWTEST_F(DisplayManagerProxyTest, GetScreenColorSpace, Function | SmallTest | Level1)
638 {
639 GraphicCM_ColorSpaceType colorSpaces;
640 DisplayManagerProxy proxy1(nullptr);
641 EXPECT_EQ(nullptr, proxy1.remoteObject_);
642 auto result1 = proxy1.GetScreenColorSpace(0, colorSpaces);
643 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
644
645 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
646 DisplayManagerProxy proxy2(remoteMocker);
647 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
648
649 auto result2 = proxy2.GetScreenColorSpace(0, colorSpaces);
650 EXPECT_EQ(DMError::DM_OK, result2);
651
652 remoteMocker->sendRequestResult_ = 1;
653 auto result3 = proxy2.GetScreenColorSpace(0, colorSpaces);
654 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
655 }
656
657 /**
658 * @tc.name: SetScreenColorSpace
659 * @tc.desc: test DisplayManagerProxy::SetScreenColorSpace
660 * @tc.type: FUNC
661 */
662 HWTEST_F(DisplayManagerProxyTest, SetScreenColorSpace, Function | SmallTest | Level1)
663 {
664 GraphicCM_ColorSpaceType colorSpaces = GraphicCM_ColorSpaceType{GRAPHIC_CM_BT601_EBU_FULL};
665 DisplayManagerProxy proxy1(nullptr);
666 EXPECT_EQ(nullptr, proxy1.remoteObject_);
667 auto result1 = proxy1.SetScreenColorSpace(0, colorSpaces);
668 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
669
670 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
671 DisplayManagerProxy proxy2(remoteMocker);
672 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
673
674 auto result2 = proxy2.SetScreenColorSpace(0, colorSpaces);
675 EXPECT_EQ(DMError::DM_OK, result2);
676
677 remoteMocker->sendRequestResult_ = 1;
678 auto result3 = proxy2.SetScreenColorSpace(0, colorSpaces);
679 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
680 }
681
682 /**
683 * @tc.name: SuspendBegin
684 * @tc.desc: test DisplayManagerProxy::SuspendBegin
685 * @tc.type: FUNC
686 */
687 HWTEST_F(DisplayManagerProxyTest, SuspendBegin, Function | SmallTest | Level1)
688 {
689 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
690 DisplayManagerProxy proxy1(remoteMocker);
691 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
692
693 PowerStateChangeReason reason = PowerStateChangeReason{0};
694 auto result1 = proxy1.SuspendBegin(reason);
695 EXPECT_EQ(result1, false);
696
697 remoteMocker->sendRequestResult_ = 1;
698 auto result2 = proxy1.SuspendBegin(reason);
699 EXPECT_EQ(result2, false);
700 }
701
702 /**
703 * @tc.name: SuspendEnd
704 * @tc.desc: test DisplayManagerProxy::SuspendEnd
705 * @tc.type: FUNC
706 */
707 HWTEST_F(DisplayManagerProxyTest, SuspendEnd, Function | SmallTest | Level1)
708 {
709 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
710 DisplayManagerProxy proxy1(remoteMocker);
711 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
712
713 auto result1 = proxy1.SuspendEnd();
714 EXPECT_EQ(result1, false);
715
716 remoteMocker->sendRequestResult_ = 1;
717 auto result2 = proxy1.SuspendEnd();
718 EXPECT_EQ(result2, false);
719 }
720
721 /**
722 * @tc.name: SetScreenPowerForAll
723 * @tc.desc: test DisplayManagerProxy::SetScreenPowerForAll
724 * @tc.type: FUNC
725 */
726 HWTEST_F(DisplayManagerProxyTest, SetScreenPowerForAll, Function | SmallTest | Level1)
727 {
728 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
729 DisplayManagerProxy proxy1(remoteMocker);
730 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
731
732 ScreenPowerState state = ScreenPowerState{0};
733 PowerStateChangeReason reason = PowerStateChangeReason{0};
734 auto result1 = proxy1.SetScreenPowerForAll(state, reason);
735 EXPECT_EQ(result1, false);
736
737 remoteMocker->sendRequestResult_ = 1;
738 auto result2 = proxy1.SetScreenPowerForAll(state, reason);
739 EXPECT_EQ(result2, false);
740 }
741
742 /**
743 * @tc.name: SetSpecifiedScreenPower
744 * @tc.desc: test DisplayManagerProxy::SetSpecifiedScreenPower
745 * @tc.type: FUNC
746 */
747 HWTEST_F(DisplayManagerProxyTest, SetSpecifiedScreenPower, Function | SmallTest | Level1)
748 {
749 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
750 DisplayManagerProxy proxy1(remoteMocker);
751 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
752
753 ScreenPowerState state = ScreenPowerState{0};
754 PowerStateChangeReason reason = PowerStateChangeReason{0};
755 auto result1 = proxy1.SetSpecifiedScreenPower(0, state, reason);
756 EXPECT_EQ(result1, false);
757
758 remoteMocker->sendRequestResult_ = 1;
759 auto result2 = proxy1.SetSpecifiedScreenPower(0, state, reason);
760 EXPECT_EQ(result2, false);
761 }
762
763 /**
764 * @tc.name: SetDisplayState
765 * @tc.desc: test DisplayManagerProxy::SetDisplayState
766 * @tc.type: FUNC
767 */
768 HWTEST_F(DisplayManagerProxyTest, SetDisplayState, Function | SmallTest | Level1)
769 {
770 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
771 DisplayManagerProxy proxy1(remoteMocker);
772 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
773
774 DisplayState state = DisplayState{0};
775 auto result1 = proxy1.SetDisplayState(state);
776 EXPECT_EQ(result1, false);
777
778 remoteMocker->sendRequestResult_ = 1;
779 auto result2 = proxy1.SetDisplayState(state);
780 EXPECT_EQ(result2, false);
781 }
782
783 /**
784 * @tc.name: AddSurfaceNodeToDisplay
785 * @tc.desc: test DisplayManagerProxy::AddSurfaceNodeToDisplay
786 * @tc.type: FUNC
787 */
788 HWTEST_F(DisplayManagerProxyTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level1)
789 {
790 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
791 DisplayManagerProxy proxy1(remoteMocker);
792 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
793
794 std::shared_ptr<class RSSurfaceNode> surfaceNode;
795 auto result1 = proxy1.AddSurfaceNodeToDisplay(0, surfaceNode, true);
796 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result1);
797
798 remoteMocker->sendRequestResult_ = 1;
799 auto result2 = proxy1.AddSurfaceNodeToDisplay(0, surfaceNode, true);
800 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result2);
801 }
802
803 /**
804 * @tc.name: RemoveSurfaceNodeFromDisplay
805 * @tc.desc: test DisplayManagerProxy::RemoveSurfaceNodeFromDisplay
806 * @tc.type: FUNC
807 */
808 HWTEST_F(DisplayManagerProxyTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level1)
809 {
810 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
811 DisplayManagerProxy proxy1(remoteMocker);
812 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
813
814 std::shared_ptr<class RSSurfaceNode> surfaceNode;
815 auto result1 = proxy1.RemoveSurfaceNodeFromDisplay(0, surfaceNode);
816 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result1);
817
818 remoteMocker->sendRequestResult_ = 1;
819 auto result2 = proxy1.RemoveSurfaceNodeFromDisplay(0, surfaceNode);
820 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result2);
821 }
822
823 /**
824 * @tc.name: HasPrivateWindow
825 * @tc.desc: test DisplayManagerProxy::HasPrivateWindow
826 * @tc.type: FUNC
827 */
828 HWTEST_F(DisplayManagerProxyTest, HasPrivateWindow, Function | SmallTest | Level1)
829 {
830 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
831 DisplayManagerProxy proxy1(remoteMocker);
832 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
833
834 bool hasPrivateWindow = true;
835 auto result1 = proxy1.HasPrivateWindow(0, hasPrivateWindow);
836 EXPECT_EQ(DMError::DM_OK, result1);
837
838 remoteMocker->sendRequestResult_ = 1;
839 auto result2 = proxy1.HasPrivateWindow(0, hasPrivateWindow);
840 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result2);
841 }
842
843 /**
844 * @tc.name: SetFreeze
845 * @tc.desc: test DisplayManagerProxy::SetFreeze
846 * @tc.type: FUNC
847 */
848 HWTEST_F(DisplayManagerProxyTest, SetFreeze, Function | SmallTest | Level1)
849 {
850 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
851 DisplayManagerProxy proxy1(remoteMocker);
852 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
853
854 std::vector<DisplayId> displayIds;
855 auto result1 = proxy1.SetFreeze(displayIds, true);
856 EXPECT_TRUE(result1);
857
858 remoteMocker->sendRequestResult_ = 1;
859 auto result2 = proxy1.SetFreeze(displayIds, true);
860 EXPECT_FALSE(result2);
861 }
862
863 /**
864 * @tc.name: GetDisplayState
865 * @tc.desc: test DisplayManagerProxy::GetDisplayState
866 * @tc.type: FUNC
867 */
868 HWTEST_F(DisplayManagerProxyTest, GetDisplayState, Function | SmallTest | Level1)
869 {
870 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
871 DisplayManagerProxy proxy1(remoteMocker);
872 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
873
874 DisplayId displayId = 0;
875 auto result1 = proxy1.GetDisplayState(displayId);
876 EXPECT_EQ(result1, DisplayState::UNKNOWN);
877
878 remoteMocker->sendRequestResult_ = 1;
879 auto result2 = proxy1.GetDisplayState(displayId);
880 EXPECT_EQ(result2, DisplayState::UNKNOWN);
881 }
882
883 /**
884 * @tc.name: GetScreenPower
885 * @tc.desc: test DisplayManagerProxy::GetScreenPower
886 * @tc.type: FUNC
887 */
888 HWTEST_F(DisplayManagerProxyTest, GetScreenPower, Function | SmallTest | Level1)
889 {
890 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
891 DisplayManagerProxy proxy1(remoteMocker);
892 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
893
894 auto result1 = proxy1.GetScreenPower(0);
895 EXPECT_EQ(result1, ScreenPowerState::POWER_ON);
896
897 remoteMocker->sendRequestResult_ = 1;
898 auto result2 = proxy1.GetScreenPower(0);
899 EXPECT_EQ(result2, ScreenPowerState::INVALID_STATE);
900 }
901
902 /**
903 * @tc.name: GetAllDisplayIds
904 * @tc.desc: test DisplayManagerProxy::GetAllDisplayIds
905 * @tc.type: FUNC
906 */
907 HWTEST_F(DisplayManagerProxyTest, GetAllDisplayIds, Function | SmallTest | Level1)
908 {
909 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
910 DisplayManagerProxy proxy1(remoteMocker);
911 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
912
913 auto result1 = proxy1.GetAllDisplayIds();
914 EXPECT_TRUE(result1.empty());
915
916 remoteMocker->sendRequestResult_ = 1;
917 auto result2 = proxy1.GetAllDisplayIds();
918 EXPECT_TRUE(result2.empty());
919 }
920
921 /**
922 * @tc.name: GetCutoutInfo
923 * @tc.desc: test DisplayManagerProxy::GetCutoutInfo
924 * @tc.type: FUNC
925 */
926 HWTEST_F(DisplayManagerProxyTest, GetCutoutInfo, Function | SmallTest | Level1)
927 {
928 DisplayManagerProxy proxy1(nullptr);
929 EXPECT_EQ(nullptr, proxy1.remoteObject_);
930 auto result1 = proxy1.GetCutoutInfo(0);
931 EXPECT_EQ(nullptr, result1);
932
933 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
934 DisplayManagerProxy proxy2(remoteMocker);
935 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
936
937 auto result2 = proxy2.GetCutoutInfo(0);
938 EXPECT_EQ(nullptr, result2);
939
940 remoteMocker->sendRequestResult_ = 1;
941 auto result3 = proxy2.GetCutoutInfo(0);
942 EXPECT_EQ(nullptr, result3);
943 }
944
945 /**
946 * @tc.name: NotifyDisplayEvent
947 * @tc.desc: test DisplayManagerProxy::NotifyDisplayEvent
948 * @tc.type: FUNC
949 */
950 HWTEST_F(DisplayManagerProxyTest, NotifyDisplayEvent, Function | SmallTest | Level1)
951 {
952 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
953 DisplayManagerProxy proxy1(remoteMocker);
954 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy1.remoteObject_);
955
956 DisplayEvent event = DisplayEvent::UNLOCK;
957 proxy1.NotifyDisplayEvent(event);
958 EXPECT_TRUE(true);
959
960 remoteMocker->sendRequestResult_ = 1;
961 proxy1.NotifyDisplayEvent(event);
962 EXPECT_TRUE(true);
963 }
964
965 /**
966 * @tc.name: MakeMirror
967 * @tc.desc: test DisplayManagerProxy::MakeMirror
968 * @tc.type: FUNC
969 */
970 HWTEST_F(DisplayManagerProxyTest, MakeMirror, Function | SmallTest | Level1)
971 {
972 ScreenId mainScreenId = static_cast<ScreenId>(0);
973 std::vector<ScreenId> mirrorScreenId;
974 mirrorScreenId.emplace_back(1001);
975 ScreenId screenGroupId{0};
976 DisplayManagerProxy proxy1(nullptr);
977 EXPECT_EQ(nullptr, proxy1.remoteObject_);
978
979 auto result1 = proxy1.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
980 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
981
982 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
983 DisplayManagerProxy proxy2(remoteMocker);
984 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
985
986 auto result2 = proxy2.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
987 EXPECT_EQ(DMError::DM_OK, result2);
988
989 remoteMocker->sendRequestResult_ = 1;
990 auto result3 = proxy2.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
991 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
992 }
993
994 /**
995 * @tc.name: StopMirror
996 * @tc.desc: test DisplayManagerProxy::StopMirror
997 * @tc.type: FUNC
998 */
999 HWTEST_F(DisplayManagerProxyTest, StopMirror, Function | SmallTest | Level1)
1000 {
1001 std::vector<ScreenId> mirrorScreenId;
1002 mirrorScreenId.emplace_back(1001);
1003 DisplayManagerProxy proxy1(nullptr);
1004 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1005
1006 auto result1 = proxy1.StopMirror(mirrorScreenId);
1007 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1008
1009 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1010 DisplayManagerProxy proxy2(remoteMocker);
1011 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1012
1013 auto result2 = proxy2.StopMirror(mirrorScreenId);
1014 EXPECT_EQ(DMError::DM_OK, result2);
1015
1016 remoteMocker->sendRequestResult_ = 1;
1017 auto result3 = proxy2.StopMirror(mirrorScreenId);
1018 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1019 }
1020
1021 /**
1022 * @tc.name: GetScreenInfoById
1023 * @tc.desc: test DisplayManagerProxy::GetScreenInfoById
1024 * @tc.type: FUNC
1025 */
1026 HWTEST_F(DisplayManagerProxyTest, GetScreenInfoById, Function | SmallTest | Level1)
1027 {
1028 ScreenId screenId = static_cast<ScreenId>(0);
1029 DisplayManagerProxy proxy1(nullptr);
1030 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1031
1032 auto result1 = proxy1.GetScreenInfoById(screenId);
1033 EXPECT_EQ(nullptr, result1);
1034
1035 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1036 DisplayManagerProxy proxy2(remoteMocker);
1037 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1038
1039 auto result2 = proxy2.GetScreenInfoById(screenId);
1040 EXPECT_EQ(nullptr, result2);
1041
1042 remoteMocker->sendRequestResult_ = 1;
1043 auto result3 = proxy2.GetScreenInfoById(screenId);
1044 EXPECT_EQ(nullptr, result3);
1045 }
1046
1047 /**
1048 * @tc.name: GetScreenGroupInfoById
1049 * @tc.desc: test DisplayManagerProxy::GetScreenGroupInfoById
1050 * @tc.type: FUNC
1051 */
1052 HWTEST_F(DisplayManagerProxyTest, GetScreenGroupInfoById, Function | SmallTest | Level1)
1053 {
1054 ScreenId screenId = static_cast<ScreenId>(0);
1055 DisplayManagerProxy proxy1(nullptr);
1056 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1057
1058 auto result1 = proxy1.GetScreenGroupInfoById(screenId);
1059 EXPECT_EQ(nullptr, result1);
1060
1061 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1062 DisplayManagerProxy proxy2(remoteMocker);
1063 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1064
1065 auto result2 = proxy2.GetScreenGroupInfoById(screenId);
1066 EXPECT_EQ(nullptr, result2);
1067
1068 remoteMocker->sendRequestResult_ = 1;
1069 auto result3 = proxy2.GetScreenGroupInfoById(screenId);
1070 EXPECT_EQ(nullptr, result3);
1071 }
1072
1073 /**
1074 * @tc.name: GetAllScreenInfos
1075 * @tc.desc: test DisplayManagerProxy::GetAllScreenInfos
1076 * @tc.type: FUNC
1077 */
1078 HWTEST_F(DisplayManagerProxyTest, GetAllScreenInfos, Function | SmallTest | Level1)
1079 {
1080 std::vector<sptr<ScreenInfo>> screenInfos{nullptr};
1081 DisplayManagerProxy proxy1(nullptr);
1082 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1083
1084 auto result1 = proxy1.GetAllScreenInfos(screenInfos);
1085 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1086
1087 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1088 DisplayManagerProxy proxy2(remoteMocker);
1089 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1090
1091 auto result2 = proxy2.GetAllScreenInfos(screenInfos);
1092 EXPECT_EQ(DMError::DM_OK, result2);
1093
1094 remoteMocker->sendRequestResult_ = 1;
1095 auto result3 = proxy2.GetAllScreenInfos(screenInfos);
1096 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1097 }
1098
1099 /**
1100 * @tc.name: MakeExpand
1101 * @tc.desc: test DisplayManagerProxy::MakeExpand
1102 * @tc.type: FUNC
1103 */
1104 HWTEST_F(DisplayManagerProxyTest, MakeExpand, Function | SmallTest | Level1)
1105 {
1106 ScreenId screenId_ = static_cast<ScreenId>(0);
1107 std::vector<ScreenId> screenId;
1108 screenId.push_back(screenId_);
1109 std::vector<Point> startPoint;
1110 Point point{0, 0};
1111 startPoint.push_back(point);
1112 ScreenId screenGroupId{0};
1113 DisplayManagerProxy proxy1(nullptr);
1114 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1115
1116 auto result1 = proxy1.MakeExpand(screenId, startPoint, screenGroupId);
1117 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result1);
1118
1119 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1120 DisplayManagerProxy proxy2(remoteMocker);
1121 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1122
1123 auto result2 = proxy2.MakeExpand(screenId, startPoint, screenGroupId);
1124 EXPECT_EQ(DMError::DM_OK, result2);
1125
1126 remoteMocker->sendRequestResult_ = 1;
1127 auto result3 = proxy2.MakeExpand(screenId, startPoint, screenGroupId);
1128 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1129 }
1130
1131 /**
1132 * @tc.name: StopExpand
1133 * @tc.desc: test DisplayManagerProxy::StopExpand
1134 * @tc.type: FUNC
1135 */
1136 HWTEST_F(DisplayManagerProxyTest, StopExpand, Function | SmallTest | Level1)
1137 {
1138 ScreenId screenId_ = static_cast<ScreenId>(0);
1139 std::vector<ScreenId> screenId;
1140 screenId.push_back(screenId_);
1141 DisplayManagerProxy proxy1(nullptr);
1142 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1143
1144 auto result1 = proxy1.StopExpand(screenId);
1145 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1146
1147 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1148 DisplayManagerProxy proxy2(remoteMocker);
1149 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1150
1151 auto result2 = proxy2.StopExpand(screenId);
1152 EXPECT_EQ(DMError::DM_OK, result2);
1153
1154 remoteMocker->sendRequestResult_ = 1;
1155 auto result3 = proxy2.StopExpand(screenId);
1156 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1157 }
1158
1159 /**
1160 * @tc.name: RemoveVirtualScreenFromGroup
1161 * @tc.desc: test DisplayManagerProxy::RemoveVirtualScreenFromGroup
1162 * @tc.type: FUNC
1163 */
1164 HWTEST_F(DisplayManagerProxyTest, RemoveVirtualScreenFromGroup, Function | SmallTest | Level1)
1165 {
1166 ScreenId screenId_ = static_cast<ScreenId>(0);
1167 std::vector<ScreenId> screenId;
1168 screenId.push_back(screenId_);
1169 DisplayManagerProxy proxy1(nullptr);
1170 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1171
1172 proxy1.RemoveVirtualScreenFromGroup(screenId);
1173 EXPECT_TRUE(true);
1174
1175 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1176 DisplayManagerProxy proxy2(remoteMocker);
1177 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1178
1179 proxy2.RemoveVirtualScreenFromGroup(screenId);
1180 EXPECT_TRUE(true);
1181
1182 remoteMocker->sendRequestResult_ = 1;
1183 proxy2.RemoveVirtualScreenFromGroup(screenId);
1184 EXPECT_TRUE(true);
1185 }
1186
1187 /**
1188 * @tc.name: SetScreenActiveMode
1189 * @tc.desc: test DisplayManagerProxy::SetScreenActiveMode
1190 * @tc.type: FUNC
1191 */
1192 HWTEST_F(DisplayManagerProxyTest, SetScreenActiveMode, Function | SmallTest | Level1)
1193 {
1194 ScreenId screenId = static_cast<ScreenId>(0);
1195 DisplayManagerProxy proxy1(nullptr);
1196 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1197
1198 auto result1 = proxy1.SetScreenActiveMode(screenId, 0);
1199 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1200
1201 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1202 DisplayManagerProxy proxy2(remoteMocker);
1203 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1204
1205 auto result2 = proxy2.SetScreenActiveMode(screenId, 0);
1206 EXPECT_EQ(DMError::DM_OK, result2);
1207
1208 remoteMocker->sendRequestResult_ = 1;
1209 auto result3 = proxy2.SetScreenActiveMode(screenId, 0);
1210 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1211 }
1212
1213 /**
1214 * @tc.name: SetVirtualPixelRatio
1215 * @tc.desc: test DisplayManagerProxy::SetVirtualPixelRatio
1216 * @tc.type: FUNC
1217 */
1218 HWTEST_F(DisplayManagerProxyTest, SetVirtualPixelRatio, Function | SmallTest | Level1)
1219 {
1220 ScreenId screenId = static_cast<ScreenId>(0);
1221 float virtualPixelRatio = 0;
1222 DisplayManagerProxy proxy1(nullptr);
1223 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1224
1225 auto result1 = proxy1.SetVirtualPixelRatio(screenId, virtualPixelRatio);
1226 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1227
1228 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1229 DisplayManagerProxy proxy2(remoteMocker);
1230 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1231
1232 auto result2 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio);
1233 EXPECT_EQ(DMError::DM_OK, result2);
1234
1235 remoteMocker->sendRequestResult_ = 1;
1236 auto result3 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio);
1237 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1238 }
1239
1240 /**
1241 * @tc.name: SetResolution
1242 * @tc.desc: test DisplayManagerProxy::SetResolution
1243 * @tc.type: FUNC
1244 */
1245 HWTEST_F(DisplayManagerProxyTest, SetResolution, Function | SmallTest | Level1)
1246 {
1247 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1248 DisplayManagerProxy proxy(remoteMocker);
1249 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1250 ScreenId screenId = 0;
1251 auto result = proxy.SetResolution(screenId, 50, 100, 1.00);
1252 EXPECT_EQ(DMError::DM_OK, result);
1253 }
1254
1255 /**
1256 * @tc.name: GetDensityInCurResolution
1257 * @tc.desc: test DisplayManagerProxy::GetDensityInCurResolution
1258 * @tc.type: FUNC
1259 */
1260 HWTEST_F(DisplayManagerProxyTest, GetDensityInCurResolution, Function | SmallTest | Level1)
1261 {
1262 ScreenId screenId = static_cast<ScreenId>(0);
1263 float virtualPixelRatio = 0;
1264 DisplayManagerProxy proxy1(nullptr);
1265 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1266
1267 auto result1 = proxy1.GetDensityInCurResolution(screenId, virtualPixelRatio);
1268 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1269
1270 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1271 DisplayManagerProxy proxy2(remoteMocker);
1272 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1273
1274 auto result2 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio);
1275 EXPECT_EQ(DMError::DM_OK, result2);
1276
1277 remoteMocker->sendRequestResult_ = 1;
1278 auto result3 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio);
1279 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1280 }
1281
1282 /**
1283 * @tc.name: IsScreenRotationLocked
1284 * @tc.desc: test DisplayManagerProxy::IsScreenRotationLocked
1285 * @tc.type: FUNC
1286 */
1287 HWTEST_F(DisplayManagerProxyTest, IsScreenRotationLocked, Function | SmallTest | Level1)
1288 {
1289 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1290 DisplayManagerProxy proxy(remoteMocker);
1291 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1292 bool isLocked = true;
1293 auto result = proxy.IsScreenRotationLocked(isLocked);
1294 EXPECT_EQ(DMError::DM_OK, result);
1295 }
1296
1297 /**
1298 * @tc.name: SetScreenRotationLocked
1299 * @tc.desc: test DisplayManagerProxy::SetScreenRotationLocked
1300 * @tc.type: FUNC
1301 */
1302 HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLocked, Function | SmallTest | Level1)
1303 {
1304 DisplayManagerProxy proxy1(nullptr);
1305 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1306
1307 auto result1 = proxy1.SetScreenRotationLocked(true);
1308 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1309
1310 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1311 DisplayManagerProxy proxy2(remoteMocker);
1312 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1313
1314 auto result2 = proxy2.SetScreenRotationLocked(true);
1315 EXPECT_EQ(DMError::DM_OK, result2);
1316
1317 remoteMocker->sendRequestResult_ = 1;
1318 auto result3 = proxy2.SetScreenRotationLocked(true);
1319 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1320 }
1321
1322 /**
1323 * @tc.name: SetScreenRotationLockedFromJs
1324 * @tc.desc: test DisplayManagerProxy::SetScreenRotationLockedFromJs
1325 * @tc.type: FUNC
1326 */
1327 HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLockedFromJs, Function | SmallTest | Level1)
1328 {
1329 DisplayManagerProxy proxy1(nullptr);
1330 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1331
1332 auto result1 = proxy1.SetScreenRotationLockedFromJs(true);
1333 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1334
1335 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1336 DisplayManagerProxy proxy2(remoteMocker);
1337 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1338
1339 auto result2 = proxy2.SetScreenRotationLockedFromJs(true);
1340 EXPECT_EQ(DMError::DM_OK, result2);
1341
1342 remoteMocker->sendRequestResult_ = 1;
1343 auto result3 = proxy2.SetScreenRotationLockedFromJs(true);
1344 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1345 }
1346
1347 /**
1348 * @tc.name: ResizeVirtualScreen
1349 * @tc.desc: test DisplayManagerProxy::ResizeVirtualScreen
1350 * @tc.type: FUNC
1351 */
1352 HWTEST_F(DisplayManagerProxyTest, ResizeVirtualScreen, Function | SmallTest | Level1)
1353 {
1354 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1355 DisplayManagerProxy proxy(remoteMocker);
1356 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1357 ScreenId screenId = 0;
1358 auto result = proxy.ResizeVirtualScreen(screenId, 50, 100);
1359 EXPECT_EQ(DMError::DM_OK, result);
1360 }
1361
1362 /**
1363 * @tc.name: MakeUniqueScreen
1364 * @tc.desc: test DisplayManagerProxy::MakeUniqueScreen
1365 * @tc.type: FUNC
1366 */
1367 HWTEST_F(DisplayManagerProxyTest, MakeUniqueScreen, Function | SmallTest | Level1)
1368 {
1369 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1370 DisplayManagerProxy proxy(remoteMocker);
1371 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1372 std::vector<ScreenId> screenIds;
1373 std::vector<DisplayId> displayIds;
1374 auto result = proxy.MakeUniqueScreen(screenIds, displayIds);
1375 EXPECT_EQ(DMError::DM_OK, result);
1376 }
1377
1378 /**
1379 * @tc.name: RemoveVirtualScreenFromGroup02
1380 * @tc.desc: test DisplayManagerProxy::RemoveVirtualScreenFromGroup02
1381 * @tc.type: FUNC
1382 */
1383 HWTEST_F(DisplayManagerProxyTest, RemoveVirtualScreenFromGroup02, Function | SmallTest | Level1)
1384 {
1385 ScreenId screenId_ = static_cast<ScreenId>(0);
1386 std::vector<ScreenId> screenId;
1387 screenId.push_back(screenId_);
1388 DisplayManagerProxy proxy1(nullptr);
1389 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1390
1391 proxy1.RemoveVirtualScreenFromGroup(screenId);
1392 EXPECT_TRUE(true);
1393
1394 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1395 DisplayManagerProxy proxy2(remoteMocker);
1396 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1397
1398 proxy2.RemoveVirtualScreenFromGroup(screenId);
1399 EXPECT_TRUE(true);
1400
1401 remoteMocker->sendRequestResult_ = 1;
1402 proxy2.RemoveVirtualScreenFromGroup(screenId);
1403 EXPECT_TRUE(true);
1404 }
1405
1406 /**
1407 * @tc.name: SetScreenActiveMode02
1408 * @tc.desc: test DisplayManagerProxy::SetScreenActiveMode02
1409 * @tc.type: FUNC
1410 */
1411 HWTEST_F(DisplayManagerProxyTest, SetScreenActiveMode02, Function | SmallTest | Level1)
1412 {
1413 ScreenId screenId = static_cast<ScreenId>(0);
1414 DisplayManagerProxy proxy1(nullptr);
1415 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1416
1417 auto result1 = proxy1.SetScreenActiveMode(screenId, 0);
1418 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1419
1420 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1421 DisplayManagerProxy proxy2(remoteMocker);
1422 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1423
1424 auto result2 = proxy2.SetScreenActiveMode(screenId, 0);
1425 EXPECT_EQ(DMError::DM_OK, result2);
1426
1427 remoteMocker->sendRequestResult_ = 1;
1428 auto result3 = proxy2.SetScreenActiveMode(screenId, 0);
1429 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1430 }
1431
1432 /**
1433 * @tc.name: SetVirtualPixelRatio02
1434 * @tc.desc: test DisplayManagerProxy::SetVirtualPixelRatio02
1435 * @tc.type: FUNC
1436 */
1437 HWTEST_F(DisplayManagerProxyTest, SetVirtualPixelRatio02, Function | SmallTest | Level1)
1438 {
1439 ScreenId screenId = static_cast<ScreenId>(0);
1440 float virtualPixelRatio = 0;
1441 DisplayManagerProxy proxy1(nullptr);
1442 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1443
1444 auto result1 = proxy1.SetVirtualPixelRatio(screenId, virtualPixelRatio);
1445 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1446
1447 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1448 DisplayManagerProxy proxy2(remoteMocker);
1449 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1450
1451 auto result2 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio);
1452 EXPECT_EQ(DMError::DM_OK, result2);
1453
1454 remoteMocker->sendRequestResult_ = 1;
1455 auto result3 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio);
1456 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1457 }
1458
1459 /**
1460 * @tc.name: SetResolution02
1461 * @tc.desc: test DisplayManagerProxy::SetResolution02
1462 * @tc.type: FUNC
1463 */
1464 HWTEST_F(DisplayManagerProxyTest, SetResolution02, Function | SmallTest | Level1)
1465 {
1466 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1467 DisplayManagerProxy proxy(remoteMocker);
1468 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1469 ScreenId screenId = 0;
1470 auto result = proxy.SetResolution(screenId, 50, 100, 1.00);
1471 EXPECT_EQ(DMError::DM_OK, result);
1472 }
1473
1474 /**
1475 * @tc.name: GetDensityInCurResolution02
1476 * @tc.desc: test DisplayManagerProxy::GetDensityInCurResolution02
1477 * @tc.type: FUNC
1478 */
1479 HWTEST_F(DisplayManagerProxyTest, GetDensityInCurResolution02, Function | SmallTest | Level1)
1480 {
1481 ScreenId screenId = static_cast<ScreenId>(0);
1482 float virtualPixelRatio = 0;
1483 DisplayManagerProxy proxy1(nullptr);
1484 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1485
1486 auto result1 = proxy1.GetDensityInCurResolution(screenId, virtualPixelRatio);
1487 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1488
1489 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1490 DisplayManagerProxy proxy2(remoteMocker);
1491 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1492
1493 auto result2 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio);
1494 EXPECT_EQ(DMError::DM_OK, result2);
1495
1496 remoteMocker->sendRequestResult_ = 1;
1497 auto result3 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio);
1498 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1499 }
1500
1501 /**
1502 * @tc.name: IsScreenRotationLocked02
1503 * @tc.desc: test DisplayManagerProxy::IsScreenRotationLocked02
1504 * @tc.type: FUNC
1505 */
1506 HWTEST_F(DisplayManagerProxyTest, IsScreenRotationLocked02, Function | SmallTest | Level1)
1507 {
1508 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1509 DisplayManagerProxy proxy(remoteMocker);
1510 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1511 bool isLocked = true;
1512 auto result = proxy.IsScreenRotationLocked(isLocked);
1513 EXPECT_EQ(DMError::DM_OK, result);
1514 }
1515
1516 /**
1517 * @tc.name: SetScreenRotationLocked02
1518 * @tc.desc: test DisplayManagerProxy::SetScreenRotationLocked02
1519 * @tc.type: FUNC
1520 */
1521 HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLocked02, Function | SmallTest | Level1)
1522 {
1523 DisplayManagerProxy proxy1(nullptr);
1524 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1525
1526 auto result1 = proxy1.SetScreenRotationLocked(true);
1527 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1528
1529 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1530 DisplayManagerProxy proxy2(remoteMocker);
1531 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1532
1533 auto result2 = proxy2.SetScreenRotationLocked(true);
1534 EXPECT_EQ(DMError::DM_OK, result2);
1535
1536 remoteMocker->sendRequestResult_ = 1;
1537 auto result3 = proxy2.SetScreenRotationLocked(true);
1538 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1539 }
1540
1541 /**
1542 * @tc.name: SetScreenRotationLockedFromJs02
1543 * @tc.desc: test DisplayManagerProxy::SetScreenRotationLockedFromJs02
1544 * @tc.type: FUNC
1545 */
1546 HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLockedFromJs02, Function | SmallTest | Level1)
1547 {
1548 DisplayManagerProxy proxy1(nullptr);
1549 EXPECT_EQ(nullptr, proxy1.remoteObject_);
1550
1551 auto result1 = proxy1.SetScreenRotationLockedFromJs(true);
1552 EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1);
1553
1554 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1555 DisplayManagerProxy proxy2(remoteMocker);
1556 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
1557
1558 auto result2 = proxy2.SetScreenRotationLockedFromJs(true);
1559 EXPECT_EQ(DMError::DM_OK, result2);
1560
1561 remoteMocker->sendRequestResult_ = 1;
1562 auto result3 = proxy2.SetScreenRotationLockedFromJs(true);
1563 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
1564 }
1565
1566 /**
1567 * @tc.name: ResizeVirtualScreen02
1568 * @tc.desc: test DisplayManagerProxy::ResizeVirtualScreen02
1569 * @tc.type: FUNC
1570 */
1571 HWTEST_F(DisplayManagerProxyTest, ResizeVirtualScreen02, Function | SmallTest | Level1)
1572 {
1573 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1574 DisplayManagerProxy proxy(remoteMocker);
1575 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1576 ScreenId screenId = 0;
1577 auto result = proxy.ResizeVirtualScreen(screenId, 50, 100);
1578 EXPECT_EQ(DMError::DM_OK, result);
1579 }
1580
1581 /**
1582 * @tc.name: MakeUniqueScreen02
1583 * @tc.desc: test DisplayManagerProxy::MakeUniqueScreen02
1584 * @tc.type: FUNC
1585 */
1586 HWTEST_F(DisplayManagerProxyTest, MakeUniqueScreen02, Function | SmallTest | Level1)
1587 {
1588 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
1589 DisplayManagerProxy proxy(remoteMocker);
1590 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
1591 std::vector<ScreenId> screenIds;
1592 std::vector<DisplayId> displayIds;
1593 auto result = proxy.MakeUniqueScreen(screenIds, displayIds);
1594 EXPECT_EQ(DMError::DM_OK, result);
1595 }
1596 }
1597 } // namespace Rosen
1598 } // namespace OHOS