• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "hdf_io_service.h"
18 #include "hdf_pm_driver_test.h"
19 
20 using namespace testing::ext;
21 
22 class HdfPmTest : public testing::Test {
23 public:
24     static void SetUpTestCase();
25     static void TearDownTestCase();
26     void SetUp();
27     void TearDown();
28     static struct HdfIoService *ioService;
29 };
30 
31 struct HdfIoService *HdfPmTest::ioService = nullptr;
32 
SetUpTestCase()33 void HdfPmTest::SetUpTestCase()
34 {
35     ioService = HdfIoServiceBind("pm_ut_service");
36     ASSERT_TRUE(ioService != nullptr);
37     ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_BEGEN, nullptr, nullptr);
38 }
39 
TearDownTestCase()40 void HdfPmTest::TearDownTestCase()
41 {
42     ASSERT_TRUE(ioService != nullptr);
43     ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_END, nullptr, nullptr);
44     HdfIoServiceRecycle(ioService);
45 }
46 
SetUp()47 void HdfPmTest::SetUp()
48 {
49 }
50 
TearDown()51 void HdfPmTest::TearDown()
52 {
53 }
54 
55 /**
56   * @tc.name: HdfPmTestOneDriverOnce
57   * @tc.desc: test one driver
58   * @tc.type: FUNC
59   * @tc.require: SR000GGTQF
60   */
61 HWTEST_F(HdfPmTest, HdfPmTestOneDriverOnce, TestSize.Level3)
62 {
63     ASSERT_TRUE(ioService != nullptr);
64 
65     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_ONCE, nullptr, nullptr);
66     EXPECT_TRUE(ret == HDF_SUCCESS);
67 }
68 
69 /**
70   * @tc.name: HdfPmTestOneDriverTwice
71   * @tc.desc: test one driver
72   * @tc.type: FUNC
73   * @tc.require: SR000GGTQF
74   */
75 HWTEST_F(HdfPmTest, HdfPmTestOneDriverTwice, TestSize.Level3)
76 {
77     ASSERT_TRUE(ioService != nullptr);
78 
79     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_TWICE, nullptr, nullptr);
80     EXPECT_TRUE(ret == HDF_SUCCESS);
81 }
82 
83 /**
84   * @tc.name: HdfPmTestOneDriverTen
85   * @tc.desc: test one driver
86   * @tc.type: FUNC
87   * @tc.require: SR000GGTQF
88   */
89 HWTEST_F(HdfPmTest, HdfPmTestOneDriverTen, TestSize.Level3)
90 {
91     ASSERT_TRUE(ioService != nullptr);
92 
93     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_TEN, nullptr, nullptr);
94     EXPECT_TRUE(ret == HDF_SUCCESS);
95 }
96 
97 /**
98   * @tc.name: HdfPmTestOneDriverHundred
99   * @tc.desc: test one driver
100   * @tc.type: FUNC
101   * @tc.require: SR000GGTQF
102   */
103 HWTEST_F(HdfPmTest, HdfPmTestOneDriverHundred, TestSize.Level3)
104 {
105     ASSERT_TRUE(ioService != nullptr);
106 
107     int32_t ret = ioService->dispatcher->Dispatch(
108         &ioService->object, HDF_PM_TEST_ONE_DRIVER_HUNDRED, nullptr, nullptr);
109     EXPECT_TRUE(ret == HDF_SUCCESS);
110 }
111 
112 /**
113   * @tc.name: HdfPmTestOneDriverThousand
114   * @tc.desc: test one driver
115   * @tc.type: FUNC
116   * @tc.require: SR000GGTQF
117   */
118 HWTEST_F(HdfPmTest, HdfPmTestOneDriverThousand, TestSize.Level3)
119 {
120     ASSERT_TRUE(ioService != nullptr);
121 
122     int32_t ret = ioService->dispatcher->Dispatch(
123         &ioService->object, HDF_PM_TEST_ONE_DRIVER_THOUSAND, nullptr, nullptr);
124     EXPECT_TRUE(ret == HDF_SUCCESS);
125 }
126 
127 /**
128   * @tc.name: HdfPmTestTwoDriverOnce
129   * @tc.desc: test two drivers
130   * @tc.type: FUNC
131   * @tc.require: SR000GGTQF
132   */
133 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverOnce, TestSize.Level3)
134 {
135     ASSERT_TRUE(ioService != nullptr);
136 
137     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_ONCE, nullptr, nullptr);
138     EXPECT_TRUE(ret == HDF_SUCCESS);
139 }
140 
141 /**
142   * @tc.name: HdfPmTestTwoDriverTwice
143   * @tc.desc: test two drivers
144   * @tc.type: FUNC
145   * @tc.require: SR000GGTQF
146   */
147 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverTwice, TestSize.Level3)
148 {
149     ASSERT_TRUE(ioService != nullptr);
150 
151     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_TWICE, nullptr, nullptr);
152     EXPECT_TRUE(ret == HDF_SUCCESS);
153 }
154 
155 /**
156   * @tc.name: HdfPmTestTwoDriverTen
157   * @tc.desc: test two drivers
158   * @tc.type: FUNC
159   * @tc.require: SR000GGTQF
160   */
161 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverTen, TestSize.Level3)
162 {
163     ASSERT_TRUE(ioService != nullptr);
164 
165     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_TEN, nullptr, nullptr);
166     EXPECT_TRUE(ret == HDF_SUCCESS);
167 }
168 
169 /**
170   * @tc.name: HdfPmTestTwoDriverHundred
171   * @tc.desc: test two drivers
172   * @tc.type: FUNC
173   * @tc.require: SR000GGTQF
174   */
175 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverHundred, TestSize.Level3)
176 {
177     ASSERT_TRUE(ioService != nullptr);
178 
179     int32_t ret = ioService->dispatcher->Dispatch(
180         &ioService->object, HDF_PM_TEST_TWO_DRIVER_HUNDRED, nullptr, nullptr);
181     EXPECT_TRUE(ret == HDF_SUCCESS);
182 }
183 
184 /**
185   * @tc.name: HdfPmTestTwoDriverThousand
186   * @tc.desc: test two drivers
187   * @tc.type: FUNC
188   * @tc.require: SR000GGTQF
189   */
190 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverThousand, TestSize.Level3)
191 {
192     ASSERT_TRUE(ioService != nullptr);
193 
194     int32_t ret = ioService->dispatcher->Dispatch(
195         &ioService->object, HDF_PM_TEST_TWO_DRIVER_THOUSAND, nullptr, nullptr);
196     EXPECT_TRUE(ret == HDF_SUCCESS);
197 }
198 
199 /**
200   * @tc.name: HdfPmTestThreeDriverOnce
201   * @tc.desc: test three drivers
202   * @tc.type: FUNC
203   * @tc.require: SR000GGTQF
204   */
205 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverOnce, TestSize.Level3)
206 {
207     ASSERT_TRUE(ioService != nullptr);
208 
209     int32_t ret = ioService->dispatcher->Dispatch(
210         &ioService->object, HDF_PM_TEST_THREE_DRIVER_ONCE, nullptr, nullptr);
211     EXPECT_TRUE(ret == HDF_SUCCESS);
212 }
213 
214 /**
215   * @tc.name: HdfPmTestThreeDriverTwice
216   * @tc.desc: test three drivers
217   * @tc.type: FUNC
218   * @tc.require: SR000GGTQF
219   */
220 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverTwice, TestSize.Level3)
221 {
222     ASSERT_TRUE(ioService != nullptr);
223 
224     int32_t ret = ioService->dispatcher->Dispatch(
225         &ioService->object, HDF_PM_TEST_THREE_DRIVER_TWICE, nullptr, nullptr);
226     EXPECT_TRUE(ret == HDF_SUCCESS);
227 }
228 
229 /**
230   * @tc.name: HdfPmTestThreeDriverTen
231   * @tc.desc: test three drivers
232   * @tc.type: FUNC
233   * @tc.require: SR000GGTQF
234   */
235 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverTen, TestSize.Level3)
236 {
237     ASSERT_TRUE(ioService != nullptr);
238 
239     int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_TEN, nullptr, nullptr);
240     EXPECT_TRUE(ret == HDF_SUCCESS);
241 }
242 
243 /**
244   * @tc.name: HdfPmTestThreeDriverHundred
245   * @tc.desc: test three drivers
246   * @tc.type: FUNC
247   * @tc.require: SR000GGTQF
248   */
249 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverHundred, TestSize.Level3)
250 {
251     ASSERT_TRUE(ioService != nullptr);
252 
253     int32_t ret = ioService->dispatcher->Dispatch(
254         &ioService->object, HDF_PM_TEST_THREE_DRIVER_HUNDRED, nullptr, nullptr);
255     EXPECT_TRUE(ret == HDF_SUCCESS);
256 }
257 
258 /**
259   * @tc.name: HdfPmTestThreeDriverThousand
260   * @tc.desc: test three drivers
261   * @tc.type: FUNC
262   * @tc.require: SR000GGTQF
263   */
264 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverThousand, TestSize.Level3)
265 {
266     ASSERT_TRUE(ioService != nullptr);
267 
268     int32_t ret = ioService->dispatcher->Dispatch(
269         &ioService->object, HDF_PM_TEST_THREE_DRIVER_THOUSAND, nullptr, nullptr);
270     EXPECT_TRUE(ret == HDF_SUCCESS);
271 }
272 
273 /**
274   * @tc.name: HdfPmTestThreeDriverSeqHundred
275   * @tc.desc: test three drivers
276   * @tc.type: FUNC
277   * @tc.require: SR000GGTQF
278   */
279 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverSeqHundred, TestSize.Level3)
280 {
281     ASSERT_TRUE(ioService != nullptr);
282 
283     int32_t ret = ioService->dispatcher->Dispatch(
284         &ioService->object, HDF_PM_TEST_THREE_DRIVER_SEQ_HUNDRED, nullptr, nullptr);
285     EXPECT_TRUE(ret == HDF_SUCCESS);
286 }
287 
288 /**
289   * @tc.name: HdfPmTestThreeDriverHundredWithSync
290   * @tc.desc: test three drivers
291   * @tc.type: FUNC
292   * @tc.require: SR000GGTQF
293   */
294 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverHundredWithSync, TestSize.Level3)
295 {
296     ASSERT_TRUE(ioService != nullptr);
297 
298     int32_t ret = ioService->dispatcher->Dispatch(
299         &ioService->object, HDF_PM_TEST_THREE_DRIVER_HUNDRED_WITH_SYNC, nullptr, nullptr);
300     EXPECT_TRUE(ret == HDF_SUCCESS);
301 }
302