• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, Hardware
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 "EGL/egl_wrapper_display.h"
19 #include "EGL/egl_wrapper_surface.h"
20 
21 #include "egl_defs.h"
22 #include "thread_private_data_ctl.h"
23 #include <parameter.h>
24 #include <parameters.h>
25 
26 using namespace testing;
27 using namespace testing::ext;
28 
29 namespace OHOS::Rosen {
30 class EglWrapperDisplayTest : public testing::Test {
31 public:
SetUpTestCase()32     static void SetUpTestCase() {}
TearDownTestCase()33     static void TearDownTestCase() {}
SetUp()34     void SetUp() {}
TearDown()35     void TearDown() {}
36 };
37 
38 /**
39  * @tc.name: GetWrapperDisplay001
40  * @tc.desc:
41  * @tc.type: FUNC
42  */
HWTEST_F(EglWrapperDisplayTest,GetWrapperDisplay001,Level1)43 HWTEST_F(EglWrapperDisplayTest, GetWrapperDisplay001, Level1)
44 {
45     auto result = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
46     ASSERT_NE(nullptr, result);
47 }
48 
49 /**
50  * @tc.name: GetWrapperDisplay002
51  * @tc.desc:
52  * @tc.type: FUNC
53  */
HWTEST_F(EglWrapperDisplayTest,GetWrapperDisplay002,Level2)54 HWTEST_F(EglWrapperDisplayTest, GetWrapperDisplay002, Level2)
55 {
56     auto result = EglWrapperDisplay::GetWrapperDisplay(nullptr);
57     ASSERT_EQ(nullptr, result);
58 }
59 
60 /**
61  * @tc.name: GetEglNativeDisplayEXT001
62  * @tc.desc:
63  * @tc.type: FUNC
64  */
HWTEST_F(EglWrapperDisplayTest,GetEglNativeDisplayEXT001,Level1)65 HWTEST_F(EglWrapperDisplayTest, GetEglNativeDisplayEXT001, Level1)
66 {
67     auto result = gWrapperHook.wrapper.eglGetPlatformDisplayEXT(0, nullptr, 0);
68     ASSERT_EQ(EGL_NO_DISPLAY, result);
69 }
70 
71 
72 /**
73  * @tc.name: MakeCurrent001
74  * @tc.desc:
75  * @tc.type: FUNC
76  */
HWTEST_F(EglWrapperDisplayTest,MakeCurrent001,Level1)77 HWTEST_F(EglWrapperDisplayTest, MakeCurrent001, Level1)
78 {
79     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
80     EGLSurface draw = EGL_NO_SURFACE;
81     EGLSurface read = EGL_NO_SURFACE;
82     EGLContext ctx = EGL_NO_CONTEXT;
83 
84     auto result = eglWrapperDisplay->MakeCurrent(draw, read, ctx);
85     ASSERT_EQ(EGL_TRUE, result);
86 }
87 
88 /**
89  * @tc.name: CreateEglContext001
90  * @tc.desc:
91  * @tc.type: FUNC
92  */
HWTEST_F(EglWrapperDisplayTest,CreateEglContext001,Level1)93 HWTEST_F(EglWrapperDisplayTest, CreateEglContext001, Level1)
94 {
95     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
96 
97     auto temp = gWrapperHook.isLoad;
98     gWrapperHook.isLoad = false;
99 
100     auto result = eglWrapperDisplay->CreateEglContext(nullptr, nullptr, 0);
101     ASSERT_EQ(EGL_NO_CONTEXT, result);
102     gWrapperHook.isLoad = temp;
103 }
104 
105 /**
106  * @tc.name: CreateEglContext002
107  * @tc.desc:
108  * @tc.type: FUNC
109  */
HWTEST_F(EglWrapperDisplayTest,CreateEglContext002,Level2)110 HWTEST_F(EglWrapperDisplayTest, CreateEglContext002, Level2)
111 {
112     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
113 
114     auto temp = gWrapperHook.isLoad;
115     gWrapperHook.isLoad = false;
116 
117     auto result = eglWrapperDisplay->CreateEglContext(nullptr, EGL_NO_CONTEXT, 0);
118     ASSERT_EQ(EGL_NO_CONTEXT, result);
119     gWrapperHook.isLoad = temp;
120 }
121 
122 /**
123  * @tc.name: CreateEglContext003
124  * @tc.desc:
125  * @tc.type: FUNC
126  */
HWTEST_F(EglWrapperDisplayTest,CreateEglContext003,Level1)127 HWTEST_F(EglWrapperDisplayTest, CreateEglContext003, Level1)
128 {
129     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
130 
131     auto result = eglWrapperDisplay->CreateEglContext(nullptr, nullptr, 0);
132     ASSERT_EQ(EGL_NO_CONTEXT, result);
133 }
134 
135 /**
136  * @tc.name: CreateEglSurface001
137  * @tc.desc:
138  * @tc.type: FUNC
139  */
HWTEST_F(EglWrapperDisplayTest,CreateEglSurface001,Level1)140 HWTEST_F(EglWrapperDisplayTest, CreateEglSurface001, Level1)
141 {
142     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
143 
144     auto result = eglWrapperDisplay->CreateEglSurface(nullptr, 0, 0);
145     ASSERT_EQ(EGL_NO_SURFACE, result);
146 }
147 
148 /**
149  * @tc.name: CreateEglSurface002
150  * @tc.desc:
151  * @tc.type: FUNC
152  */
HWTEST_F(EglWrapperDisplayTest,CreateEglSurface002,Level1)153 HWTEST_F(EglWrapperDisplayTest, CreateEglSurface002, Level1)
154 {
155     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
156 
157     auto temp = gWrapperHook.isLoad;
158     gWrapperHook.isLoad = false;
159 
160     NativeWindowType window = nullptr;
161     auto result = eglWrapperDisplay->CreateEglSurface(nullptr, window, 0);
162     ASSERT_EQ(EGL_NO_SURFACE, result);
163     gWrapperHook.isLoad = temp;
164 }
165 
166 /**
167  * @tc.name: CreatePixmapSurface001
168  * @tc.desc:
169  * @tc.type: FUNC
170  */
HWTEST_F(EglWrapperDisplayTest,CreatePixmapSurface001,Level1)171 HWTEST_F(EglWrapperDisplayTest, CreatePixmapSurface001, Level1)
172 {
173     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
174 
175     auto result = eglWrapperDisplay->CreatePixmapSurface(nullptr, 0, 0);
176     ASSERT_EQ(EGL_NO_SURFACE, result);
177 }
178 
179 /**
180  * @tc.name: CreatePixmapSurface002
181  * @tc.desc:
182  * @tc.type: FUNC
183  */
HWTEST_F(EglWrapperDisplayTest,CreatePixmapSurface002,Level2)184 HWTEST_F(EglWrapperDisplayTest, CreatePixmapSurface002, Level2)
185 {
186     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
187 
188     auto temp = gWrapperHook.isLoad;
189     gWrapperHook.isLoad = false;
190 
191     EGLNativePixmapType window = nullptr;
192     auto result = eglWrapperDisplay->CreatePixmapSurface(nullptr, window, 0);
193     ASSERT_EQ(EGL_NO_SURFACE, result);
194     gWrapperHook.isLoad = temp;
195 }
196 
197 /**
198  * @tc.name: QueryContext001
199  * @tc.desc:
200  * @tc.type: FUNC
201  */
HWTEST_F(EglWrapperDisplayTest,QueryContext001,Level1)202 HWTEST_F(EglWrapperDisplayTest, QueryContext001, Level1)
203 {
204     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
205 
206     auto result = eglWrapperDisplay->QueryContext(nullptr, 0, 0);
207     ASSERT_EQ(EGL_FALSE, result);
208 }
209 
210 /**
211  * @tc.name: QueryContext002
212  * @tc.desc:
213  * @tc.type: FUNC
214  */
HWTEST_F(EglWrapperDisplayTest,QueryContext002,Level1)215 HWTEST_F(EglWrapperDisplayTest, QueryContext002, Level1)
216 {
217     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
218 
219     auto temp = gWrapperHook.isLoad;
220     gWrapperHook.isLoad = false;
221 
222     auto result = eglWrapperDisplay->QueryContext(nullptr, 0, 0);
223     ASSERT_EQ(EGL_FALSE, result);
224     gWrapperHook.isLoad = temp;
225 }
226 
227 /**
228  * @tc.name: QuerySurface001
229  * @tc.desc:
230  * @tc.type: FUNC
231  */
HWTEST_F(EglWrapperDisplayTest,QuerySurface001,Level1)232 HWTEST_F(EglWrapperDisplayTest, QuerySurface001, Level1)
233 {
234     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
235 
236     auto result = eglWrapperDisplay->QuerySurface(nullptr, 0, 0);
237     ASSERT_EQ(EGL_FALSE, result);
238 }
239 
240 /**
241  * @tc.name: QuerySurface002
242  * @tc.desc:
243  * @tc.type: FUNC
244  */
HWTEST_F(EglWrapperDisplayTest,QuerySurface002,Level1)245 HWTEST_F(EglWrapperDisplayTest, QuerySurface002, Level1)
246 {
247     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
248 
249     auto temp = gWrapperHook.isLoad;
250     gWrapperHook.isLoad = false;
251 
252     auto result = eglWrapperDisplay->QuerySurface(nullptr, 0, 0);
253     ASSERT_EQ(EGL_FALSE, result);
254     gWrapperHook.isLoad = temp;
255 }
256 
257 /**
258  * @tc.name: BindTexImage001
259  * @tc.desc:
260  * @tc.type: FUNC
261  */
HWTEST_F(EglWrapperDisplayTest,BindTexImage001,Level1)262 HWTEST_F(EglWrapperDisplayTest, BindTexImage001, Level1)
263 {
264     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
265 
266     auto result = eglWrapperDisplay->BindTexImage(nullptr, 0);
267     ASSERT_EQ(EGL_FALSE, result);
268 }
269 
270 /**
271  * @tc.name: BindTexImage002
272  * @tc.desc:
273  * @tc.type: FUNC
274  */
HWTEST_F(EglWrapperDisplayTest,BindTexImage002,Level1)275 HWTEST_F(EglWrapperDisplayTest, BindTexImage002, Level1)
276 {
277     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
278 
279     auto temp = gWrapperHook.isLoad;
280     gWrapperHook.isLoad = false;
281 
282     auto result = eglWrapperDisplay->BindTexImage(nullptr, 0);
283     ASSERT_EQ(EGL_FALSE, result);
284     gWrapperHook.isLoad = temp;
285 }
286 
287 /**
288  * @tc.name: ReleaseTexImage001
289  * @tc.desc:
290  * @tc.type: FUNC
291  */
HWTEST_F(EglWrapperDisplayTest,ReleaseTexImage001,Level1)292 HWTEST_F(EglWrapperDisplayTest, ReleaseTexImage001, Level1)
293 {
294     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
295 
296     auto result = eglWrapperDisplay->ReleaseTexImage(nullptr, 0);
297     ASSERT_EQ(EGL_FALSE, result);
298 }
299 
300 /**
301  * @tc.name: ReleaseTexImage002
302  * @tc.desc:
303  * @tc.type: FUNC
304  */
HWTEST_F(EglWrapperDisplayTest,ReleaseTexImage002,Level1)305 HWTEST_F(EglWrapperDisplayTest, ReleaseTexImage002, Level1)
306 {
307     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
308 
309     auto temp = gWrapperHook.isLoad;
310     gWrapperHook.isLoad = false;
311 
312     auto result = eglWrapperDisplay->ReleaseTexImage(nullptr, 0);
313     ASSERT_EQ(EGL_FALSE, result);
314     gWrapperHook.isLoad = temp;
315 }
316 
317 /**
318  * @tc.name: SurfaceAttrib001
319  * @tc.desc:
320  * @tc.type: FUNC
321  */
HWTEST_F(EglWrapperDisplayTest,SurfaceAttrib001,Level1)322 HWTEST_F(EglWrapperDisplayTest, SurfaceAttrib001, Level1)
323 {
324     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
325 
326     auto result = eglWrapperDisplay->SurfaceAttrib(nullptr, 0, 0);
327     ASSERT_EQ(EGL_FALSE, result);
328 }
329 
330 /**
331  * @tc.name: SurfaceAttrib002
332  * @tc.desc:
333  * @tc.type: FUNC
334  */
HWTEST_F(EglWrapperDisplayTest,SurfaceAttrib002,Level1)335 HWTEST_F(EglWrapperDisplayTest, SurfaceAttrib002, Level1)
336 {
337     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
338 
339     auto temp = gWrapperHook.isLoad;
340     gWrapperHook.isLoad = false;
341 
342     auto result = eglWrapperDisplay->SurfaceAttrib(nullptr, 0, 0);
343     ASSERT_EQ(EGL_FALSE, result);
344     gWrapperHook.isLoad = temp;
345 }
346 
347 
348 /**
349  * @tc.name: CreatePbufferFromClientBuffer001
350  * @tc.desc:
351  * @tc.type: FUNC
352  */
HWTEST_F(EglWrapperDisplayTest,CreatePbufferFromClientBuffer001,Level1)353 HWTEST_F(EglWrapperDisplayTest, CreatePbufferFromClientBuffer001, Level1)
354 {
355     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
356 
357     auto temp = gWrapperHook.isLoad;
358     gWrapperHook.isLoad = false;
359 
360     auto result = eglWrapperDisplay->CreatePbufferFromClientBuffer(0, nullptr, nullptr, 0);
361     ASSERT_EQ(EGL_NO_SURFACE, result);
362     gWrapperHook.isLoad = temp;
363 }
364 
365 /**
366  * @tc.name: CreatePbufferFromClientBuffer002
367  * @tc.desc:
368  * @tc.type: FUNC
369  */
HWTEST_F(EglWrapperDisplayTest,CreatePbufferFromClientBuffer002,Level1)370 HWTEST_F(EglWrapperDisplayTest, CreatePbufferFromClientBuffer002, Level1)
371 {
372     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
373 
374     auto result = eglWrapperDisplay->CreatePbufferFromClientBuffer(0, nullptr, nullptr, 0);
375     ASSERT_EQ(EGL_NO_SURFACE, result);
376 }
377 
378 /**
379  * @tc.name: CreateImage001
380  * @tc.desc:
381  * @tc.type: FUNC
382  */
HWTEST_F(EglWrapperDisplayTest,CreateImage001,Level1)383 HWTEST_F(EglWrapperDisplayTest, CreateImage001, Level1)
384 {
385     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
386 
387     auto temp = gWrapperHook.isLoad;
388     gWrapperHook.isLoad = false;
389 
390     auto result = eglWrapperDisplay->CreateImage(EGL_NO_CONTEXT, 0, nullptr, nullptr);
391     ASSERT_EQ(EGL_NO_IMAGE_KHR, result);
392     gWrapperHook.isLoad = temp;
393 }
394 
395 /**
396  * @tc.name: CreateImage002
397  * @tc.desc:
398  * @tc.type: FUNC
399  */
HWTEST_F(EglWrapperDisplayTest,CreateImage002,Level1)400 HWTEST_F(EglWrapperDisplayTest, CreateImage002, Level1)
401 {
402     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
403 
404     auto result = eglWrapperDisplay->CreateImage(nullptr, 0, nullptr, nullptr);
405     ASSERT_EQ(EGL_NO_IMAGE_KHR, result);
406 }
407 
408 /**
409  * @tc.name: DestroyImage001
410  * @tc.desc:
411  * @tc.type: FUNC
412  */
HWTEST_F(EglWrapperDisplayTest,DestroyImage001,Level1)413 HWTEST_F(EglWrapperDisplayTest, DestroyImage001, Level1)
414 {
415     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
416 
417     auto temp = gWrapperHook.isLoad;
418     gWrapperHook.isLoad = false;
419 
420     auto result = eglWrapperDisplay->DestroyImage(nullptr);
421     ASSERT_EQ(EGL_FALSE, result);
422     gWrapperHook.isLoad = temp;
423 }
424 
425 /**
426  * @tc.name: CreatePlatformWindowSurface001
427  * @tc.desc:
428  * @tc.type: FUNC
429  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformWindowSurface001,Level1)430 HWTEST_F(EglWrapperDisplayTest, CreatePlatformWindowSurface001, Level1)
431 {
432     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
433 
434     auto result = eglWrapperDisplay->CreatePlatformWindowSurface(nullptr, nullptr, 0);
435     ASSERT_EQ(EGL_NO_SURFACE, result);
436 }
437 
438 /**
439  * @tc.name: CreatePlatformWindowSurface002
440  * @tc.desc:
441  * @tc.type: FUNC
442  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformWindowSurface002,Level2)443 HWTEST_F(EglWrapperDisplayTest, CreatePlatformWindowSurface002, Level2)
444 {
445     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
446 
447     auto temp = gWrapperHook.isLoad;
448     gWrapperHook.isLoad = false;
449 
450     auto result = eglWrapperDisplay->CreatePlatformWindowSurface(nullptr, &gWrapperHook, 0);
451     ASSERT_EQ(EGL_NO_SURFACE, result);
452     gWrapperHook.isLoad = temp;
453 }
454 
455 /**
456  * @tc.name: CreatePlatformPixmapSurface001
457  * @tc.desc:
458  * @tc.type: FUNC
459  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformPixmapSurface001,Level1)460 HWTEST_F(EglWrapperDisplayTest, CreatePlatformPixmapSurface001, Level1)
461 {
462     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
463 
464     auto result = eglWrapperDisplay->CreatePlatformPixmapSurface(nullptr, nullptr, 0);
465     ASSERT_EQ(EGL_NO_SURFACE, result);
466 }
467 
468 /**
469  * @tc.name: CreatePlatformPixmapSurface002
470  * @tc.desc:
471  * @tc.type: FUNC
472  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformPixmapSurface002,Level2)473 HWTEST_F(EglWrapperDisplayTest, CreatePlatformPixmapSurface002, Level2)
474 {
475     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
476 
477     auto temp = gWrapperHook.isLoad;
478     gWrapperHook.isLoad = false;
479 
480     auto result = eglWrapperDisplay->CreatePlatformPixmapSurface(nullptr, &gWrapperHook, 0);
481     ASSERT_EQ(EGL_NO_SURFACE, result);
482     gWrapperHook.isLoad = temp;
483 }
484 
485 /**
486  * @tc.name: LockSurfaceKHR001
487  * @tc.desc:
488  * @tc.type: FUNC
489  */
HWTEST_F(EglWrapperDisplayTest,LockSurfaceKHR001,Level1)490 HWTEST_F(EglWrapperDisplayTest, LockSurfaceKHR001, Level1)
491 {
492     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
493 
494     auto result = eglWrapperDisplay->LockSurfaceKHR(nullptr, 0);
495     ASSERT_EQ(EGL_FALSE, result);
496 }
497 
498 /**
499  * @tc.name: LockSurfaceKHR002
500  * @tc.desc:
501  * @tc.type: FUNC
502  */
HWTEST_F(EglWrapperDisplayTest,LockSurfaceKHR002,Level1)503 HWTEST_F(EglWrapperDisplayTest, LockSurfaceKHR002, Level1)
504 {
505     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
506 
507     auto temp = gWrapperHook.isLoad;
508     gWrapperHook.isLoad = false;
509 
510     auto result = eglWrapperDisplay->LockSurfaceKHR(nullptr, 0);
511     ASSERT_EQ(EGL_FALSE, result);
512     gWrapperHook.isLoad = temp;
513 }
514 
515 
516 /**
517  * @tc.name: UnlockSurfaceKHR001
518  * @tc.desc:
519  * @tc.type: FUNC
520  */
HWTEST_F(EglWrapperDisplayTest,UnlockSurfaceKHR001,Level1)521 HWTEST_F(EglWrapperDisplayTest, UnlockSurfaceKHR001, Level1)
522 {
523     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
524 
525     auto temp = gWrapperHook.isLoad;
526     gWrapperHook.isLoad = false;
527 
528     auto result = eglWrapperDisplay->UnlockSurfaceKHR(nullptr);
529     ASSERT_EQ(EGL_FALSE, result);
530     gWrapperHook.isLoad = temp;
531 }
532 
533 /**
534  * @tc.name: UnLockSurfaceKHR002
535  * @tc.desc:
536  * @tc.type: FUNC
537  */
HWTEST_F(EglWrapperDisplayTest,UnLockSurfaceKHR002,Level1)538 HWTEST_F(EglWrapperDisplayTest, UnLockSurfaceKHR002, Level1)
539 {
540     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
541 
542     auto result = eglWrapperDisplay->UnlockSurfaceKHR(nullptr);
543     ASSERT_EQ(EGL_FALSE, result);
544 }
545 
546 /**
547  * @tc.name: CreateImageKHR001
548  * @tc.desc:
549  * @tc.type: FUNC
550  */
HWTEST_F(EglWrapperDisplayTest,CreateImageKHR001,Level1)551 HWTEST_F(EglWrapperDisplayTest, CreateImageKHR001, Level1)
552 {
553     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
554 
555     auto temp = gWrapperHook.isLoad;
556     gWrapperHook.isLoad = false;
557 
558     auto result = eglWrapperDisplay->CreateImageKHR(EGL_NO_CONTEXT, 0, nullptr, nullptr);
559     ASSERT_EQ(EGL_NO_IMAGE_KHR, result);
560     gWrapperHook.isLoad = temp;
561 }
562 
563 /**
564  * @tc.name: CreateImageKHR002
565  * @tc.desc:
566  * @tc.type: FUNC
567  */
HWTEST_F(EglWrapperDisplayTest,CreateImageKHR002,Level1)568 HWTEST_F(EglWrapperDisplayTest, CreateImageKHR002, Level1)
569 {
570     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
571 
572     auto result = eglWrapperDisplay->CreateImageKHR(nullptr, 0, nullptr, nullptr);
573     ASSERT_EQ(EGL_NO_IMAGE_KHR, result);
574 }
575 
576 /**
577  * @tc.name: DestroyImageKHR001
578  * @tc.desc:
579  * @tc.type: FUNC
580  */
HWTEST_F(EglWrapperDisplayTest,DestroyImageKHR001,Level1)581 HWTEST_F(EglWrapperDisplayTest, DestroyImageKHR001, Level1)
582 {
583     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
584 
585     auto temp = gWrapperHook.isLoad;
586     gWrapperHook.isLoad = false;
587 
588     auto result = eglWrapperDisplay->DestroyImageKHR(nullptr);
589     ASSERT_EQ(EGL_FALSE, result);
590     gWrapperHook.isLoad = temp;
591 }
592 
593 /**
594  * @tc.name: CreateStreamProducerSurfaceKHR001
595  * @tc.desc:
596  * @tc.type: FUNC
597  */
HWTEST_F(EglWrapperDisplayTest,CreateStreamProducerSurfaceKHR001,Level1)598 HWTEST_F(EglWrapperDisplayTest, CreateStreamProducerSurfaceKHR001, Level1)
599 {
600     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
601 
602     auto temp = gWrapperHook.isLoad;
603     gWrapperHook.isLoad = false;
604 
605     auto result = eglWrapperDisplay->CreateStreamProducerSurfaceKHR(nullptr, nullptr, 0);
606     ASSERT_EQ(EGL_NO_SURFACE, result);
607     gWrapperHook.isLoad = temp;
608 }
609 
610 /**
611  * @tc.name: SwapBuffersWithDamageKHR001
612  * @tc.desc:
613  * @tc.type: FUNC
614  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageKHR001,Level1)615 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageKHR001, Level1)
616 {
617     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
618 
619     auto result = eglWrapperDisplay->SwapBuffersWithDamageKHR(nullptr, 0, 0);
620     ASSERT_EQ(EGL_FALSE, result);
621 }
622 
623 /**
624  * @tc.name: SwapBuffersWithDamageKHR002
625  * @tc.desc:
626  * @tc.type: FUNC
627  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageKHR002,Level1)628 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageKHR002, Level1)
629 {
630     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
631 
632     auto temp = gWrapperHook.isLoad;
633     gWrapperHook.isLoad = false;
634 
635     auto result = eglWrapperDisplay->SwapBuffersWithDamageKHR(nullptr, 0, 0);
636     ASSERT_EQ(EGL_FALSE, result);
637     gWrapperHook.isLoad = temp;
638 }
639 
640 /**
641  * @tc.name: SwapBuffersWithDamageKHR003
642  * @tc.desc:
643  * @tc.type: FUNC
644  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageKHR003,Level1)645 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageKHR003, Level1)
646 {
647     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
648 
649     auto result = eglWrapperDisplay->SwapBuffersWithDamageKHR(nullptr, 0, -1);
650     ASSERT_EQ(EGL_FALSE, result);
651 }
652 
653 /**
654  * @tc.name: SwapBuffersWithDamageKHR004
655  * @tc.desc:
656  * @tc.type: FUNC
657  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageKHR004,Level1)658 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageKHR004, Level1)
659 {
660     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
661     auto surface = new EglWrapperSurface(eglWrapperDisplay, EGL_NO_SURFACE, nullptr, EGL_GL_COLORSPACE_SRGB_KHR);
662 
663     auto result = eglWrapperDisplay->SwapBuffersWithDamageKHR(surface, nullptr, -1);
664     ASSERT_EQ(EGL_FALSE, result);
665 
666     result = eglWrapperDisplay->SwapBuffersWithDamageKHR(surface, nullptr, 2);
667     ASSERT_EQ(EGL_FALSE, result);
668 
669     result = eglWrapperDisplay->SwapBuffersWithDamageKHR(surface, nullptr, 0);
670     ASSERT_EQ(EGL_FALSE, result);
671 
672     EGLint n_rects = 1;
673     EGLint rects[4] = {0, 0, 100, 100};
674 
675     result = eglWrapperDisplay->SwapBuffersWithDamageKHR(surface, rects, n_rects);
676     ASSERT_EQ(EGL_FALSE, result);
677 }
678 
679 /**
680  * @tc.name: SetDamageRegionKHR001
681  * @tc.desc:
682  * @tc.type: FUNC
683  */
HWTEST_F(EglWrapperDisplayTest,SetDamageRegionKHR001,Level1)684 HWTEST_F(EglWrapperDisplayTest, SetDamageRegionKHR001, Level1)
685 {
686     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
687 
688     auto result = eglWrapperDisplay->SetDamageRegionKHR(nullptr, 0, 0);
689     ASSERT_EQ(EGL_FALSE, result);
690 }
691 
692 /**
693  * @tc.name: SetDamageRegionKHR002
694  * @tc.desc:
695  * @tc.type: FUNC
696  */
HWTEST_F(EglWrapperDisplayTest,SetDamageRegionKHR002,Level1)697 HWTEST_F(EglWrapperDisplayTest, SetDamageRegionKHR002, Level1)
698 {
699     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
700 
701     auto result = eglWrapperDisplay->SetDamageRegionKHR(nullptr, 0, -1);
702     ASSERT_EQ(EGL_FALSE, result);
703 }
704 
705 /**
706  * @tc.name: SetDamageRegionKHR003
707  * @tc.desc:
708  * @tc.type: FUNC
709  */
HWTEST_F(EglWrapperDisplayTest,SetDamageRegionKHR003,Level1)710 HWTEST_F(EglWrapperDisplayTest, SetDamageRegionKHR003, Level1)
711 {
712     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
713 
714     auto temp = gWrapperHook.isLoad;
715     gWrapperHook.isLoad = false;
716 
717     auto result = eglWrapperDisplay->SetDamageRegionKHR(nullptr, 0, 0);
718     ASSERT_EQ(EGL_FALSE, result);
719     gWrapperHook.isLoad = temp;
720 }
721 
722 /**
723  * @tc.name: GetCompositorTimingSupportedANDROID001
724  * @tc.desc:
725  * @tc.type: FUNC
726  */
HWTEST_F(EglWrapperDisplayTest,GetCompositorTimingSupportedANDROID001,Level1)727 HWTEST_F(EglWrapperDisplayTest, GetCompositorTimingSupportedANDROID001, Level1)
728 {
729     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
730 
731     auto result = eglWrapperDisplay->GetCompositorTimingSupportedANDROID(nullptr, 0);
732     ASSERT_EQ(EGL_FALSE, result);
733 }
734 
735 /**
736  * @tc.name: GetCompositorTimingSupportedANDROID002
737  * @tc.desc:
738  * @tc.type: FUNC
739  */
HWTEST_F(EglWrapperDisplayTest,GetCompositorTimingSupportedANDROID002,Level1)740 HWTEST_F(EglWrapperDisplayTest, GetCompositorTimingSupportedANDROID002, Level1)
741 {
742     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
743 
744     auto temp = gWrapperHook.isLoad;
745     gWrapperHook.isLoad = false;
746 
747     auto result = eglWrapperDisplay->GetCompositorTimingSupportedANDROID(nullptr, 0);
748     ASSERT_EQ(EGL_FALSE, result);
749     gWrapperHook.isLoad = temp;
750 }
751 
752 /**
753  * @tc.name: GetFrameTimestampSupportedANDROID001
754  * @tc.desc:
755  * @tc.type: FUNC
756  */
HWTEST_F(EglWrapperDisplayTest,GetFrameTimestampSupportedANDROID001,Level1)757 HWTEST_F(EglWrapperDisplayTest, GetFrameTimestampSupportedANDROID001, Level1)
758 {
759     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
760 
761     auto result = eglWrapperDisplay->GetFrameTimestampSupportedANDROID(nullptr, 0);
762     ASSERT_EQ(EGL_FALSE, result);
763 }
764 
765 /**
766  * @tc.name: PresentationTimeANDROID001
767  * @tc.desc:
768  * @tc.type: FUNC
769  */
HWTEST_F(EglWrapperDisplayTest,PresentationTimeANDROID001,Level1)770 HWTEST_F(EglWrapperDisplayTest, PresentationTimeANDROID001, Level1)
771 {
772     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
773 
774     auto result = eglWrapperDisplay->PresentationTimeANDROID(nullptr, 0);
775     ASSERT_EQ(EGL_FALSE, result);
776 }
777 
778 /**
779  * @tc.name: CreatePlatformWindowSurfaceEXT001
780  * @tc.desc:
781  * @tc.type: FUNC
782  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformWindowSurfaceEXT001,Level1)783 HWTEST_F(EglWrapperDisplayTest, CreatePlatformWindowSurfaceEXT001, Level1)
784 {
785     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
786 
787     auto result = eglWrapperDisplay->CreatePlatformWindowSurfaceEXT(nullptr, nullptr, nullptr);
788     ASSERT_EQ(EGL_NO_SURFACE, result);
789 }
790 
791 /**
792  * @tc.name: CreatePlatformWindowSurfaceEXT002
793  * @tc.desc:
794  * @tc.type: FUNC
795  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformWindowSurfaceEXT002,Level1)796 HWTEST_F(EglWrapperDisplayTest, CreatePlatformWindowSurfaceEXT002, Level1)
797 {
798     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
799 
800     auto temp = gWrapperHook.isLoad;
801     gWrapperHook.isLoad = false;
802 
803     auto result = eglWrapperDisplay->CreatePlatformWindowSurfaceEXT(nullptr, nullptr, nullptr);
804     ASSERT_EQ(EGL_NO_SURFACE, result);
805     gWrapperHook.isLoad = temp;
806 }
807 
808 /**
809  * @tc.name: CreatePlatformPixmapSurfaceEXT001
810  * @tc.desc:
811  * @tc.type: FUNC
812  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformPixmapSurfaceEXT001,Level1)813 HWTEST_F(EglWrapperDisplayTest, CreatePlatformPixmapSurfaceEXT001, Level1)
814 {
815     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
816 
817     auto result = eglWrapperDisplay->CreatePlatformPixmapSurfaceEXT(nullptr, nullptr, nullptr);
818     ASSERT_EQ(EGL_NO_SURFACE, result);
819 }
820 
821 /**
822  * @tc.name: CreatePlatformPixmapSurfaceEXT002
823  * @tc.desc:
824  * @tc.type: FUNC
825  */
HWTEST_F(EglWrapperDisplayTest,CreatePlatformPixmapSurfaceEXT002,Level1)826 HWTEST_F(EglWrapperDisplayTest, CreatePlatformPixmapSurfaceEXT002, Level1)
827 {
828     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
829 
830     auto temp = gWrapperHook.isLoad;
831     gWrapperHook.isLoad = false;
832 
833     auto result = eglWrapperDisplay->CreatePlatformPixmapSurfaceEXT(nullptr, nullptr, nullptr);
834     ASSERT_EQ(EGL_NO_SURFACE, result);
835     gWrapperHook.isLoad = temp;
836 }
837 
838 /**
839  * @tc.name: SwapBuffer001
840  * @tc.desc:
841  * @tc.type: FUNC
842  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffer001,Level1)843 HWTEST_F(EglWrapperDisplayTest, SwapBuffer001, Level1)
844 {
845     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
846     auto surface = new EglWrapperSurface(eglWrapperDisplay, EGL_NO_SURFACE, nullptr, EGL_GL_COLORSPACE_SRGB_KHR);
847 
848     auto result = eglWrapperDisplay->SwapBuffers(surface);
849     ASSERT_EQ(EGL_FALSE, result);
850 
851     result = eglWrapperDisplay->SwapBuffers(nullptr);
852     ASSERT_EQ(EGL_FALSE, result);
853 
854     EglWrapperSurface* invalidSurf = (EglWrapperSurface*)(0x01);
855     result = eglWrapperDisplay->SwapBuffers(invalidSurf);
856     ASSERT_EQ(EGL_FALSE, result);
857 }
858 
859 /**
860  * @tc.name: SwapBuffersWithDamageEXT001
861  * @tc.desc:
862  * @tc.type: FUNC
863  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageEXT001,Level1)864 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageEXT001, Level1)
865 {
866     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
867 
868     auto result = eglWrapperDisplay->SwapBuffersWithDamageEXT(nullptr, nullptr, 0);
869     ASSERT_EQ(EGL_FALSE, result);
870 }
871 
872 /**
873  * @tc.name: SwapBuffersWithDamageEXT002
874  * @tc.desc:
875  * @tc.type: FUNC
876  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageEXT002,Level1)877 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageEXT002, Level1)
878 {
879     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
880 
881     auto result = eglWrapperDisplay->SetDamageRegionKHR(nullptr, nullptr,   -1);
882     ASSERT_EQ(EGL_FALSE, result);
883 }
884 
885 /**
886  * @tc.name: SwapBuffersWithDamageEXT003
887  * @tc.desc:
888  * @tc.type: FUNC
889  */
HWTEST_F(EglWrapperDisplayTest,SwapBuffersWithDamageEXT003,Level1)890 HWTEST_F(EglWrapperDisplayTest, SwapBuffersWithDamageEXT003, Level1)
891 {
892     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
893     auto surface = new EglWrapperSurface(eglWrapperDisplay, EGL_NO_SURFACE, nullptr, EGL_GL_COLORSPACE_SRGB_KHR);
894 
895     auto result = eglWrapperDisplay->SwapBuffersWithDamageEXT(surface, nullptr, -1);
896     ASSERT_EQ(EGL_FALSE, result);
897 
898     result = eglWrapperDisplay->SwapBuffersWithDamageEXT(surface, nullptr, 2);
899     ASSERT_EQ(EGL_FALSE, result);
900 
901     result = eglWrapperDisplay->SwapBuffersWithDamageEXT(surface, nullptr, 0);
902     ASSERT_EQ(EGL_FALSE, result);
903 
904     EGLint n_rects = 1;
905     EGLint rects[4] = {0, 0, 100, 100};
906 
907     result = eglWrapperDisplay->SwapBuffersWithDamageEXT(surface, rects, n_rects);
908     ASSERT_EQ(EGL_FALSE, result);
909 }
910 
911 /**
912  * @tc.name: UpdateQueryValue001
913  * @tc.desc:
914  * @tc.type: FUNC
915  */
HWTEST_F(EglWrapperDisplayTest,UpdateQueryValue001,Level1)916 HWTEST_F(EglWrapperDisplayTest, UpdateQueryValue001, Level1)
917 {
918     EGLint major;
919     EGLint minor;
920     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
921     system::SetParameter("debug.swap.buffer.with.damage", "0");
922     eglWrapperDisplay->UpdateQueryValue(&major, &minor);
923     auto value = strstr(eglWrapperDisplay->GetExtensionValue(), "EGL_KHR_swap_buffers_with_damage");
924     EXPECT_EQ(value, nullptr);
925 }
926 
927 /**
928  * @tc.name: UpdateQueryValue002
929  * @tc.desc:
930  * @tc.type: FUNC
931  */
HWTEST_F(EglWrapperDisplayTest,UpdateQueryValue002,Level1)932 HWTEST_F(EglWrapperDisplayTest, UpdateQueryValue002, Level1)
933 {
934     EGLint major;
935     EGLint minor;
936     auto eglWrapperDisplay = EglWrapperDisplay::GetWrapperDisplay((EGLDisplay)&EglWrapperDisplay::wrapperDisp_);
937     system::SetParameter("debug.swap.buffer.with.damage", "1");
938     eglWrapperDisplay->UpdateQueryValue(&major, &minor);
939     auto value = strstr(eglWrapperDisplay->GetExtensionValue(), "EGL_KHR_swap_buffers_with_damage");
940     EXPECT_NE(value, nullptr);
941 }
942 } // OHOS::Rosen