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 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
387 DisplayManagerProxy proxy2(remoteMocker);
388 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
389 auto result2 = proxy2.SetScreenColorTransform(0);
390 EXPECT_EQ(DMError::DM_OK, result2);
391
392 remoteMocker->sendRequestResult_ = 1;
393 auto result3 = proxy2.SetScreenColorTransform(0);
394 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
395 }
396
397 /**
398 * @tc.name: RegisterDisplayManagerAgent01
399 * @tc.desc: test DisplayManagerProxy::RegisterDisplayManagerAgent
400 * @tc.type: FUNC
401 */
402 HWTEST_F(DisplayManagerProxyTest, RegisterDisplayManagerAgent01, Function | SmallTest | Level1)
403 {
404 sptr<IRemoteObject> iRemoteObject = new IRemoteObjectMocker();
405 DisplayManagerProxy proxy1(iRemoteObject);
406 EXPECT_NE(nullptr, proxy1.remoteObject_);
407 sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
408 DisplayManagerAgentType type = DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER;
409 DMError result01 = proxy1.RegisterDisplayManagerAgent(displayManagerAgent, type);
410 EXPECT_EQ(result01, DMError::DM_OK);
411 }
412
413 /**
414 * @tc.name: UnregisterDisplayManagerAgent01
415 * @tc.desc: test DisplayManagerProxy::UnregisterDisplayManagerAgent
416 * @tc.type: FUNC
417 */
418 HWTEST_F(DisplayManagerProxyTest, UnregisterDisplayManagerAgent01, Function | SmallTest | Level1)
419 {
420 sptr<IRemoteObject> iRemoteObject = new IRemoteObjectMocker();
421 DisplayManagerProxy proxy1(iRemoteObject);
422 EXPECT_NE(nullptr, proxy1.remoteObject_);
423 sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
424 DisplayManagerAgentType type = DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER;
425 DMError result01 = proxy1.UnregisterDisplayManagerAgent(displayManagerAgent, type);
426 EXPECT_EQ(result01, DMError::DM_OK);
427 }
428
429 /**
430 * @tc.name: WakeUpBegin01
431 * @tc.desc: test DisplayManagerProxy::WakeUpBegin
432 * @tc.type: FUNC
433 */
434 HWTEST_F(DisplayManagerProxyTest, WakeUpBegin01, Function | SmallTest | Level1)
435 {
436 sptr<IRemoteObject> iRemoteObject = new IRemoteObjectMocker();
437 DisplayManagerProxy proxy1(iRemoteObject);
438 EXPECT_NE(nullptr, proxy1.remoteObject_);
439 PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON;
440 bool result01 = proxy1.WakeUpBegin(reason);
441 EXPECT_EQ(result01, false);
442 }
443
444 /**
445 * @tc.name: WakeUpEnd01
446 * @tc.desc: test DisplayManagerProxy::WakeUpEnd
447 * @tc.type: FUNC
448 */
449 HWTEST_F(DisplayManagerProxyTest, WakeUpEnd01, Function | SmallTest | Level1)
450 {
451 sptr<IRemoteObject> iRemoteObject = new IRemoteObjectMocker();
452 DisplayManagerProxy proxy1(iRemoteObject);
453 EXPECT_NE(nullptr, proxy1.remoteObject_);
454 bool result01 = proxy1.WakeUpEnd();
455 EXPECT_EQ(result01, false);
456 }
457
458 /**
459 * @tc.name: GetPixelFormat
460 * @tc.desc: test DisplayManagerProxy::GetPixelFormat
461 * @tc.type: FUNC
462 */
463 HWTEST_F(DisplayManagerProxyTest, GetPixelFormat, Function | SmallTest | Level1)
464 {
465 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
466 DisplayManagerProxy proxy(remoteMocker);
467 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
468 GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT1};
469 auto result = proxy.GetPixelFormat(0, pixelFormat);
470 EXPECT_EQ(DMError::DM_OK, result);
471 }
472
473 /**
474 * @tc.name: SetPixelFormat
475 * @tc.desc: test DisplayManagerProxy::SetPixelFormat
476 * @tc.type: FUNC
477 */
478 HWTEST_F(DisplayManagerProxyTest, SetPixelFormat, Function | SmallTest | Level1)
479 {
480 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
481 DisplayManagerProxy proxy(remoteMocker);
482 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
483 GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT1};
484 auto result = proxy.SetPixelFormat(0, pixelFormat);
485 EXPECT_EQ(DMError::DM_OK, result);
486 }
487
488 /**
489 * @tc.name: GetSupportedHDRFormats
490 * @tc.desc: test DisplayManagerProxy::GetSupportedHDRFormats
491 * @tc.type: FUNC
492 */
493 HWTEST_F(DisplayManagerProxyTest, GetSupportedHDRFormats, Function | SmallTest | Level1)
494 {
495 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
496 DisplayManagerProxy proxy(remoteMocker);
497 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
498 std::vector<ScreenHDRFormat> hdrFormats;
499 auto result = proxy.GetSupportedHDRFormats(0, hdrFormats);
500 EXPECT_EQ(DMError::DM_OK, result);
501 }
502
503 /**
504 * @tc.name: SetScreenHDRFormat
505 * @tc.desc: test DisplayManagerProxy::SetScreenHDRFormat
506 * @tc.type: FUNC
507 */
508 HWTEST_F(DisplayManagerProxyTest, SetScreenHDRFormat, Function | SmallTest | Level1)
509 {
510 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
511 DisplayManagerProxy proxy(remoteMocker);
512 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
513 auto result = proxy.SetScreenHDRFormat(0, 0);
514 EXPECT_EQ(DMError::DM_OK, result);
515 }
516
517 /**
518 * @tc.name: GetScreenHDRFormat
519 * @tc.desc: test DisplayManagerProxy::GetScreenHDRFormat
520 * @tc.type: FUNC
521 */
522 HWTEST_F(DisplayManagerProxyTest, GetScreenHDRFormat, Function | SmallTest | Level1)
523 {
524 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
525 DisplayManagerProxy proxy(remoteMocker);
526 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
527 ScreenHDRFormat hdrFormats = ScreenHDRFormat{VIDEO_HLG};
528 auto result = proxy.GetScreenHDRFormat(0, hdrFormats);
529 EXPECT_EQ(DMError::DM_OK, result);
530 }
531
532 /**
533 * @tc.name: GetSupportedColorSpaces
534 * @tc.desc: test DisplayManagerProxy::GetSupportedColorSpaces
535 * @tc.type: FUNC
536 */
537 HWTEST_F(DisplayManagerProxyTest, GetSupportedColorSpaces, Function | SmallTest | Level1)
538 {
539 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
540 DisplayManagerProxy proxy(remoteMocker);
541 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
542 std::vector<GraphicCM_ColorSpaceType> colorSpaces;
543 auto result = proxy.GetSupportedColorSpaces(0, colorSpaces);
544 EXPECT_EQ(DMError::DM_OK, result);
545 }
546
547 /**
548 * @tc.name: GetScreenColorSpace
549 * @tc.desc: test DisplayManagerProxy::GetScreenColorSpace
550 * @tc.type: FUNC
551 */
552 HWTEST_F(DisplayManagerProxyTest, GetScreenColorSpace, Function | SmallTest | Level1)
553 {
554 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
555 DisplayManagerProxy proxy(remoteMocker);
556 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
557 GraphicCM_ColorSpaceType colorSpaces;
558 auto result = proxy.GetScreenColorSpace(0, colorSpaces);
559 EXPECT_EQ(DMError::DM_OK, result);
560 }
561
562 /**
563 * @tc.name: SetScreenColorSpace
564 * @tc.desc: test DisplayManagerProxy::SetScreenColorSpace
565 * @tc.type: FUNC
566 */
567 HWTEST_F(DisplayManagerProxyTest, SetScreenColorSpace, Function | SmallTest | Level1)
568 {
569 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
570 DisplayManagerProxy proxy(remoteMocker);
571 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
572 GraphicCM_ColorSpaceType colorSpaces = GraphicCM_ColorSpaceType{GRAPHIC_CM_BT601_EBU_FULL};
573 auto result = proxy.SetScreenColorSpace(0, colorSpaces);
574 EXPECT_EQ(DMError::DM_OK, result);
575 }
576
577 /**
578 * @tc.name: SuspendBegin
579 * @tc.desc: test DisplayManagerProxy::SuspendBegin
580 * @tc.type: FUNC
581 */
582 HWTEST_F(DisplayManagerProxyTest, SuspendBegin, Function | SmallTest | Level1)
583 {
584 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
585 DisplayManagerProxy proxy(remoteMocker);
586 PowerStateChangeReason reason = PowerStateChangeReason{0};
587 auto result = proxy.SuspendBegin(reason);
588 ASSERT_FALSE(result);
589 }
590
591 /**
592 * @tc.name: SuspendEnd
593 * @tc.desc: test DisplayManagerProxy::SuspendEnd
594 * @tc.type: FUNC
595 */
596 HWTEST_F(DisplayManagerProxyTest, SuspendEnd, Function | SmallTest | Level1)
597 {
598 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
599 DisplayManagerProxy proxy(remoteMocker);
600 auto result = proxy.SuspendEnd();
601 ASSERT_FALSE(result);
602 }
603
604 /**
605 * @tc.name: SetScreenPowerForAll
606 * @tc.desc: test DisplayManagerProxy::SetScreenPowerForAll
607 * @tc.type: FUNC
608 */
609 HWTEST_F(DisplayManagerProxyTest, SetScreenPowerForAll, Function | SmallTest | Level1)
610 {
611 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
612 DisplayManagerProxy proxy(remoteMocker);
613 ScreenPowerState state = ScreenPowerState{0};
614 PowerStateChangeReason reason = PowerStateChangeReason{0};
615 auto result = proxy.SetScreenPowerForAll(state, reason);
616 ASSERT_FALSE(result);
617 }
618
619 /**
620 * @tc.name: SetSpecifiedScreenPower
621 * @tc.desc: test DisplayManagerProxy::SetSpecifiedScreenPower
622 * @tc.type: FUNC
623 */
624 HWTEST_F(DisplayManagerProxyTest, SetSpecifiedScreenPower, Function | SmallTest | Level1)
625 {
626 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
627 DisplayManagerProxy proxy(remoteMocker);
628 ScreenPowerState state = ScreenPowerState{0};
629 PowerStateChangeReason reason = PowerStateChangeReason{0};
630 auto result = proxy.SetSpecifiedScreenPower(0, state, reason);
631 ASSERT_FALSE(result);
632 }
633
634 /**
635 * @tc.name: SetDisplayState
636 * @tc.desc: test DisplayManagerProxy::SetDisplayState
637 * @tc.type: FUNC
638 */
639 HWTEST_F(DisplayManagerProxyTest, SetDisplayState, Function | SmallTest | Level1)
640 {
641 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
642 DisplayManagerProxy proxy(remoteMocker);
643 DisplayState state = DisplayState{0};
644 auto result = proxy.SetDisplayState(state);
645 ASSERT_FALSE(result);
646 }
647
648 /**
649 * @tc.name: AddSurfaceNodeToDisplay
650 * @tc.desc: test DisplayManagerProxy::AddSurfaceNodeToDisplay
651 * @tc.type: FUNC
652 */
653 HWTEST_F(DisplayManagerProxyTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level1)
654 {
655 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
656 DisplayManagerProxy proxy(remoteMocker);
657 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
658 std::shared_ptr<class RSSurfaceNode> surfaceNode;
659 auto result = proxy.AddSurfaceNodeToDisplay(0, surfaceNode, true);
660 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result);
661 }
662
663 /**
664 * @tc.name: RemoveSurfaceNodeFromDisplay
665 * @tc.desc: test DisplayManagerProxy::RemoveSurfaceNodeFromDisplay
666 * @tc.type: FUNC
667 */
668 HWTEST_F(DisplayManagerProxyTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level1)
669 {
670 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
671 DisplayManagerProxy proxy(remoteMocker);
672 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
673 std::shared_ptr<class RSSurfaceNode> surfaceNode;
674 auto result = proxy.RemoveSurfaceNodeFromDisplay(0, surfaceNode);
675 EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result);
676 }
677
678 /**
679 * @tc.name: HasPrivateWindow
680 * @tc.desc: test DisplayManagerProxy::HasPrivateWindow
681 * @tc.type: FUNC
682 */
683 HWTEST_F(DisplayManagerProxyTest, HasPrivateWindow, Function | SmallTest | Level1)
684 {
685 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
686 DisplayManagerProxy proxy(remoteMocker);
687 EXPECT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy.remoteObject_);
688 bool hasPrivateWindow = true;
689 auto result = proxy.HasPrivateWindow(0, hasPrivateWindow);
690 EXPECT_EQ(DMError::DM_OK, result);
691 }
692
693 /**
694 * @tc.name: SetFreeze
695 * @tc.desc: test DisplayManagerProxy::SetFreeze
696 * @tc.type: FUNC
697 */
698 HWTEST_F(DisplayManagerProxyTest, SetFreeze, Function | SmallTest | Level1)
699 {
700 sptr<RemoteMocker> remoteMocker = new RemoteMocker();
701 DisplayManagerProxy proxy(remoteMocker);
702 DisplayEvent event = DisplayEvent{0};
703 proxy.NotifyDisplayEvent(event);
704
705 std::vector<DisplayId> displayIds;
706 auto result = proxy.SetFreeze(displayIds, true);
707 ASSERT_TRUE(result);
708 }
709 }
710 } // namespace Rosen
711 } // namespace OHOS