• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 <parameter.h>
17 #include <parameters.h>
18 #include "gtest/gtest.h"
19 
20 #include "EGL/egl.h"
21 #include "EGL/eglext.h"
22 #include "GLES3/gl32.h"
23 
24 #include "draw/color.h"
25 #include "image/gpu_context.h"
26 #include "utils/log.h"
27 
28 using namespace testing;
29 using namespace testing::ext;
30 
31 namespace OHOS {
32 namespace Rosen {
33 namespace Drawing {
34 constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2;
35 
36 class ShaderPersistentCache : public GPUContextOptions::PersistentCache {
37 public:
38     ShaderPersistentCache() = default;
39     ~ShaderPersistentCache() override = default;
40 
Load(const Data & key)41     std::shared_ptr<Data> Load(const Data& key) override { return nullptr; };
Store(const Data & key,const Data & data)42     void Store(const Data& key, const Data& data) override {};
43 };
44 
45 class GpuContextTest : public testing::Test {
46 public:
47     static void SetUpTestCase();
48     static void TearDownTestCase();
49     void SetUp() override;
50     void TearDown() override;
51 
52     static void InitEGL();
53     static void DestroyEGL();
54 
55 private:
56     static EGLDisplay eglDisplay_;
57     static EGLContext eglContext_;
58 };
59 
60 EGLDisplay GpuContextTest::eglDisplay_ = EGL_NO_DISPLAY;
61 EGLContext GpuContextTest::eglContext_ = EGL_NO_CONTEXT;
62 
SetUpTestCase()63 void GpuContextTest::SetUpTestCase()
64 {
65     InitEGL();
66 }
67 
TearDownTestCase()68 void GpuContextTest::TearDownTestCase()
69 {
70     DestroyEGL();
71 }
72 
SetUp()73 void GpuContextTest::SetUp() {}
TearDown()74 void GpuContextTest::TearDown() {}
75 
InitEGL()76 void GpuContextTest::InitEGL()
77 {
78     LOGI("Creating EGLContext!!!");
79     eglDisplay_ = eglGetDisplay(static_cast<EGLNativeDisplayType>(EGL_DEFAULT_DISPLAY));
80     if (eglDisplay_ == EGL_NO_DISPLAY) {
81         LOGW("Failed to create EGLDisplay gl errno : %{public}x", eglGetError());
82         return;
83     }
84 
85     EGLint major, minor;
86     if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) {
87         LOGE("Failed to initialize EGLDisplay");
88         return;
89     }
90 
91     if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
92         LOGE("Failed to bind OpenGL ES API");
93         return;
94     }
95 
96     unsigned int ret;
97     EGLConfig config;
98     EGLint count;
99     EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
100         EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE };
101 
102     ret = eglChooseConfig(eglDisplay_, configAttribs, &config, 1, &count);
103     if (!(ret && static_cast<unsigned int>(count) >= 1)) {
104         LOGE("Failed to eglChooseConfig");
105         return;
106     }
107 
108     static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE };
109 
110     eglContext_ = eglCreateContext(eglDisplay_, config, EGL_NO_CONTEXT, contextAttribs);
111     if (eglContext_ == EGL_NO_CONTEXT) {
112         LOGE("Failed to create egl context %{public}x", eglGetError());
113         return;
114     }
115     if (!eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_)) {
116         LOGE("Failed to make current on surface, error is %{public}x", eglGetError());
117         return;
118     }
119 
120     LOGI("Create EGL context successfully, version %{public}d.%{public}d", major, minor);
121 }
122 
DestroyEGL()123 void GpuContextTest::DestroyEGL()
124 {
125     if (eglDisplay_ == EGL_NO_DISPLAY) {
126         return;
127     }
128 
129     eglDestroyContext(eglDisplay_, eglContext_);
130     eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
131     eglTerminate(eglDisplay_);
132     eglReleaseThread();
133 
134     eglDisplay_ = EGL_NO_DISPLAY;
135     eglContext_ = EGL_NO_CONTEXT;
136 }
137 
138 /**
139  * @tc.name: GPUContextCreateTest001
140  * @tc.desc: Test for creating GPUContext.
141  * @tc.type: FUNC
142  * @tc.require: I774GD
143  */
144 HWTEST_F(GpuContextTest, GPUContextCreateTest001, TestSize.Level1)
145 {
146     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
147     ASSERT_TRUE(gpuContext != nullptr);
148 }
149 
150 /**
151  * @tc.name: GPUContextCreateTest001
152  * @tc.desc: Test for creating a GL GPUContext for a backend context.
153  * @tc.type: FUNC
154  * @tc.require: I774GD
155  */
156 HWTEST_F(GpuContextTest, BuildFromGLTest001, TestSize.Level1)
157 {
158     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
159     ASSERT_TRUE(gpuContext != nullptr);
160     GPUContextOptions options;
161     EXPECT_TRUE(gpuContext->BuildFromGL(options));
162 
163     gpuContext->Flush();
164     std::chrono::milliseconds msNotUsed;
165     gpuContext->PerformDeferredCleanup(msNotUsed);
166     int32_t maxResource = 100;
167     size_t maxResourceBytes = 1000;
168     gpuContext->GetResourceCacheLimits(&maxResource, &maxResourceBytes);
169     gpuContext->SetResourceCacheLimits(maxResource, maxResourceBytes);
170 }
171 
172 /**
173  * @tc.name: GPUContextCreateTest002
174  * @tc.desc: Test for creating a GL GPUContext for a backend context.
175  * @tc.type: FUNC
176  * @tc.require: I774GD
177  */
178 HWTEST_F(GpuContextTest, BuildFromGLTest002, TestSize.Level1)
179 {
180     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
181     ASSERT_TRUE(gpuContext != nullptr);
182     GPUContextOptions options;
183     auto persistentCache = std::make_shared<ShaderPersistentCache>();
184     options.SetPersistentCache(persistentCache.get());
185     EXPECT_TRUE(gpuContext->BuildFromGL(options));
186 }
187 
188 #ifdef RS_ENABLE_VK
189 /**
190  * @tc.name: GPUContextCreateTest003
191  * @tc.desc: Test for creating a VK GPUContext for a backend context.
192  * @tc.type: FUNC
193  * @tc.require: I774GD
194  */
195 HWTEST_F(GpuContextTest, BuildFromVKTest001, TestSize.Level1)
196 {
197     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
198     ASSERT_TRUE(gpuContext != nullptr);
199     GrVkBackendContext grVkBackendContext;
200     ASSERT_FALSE(gpuContext->BuildFromVK(grVkBackendContext));
201 }
202 
203 /**
204  * @tc.name: GPUContextCreateTest004
205  * @tc.desc: Test for creating a VK GPUContext for a backend context.
206  * @tc.type: FUNC
207  * @tc.require: I774GD
208  */
209 HWTEST_F(GpuContextTest, BuildFromVKTest002, TestSize.Level1)
210 {
211     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
212     ASSERT_TRUE(gpuContext != nullptr);
213     GrVkBackendContext grVkBackendContext;
214     GPUContextOptions options;
215     options.SetAllowPathMaskCaching(true);
216     ASSERT_FALSE(gpuContext->BuildFromVK(grVkBackendContext, options));
217 }
218 
219 /**
220  * @tc.name: GPUContextStoreVkPipelineCacheDataTest001
221  * @tc.desc: Test for storing VK pipeline cache data.
222  * @tc.type: FUNC
223  * @tc.require: I774GD
224  */
225 HWTEST_F(GpuContextTest, GPUContextStoreVkPipelineCacheDataTest001, TestSize.Level1)
226 {
227     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
228     ASSERT_TRUE(gpuContext != nullptr);
229     gpuContext->StoreVkPipelineCacheData();
230 }
231 #endif
232 
233 /**
234  * @tc.name: FlushTest001
235  * @tc.desc: Test for flushing to underlying 3D API specific objects.
236  * @tc.type: FUNC
237  * @tc.require: I774GD
238  */
239 HWTEST_F(GpuContextTest, FlushTest001, TestSize.Level1)
240 {
241     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
242     ASSERT_TRUE(gpuContext != nullptr);
243     gpuContext->Flush();
244 }
245 
246 /**
247  * @tc.name: PerformDeferredCleanupTest001
248  * @tc.desc: Test for Purging GPU resources that haven't been used in the past 'msNotUsed' milliseconds.
249  * @tc.type: FUNC
250  * @tc.require: I774GD
251  */
252 HWTEST_F(GpuContextTest, PerformDeferredCleanupTest001, TestSize.Level1)
253 {
254     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
255     ASSERT_TRUE(gpuContext != nullptr);
256     std::chrono::milliseconds msNotUsed;
257     gpuContext->PerformDeferredCleanup(msNotUsed);
258 }
259 
260 /**
261  * @tc.name: GetResourceCacheLimitsTest001
262  * @tc.desc: Test for geting the current GPU resource cache limits.
263  * @tc.type: FUNC
264  * @tc.require: I774GD
265  */
266 HWTEST_F(GpuContextTest, GetResourceCacheLimitsTest001, TestSize.Level1)
267 {
268     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
269     ASSERT_TRUE(gpuContext != nullptr);
270     int32_t maxResource = 0;
271     size_t maxResourceBytes = 0;
272     gpuContext->GetResourceCacheLimits(&maxResource, &maxResourceBytes);
273 }
274 
275 /**
276  * @tc.name: GetResourceCacheLimitsTest002
277  * @tc.desc: Test for geting the current GPU resource cache limits.
278  * @tc.type: FUNC
279  * @tc.require: I774GD
280  */
281 HWTEST_F(GpuContextTest, GetResourceCacheLimitsTest002, TestSize.Level1)
282 {
283     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
284     ASSERT_TRUE(gpuContext != nullptr);
285     int32_t maxResource = 10;
286     size_t maxResourceBytes = 1000;
287     gpuContext->GetResourceCacheLimits(&maxResource, &maxResourceBytes);
288 }
289 
290 /**
291  * @tc.name: SetResourceCacheLimitsTest001
292  * @tc.desc: Test for set specify the GPU resource cache limits.
293  * @tc.type: FUNC
294  * @tc.require: I774GD
295  */
296 HWTEST_F(GpuContextTest, SetResourceCacheLimitsTest001, TestSize.Level1)
297 {
298     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
299     ASSERT_TRUE(gpuContext != nullptr);
300     int32_t maxResource = 0;
301     size_t maxResourceBytes = 0;
302     gpuContext->SetResourceCacheLimits(maxResource, maxResourceBytes);
303 }
304 
305 /**
306  * @tc.name: SetResourceCacheLimitsTest002
307  * @tc.desc: Test for set specify the GPU resource cache limits.
308  * @tc.type: FUNC
309  * @tc.require: I774GD
310  */
311 HWTEST_F(GpuContextTest, SetResourceCacheLimitsTest002, TestSize.Level1)
312 {
313     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
314     ASSERT_TRUE(gpuContext != nullptr);
315     int32_t maxResource = 100;
316     size_t maxResourceBytes = 1000;
317     gpuContext->SetResourceCacheLimits(maxResource, maxResourceBytes);
318 }
319 
320 /**
321  * @tc.name: ReleaseResourcesAndAbandonContextTest001
322  * @tc.desc: Test for Purging GPU resources that haven't been used in the past 'msNotUsed' milliseconds.
323  * @tc.type: FUNC
324  * @tc.require: I774GD
325  */
326 HWTEST_F(GpuContextTest, ReleaseResourcesAndAbandonContextTest001, TestSize.Level1)
327 {
328     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
329     ASSERT_TRUE(gpuContext != nullptr);
330     gpuContext->ReleaseResourcesAndAbandonContext();
331 }
332 
333 /**
334  * @tc.name: PurgeUnlockedResourcesByTagTest001
335  * @tc.desc: Test for Purging GPU resources that haven't been used in the past 'msNotUsed' milliseconds.
336  * @tc.type: FUNC
337  * @tc.require: I774GD
338  */
339 HWTEST_F(GpuContextTest, PurgeUnlockedResourcesByTagTest001, TestSize.Level1)
340 {
341     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
342     ASSERT_TRUE(gpuContext != nullptr);
343     GPUResourceTag tag(0, 0, 0, 0, "PurgeUnlockedResourcesByTagTest001");
344     gpuContext->PurgeUnlockedResourcesByTag(true, tag);
345 }
346 
347 /**
348  * @tc.name: ReleaseByTagTest001
349  * @tc.desc: Test for Purging GPU resources that haven't been used in the past 'msNotUsed' milliseconds.
350  * @tc.type: FUNC
351  * @tc.require: I774GD
352  */
353 HWTEST_F(GpuContextTest, ReleaseByTagTest001, TestSize.Level1)
354 {
355     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
356     ASSERT_TRUE(gpuContext != nullptr);
357     GPUResourceTag tag(0, 0, 0, 0, "ReleaseByTagTest001");
358     gpuContext->ReleaseByTag(tag);
359 }
360 
361 /**
362  * @tc.name: FlushAndSubmitTest001
363  * @tc.desc: Test for flushing and submitting.
364  * @tc.type: FUNC
365  * @tc.require: I774GD
366  */
367 HWTEST_F(GpuContextTest, FlushAndSubmitTest001, TestSize.Level1)
368 {
369     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
370     ASSERT_TRUE(gpuContext != nullptr);
371     gpuContext->FlushAndSubmit();
372 }
373 
374 /**
375  * @tc.name: GetResourceCacheUsageTest001
376  * @tc.desc: Test for getting resource cache usage.
377  * @tc.type: FUNC
378  * @tc.require: I774GD
379  */
380 HWTEST_F(GpuContextTest, GetResourceCacheUsageTest001, TestSize.Level1)
381 {
382     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
383     ASSERT_TRUE(gpuContext != nullptr);
384     int resourceCount;
385     size_t resourceBytes;
386     gpuContext->GetResourceCacheUsage(&resourceCount, &resourceBytes);
387 }
388 
389 /**
390  * @tc.name: DumpGpuStatsTest001
391  * @tc.desc: Test for dumping gpu stats.
392  * @tc.type: FUNC
393  * @tc.require: I774GD
394  */
395 HWTEST_F(GpuContextTest, DumpGpuStatsTest001, TestSize.Level1)
396 {
397     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
398     ASSERT_TRUE(gpuContext != nullptr);
399     std::string out;
400     gpuContext->DumpGpuStats(out);
401 }
402 
403 /**
404  * @tc.name: PurgeUnlockedResourcesTest001
405  * @tc.desc: Test for purging unlocked resources.
406  * @tc.type: FUNC
407  * @tc.require: I774GD
408  */
409 HWTEST_F(GpuContextTest, PurgeUnlockedResourcesTest001, TestSize.Level1)
410 {
411     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
412     ASSERT_TRUE(gpuContext != nullptr);
413     gpuContext->PurgeUnlockedResources(true);
414     gpuContext->PurgeUnlockedResources(false);
415 }
416 
417 /**
418  * @tc.name: PurgeUnlockedResourcesByPidTest001
419  * @tc.desc: Test for purging unlocked resources by pid.
420  * @tc.type: FUNC
421  * @tc.require: I774GD
422  */
423 HWTEST_F(GpuContextTest, PurgeUnlockedResourcesByPidTest001, TestSize.Level1)
424 {
425     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
426     ASSERT_TRUE(gpuContext != nullptr);
427     std::set<pid_t> exitedPidSet = { 0, 1, 100 };
428     gpuContext->PurgeUnlockedResourcesByPid(true, exitedPidSet);
429     gpuContext->PurgeUnlockedResourcesByPid(false, exitedPidSet);
430 }
431 
432 /**
433  * @tc.name: PurgeUnlockAndSafeCacheGpuResourcesTest001
434  * @tc.desc: Test for purging unlocked and safe resources.
435  * @tc.type: FUNC
436  * @tc.require: I774GD
437  */
438 HWTEST_F(GpuContextTest, PurgeUnlockAndSafeCacheGpuResourcesTest001, TestSize.Level1)
439 {
440     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
441     ASSERT_TRUE(gpuContext != nullptr);
442     gpuContext->PurgeUnlockAndSafeCacheGpuResources();
443 }
444 
445 /**
446  * @tc.name: PurgeCacheBetweenFramesTest001
447  * @tc.desc: Test for purging cache betweem frames.
448  * @tc.type: FUNC
449  * @tc.require: I774GD
450  */
451 HWTEST_F(GpuContextTest, PurgeCacheBetweenFramesTest001, TestSize.Level1)
452 {
453     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
454     ASSERT_TRUE(gpuContext != nullptr);
455     std::set<pid_t> exitedPidSet = { 0, 1, 100 };
456     std::set<pid_t> protectedPidSet = { 0, 1 };
457     gpuContext->PurgeCacheBetweenFrames(true, exitedPidSet, protectedPidSet);
458     gpuContext->PurgeCacheBetweenFrames(false, exitedPidSet, protectedPidSet);
459 }
460 
461 /**
462  * @tc.name: DumpMemoryStatisticsByTagTest001
463  * @tc.desc: Test for dumping memory statistics by tag.
464  * @tc.type: FUNC
465  * @tc.require: I774GD
466  */
467 HWTEST_F(GpuContextTest, DumpMemoryStatisticsByTagTest001, TestSize.Level1)
468 {
469     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
470     ASSERT_TRUE(gpuContext != nullptr);
471     TraceMemoryDump traceMemoryDump("category", true);
472     GPUResourceTag tag(0, 0, 0, 0, "tag");
473     gpuContext->DumpMemoryStatisticsByTag(&traceMemoryDump, tag);
474     gpuContext->DumpMemoryStatisticsByTag(nullptr, tag);
475 }
476 
477 /**
478  * @tc.name: DumpMemoryStatisticsTest001
479  * @tc.desc: Test for dumping memory statistics.
480  * @tc.type: FUNC
481  * @tc.require: I774GD
482  */
483 HWTEST_F(GpuContextTest, DumpMemoryStatisticsTest001, TestSize.Level1)
484 {
485     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
486     ASSERT_TRUE(gpuContext != nullptr);
487     TraceMemoryDump traceMemoryDump("category", true);
488     gpuContext->DumpMemoryStatistics(&traceMemoryDump);
489 }
490 
491 /**
492  * @tc.name: GetUpdatedMemoryMapTest001
493  * @tc.desc: Test for getting updated memory map.
494  * @tc.type: FUNC
495  * @tc.require: I774GD
496  */
497 HWTEST_F(GpuContextTest, GetUpdatedMemoryMapTest001, TestSize.Level1)
498 {
499     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
500     ASSERT_TRUE(gpuContext != nullptr);
501     std::unordered_map<pid_t, size_t> out;
502     gpuContext->GetUpdatedMemoryMap(out);
503 }
504 
505 /**
506  * @tc.name: InitGpuMemoryLimitTest001
507  * @tc.desc: Test for initiating gpu memory limit.
508  * @tc.type: FUNC
509  * @tc.require: I774GD
510  */
511 HWTEST_F(GpuContextTest, InitGpuMemoryLimitTest001, TestSize.Level1)
512 {
513     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
514     ASSERT_TRUE(gpuContext != nullptr);
515     uint64_t size = 1024 * 2;
516     gpuContext->InitGpuMemoryLimit(nullptr, size);
517 }
518 
519 /**
520  * @tc.name: ResetContextTest001
521  * @tc.desc: Test for resetting context.
522  * @tc.type: FUNC
523  * @tc.require: I774GD
524  */
525 HWTEST_F(GpuContextTest, ResetContextTest001, TestSize.Level1)
526 {
527     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
528     ASSERT_TRUE(gpuContext != nullptr);
529     gpuContext->ResetContext();
530 }
531 
532 /**
533  * @tc.name: VmaDefragmentTest001
534  * @tc.desc: Test for vma defragment.
535  * @tc.type: FUNC
536  * @tc.require: I774GD
537  */
538 HWTEST_F(GpuContextTest, VmaDefragmentTest001, TestSize.Level1)
539 {
540     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
541     ASSERT_TRUE(gpuContext != nullptr);
542     gpuContext->VmaDefragment();
543 }
544 
545 /**
546  * @tc.name: BeginFrameTest001
547  * @tc.desc: Test for beginning frame.
548  * @tc.type: FUNC
549  * @tc.require: I774GD
550  */
551 HWTEST_F(GpuContextTest, BeginFrameTest001, TestSize.Level1)
552 {
553     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
554     ASSERT_TRUE(gpuContext != nullptr);
555     gpuContext->BeginFrame();
556 }
557 
558 /**
559  * @tc.name: EndFrameTest001
560  * @tc.desc: Test for ending frame.
561  * @tc.type: FUNC
562  * @tc.require: I774GD
563  */
564 HWTEST_F(GpuContextTest, EndFrameTest001, TestSize.Level1)
565 {
566     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
567     ASSERT_TRUE(gpuContext != nullptr);
568     gpuContext->EndFrame();
569 }
570 
571 /**
572  * @tc.name: SetGpuCacheSuppressWindowSwitchTest001
573  * @tc.desc: Test for setting gpu cache suppress window switch.
574  * @tc.type: FUNC
575  * @tc.require: I774GD
576  */
577 HWTEST_F(GpuContextTest, SetGpuCacheSuppressWindowSwitchTest001, TestSize.Level1)
578 {
579     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
580     ASSERT_TRUE(gpuContext != nullptr);
581     gpuContext->SetGpuCacheSuppressWindowSwitch(true);
582     gpuContext->SetGpuCacheSuppressWindowSwitch(false);
583 }
584 
585 /**
586  * @tc.name: SetGpuMemoryAsyncReclaimerSwitchTest001
587  * @tc.desc: Test for setting gpu memory async reclaimer switch.
588  * @tc.type: FUNC
589  * @tc.require: I774GD
590  */
591 HWTEST_F(GpuContextTest, SetGpuMemoryAsyncReclaimerSwitchTest001, TestSize.Level1)
592 {
593     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
594     ASSERT_TRUE(gpuContext != nullptr);
595     gpuContext->SetGpuMemoryAsyncReclaimerSwitch(true, nullptr);
596     gpuContext->SetGpuMemoryAsyncReclaimerSwitch(false, nullptr);
597 }
598 
599 /**
600  * @tc.name: FlushGpuMemoryInWaitQueueTest001
601  * @tc.desc: Test for flushing gpu memory in wait queue.
602  * @tc.type: FUNC
603  * @tc.require: I774GD
604  */
605 HWTEST_F(GpuContextTest, FlushGpuMemoryInWaitQueueTest001, TestSize.Level1)
606 {
607     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
608     ASSERT_TRUE(gpuContext != nullptr);
609     gpuContext->FlushGpuMemoryInWaitQueue();
610 }
611 
612 /**
613  * @tc.name: SuppressGpuCacheBelowCertainRatioTest001
614  * @tc.desc: Test for suppressing gpu cache below certain ratio.
615  * @tc.type: FUNC
616  * @tc.require: I774GD
617  */
618 HWTEST_F(GpuContextTest, SuppressGpuCacheBelowCertainRatioTest001, TestSize.Level1)
619 {
620     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
621     ASSERT_TRUE(gpuContext != nullptr);
622     gpuContext->SuppressGpuCacheBelowCertainRatio(nullptr);
623 }
624 
625 /**
626  * @tc.name: RegisterVulkanErrorCallbackTest001
627  * @tc.desc: Test for register vulkan error callback.
628  * @tc.type: FUNC
629  * @tc.require: IBOLWU
630  */
631 HWTEST_F(GpuContextTest, RegisterVulkanErrorCallbackTest001, TestSize.Level1)
632 {
633     std::unique_ptr<GPUContext> gpuContext = std::make_unique<GPUContext>();
634     ASSERT_TRUE(gpuContext != nullptr);
635     gpuContext->RegisterVulkanErrorCallback(nullptr);
636 }
637 
638 } // namespace Drawing
639 } // namespace Rosen
640 } // namespace OHOS
641