• 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, 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 #include <hilog/log.h>
18 
19 #include "render_context.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS::Rosen {
24 class RenderContextTest : public testing::Test {
25 public:
26     static constexpr HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, 0, "RenderContextTest" };
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void RenderContextTest::SetUpTestCase() {}
TearDownTestCase()34 void RenderContextTest::TearDownTestCase() {}
SetUp()35 void RenderContextTest::SetUp() {}
TearDown()36 void RenderContextTest::TearDown() {}
37 
38 /**
39  * @tc.name: CreateEGLSurfaceTest001
40  * @tc.desc: Verify the CreateEGLSurfaceTest001 of RenderContextTest
41  * @tc.type: FUNC
42  */
43 HWTEST_F(RenderContextTest, CreateEGLSurfaceTest001, Function | SmallTest | Level2)
44 {
45 #ifdef ACE_ENABLE_GL
46     // start CreateEGLSurfaceTest001 test
47     RenderContext renderContext;
48     EGLSurface eglSurface = renderContext.CreateEGLSurface(nullptr);
49     EXPECT_EQ(eglSurface, EGL_NO_SURFACE);
50 #endif
51 }
52 
53 /**
54  * @tc.name: CreateEGLSurfaceTest002
55  * @tc.desc: Verify the CreateEGLSurfaceTest002 of RenderContextTest
56  * @tc.type: FUNC
57  */
58 HWTEST_F(RenderContextTest, CreateEGLSurfaceTest002, Function | SmallTest | Level2)
59 {
60 #ifdef ACE_ENABLE_GL
61     // start CreateEGLSurfaceTest002 test
62     RenderContext renderContext;
63     renderContext.InitializeEglContext();
64     EGLSurface eglSurface = renderContext.CreateEGLSurface(nullptr);
65     EXPECT_EQ(eglSurface, EGL_NO_SURFACE);
66 #endif
67 }
68 
69 /**
70  * @tc.name: SetUpGrContextTest
71  * @tc.desc: Verify the SetUpGrContextTest of RenderContextTest
72  * @tc.type: FUNC
73  */
74 HWTEST_F(RenderContextTest, SetUpGrContextTest, Function | SmallTest | Level2)
75 {
76 #ifdef ACE_ENABLE_GL
77     // start SetUpGrContextTest test
78     RenderContext renderContext;
79     bool grContext = renderContext.SetUpGrContext();
80     EXPECT_EQ(grContext, false);
81 #endif
82 }
83 
84 /**
85  * @tc.name: AcquireSurfaceTest
86  * @tc.desc: Verify the AcquireSurfaceTest of RenderContextTest
87  * @tc.type: FUNC
88  */
89 HWTEST_F(RenderContextTest, AcquireSurfaceTest, Function | SmallTest | Level2)
90 {
91 #ifdef ACE_ENABLE_GL
92     // start AcquireSurfaceTest test
93     RenderContext renderContext;
94     auto surface = renderContext.AcquireSurface(0, 0);
95     EXPECT_TRUE(surface == nullptr);
96 #endif
97 }
98 
99 /**
100  * @tc.name: QueryEglBufferAgeTest001
101  * @tc.desc: Verify the QueryEglBufferAgeTest001 of RenderContextTest
102  * @tc.type: FUNC
103  */
104 HWTEST_F(RenderContextTest, QueryEglBufferAgeTest001, Function | SmallTest | Level2)
105 {
106 #ifdef ACE_ENABLE_GL
107     // start QueryEglBufferAgeTest001 test
108     RenderContext renderContext;
109     EGLint bufferAge = renderContext.QueryEglBufferAge();
110     EXPECT_EQ(bufferAge, EGL_UNKNOWN);
111 #endif
112 }
113 
114 /**
115  * @tc.name: QueryEglBufferAgeTest002
116  * @tc.desc: Verify the QueryEglBufferAgeTest002 of RenderContextTest
117  * @tc.type: FUNC
118  */
119 HWTEST_F(RenderContextTest, QueryEglBufferAgeTest002, Function | SmallTest | Level2)
120 {
121 #ifdef ACE_ENABLE_GL
122     // start QueryEglBufferAgeTest002 test
123     RenderContext renderContext;
124     EGLint bufferAge = renderContext.QueryEglBufferAge();
125     EXPECT_EQ(bufferAge, EGL_UNKNOWN);
126 #endif
127 }
128 } // namespace OHOS::Rosen