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