1 /*
2 * Copyright (c) 2024 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 <cstddef>
17 #include "gtest/gtest.h"
18 #include "skia_adapter/skia_trace_memory_dump.h"
19 #include "image/trace_memory_dump.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class SkiaTraceMemoryDumpTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33 };
34
SetUpTestCase()35 void SkiaTraceMemoryDumpTest::SetUpTestCase() {}
TearDownTestCase()36 void SkiaTraceMemoryDumpTest::TearDownTestCase() {}
SetUp()37 void SkiaTraceMemoryDumpTest::SetUp() {}
TearDown()38 void SkiaTraceMemoryDumpTest::TearDown() {}
39
40 /**
41 * @tc.name: GetGpuMemorySizeInMB001
42 * @tc.desc: Test GetGpuMemorySizeInMB
43 * @tc.type: FUNC
44 * @tc.require:I91EDT
45 */
46 HWTEST_F(SkiaTraceMemoryDumpTest, GetGpuMemorySizeInMB001, TestSize.Level1)
47 {
48 SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
49 skiaTraceMemoryDump.DumpNumericValue("dumpName1", "valueName", "bytes", 1);
50 skiaTraceMemoryDump.DumpStringValue("dumpName1", "valueName", "1");
51 DfxString log;
52 skiaTraceMemoryDump.LogOutput(log);
53 skiaTraceMemoryDump.LogTotals(log);
54 ASSERT_TRUE(skiaTraceMemoryDump.GetGpuMemorySizeInMB() >= 0);
55 }
56
57
58 /**
59 * @tc.name: GetGpuMemorySizeInMB002
60 * @tc.desc: Test GetGpuMemorySizeInMB
61 * @tc.type: FUNC
62 * @tc.require:I91EDT
63 */
64 HWTEST_F(SkiaTraceMemoryDumpTest, GetGpuMemorySizeInMB002, TestSize.Level1)
65 {
66 SkiaTraceMemoryDump skiaTraceMemoryDump{nullptr, false};
67 skiaTraceMemoryDump.DumpNumericValue("dumpName1", "valueName", "bytes", 1);
68 skiaTraceMemoryDump.DumpStringValue("dumpName1", "valueName", "1");
69 DfxString log;
70 skiaTraceMemoryDump.LogOutput(log);
71 skiaTraceMemoryDump.LogTotals(log);
72 ASSERT_TRUE(skiaTraceMemoryDump.GetGpuMemorySizeInMB() >= 0);
73 }
74
75
76 /**
77 * @tc.name: GetGLMemorySize001
78 * @tc.desc: Test GetGLMemorySize
79 * @tc.type: FUNC
80 * @tc.require:I91EDT
81 */
82 HWTEST_F(SkiaTraceMemoryDumpTest, GetGLMemorySize001, TestSize.Level1)
83 {
84 SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
85 ASSERT_TRUE(skiaTraceMemoryDump.GetGLMemorySize() >= 0);
86 }
87
88 /**
89 * @tc.name: GetGLMemorySize002
90 * @tc.desc: Test GetGLMemorySize
91 * @tc.type: FUNC
92 * @tc.require:I91EDT
93 */
94 HWTEST_F(SkiaTraceMemoryDumpTest, GetGLMemorySize002, TestSize.Level1)
95 {
96 SkiaTraceMemoryDump skiaTraceMemoryDump{nullptr, false};
97 ASSERT_TRUE(skiaTraceMemoryDump.GetGLMemorySize() >= 0);
98 }
99
100 /**
101 * @tc.name: GetTraceMemoryDump001
102 * @tc.desc: Test GetTraceMemoryDump
103 * @tc.type: FUNC
104 * @tc.require:I91EDT
105 */
106 HWTEST_F(SkiaTraceMemoryDumpTest, GetTraceMemoryDump001, TestSize.Level1)
107 {
108 SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
109 ASSERT_TRUE(skiaTraceMemoryDump.GetTraceMemoryDump() != nullptr);
110 }
111
112 } // namespace Drawing
113 } // namespace Rosen
114 } // namespace OHOS