• 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_layer.h"
19 
20 #include "egl_defs.h"
21 
22 #include <iostream>
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS::Rosen {
28 class EglWrapperLayerTest : public testing::Test {
29 public:
SetUpTestCase()30     static void SetUpTestCase() {}
TearDownTestCase()31     static void TearDownTestCase() {}
SetUp()32     void SetUp() {}
TearDown()33     void TearDown() {}
34 };
35 
36 /**
37  * @tc.name: Init001
38  * @tc.desc:
39  * @tc.type: FUNC
40  */
HWTEST_F(EglWrapperLayerTest,Init001,Level1)41 HWTEST_F(EglWrapperLayerTest, Init001, Level1)
42 {
43     EglWrapperDispatchTable dispatchTable;
44     auto result = EglWrapperLayer::GetInstance().Init(&dispatchTable);
45     EXPECT_TRUE(result);
46 }
47 
48 /**
49  * @tc.name: Init002
50  * @tc.desc:
51  * @tc.type: FUNC
52  */
HWTEST_F(EglWrapperLayerTest,Init002,Level2)53 HWTEST_F(EglWrapperLayerTest, Init002, Level2)
54 {
55     EglWrapperDispatchTable dispatchTable;
56     auto& layer = EglWrapperLayer::GetInstance();
57     layer.initialized_ = true;
58     EXPECT_TRUE(layer.Init(&dispatchTable));
59     layer.initialized_ = false;
60     EXPECT_FALSE(layer.Init(nullptr));
61 }
62 
63 /**
64  * @tc.name: InitLayers001
65  * @tc.desc:
66  * @tc.type: FUNC
67  */
HWTEST_F(EglWrapperLayerTest,InitLayers001,Level1)68 HWTEST_F(EglWrapperLayerTest, InitLayers001, Level1)
69 {
70     EglWrapperDispatchTable dispatchTable;
71     auto& layer = EglWrapperLayer::GetInstance();
72     layer.layerInit_ = {};
73     layer.InitLayers(&dispatchTable);
74     LayerInitFunc initFunc = [](const void* data, GetNextLayerAddr getAddr) -> EglWrapperFuncPointer {
75         return [](){};
76     };
77     layer.layerInit_.push_back(initFunc);
78     EXPECT_FALSE(layer.layerInit_.empty());
79     layer.layerSetup_ = {};
80     layer.InitLayers(&dispatchTable);
81     LayerSetupFunc setupFunc = [](const char* data, EglWrapperFuncPointer getAddr) -> EglWrapperFuncPointer {
82         return [](){};
83     };
84     layer.layerSetup_.push_back(setupFunc);
85     layer.InitLayers(&dispatchTable);
86     layer.layerInit_.clear();
87     layer.InitLayers(&dispatchTable);
88 }
89 
90 /**
91  * @tc.name: LoadLayers001
92  * @tc.desc:
93  * @tc.type: FUNC
94  */
HWTEST_F(EglWrapperLayerTest,LoadLayers001,Level1)95 HWTEST_F(EglWrapperLayerTest, LoadLayers001, Level1)
96 {
97     EglWrapperDispatchTable dispatchTable;
98 
99     bool result = EglWrapperLayer::GetInstance().LoadLayers();
100     ASSERT_TRUE(result);
101 }
102 
103 /**
104  * @tc.name: InitBundleInfo001
105  * @tc.desc:
106  * @tc.type: FUNC
107  */
HWTEST_F(EglWrapperLayerTest,InitBundleInfo001,Level1)108 HWTEST_F(EglWrapperLayerTest, InitBundleInfo001, Level1)
109 {
110     EglWrapperDispatchTable dispatchTable;
111     bool result = EglWrapperLayer::GetInstance().InitBundleInfo();
112     ASSERT_FALSE(result);
113 }
114 } // OHOS::Rosen