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 "memory_handler.h"
18
19 using namespace testing;
20 using namespace testing::ext;
21
22 namespace OHOS {
23 namespace Rosen {
24 class MemoryHandlerTest : public testing::Test {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 void SetUp() override;
29 void TearDown() override;
30 };
31
SetUpTestCase()32 void MemoryHandlerTest::SetUpTestCase() {}
TearDownTestCase()33 void MemoryHandlerTest::TearDownTestCase() {}
SetUp()34 void MemoryHandlerTest::SetUp() {}
TearDown()35 void MemoryHandlerTest::TearDown() {}
36
37 /**
38 * @tc.name: ClearRedundantResourcesTest001
39 * @tc.desc: Verify the ClearRedundantResourcesTest001 of MemoryHandlerTest
40 * @tc.type: FUNC
41 */
42 HWTEST_F(MemoryHandlerTest, ClearRedundantResourcesTest001, TestSize.Level1)
43 {
44 MemoryHandler::ClearRedundantResources(nullptr);
45 auto gpuContext = new Drawing::GPUContext();
46 EXPECT_NE(gpuContext, nullptr);
47 MemoryHandler::ClearRedundantResources(gpuContext);
48 delete gpuContext;
49 gpuContext = nullptr;
50 }
51
52 /**
53 * @tc.name: QuerryShaderTest001
54 * @tc.desc: Verify the QuerryShaderTest001 of MemoryHandlerTest
55 * @tc.type: FUNC
56 */
57 HWTEST_F(MemoryHandlerTest, QuerryShaderTest001, TestSize.Level1)
58 {
59 EXPECT_NE(MemoryHandler::QuerryShader(), "");
60 }
61
62 /**
63 * @tc.name: QuerryShaderTest002
64 * @tc.desc: Verify the QuerryShaderTest002 of MemoryHandlerTest
65 * @tc.type: FUNC
66 */
67 HWTEST_F(MemoryHandlerTest, QuerryShaderTest002, TestSize.Level1)
68 {
69 ShaderCache::Instance().SetFilePath("test");
70 ShaderCache::Instance().InitShaderCache();
71 EXPECT_NE(MemoryHandler::QuerryShader(), "");
72 }
73 } // namespace Rosen
74 } // namespace OHOS