• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include <string>
18 
19 #include "rs_frame_report.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 class RsFrameReportTest : 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 RsFrameReportTest::SetUpTestCase() {}
TearDownTestCase()35 void RsFrameReportTest::TearDownTestCase() {}
SetUp()36 void RsFrameReportTest::SetUp() {}
TearDown()37 void RsFrameReportTest::TearDown() {}
38 
39 /**
40  * @tc.name: GetEnable001
41  * @tc.desc: test
42  * @tc.type:FUNC
43  * @tc.require:
44  */
45 HWTEST_F(RsFrameReportTest, GetEnable001, TestSize.Level1)
46 {
47     RsFrameReport& fr = RsFrameReport::GetInstance();
48     fr.LoadLibrary();
49     fr.GetEnable();
50     EXPECT_EQ(fr.GetEnable(), 1);
51 }
52 
53 /**
54  * @tc.name: SendCommandsStart001
55  * @tc.desc: test
56  * @tc.type:FUNC
57  * @tc.require:
58  */
59 HWTEST_F(RsFrameReportTest, SendCommandsStart001, TestSize.Level1)
60 {
61     RsFrameReport& fr = RsFrameReport::GetInstance();
62     fr.LoadLibrary();
63     EXPECT_EQ(fr.sendCommandsStartFunc_, nullptr);
64     fr.SendCommandsStart();
65 }
66 
67 /**
68  * @tc.name: SetFrameParam001
69  * @tc.desc: test
70  * @tc.type:FUNC
71  * @tc.require:
72  */
73 HWTEST_F(RsFrameReportTest, SetFrameParam001, TestSize.Level1)
74 {
75     RsFrameReport& fr = RsFrameReport::GetInstance();
76     EXPECT_EQ(fr.setFrameParamFunc_, nullptr);
77     fr.SetFrameParam(0, 0, 0, 0);
78 }
79 
80 /**
81  * @tc.name: LoadLibrary001
82  * @tc.desc: test
83  * @tc.type:FUNC
84  * @tc.require:
85  */
86 HWTEST_F(RsFrameReportTest, LoadLibrary001, TestSize.Level1)
87 {
88     RsFrameReport& fr = RsFrameReport::GetInstance();
89     fr.LoadLibrary();
90     EXPECT_TRUE(fr.frameSchedSoLoaded_);
91 }
92 
93 /**
94  * @tc.name: LoadSymbol001
95  * @tc.desc: test
96  * @tc.type:FUNC
97  * @tc.require:
98  */
99 HWTEST_F(RsFrameReportTest, LoadSymbol001, TestSize.Level1)
100 {
101     RsFrameReport& fr = RsFrameReport::GetInstance();
102     fr.LoadSymbol("function");
103     fr.LoadLibrary();
104     fr.LoadSymbol("function");
105     EXPECT_TRUE(fr.frameSchedSoLoaded_);
106 }
107 
108 /**
109  * @tc.name: LoadLibrary002
110  * @tc.desc: test
111  * @tc.type:FUNC
112  * @tc.require:
113  */
114 HWTEST_F(RsFrameReportTest, LoadLibrary002, TestSize.Level1)
115 {
116     RsFrameReport& fr = RsFrameReport::GetInstance();
117     fr.frameSchedSoLoaded_ = false;
118     fr.LoadLibrary();
119     fr.frameSchedSoLoaded_ = true;
120     EXPECT_TRUE(fr.LoadLibrary());
121 }
122 
123 /**
124  * @tc.name: ReportSchedEvent001
125  * @tc.desc: test
126  * @tc.type:FUNC
127  * @tc.require:
128  */
129 HWTEST_F(RsFrameReportTest, ReportSchedEvent001, TestSize.Level1)
130 {
131     RsFrameReport& fr = RsFrameReport::GetInstance();
132     EXPECT_EQ(fr.reportSchedEventFunc_, nullptr);
133     fr.ReportSchedEvent(FrameSchedEvent::INIT, {});
134     EXPECT_NE(fr.reportSchedEventFunc_, nullptr);
135     fr.ReportSchedEvent(FrameSchedEvent::INIT, {});
136 }
137 
138 /**
139  * @tc.name: ReportScbSceneInfo001
140  * @tc.desc: test
141  * @tc.type:FUNC
142  * @tc.require:
143  */
144 HWTEST_F(RsFrameReportTest, ReportScbSceneInfo001, TestSize.Level1)
145 {
146     RsFrameReport& fr = RsFrameReport::GetInstance();
147     std::string description = "test";
148     bool eventStatus = true;
149     fr.ReportScbSceneInfo(description, eventStatus);
150     EXPECT_NE(fr.reportSchedEventFunc_, nullptr);
151     eventStatus = false;
152     fr.ReportScbSceneInfo(description, eventStatus);
153     EXPECT_NE(fr.reportSchedEventFunc_, nullptr);
154 }
155 
156 /**
157  * @tc.name: ReportFrameDeadline001
158  * @tc.desc: test
159  * @tc.type:FUNC
160  * @tc.require:
161  */
162 HWTEST_F(RsFrameReportTest, ReportFrameDeadline001, TestSize.Level1)
163 {
164     RsFrameReport& fr = RsFrameReport::GetInstance();
165     int deadline = 8333;
166     uint32_t currentRate = 120;
167     fr.ReportFrameDeadline(deadline, currentRate);
168     EXPECT_NE(fr.reportSchedEventFunc_, nullptr);
169     deadline = -8333;
170     fr.ReportFrameDeadline(deadline, currentRate);
171     EXPECT_NE(fr.reportSchedEventFunc_, nullptr);
172     deadline = 0;
173     fr.ReportFrameDeadline(deadline, currentRate);
174     EXPECT_NE(fr.reportSchedEventFunc_, nullptr);
175 }
176 
177 /**
178  * @tc.name: ReportBufferCount001
179  * @tc.desc: test
180  * @tc.type:FUNC
181  * @tc.require:
182  */
183 HWTEST_F(RsFrameReportTest, ReportBufferCount001, TestSize.Level1)
184 {
185     RsFrameReport& fr = RsFrameReport::GetInstance();
186     EXPECT_EQ(fr.bufferCount_, 0);
187     fr.ReportBufferCount(1);
188     EXPECT_EQ(fr.bufferCount_, 1);
189 }
190 
191 /**
192  * @tc.name: ReportHardwareInfo001
193  * @tc.desc: test
194  * @tc.type:FUNC
195  * @tc.require:
196  */
197 HWTEST_F(RsFrameReportTest, ReportHardwareInfo001, TestSize.Level1)
198 {
199     RsFrameReport& fr = RsFrameReport::GetInstance();
200     EXPECT_EQ(fr.hardwareTid_, 0);
201     fr.ReportHardwareInfo(1);
202     EXPECT_EQ(fr.hardwareTid_, 1);
203 }
204 
205 /**
206  * @tc.name: ReportUnmarshalData001
207  * @tc.desc: test
208  * @tc.type:FUNC
209  * @tc.require:
210  */
211 HWTEST_F(RsFrameReportTest, ReportUnmarshalData001, TestSize.Level1)
212 {
213     int unmarshalTid = 123456;
214     size_t dataSize = 20 * 1024;
215     RsFrameReport& fr = RsFrameReport::GetInstance();
216     fr.ReportUnmarshalData(unmarshalTid, dataSize);
217     unmarshalTid = 0;
218     fr.ReportUnmarshalData(unmarshalTid, dataSize);
219     EXPECT_EQ(fr.hardwareTid_, 1);
220 }
221 } // namespace Rosen
222 } // namespace OHOS
223