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_context.h"
19 
20 #include "EGL/egl_wrapper_display.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS::Rosen {
26 class EglWrapperContextTest : public testing::Test {
27 public:
SetUpTestCase()28     static void SetUpTestCase() {}
TearDownTestCase()29     static void TearDownTestCase() {}
SetUp()30     void SetUp() {}
TearDown()31     void TearDown() {}
32 };
33 
34 /**
35  * @tc.name: GetCurrentSurface001
36  * @tc.desc:
37  * @tc.type: FUNC
38  */
HWTEST_F(EglWrapperContextTest,GetCurrentSurface001,Level1)39 HWTEST_F(EglWrapperContextTest, GetCurrentSurface001, Level1)
40 {
41     EGLDisplay display = nullptr;
42     EglWrapperDisplay *disp = EglWrapperDisplay::GetWrapperDisplay(display);
43     EGLContext context = nullptr;
44     EglWrapperContext ctx(disp, context);
45 
46     EGLSurface draw = nullptr;
47     EGLSurface read = nullptr;
48     ctx.SetCurrentSurface(draw, read);
49 
50     auto result = ctx.GetCurrentSurface(EGL_READ);
51     ASSERT_EQ(read, result);
52     result = ctx.GetCurrentSurface(EGL_DRAW);
53     ASSERT_EQ(draw, result);
54     result = ctx.GetCurrentSurface(0);
55     ASSERT_EQ(EGL_NO_SURFACE, result);
56 }
57 } // OHOS::Rosen