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, 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 "image/trace_memory_dump.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class TraceMemoryDumpTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp() override;
31 void TearDown() override;
32 };
33
SetUpTestCase()34 void TraceMemoryDumpTest::SetUpTestCase() {}
TearDownTestCase()35 void TraceMemoryDumpTest::TearDownTestCase() {}
SetUp()36 void TraceMemoryDumpTest::SetUp() {}
TearDown()37 void TraceMemoryDumpTest::TearDown() {}
38
39 /**
40 * @tc.name: DumpNumericValueTest001
41 * @tc.desc:
42 * @tc.type: FUNC
43 * @tc.require:AR000GGNV3
44 * @tc.author:
45 */
46 HWTEST_F(TraceMemoryDumpTest, DumpNumericValueTest001, TestSize.Level1)
47 {
48 std::unique_ptr<TraceMemoryDump> traceMemoryDump = std::make_unique<TraceMemoryDump>("category", true);
49 ASSERT_TRUE(traceMemoryDump != nullptr);
50 traceMemoryDump->DumpNumericValue("dumpName", "valueName", "units", 0);
51 }
52
53 /**
54 * @tc.name: DumpStringValueTest001
55 * @tc.desc:
56 * @tc.type: FUNC
57 * @tc.require:AR000GGNV3
58 * @tc.author:
59 */
60 HWTEST_F(TraceMemoryDumpTest, DumpStringValueTest001, TestSize.Level1)
61 {
62 std::unique_ptr<TraceMemoryDump> traceMemoryDump = std::make_unique<TraceMemoryDump>("category", true);
63 ASSERT_TRUE(traceMemoryDump != nullptr);
64 traceMemoryDump->DumpStringValue("dumpName", "valueName", "value");
65 }
66
67 /**
68 * @tc.name: LogOutputTest001
69 * @tc.desc:
70 * @tc.type: FUNC
71 * @tc.require:AR000GGNV3
72 * @tc.author:
73 */
74 HWTEST_F(TraceMemoryDumpTest, LogOutputTest001, TestSize.Level1)
75 {
76 std::unique_ptr<TraceMemoryDump> traceMemoryDump = std::make_unique<TraceMemoryDump>("category", true);
77 ASSERT_TRUE(traceMemoryDump != nullptr);
78 DfxString log;
79 traceMemoryDump->LogOutput(log);
80 }
81
82 /**
83 * @tc.name: LogTotalsTest001
84 * @tc.desc:
85 * @tc.type: FUNC
86 * @tc.require:AR000GGNV3
87 * @tc.author:
88 */
89 HWTEST_F(TraceMemoryDumpTest, LogTotalsTest001, TestSize.Level1)
90 {
91 std::unique_ptr<TraceMemoryDump> traceMemoryDump = std::make_unique<TraceMemoryDump>("category", true);
92 ASSERT_TRUE(traceMemoryDump != nullptr);
93 DfxString log;
94 traceMemoryDump->LogTotals(log);
95 }
96
97 /**
98 * @tc.name: GetGpuMemorySizeInMBTest001
99 * @tc.desc:
100 * @tc.type: FUNC
101 * @tc.require:AR000GGNV3
102 * @tc.author:
103 */
104 HWTEST_F(TraceMemoryDumpTest, GetGpuMemorySizeInMBTest001, TestSize.Level1)
105 {
106 std::unique_ptr<TraceMemoryDump> traceMemoryDump = std::make_unique<TraceMemoryDump>("category", true);
107 ASSERT_TRUE(traceMemoryDump != nullptr);
108 float mem = traceMemoryDump->GetGpuMemorySizeInMB();
109 EXPECT_GE(mem, 0.0);
110 }
111
112 /**
113 * @tc.name: GetGLMemorySizeTest001
114 * @tc.desc:
115 * @tc.type: FUNC
116 * @tc.require:AR000GGNV3
117 * @tc.author:
118 */
119 HWTEST_F(TraceMemoryDumpTest, GetGLMemorySizeTest001, TestSize.Level1)
120 {
121 std::unique_ptr<TraceMemoryDump> traceMemoryDump = std::make_unique<TraceMemoryDump>("category", true);
122 ASSERT_TRUE(traceMemoryDump != nullptr);
123 float mem = traceMemoryDump->GetGLMemorySize();
124 EXPECT_GE(mem, 0.0);
125 }
126 } // namespace Drawing
127 } // namespace Rosen
128 } // namespace OHOS