• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: DumpNumericValue001
42  * @tc.desc: Test DumpNumericValue
43  * @tc.type: FUNC
44  * @tc.require:I91EDT
45  */
46 HWTEST_F(SkiaTraceMemoryDumpTest, DumpNumericValue001, TestSize.Level1)
47 {
48     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
49     skiaTraceMemoryDump.DumpNumericValue("dumpName1", "valueName", "bytes", 1);
50 }
51 
52 /**
53  * @tc.name: DumpStringValue001
54  * @tc.desc: Test DumpStringValue
55  * @tc.type: FUNC
56  * @tc.require:I91EDT
57  */
58 HWTEST_F(SkiaTraceMemoryDumpTest, DumpStringValue001, TestSize.Level1)
59 {
60     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
61     skiaTraceMemoryDump.DumpStringValue("dumpName1", "valueName", "1");
62 }
63 
64 /**
65  * @tc.name: LogOutput001
66  * @tc.desc: Test LogOutput
67  * @tc.type: FUNC
68  * @tc.require:I91EDT
69  */
70 HWTEST_F(SkiaTraceMemoryDumpTest, LogOutput001, TestSize.Level1)
71 {
72     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
73     DfxString log;
74     skiaTraceMemoryDump.LogOutput(log);
75 }
76 
77 /**
78  * @tc.name: LogTotals001
79  * @tc.desc: Test LogTotals
80  * @tc.type: FUNC
81  * @tc.require:I91EDT
82  */
83 HWTEST_F(SkiaTraceMemoryDumpTest, LogTotals001, TestSize.Level1)
84 {
85     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
86     DfxString log;
87     skiaTraceMemoryDump.LogTotals(log);
88 }
89 
90 /**
91  * @tc.name: GetGpuMemorySizeInMB001
92  * @tc.desc: Test GetGpuMemorySizeInMB
93  * @tc.type: FUNC
94  * @tc.require:I91EDT
95  */
96 HWTEST_F(SkiaTraceMemoryDumpTest, GetGpuMemorySizeInMB001, TestSize.Level1)
97 {
98     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
99     ASSERT_TRUE(skiaTraceMemoryDump.GetGpuMemorySizeInMB() >= 0);
100 }
101 
102 /**
103  * @tc.name: GetGLMemorySize001
104  * @tc.desc: Test GetGLMemorySize
105  * @tc.type: FUNC
106  * @tc.require:I91EDT
107  */
108 HWTEST_F(SkiaTraceMemoryDumpTest, GetGLMemorySize001, TestSize.Level1)
109 {
110     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
111     ASSERT_TRUE(skiaTraceMemoryDump.GetGLMemorySize() >= 0);
112 }
113 
114 /**
115  * @tc.name: GetTraceMemoryDump001
116  * @tc.desc: Test GetTraceMemoryDump
117  * @tc.type: FUNC
118  * @tc.require:I91EDT
119  */
120 HWTEST_F(SkiaTraceMemoryDumpTest, GetTraceMemoryDump001, TestSize.Level1)
121 {
122     SkiaTraceMemoryDump skiaTraceMemoryDump{"category", false};
123     ASSERT_TRUE(skiaTraceMemoryDump.GetTraceMemoryDump() != nullptr);
124 }
125 } // namespace Drawing
126 } // namespace Rosen
127 } // namespace OHOS