1 /*
2  * Copyright (c) 2023-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 <algorithm>
17 #include <cmath>
18 #include <cstdio>
19 #include <fcntl.h>
20 #include <functional>
21 #include <gtest/gtest.h>
22 #include <mutex>
23 #include <securec.h>
24 #include <unistd.h>
25 
26 #include "hdf_base.h"
27 #include "osal_time.h"
28 #include "v1_2/ipower_hdi_callback.h"
29 #include "v1_2/ipower_interface.h"
30 #include "v1_2/power_types.h"
31 #include "v1_2/running_lock_types.h"
32 
33 using namespace OHOS::HDI;
34 using namespace OHOS::HDI::Power::V1_2;
35 using namespace testing::ext;
36 
37 namespace {
38 class PowerHdiCallback : public IPowerHdiCallback {
39 public:
40     ~PowerHdiCallback() override{};
41     int32_t OnSuspend() override { return 0; };
42 
43     int32_t OnWakeup() override { return 0; };
44 };
45 
46 sptr<IPowerHdiCallback> g_callback = new PowerHdiCallback();
47 sptr<IPowerInterface> g_powerInterface = nullptr;
48 std::mutex g_mutex;
49 const uint32_t MAX_PATH = 256;
50 const uint32_t MAX_FILE = 1024;
51 const uint32_t WAIT_TIME = 1;
52 const std::string SUSPEND_STATE = "mem";
53 const std::string SUSPEND_STATE_PATH = "/sys/power/state";
54 const std::string LOCK_PATH = "/sys/power/wake_lock";
55 const std::string UNLOCK_PATH = "/sys/power/wake_unlock";
56 const std::string WAKEUP_COUNT_PATH = "/sys/power/wakeup_count";
57 
58 class HdfPowerHdiTestAdditional : public testing::Test {
59 public:
60     static void SetUpTestCase();
61     static void TearDownTestCase();
62     void SetUp();
63     void TearDown();
64     static int32_t ReadFile(const std::string path, std::string &buf, size_t size);
65 };
66 
SetUpTestCase()67 void HdfPowerHdiTestAdditional::SetUpTestCase() { g_powerInterface = IPowerInterface::Get(true); }
68 
TearDownTestCase()69 void HdfPowerHdiTestAdditional::TearDownTestCase() {}
70 
SetUp()71 void HdfPowerHdiTestAdditional::SetUp() {}
72 
TearDown()73 void HdfPowerHdiTestAdditional::TearDown() {}
74 
ReadFile(const std::string path, std::string &buf, size_t size)75 int32_t HdfPowerHdiTestAdditional::ReadFile(const std::string path, std::string &buf, size_t size)
76 {
77     std::lock_guard<std::mutex> lock(g_mutex);
78     int32_t ret;
79     char readbuf[size];
80     int32_t fd = open(path.c_str(), O_RDONLY, S_IRUSR | S_IRGRP | S_IROTH);
81     if (fd < HDF_SUCCESS) {
82         return HDF_FAILURE;
83     }
84 
85     ret = read(fd, readbuf, size);
86     if (ret < HDF_SUCCESS) {
87         close(fd);
88         return HDF_FAILURE;
89     }
90     buf = readbuf;
91     if (readbuf[0] == '\0') {
92         EXPECT_EQ(0, 1);
93     }
94     EXPECT_FALSE(buf.empty());
95     close(fd);
96     buf.push_back('\0');
97     return HDF_SUCCESS;
98 }
99 
100 /**
101  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_0500
102  * @tc.name   : testHoldRunningLock001
103  * @tc.desc   : check HoldRunningLock,type = RUNNINGLOCK_BACKGROUND_PHONE
104  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock001, Function | MediumTest | Level1)105 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock001, Function | MediumTest | Level1)
106 {
107     struct RunningLockInfo info = {
108         .name = "test_HoldRunningLock",
109         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
110         .timeoutMs = 3000,
111         .pid = 0,
112         .uid = 0,
113     };
114     int32_t ret = g_powerInterface->HoldRunningLock(info);
115     EXPECT_TRUE(HDF_SUCCESS == ret);
116     ret = g_powerInterface->UnholdRunningLock(info);
117     EXPECT_TRUE(HDF_SUCCESS == ret);
118 }
119 
120 /**
121  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_0600
122  * @tc.name   : testHoldRunningLock002
123  * @tc.desc   : check HoldRunningLock,type = RUNNINGLOCK_BACKGROUND_NOTIFICATION
124  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock002, Function | MediumTest | Level1)125 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock002, Function | MediumTest | Level1)
126 {
127     struct RunningLockInfo info = {
128         .name = "test_HoldRunningLock",
129         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
130         .timeoutMs = 3000,
131         .pid = 0,
132         .uid = 0,
133     };
134     int32_t ret = g_powerInterface->HoldRunningLock(info);
135     EXPECT_TRUE(HDF_SUCCESS == ret);
136     ret = g_powerInterface->UnholdRunningLock(info);
137     EXPECT_TRUE(HDF_SUCCESS == ret);
138 }
139 
140 /**
141  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_0700
142  * @tc.name   : testHoldRunningLock003
143  * @tc.desc   : check HoldRunningLock,type = RUNNINGLOCK_BACKGROUND_AUDIO
144  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock003, Function | MediumTest | Level1)145 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock003, Function | MediumTest | Level1)
146 {
147     struct RunningLockInfo info = {
148         .name = "test_HoldRunningLock",
149         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
150         .timeoutMs = 3000,
151         .pid = 0,
152         .uid = 0,
153     };
154     int32_t ret = g_powerInterface->HoldRunningLock(info);
155     EXPECT_TRUE(HDF_SUCCESS == ret);
156     ret = g_powerInterface->UnholdRunningLock(info);
157     EXPECT_TRUE(HDF_SUCCESS == ret);
158 }
159 
160 /**
161  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_0800
162  * @tc.name   : testHoldRunningLock004
163  * @tc.desc   : check HoldRunningLock,type = RUNNINGLOCK_BACKGROUND_SPORT
164  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock004, Function | MediumTest | Level1)165 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock004, Function | MediumTest | Level1)
166 {
167     struct RunningLockInfo info = {
168         .name = "test_HoldRunningLock",
169         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
170         .timeoutMs = 3000,
171         .pid = 0,
172         .uid = 0,
173     };
174     int32_t ret = g_powerInterface->HoldRunningLock(info);
175     EXPECT_TRUE(HDF_SUCCESS == ret);
176     ret = g_powerInterface->UnholdRunningLock(info);
177     EXPECT_TRUE(HDF_SUCCESS == ret);
178 }
179 
180 /**
181  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_0900
182  * @tc.name   : testHoldRunningLock005
183  * @tc.desc   : check HoldRunningLock,type = RUNNINGLOCK_BACKGROUND_NAVIGATION
184  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock005, Function | MediumTest | Level1)185 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock005, Function | MediumTest | Level1)
186 {
187     struct RunningLockInfo info = {
188         .name = "test_HoldRunningLock",
189         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
190         .timeoutMs = 3000,
191         .pid = 0,
192         .uid = 0,
193     };
194     int32_t ret = g_powerInterface->HoldRunningLock(info);
195     EXPECT_TRUE(HDF_SUCCESS == ret);
196     ret = g_powerInterface->UnholdRunningLock(info);
197     EXPECT_TRUE(HDF_SUCCESS == ret);
198 }
199 
200 /**
201  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1000
202  * @tc.name   : testHoldRunningLock006
203  * @tc.desc   : check HoldRunningLock,type = RUNNINGLOCK_BACKGROUND_TASK
204  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock006, Function | MediumTest | Level1)205 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock006, Function | MediumTest | Level1)
206 {
207     struct RunningLockInfo info = {
208         .name = "test_HoldRunningLock",
209         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
210         .timeoutMs = 3000,
211         .pid = 0,
212         .uid = 0,
213     };
214     int32_t ret = g_powerInterface->HoldRunningLock(info);
215     EXPECT_TRUE(HDF_SUCCESS == ret);
216     ret = g_powerInterface->UnholdRunningLock(info);
217     EXPECT_TRUE(HDF_SUCCESS == ret);
218 }
219 
220 /**
221  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1100
222  * @tc.name   : testHoldRunningLock007
223  * @tc.desc   : Cycle 100 times,type = RUNNINGLOCK_BACKGROUND_PHONE
224  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock007, Function | MediumTest | Level1)225 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock007, Function | MediumTest | Level1)
226 {
227     struct RunningLockInfo info = {
228         .name = "test_HoldRunningLock",
229         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
230         .timeoutMs = 3000,
231         .pid = 0,
232         .uid = 0,
233     };
234     int32_t ret;
235     for (int i = 0; i < 100; i++) {
236         ret = g_powerInterface->HoldRunningLock(info);
237         EXPECT_TRUE(HDF_SUCCESS == ret);
238         ret = g_powerInterface->UnholdRunningLock(info);
239         EXPECT_TRUE(HDF_SUCCESS == ret);
240     }
241 }
242 
243 /**
244  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1200
245  * @tc.name   : testHoldRunningLock008
246  * @tc.desc   : Cycle 100 times,type = RUNNINGLOCK_BACKGROUND_NOTIFICATION
247  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock008, Function | MediumTest | Level1)248 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock008, Function | MediumTest | Level1)
249 {
250     struct RunningLockInfo info = {
251         .name = "test_HoldRunningLock",
252         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
253         .timeoutMs = 3000,
254         .pid = 0,
255         .uid = 0,
256     };
257     int32_t ret;
258     for (int i = 0; i < 100; i++) {
259         ret = g_powerInterface->HoldRunningLock(info);
260         EXPECT_TRUE(HDF_SUCCESS == ret);
261         ret = g_powerInterface->UnholdRunningLock(info);
262         EXPECT_TRUE(HDF_SUCCESS == ret);
263     }
264 }
265 
266 /**
267  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1300
268  * @tc.name   : testHoldRunningLock009
269  * @tc.desc   : Cycle 100 times,type = RUNNINGLOCK_BACKGROUND_AUDIO
270  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock009, Function | MediumTest | Level1)271 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock009, Function | MediumTest | Level1)
272 {
273     struct RunningLockInfo info = {
274         .name = "test_HoldRunningLock",
275         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
276         .timeoutMs = 3000,
277         .pid = 0,
278         .uid = 0,
279     };
280     int32_t ret;
281     for (int i = 0; i < 100; i++) {
282         ret = g_powerInterface->HoldRunningLock(info);
283         EXPECT_TRUE(HDF_SUCCESS == ret);
284         ret = g_powerInterface->UnholdRunningLock(info);
285         EXPECT_TRUE(HDF_SUCCESS == ret);
286     }
287 }
288 
289 /**
290  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1400
291  * @tc.name   : testHoldRunningLock010
292  * @tc.desc   : Cycle 100 times,type = RUNNINGLOCK_BACKGROUND_SPORT
293  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock010, Function | MediumTest | Level1)294 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock010, Function | MediumTest | Level1)
295 {
296     struct RunningLockInfo info = {
297         .name = "test_HoldRunningLock",
298         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
299         .timeoutMs = 3000,
300         .pid = 0,
301         .uid = 0,
302     };
303     int32_t ret;
304     for (int i = 0; i < 100; i++) {
305         ret = g_powerInterface->HoldRunningLock(info);
306         EXPECT_TRUE(HDF_SUCCESS == ret);
307         ret = g_powerInterface->UnholdRunningLock(info);
308         EXPECT_TRUE(HDF_SUCCESS == ret);
309     }
310 }
311 
312 /**
313  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1500
314  * @tc.name   : testHoldRunningLock011
315  * @tc.desc   : Cycle 100 times,type = RUNNINGLOCK_BACKGROUND_NAVIGATION
316  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock011, Function | MediumTest | Level1)317 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock011, Function | MediumTest | Level1)
318 {
319     struct RunningLockInfo info = {
320         .name = "test_HoldRunningLock",
321         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
322         .timeoutMs = 3000,
323         .pid = 0,
324         .uid = 0,
325     };
326     int32_t ret;
327     for (int i = 0; i < 100; i++) {
328         ret = g_powerInterface->HoldRunningLock(info);
329         EXPECT_TRUE(HDF_SUCCESS == ret);
330         ret = g_powerInterface->UnholdRunningLock(info);
331         EXPECT_TRUE(HDF_SUCCESS == ret);
332     }
333 }
334 
335 /**
336  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1600
337  * @tc.name   : testHoldRunningLock012
338  * @tc.desc   : Cycle 100 times,type = RUNNINGLOCK_BACKGROUND_TASK
339  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock012, Function | MediumTest | Level1)340 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock012, Function | MediumTest | Level1)
341 {
342     struct RunningLockInfo info = {
343         .name = "test_HoldRunningLock",
344         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
345         .timeoutMs = 3000,
346         .pid = 0,
347         .uid = 0,
348     };
349     int32_t ret;
350     for (int i = 0; i < 100; i++) {
351         ret = g_powerInterface->HoldRunningLock(info);
352         EXPECT_TRUE(HDF_SUCCESS == ret);
353         ret = g_powerInterface->UnholdRunningLock(info);
354         EXPECT_TRUE(HDF_SUCCESS == ret);
355     }
356 }
357 
358 /**
359  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1700
360  * @tc.name   : testHoldRunningLock013
361  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_NOTIFICATION
362  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock013, Function | MediumTest | Level2)363 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock013, Function | MediumTest | Level2)
364 {
365     struct RunningLockInfo info = {
366         .name = "",
367         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
368         .timeoutMs = 3000,
369         .pid = 0,
370         .uid = 0,
371     };
372     int32_t ret = g_powerInterface->HoldRunningLock(info);
373     EXPECT_FALSE(HDF_SUCCESS == ret);
374 }
375 
376 /**
377  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1800
378  * @tc.name   : testHoldRunningLock014
379  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_AUDIO
380  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock014, Function | MediumTest | Level2)381 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock014, Function | MediumTest | Level2)
382 {
383     struct RunningLockInfo info = {
384         .name = "",
385         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
386         .timeoutMs = 3000,
387         .pid = 0,
388         .uid = 0,
389     };
390     int32_t ret = g_powerInterface->HoldRunningLock(info);
391     EXPECT_FALSE(HDF_SUCCESS == ret);
392 }
393 
394 /**
395  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_1900
396  * @tc.name   : testHoldRunningLock015
397  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_SPORT
398  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock015, Function | MediumTest | Level2)399 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock015, Function | MediumTest | Level2)
400 {
401     struct RunningLockInfo info = {
402         .name = "",
403         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
404         .timeoutMs = 3000,
405         .pid = 0,
406         .uid = 0,
407     };
408     int32_t ret = g_powerInterface->HoldRunningLock(info);
409     EXPECT_FALSE(HDF_SUCCESS == ret);
410 }
411 
412 /**
413  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2000
414  * @tc.name   : testHoldRunningLock016
415  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_NAVIGATION
416  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock016, Function | MediumTest | Level2)417 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock016, Function | MediumTest | Level2)
418 {
419     struct RunningLockInfo info = {
420         .name = "",
421         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
422         .timeoutMs = 3000,
423         .pid = 0,
424         .uid = 0,
425     };
426     int32_t ret = g_powerInterface->HoldRunningLock(info);
427     EXPECT_FALSE(HDF_SUCCESS == ret);
428 }
429 
430 /**
431  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2100
432  * @tc.name   : testHoldRunningLock017
433  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_TASK
434  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock017, Function | MediumTest | Level2)435 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock017, Function | MediumTest | Level2)
436 {
437     struct RunningLockInfo info = {
438         .name = "",
439         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
440         .timeoutMs = 3000,
441         .pid = 0,
442         .uid = 0,
443     };
444     int32_t ret = g_powerInterface->HoldRunningLock(info);
445     EXPECT_FALSE(HDF_SUCCESS == ret);
446 }
447 
448 /**
449  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2200
450  * @tc.name   : testHoldRunningLock018
451  * @tc.desc   : name is null,type = RUNNINGLOCK_BUTT
452  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock018, Function | MediumTest | Level2)453 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock018, Function | MediumTest | Level2)
454 {
455     struct RunningLockInfo info = {
456         .name = "",
457         .type = RunningLockType::RUNNINGLOCK_BUTT,
458         .timeoutMs = 3000,
459         .pid = 0,
460         .uid = 0,
461     };
462     int32_t ret = g_powerInterface->HoldRunningLock(info);
463     EXPECT_FALSE(HDF_SUCCESS == ret);
464 }
465 
466 /**
467  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2300
468  * @tc.name   : testHoldRunningLock019
469  * @tc.desc   : name is null,type = static_cast<RunningLockType>(100)
470  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock019, Function | MediumTest | Level2)471 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock019, Function | MediumTest | Level2)
472 {
473     struct RunningLockInfo info = {
474         .name = "",
475         .type = static_cast<RunningLockType>(100),
476         .timeoutMs = 3000,
477         .pid = 0,
478         .uid = 0,
479     };
480     int32_t ret = g_powerInterface->HoldRunningLock(info);
481     EXPECT_FALSE(HDF_SUCCESS == ret);
482 }
483 
484 /**
485  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2400
486  * @tc.name   : testHoldRunningLock020
487  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BACKGROUND_PHONE
488  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock020, Function | MediumTest | Level2)489 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock020, Function | MediumTest | Level2)
490 {
491     struct RunningLockInfo info = {
492         .name = "",
493         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
494         .timeoutMs = 3000,
495         .pid = 0,
496         .uid = 0,
497     };
498     int32_t ret;
499     for (int i = 0; i < 100; i++) {
500         ret = g_powerInterface->HoldRunningLock(info);
501         EXPECT_FALSE(HDF_SUCCESS == ret);
502     }
503 }
504 
505 /**
506  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2500
507  * @tc.name   : testHoldRunningLock021
508  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BACKGROUND_NOTIFICATION
509  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock021, Function | MediumTest | Level2)510 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock021, Function | MediumTest | Level2)
511 {
512     struct RunningLockInfo info = {
513         .name = "",
514         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
515         .timeoutMs = 3000,
516         .pid = 0,
517         .uid = 0,
518     };
519     int32_t ret;
520     for (int i = 0; i < 100; i++) {
521         ret = g_powerInterface->HoldRunningLock(info);
522         EXPECT_FALSE(HDF_SUCCESS == ret);
523     }
524 }
525 
526 /**
527  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2600
528  * @tc.name   : testHoldRunningLock022
529  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BACKGROUND_AUDIO
530  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock022, Function | MediumTest | Level2)531 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock022, Function | MediumTest | Level2)
532 {
533     struct RunningLockInfo info = {
534         .name = "",
535         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
536         .timeoutMs = 3000,
537         .pid = 0,
538         .uid = 0,
539     };
540     int32_t ret;
541     for (int i = 0; i < 100; i++) {
542         ret = g_powerInterface->HoldRunningLock(info);
543         EXPECT_FALSE(HDF_SUCCESS == ret);
544     }
545 }
546 
547 /**
548  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2700
549  * @tc.name   : testHoldRunningLock023
550  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BACKGROUND_SPORT
551  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock023, Function | MediumTest | Level2)552 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock023, Function | MediumTest | Level2)
553 {
554     struct RunningLockInfo info = {
555         .name = "",
556         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
557         .timeoutMs = 3000,
558         .pid = 0,
559         .uid = 0,
560     };
561     int32_t ret;
562     for (int i = 0; i < 100; i++) {
563         ret = g_powerInterface->HoldRunningLock(info);
564         EXPECT_FALSE(HDF_SUCCESS == ret);
565     }
566 }
567 
568 /**
569  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2800
570  * @tc.name   : testHoldRunningLock024
571  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BACKGROUND_NAVIGATION
572  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock024, Function | MediumTest | Level2)573 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock024, Function | MediumTest | Level2)
574 {
575     struct RunningLockInfo info = {
576         .name = "",
577         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
578         .timeoutMs = 3000,
579         .pid = 0,
580         .uid = 0,
581     };
582     int32_t ret;
583     for (int i = 0; i < 100; i++) {
584         ret = g_powerInterface->HoldRunningLock(info);
585         EXPECT_FALSE(HDF_SUCCESS == ret);
586     }
587 }
588 
589 /**
590  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_2900
591  * @tc.name   : testHoldRunningLock025
592  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BACKGROUND_TASK
593  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock025, Function | MediumTest | Level2)594 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock025, Function | MediumTest | Level2)
595 {
596     struct RunningLockInfo info = {
597         .name = "",
598         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
599         .timeoutMs = 3000,
600         .pid = 0,
601         .uid = 0,
602     };
603     int32_t ret;
604     for (int i = 0; i < 100; i++) {
605         ret = g_powerInterface->HoldRunningLock(info);
606         EXPECT_FALSE(HDF_SUCCESS == ret);
607     }
608 }
609 
610 /**
611  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3000
612  * @tc.name   : testHoldRunningLock026
613  * @tc.desc   : Cycle 100 times,name is null,type = RUNNINGLOCK_BUTT
614  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock026, Function | MediumTest | Level2)615 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock026, Function | MediumTest | Level2)
616 {
617     struct RunningLockInfo info = {
618         .name = "",
619         .type = RunningLockType::RUNNINGLOCK_BUTT,
620         .timeoutMs = 3000,
621         .pid = 0,
622         .uid = 0,
623     };
624     int32_t ret;
625     for (int i = 0; i < 100; i++) {
626         ret = g_powerInterface->HoldRunningLock(info);
627         EXPECT_FALSE(HDF_SUCCESS == ret);
628     }
629 }
630 
631 /**
632  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3100
633  * @tc.name   : testHoldRunningLock027
634  * @tc.desc   : Cycle 100 times,name is null,type = static_cast<RunningLockType>(100)
635  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock027, Function | MediumTest | Level2)636 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock027, Function | MediumTest | Level2)
637 {
638     struct RunningLockInfo info = {
639         .name = "",
640         .type = static_cast<RunningLockType>(100),
641         .timeoutMs = 3000,
642         .pid = 0,
643         .uid = 0,
644     };
645     int32_t ret;
646     for (int i = 0; i < 100; i++) {
647         ret = g_powerInterface->HoldRunningLock(info);
648         EXPECT_FALSE(HDF_SUCCESS == ret);
649     }
650 }
651 
652 /**
653  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3200
654  * @tc.name   : testHoldRunningLock028
655  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_PHONE,timeoutMs = -1
656  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock028, Function | MediumTest | Level2)657 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock028, Function | MediumTest | Level2)
658 {
659     struct RunningLockInfo info = {
660         .name = "",
661         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
662         .timeoutMs = -1,
663         .pid = 0,
664         .uid = 0,
665     };
666 
667     int32_t ret = g_powerInterface->HoldRunningLock(info);
668     EXPECT_FALSE(HDF_SUCCESS == ret);
669 }
670 
671 /**
672  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3300
673  * @tc.name   : testHoldRunningLock029
674  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_AUDIO,timeoutMs = -1
675  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock029, Function | MediumTest | Level2)676 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock029, Function | MediumTest | Level2)
677 {
678     struct RunningLockInfo info = {
679         .name = "",
680         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
681         .timeoutMs = -1,
682         .pid = 0,
683         .uid = 0,
684     };
685 
686     int32_t ret = g_powerInterface->HoldRunningLock(info);
687     EXPECT_FALSE(HDF_SUCCESS == ret);
688 }
689 
690 /**
691  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3400
692  * @tc.name   : testHoldRunningLock030
693  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_SPORT,timeoutMs = -1
694  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock030, Function | MediumTest | Level2)695 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock030, Function | MediumTest | Level2)
696 {
697     struct RunningLockInfo info = {
698         .name = "",
699         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
700         .timeoutMs = -1,
701         .pid = 0,
702         .uid = 0,
703     };
704 
705     int32_t ret = g_powerInterface->HoldRunningLock(info);
706     EXPECT_FALSE(HDF_SUCCESS == ret);
707 }
708 
709 /**
710  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3500
711  * @tc.name   : testHoldRunningLock031
712  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_NAVIGATION,timeoutMs = -1
713  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock031, Function | MediumTest | Level2)714 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock031, Function | MediumTest | Level2)
715 {
716     struct RunningLockInfo info = {
717         .name = "",
718         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
719         .timeoutMs = -1,
720         .pid = 0,
721         .uid = 0,
722     };
723 
724     int32_t ret = g_powerInterface->HoldRunningLock(info);
725     EXPECT_FALSE(HDF_SUCCESS == ret);
726 }
727 
728 /**
729  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3600
730  * @tc.name   : testHoldRunningLock032
731  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_TASK,timeoutMs = -1
732  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock032, Function | MediumTest | Level2)733 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock032, Function | MediumTest | Level2)
734 {
735     struct RunningLockInfo info = {
736         .name = "",
737         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
738         .timeoutMs = -1,
739         .pid = 0,
740         .uid = 0,
741     };
742 
743     int32_t ret = g_powerInterface->HoldRunningLock(info);
744     EXPECT_FALSE(HDF_SUCCESS == ret);
745 }
746 
747 /**
748  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3700
749  * @tc.name   : testHoldRunningLock033
750  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_PHONE,timeoutMs = -1,pid = 1
751  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock033, Function | MediumTest | Level2)752 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock033, Function | MediumTest | Level2)
753 {
754     struct RunningLockInfo info = {
755         .name = "",
756         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
757         .timeoutMs = -1,
758         .pid = 1,
759         .uid = 0,
760     };
761 
762     int32_t ret = g_powerInterface->HoldRunningLock(info);
763     EXPECT_FALSE(HDF_SUCCESS == ret);
764 }
765 
766 /**
767  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3800
768  * @tc.name   : testHoldRunningLock034
769  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_AUDIO,timeoutMs = -1,pid = 1
770  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock034, Function | MediumTest | Level2)771 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock034, Function | MediumTest | Level2)
772 {
773     struct RunningLockInfo info = {
774         .name = "",
775         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
776         .timeoutMs = -1,
777         .pid = 1,
778         .uid = 0,
779     };
780 
781     int32_t ret = g_powerInterface->HoldRunningLock(info);
782     EXPECT_FALSE(HDF_SUCCESS == ret);
783 }
784 
785 /**
786  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_3900
787  * @tc.name   : testHoldRunningLock035
788  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_SPORT,timeoutMs = -1,pid = 1
789  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock035, Function | MediumTest | Level2)790 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock035, Function | MediumTest | Level2)
791 {
792     struct RunningLockInfo info = {
793         .name = "",
794         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
795         .timeoutMs = -1,
796         .pid = 1,
797         .uid = 0,
798     };
799 
800     int32_t ret = g_powerInterface->HoldRunningLock(info);
801     EXPECT_FALSE(HDF_SUCCESS == ret);
802 }
803 
804 /**
805  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4000
806  * @tc.name   : testHoldRunningLock036
807  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_NAVIGATION,timeoutMs = -1,pid = 1
808  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock036, Function | MediumTest | Level2)809 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock036, Function | MediumTest | Level2)
810 {
811     struct RunningLockInfo info = {
812         .name = "",
813         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
814         .timeoutMs = -1,
815         .pid = 1,
816         .uid = 0,
817     };
818 
819     int32_t ret = g_powerInterface->HoldRunningLock(info);
820     EXPECT_FALSE(HDF_SUCCESS == ret);
821 }
822 
823 /**
824  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4100
825  * @tc.name   : testHoldRunningLock037
826  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_TASK,timeoutMs = -1,pid = 1
827  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock037, Function | MediumTest | Level2)828 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock037, Function | MediumTest | Level2)
829 {
830     struct RunningLockInfo info = {
831         .name = "",
832         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
833         .timeoutMs = -1,
834         .pid = 1,
835         .uid = 0,
836     };
837 
838     int32_t ret = g_powerInterface->HoldRunningLock(info);
839     EXPECT_FALSE(HDF_SUCCESS == ret);
840 }
841 
842 /**
843  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4200
844  * @tc.name   : testHoldRunningLock038
845  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_PHONE,timeoutMs = -1,pid = 1,.uid = 1
846  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock038, Function | MediumTest | Level2)847 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock038, Function | MediumTest | Level2)
848 {
849     struct RunningLockInfo info = {
850         .name = "",
851         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
852         .timeoutMs = -1,
853         .pid = 1,
854         .uid = 1,
855     };
856 
857     int32_t ret = g_powerInterface->HoldRunningLock(info);
858     EXPECT_FALSE(HDF_SUCCESS == ret);
859 }
860 
861 /**
862  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4300
863  * @tc.name   : testHoldRunningLock039
864  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_AUDIO,timeoutMs = -1,pid = 1,.uid = 1
865  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock039, Function | MediumTest | Level2)866 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock039, Function | MediumTest | Level2)
867 {
868     struct RunningLockInfo info = {
869         .name = "",
870         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
871         .timeoutMs = 1,
872         .pid = 1,
873         .uid = 1,
874     };
875 
876     int32_t ret = g_powerInterface->HoldRunningLock(info);
877     EXPECT_FALSE(HDF_SUCCESS == ret);
878 }
879 
880 /**
881  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4400
882  * @tc.name   : testHoldRunningLock040
883  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_SPORT,timeoutMs = -1,pid = 1,.uid = 1
884  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock040, Function | MediumTest | Level2)885 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock040, Function | MediumTest | Level2)
886 {
887     struct RunningLockInfo info = {
888         .name = "",
889         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
890         .timeoutMs = 1,
891         .pid = 1,
892         .uid = 1,
893     };
894 
895     int32_t ret = g_powerInterface->HoldRunningLock(info);
896     EXPECT_FALSE(HDF_SUCCESS == ret);
897 }
898 
899 /**
900  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4500
901  * @tc.name   : testHoldRunningLock041
902  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_NAVIGATION,timeoutMs = -1,pid = 1,.uid = 1
903  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock041, Function | MediumTest | Level2)904 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock041, Function | MediumTest | Level2)
905 {
906     struct RunningLockInfo info = {
907         .name = "",
908         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
909         .timeoutMs = 1,
910         .pid = 1,
911         .uid = 1,
912     };
913 
914     int32_t ret = g_powerInterface->HoldRunningLock(info);
915     EXPECT_FALSE(HDF_SUCCESS == ret);
916 }
917 
918 /**
919  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4600
920  * @tc.name   : testHoldRunningLock042
921  * @tc.desc   : name is null,type = RUNNINGLOCK_BACKGROUND_TASK,timeoutMs = -1,pid = 1,.uid = 1
922  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock042, Function | MediumTest | Level2)923 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock042, Function | MediumTest | Level2)
924 {
925     struct RunningLockInfo info = {
926         .name = "",
927         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
928         .timeoutMs = 1,
929         .pid = 1,
930         .uid = 1,
931     };
932 
933     int32_t ret = g_powerInterface->HoldRunningLock(info);
934     EXPECT_FALSE(HDF_SUCCESS == ret);
935 }
936 
937 /**
938  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4700
939  * @tc.name   : testHoldRunningLock043
940  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_PHONE
941  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock043, Function | MediumTest | Level1)942 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock043, Function | MediumTest | Level1)
943 {
944     struct RunningLockInfo info = {
945         .name = "//,,",
946         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
947         .timeoutMs = 3000,
948         .pid = 0,
949         .uid = 0,
950     };
951     int32_t ret = g_powerInterface->HoldRunningLock(info);
952     EXPECT_TRUE(HDF_SUCCESS == ret);
953     ret = g_powerInterface->UnholdRunningLock(info);
954     EXPECT_TRUE(HDF_SUCCESS == ret);
955 }
956 
957 /**
958  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4800
959  * @tc.name   : testHoldRunningLock044
960  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_NOTIFICATION
961  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock044, Function | MediumTest | Level1)962 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock044, Function | MediumTest | Level1)
963 {
964     struct RunningLockInfo info = {
965         .name = "//,,",
966         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
967         .timeoutMs = 3000,
968         .pid = 0,
969         .uid = 0,
970     };
971     int32_t ret = g_powerInterface->HoldRunningLock(info);
972     EXPECT_TRUE(HDF_SUCCESS == ret);
973     ret = g_powerInterface->UnholdRunningLock(info);
974     EXPECT_TRUE(HDF_SUCCESS == ret);
975 }
976 
977 /**
978  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_4900
979  * @tc.name   : testHoldRunningLock045
980  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_AUDIO
981  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock045, Function | MediumTest | Level1)982 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock045, Function | MediumTest | Level1)
983 {
984     struct RunningLockInfo info = {
985         .name = "//,,",
986         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
987         .timeoutMs = 3000,
988         .pid = 0,
989         .uid = 0,
990     };
991     int32_t ret = g_powerInterface->HoldRunningLock(info);
992     EXPECT_TRUE(HDF_SUCCESS == ret);
993     ret = g_powerInterface->UnholdRunningLock(info);
994     EXPECT_TRUE(HDF_SUCCESS == ret);
995 }
996 
997 /**
998  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5000
999  * @tc.name   : testHoldRunningLock046
1000  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_SPORT
1001  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock046, Function | MediumTest | Level1)1002 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock046, Function | MediumTest | Level1)
1003 {
1004     struct RunningLockInfo info = {
1005         .name = "//,,",
1006         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
1007         .timeoutMs = 3000,
1008         .pid = 0,
1009         .uid = 0,
1010     };
1011     int32_t ret = g_powerInterface->HoldRunningLock(info);
1012     EXPECT_TRUE(HDF_SUCCESS == ret);
1013     ret = g_powerInterface->UnholdRunningLock(info);
1014     EXPECT_TRUE(HDF_SUCCESS == ret);
1015 }
1016 
1017 /**
1018  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5100
1019  * @tc.name   : testHoldRunningLock047
1020  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_NAVIGATION
1021  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock047, Function | MediumTest | Level1)1022 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock047, Function | MediumTest | Level1)
1023 {
1024     struct RunningLockInfo info = {
1025         .name = "//,,",
1026         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
1027         .timeoutMs = 3000,
1028         .pid = 0,
1029         .uid = 0,
1030     };
1031     int32_t ret = g_powerInterface->HoldRunningLock(info);
1032     EXPECT_TRUE(HDF_SUCCESS == ret);
1033     ret = g_powerInterface->UnholdRunningLock(info);
1034     EXPECT_TRUE(HDF_SUCCESS == ret);
1035 }
1036 
1037 /**
1038  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5200
1039  * @tc.name   : testHoldRunningLock048
1040  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_TASK
1041  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock048, Function | MediumTest | Level1)1042 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock048, Function | MediumTest | Level1)
1043 {
1044     struct RunningLockInfo info = {
1045         .name = "//,,",
1046         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
1047         .timeoutMs = 3000,
1048         .pid = 0,
1049         .uid = 0,
1050     };
1051     int32_t ret = g_powerInterface->HoldRunningLock(info);
1052     EXPECT_TRUE(HDF_SUCCESS == ret);
1053     ret = g_powerInterface->UnholdRunningLock(info);
1054     EXPECT_TRUE(HDF_SUCCESS == ret);
1055 }
1056 
1057 /**
1058  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5300
1059  * @tc.name   : testHoldRunningLock049
1060  * @tc.desc   : name = "//,,",type = static_cast<RunningLockType>(100)
1061  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock049, Function | MediumTest | Level2)1062 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock049, Function | MediumTest | Level2)
1063 {
1064     struct RunningLockInfo info = {
1065         .name = "//,,",
1066         .type = static_cast<RunningLockType>(100),
1067         .timeoutMs = 3000,
1068         .pid = 0,
1069         .uid = 0,
1070     };
1071     int32_t ret = g_powerInterface->HoldRunningLock(info);
1072     EXPECT_FALSE(HDF_SUCCESS == ret);
1073 }
1074 
1075 /**
1076  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5400
1077  * @tc.name   : testHoldRunningLock050
1078  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_PHONE,Cycle 100 times
1079  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock050, Function | MediumTest | Level1)1080 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock050, Function | MediumTest | Level1)
1081 {
1082     struct RunningLockInfo info = {
1083         .name = "//,,",
1084         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
1085         .timeoutMs = 3000,
1086         .pid = 0,
1087         .uid = 0,
1088     };
1089     int32_t ret;
1090     for (int i = 0; i < 100; i++) {
1091         ret = g_powerInterface->HoldRunningLock(info);
1092         EXPECT_TRUE(HDF_SUCCESS == ret);
1093         ret = g_powerInterface->UnholdRunningLock(info);
1094         EXPECT_TRUE(HDF_SUCCESS == ret);
1095     }
1096 }
1097 
1098 /**
1099  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5500
1100  * @tc.name   : testHoldRunningLock051
1101  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_NOTIFICATION,Cycle 100 times
1102  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock051, Function | MediumTest | Level1)1103 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock051, Function | MediumTest | Level1)
1104 {
1105     struct RunningLockInfo info = {
1106         .name = "//,,",
1107         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
1108         .timeoutMs = 3000,
1109         .pid = 0,
1110         .uid = 0,
1111     };
1112     int32_t ret;
1113     for (int i = 0; i < 100; i++) {
1114         ret = g_powerInterface->HoldRunningLock(info);
1115         EXPECT_TRUE(HDF_SUCCESS == ret);
1116         ret = g_powerInterface->UnholdRunningLock(info);
1117         EXPECT_TRUE(HDF_SUCCESS == ret);
1118     }
1119 }
1120 
1121 /**
1122  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5600
1123  * @tc.name   : testHoldRunningLock052
1124  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_AUDIO,Cycle 100 times
1125  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock052, Function | MediumTest | Level1)1126 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock052, Function | MediumTest | Level1)
1127 {
1128     struct RunningLockInfo info = {
1129         .name = "//,,",
1130         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
1131         .timeoutMs = 3000,
1132         .pid = 0,
1133         .uid = 0,
1134     };
1135     int32_t ret;
1136     for (int i = 0; i < 100; i++) {
1137         ret = g_powerInterface->HoldRunningLock(info);
1138         EXPECT_TRUE(HDF_SUCCESS == ret);
1139         ret = g_powerInterface->UnholdRunningLock(info);
1140         EXPECT_TRUE(HDF_SUCCESS == ret);
1141     }
1142 }
1143 
1144 /**
1145  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5700
1146  * @tc.name   : testHoldRunningLock053
1147  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_SPORT,Cycle 100 times
1148  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock053, Function | MediumTest | Level1)1149 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock053, Function | MediumTest | Level1)
1150 {
1151     struct RunningLockInfo info = {
1152         .name = "//,,",
1153         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
1154         .timeoutMs = 3000,
1155         .pid = 0,
1156         .uid = 0,
1157     };
1158     int32_t ret;
1159     for (int i = 0; i < 100; i++) {
1160         ret = g_powerInterface->HoldRunningLock(info);
1161         EXPECT_TRUE(HDF_SUCCESS == ret);
1162         ret = g_powerInterface->UnholdRunningLock(info);
1163         EXPECT_TRUE(HDF_SUCCESS == ret);
1164     }
1165 }
1166 
1167 /**
1168  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5800
1169  * @tc.name   : testHoldRunningLock054
1170  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_NAVIGATION,Cycle 100 times
1171  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock054, Function | MediumTest | Level1)1172 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock054, Function | MediumTest | Level1)
1173 {
1174     struct RunningLockInfo info = {
1175         .name = "//,,",
1176         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
1177         .timeoutMs = 3000,
1178         .pid = 0,
1179         .uid = 0,
1180     };
1181     int32_t ret;
1182     for (int i = 0; i < 100; i++) {
1183         ret = g_powerInterface->HoldRunningLock(info);
1184         EXPECT_TRUE(HDF_SUCCESS == ret);
1185         ret = g_powerInterface->UnholdRunningLock(info);
1186         EXPECT_TRUE(HDF_SUCCESS == ret);
1187     }
1188 }
1189 
1190 /**
1191  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_5900
1192  * @tc.name   : testHoldRunningLock055
1193  * @tc.desc   : name = "//,,",type = RUNNINGLOCK_BACKGROUND_TASK,Cycle 100 times
1194  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock055, Function | MediumTest | Level1)1195 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock055, Function | MediumTest | Level1)
1196 {
1197     struct RunningLockInfo info = {
1198         .name = "//,,",
1199         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
1200         .timeoutMs = 3000,
1201         .pid = 0,
1202         .uid = 0,
1203     };
1204     int32_t ret;
1205     for (int i = 0; i < 100; i++) {
1206         ret = g_powerInterface->HoldRunningLock(info);
1207         EXPECT_TRUE(HDF_SUCCESS == ret);
1208         ret = g_powerInterface->UnholdRunningLock(info);
1209         EXPECT_TRUE(HDF_SUCCESS == ret);
1210     }
1211 }
1212 
1213 /**
1214  * @tc.number : SUB_Powermgr_Power_HDI_HoldRunningLock_6000
1215  * @tc.name   : testHoldRunningLock056
1216  * @tc.desc   : name = "//,,",type = static_cast<RunningLockType>(100),Cycle 100 times
1217  */
HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock056, Function | MediumTest | Level2)1218 HWTEST_F(HdfPowerHdiTestAdditional, testHoldRunningLock056, Function | MediumTest | Level2)
1219 {
1220     struct RunningLockInfo info = {
1221         .name = "//,,",
1222         .type = static_cast<RunningLockType>(100),
1223         .timeoutMs = 3000,
1224         .pid = 0,
1225         .uid = 0,
1226     };
1227     int32_t ret;
1228     for (int i = 0; i < 100; i++) {
1229         ret = g_powerInterface->HoldRunningLock(info);
1230         EXPECT_FALSE(HDF_SUCCESS == ret);
1231     }
1232 }
1233 
1234 /**
1235  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0300
1236  * @tc.name   : testSuspendUnblock001
1237  * @tc.desc   : check SuspendUnblock,testName = "testSuspendUnblock001"
1238  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock001, Function | MediumTest | Level1)1239 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock001, Function | MediumTest | Level1)
1240 {
1241     std::string testName = "testSuspendUnblock001";
1242     g_powerInterface->SuspendBlock(testName);
1243     sleep(WAIT_TIME);
1244     int32_t ret = g_powerInterface->SuspendUnblock(testName);
1245     EXPECT_EQ(0, ret);
1246 
1247     char unLockBuf[MAX_PATH] = {0};
1248     std::string unLockBufS;
1249     std::string unLockValue;
1250 
1251     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1252     unLockBufS = unLockBuf;
1253     sleep(WAIT_TIME);
1254     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1255     EXPECT_EQ(0, ret);
1256     EXPECT_FALSE(unLockValue.empty());
1257     auto pos = unLockValue.find(testName);
1258     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock001 failed unLock: " << unLockValue;
1259 }
1260 
1261 /**
1262  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0400
1263  * @tc.name   : testSuspendUnblock002
1264  * @tc.desc   : check SuspendUnblock,testName = "0"
1265  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock002, Function | MediumTest | Level1)1266 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock002, Function | MediumTest | Level1)
1267 {
1268     std::string testName = "0";
1269     g_powerInterface->SuspendBlock(testName);
1270     sleep(WAIT_TIME);
1271     int32_t ret = g_powerInterface->SuspendUnblock(testName);
1272     EXPECT_EQ(0, ret);
1273 
1274     char unLockBuf[MAX_PATH] = {0};
1275     std::string unLockBufS;
1276     std::string unLockValue;
1277 
1278     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1279     unLockBufS = unLockBuf;
1280     sleep(WAIT_TIME);
1281     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1282     EXPECT_EQ(0, ret);
1283     EXPECT_FALSE(unLockValue.empty());
1284     auto pos = unLockValue.find(testName);
1285     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock002 failed unLock: " << unLockValue;
1286 }
1287 
1288 /**
1289  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0500
1290  * @tc.name   : testSuspendUnblock003
1291  * @tc.desc   : check SuspendUnblock,testName = "QWER"
1292  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock003, Function | MediumTest | Level1)1293 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock003, Function | MediumTest | Level1)
1294 {
1295     std::string testName = "QWER";
1296     g_powerInterface->SuspendBlock(testName);
1297     sleep(WAIT_TIME);
1298     int32_t ret = g_powerInterface->SuspendUnblock(testName);
1299     EXPECT_EQ(0, ret);
1300 
1301     char unLockBuf[MAX_PATH] = {0};
1302     std::string unLockBufS;
1303     std::string unLockValue;
1304 
1305     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1306     unLockBufS = unLockBuf;
1307     sleep(WAIT_TIME);
1308     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1309     EXPECT_EQ(0, ret);
1310     EXPECT_FALSE(unLockValue.empty());
1311     auto pos = unLockValue.find(testName);
1312     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock003 failed unLock: " << unLockValue;
1313 }
1314 
1315 /**
1316  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0600
1317  * @tc.name   : testSuspendUnblock004
1318  * @tc.desc   : check SuspendUnblock,testName = ""
1319  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock004, Function | MediumTest | Level1)1320 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock004, Function | MediumTest | Level1)
1321 {
1322     std::string testName = "";
1323     g_powerInterface->SuspendBlock(testName);
1324     sleep(WAIT_TIME);
1325     int32_t ret = g_powerInterface->SuspendUnblock(testName);
1326     EXPECT_NE(0, ret);
1327 
1328     char unLockBuf[MAX_PATH] = {0};
1329     std::string unLockBufS;
1330     std::string unLockValue;
1331 
1332     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1333     unLockBufS = unLockBuf;
1334     sleep(WAIT_TIME);
1335     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1336     EXPECT_EQ(0, ret);
1337     EXPECT_FALSE(unLockValue.empty());
1338     auto pos = unLockValue.find(testName);
1339     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock004 failed unLock: " << unLockValue;
1340 }
1341 
1342 /**
1343  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0700
1344  * @tc.name   : testSuspendUnblock005
1345  * @tc.desc   : check SuspendUnblock,testName = "//,,"
1346  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock005, Function | MediumTest | Level1)1347 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock005, Function | MediumTest | Level1)
1348 {
1349     std::string testName = "//,,";
1350     g_powerInterface->SuspendBlock(testName);
1351     sleep(WAIT_TIME);
1352     int32_t ret = g_powerInterface->SuspendUnblock(testName);
1353     EXPECT_EQ(0, ret);
1354 
1355     char unLockBuf[MAX_PATH] = {0};
1356     std::string unLockBufS;
1357     std::string unLockValue;
1358 
1359     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1360     unLockBufS = unLockBuf;
1361     sleep(WAIT_TIME);
1362     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1363     EXPECT_EQ(0, ret);
1364     EXPECT_FALSE(unLockValue.empty());
1365     auto pos = unLockValue.find(testName);
1366     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock005 failed unLock: " << unLockValue;
1367 }
1368 
1369 /**
1370  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0800
1371  * @tc.name   : testSuspendUnblock006
1372  * @tc.desc   : check SuspendUnblock,testName = "a@%"
1373  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock006, Function | MediumTest | Level1)1374 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock006, Function | MediumTest | Level1)
1375 {
1376     std::string testName = "a@%";
1377     g_powerInterface->SuspendBlock(testName);
1378     sleep(WAIT_TIME);
1379     int32_t ret = g_powerInterface->SuspendUnblock(testName);
1380     EXPECT_EQ(0, ret);
1381 
1382     char unLockBuf[MAX_PATH] = {0};
1383     std::string unLockBufS;
1384     std::string unLockValue;
1385 
1386     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1387     unLockBufS = unLockBuf;
1388     sleep(WAIT_TIME);
1389     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1390     EXPECT_EQ(0, ret);
1391     EXPECT_FALSE(unLockValue.empty());
1392     auto pos = unLockValue.find(testName);
1393     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock006 failed unLock: " << unLockValue;
1394 }
1395 
1396 /**
1397  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_0900
1398  * @tc.name   : testSuspendUnblock007
1399  * @tc.desc   : check SuspendUnblock,testName = "testSuspendUnblock001",cycle 100 times
1400  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock007, Function | MediumTest | Level1)1401 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock007, Function | MediumTest | Level1)
1402 {
1403     std::string testName = "testSuspendUnblock001";
1404     int32_t ret;
1405     for (int i = 0; i < 5; i++) {
1406         g_powerInterface->SuspendBlock(testName);
1407         sleep(WAIT_TIME);
1408         ret = g_powerInterface->SuspendUnblock(testName);
1409         EXPECT_EQ(0, ret);
1410     }
1411 
1412     char unLockBuf[MAX_PATH] = {0};
1413     std::string unLockBufS;
1414     std::string unLockValue;
1415 
1416     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1417     unLockBufS = unLockBuf;
1418     sleep(WAIT_TIME);
1419     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1420     EXPECT_EQ(0, ret);
1421     EXPECT_FALSE(unLockValue.empty());
1422     auto pos = unLockValue.find(testName);
1423     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock007 failed unLock: " << unLockValue;
1424 }
1425 
1426 /**
1427  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_1000
1428  * @tc.name   : testSuspendUnblock008
1429  * @tc.desc   : check SuspendUnblock,testName = "0",cycle 100 times
1430  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock008, Function | MediumTest | Level1)1431 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock008, Function | MediumTest | Level1)
1432 {
1433     std::string testName = "0";
1434     int32_t ret;
1435     for (int i = 0; i < 5; i++) {
1436         g_powerInterface->SuspendBlock(testName);
1437         sleep(WAIT_TIME);
1438         ret = g_powerInterface->SuspendUnblock(testName);
1439         EXPECT_EQ(0, ret);
1440     }
1441 
1442     char unLockBuf[MAX_PATH] = {0};
1443     std::string unLockBufS;
1444     std::string unLockValue;
1445 
1446     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1447     unLockBufS = unLockBuf;
1448     sleep(WAIT_TIME);
1449     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1450     EXPECT_EQ(0, ret);
1451     EXPECT_FALSE(unLockValue.empty());
1452     auto pos = unLockValue.find(testName);
1453     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock008 failed unLock: " << unLockValue;
1454 }
1455 
1456 /**
1457  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_1100
1458  * @tc.name   : testSuspendUnblock009
1459  * @tc.desc   : check SuspendUnblock,testName = "QWER",cycle 100 times
1460  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock009, Function | MediumTest | Level1)1461 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock009, Function | MediumTest | Level1)
1462 {
1463     std::string testName = "QWER";
1464     int32_t ret;
1465     for (int i = 0; i < 5; i++) {
1466         g_powerInterface->SuspendBlock(testName);
1467         sleep(WAIT_TIME);
1468         ret = g_powerInterface->SuspendUnblock(testName);
1469         EXPECT_EQ(0, ret);
1470     }
1471 
1472     char unLockBuf[MAX_PATH] = {0};
1473     std::string unLockBufS;
1474     std::string unLockValue;
1475 
1476     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1477     unLockBufS = unLockBuf;
1478     sleep(WAIT_TIME);
1479     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1480     EXPECT_EQ(0, ret);
1481     EXPECT_FALSE(unLockValue.empty());
1482     auto pos = unLockValue.find(testName);
1483     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock009 failed unLock: " << unLockValue;
1484 }
1485 
1486 /**
1487  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_1200
1488  * @tc.name   : testSuspendUnblock010
1489  * @tc.desc   : check SuspendUnblock,testName = "",cycle 100 times
1490  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock010, Function | MediumTest | Level1)1491 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock010, Function | MediumTest | Level1)
1492 {
1493     std::string testName = "";
1494     int32_t ret;
1495     for (int i = 0; i < 5; i++) {
1496         g_powerInterface->SuspendBlock(testName);
1497         sleep(WAIT_TIME);
1498         ret = g_powerInterface->SuspendUnblock(testName);
1499         EXPECT_NE(0, ret);
1500     }
1501 
1502     char unLockBuf[MAX_PATH] = {0};
1503     std::string unLockBufS;
1504     std::string unLockValue;
1505 
1506     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1507     unLockBufS = unLockBuf;
1508     sleep(WAIT_TIME);
1509     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1510     EXPECT_EQ(0, ret);
1511     EXPECT_FALSE(unLockValue.empty());
1512     auto pos = unLockValue.find(testName);
1513     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock010 failed unLock: " << unLockValue;
1514 }
1515 /**
1516  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_1300
1517  * @tc.name   : testSuspendUnblock011
1518  * @tc.desc   : check SuspendUnblock,testName = "//,,",cycle 100 times
1519  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock011, Function | MediumTest | Level1)1520 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock011, Function | MediumTest | Level1)
1521 {
1522     std::string testName = "//,,";
1523     int32_t ret;
1524     for (int i = 0; i < 5; i++) {
1525         g_powerInterface->SuspendBlock(testName);
1526         sleep(WAIT_TIME);
1527         ret = g_powerInterface->SuspendUnblock(testName);
1528         EXPECT_EQ(0, ret);
1529     }
1530 
1531     char unLockBuf[MAX_PATH] = {0};
1532     std::string unLockBufS;
1533     std::string unLockValue;
1534 
1535     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1536     unLockBufS = unLockBuf;
1537     sleep(WAIT_TIME);
1538     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1539     EXPECT_EQ(0, ret);
1540     EXPECT_FALSE(unLockValue.empty());
1541     auto pos = unLockValue.find(testName);
1542     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock011 failed unLock: " << unLockValue;
1543 }
1544 
1545 /**
1546  * @tc.number : SUB_Powermgr_Power_HDI_SuspendUnblock_1400
1547  * @tc.name   : testSuspendUnblock012
1548  * @tc.desc   : check SuspendUnblock,testName = "a@%",cycle 100 times
1549  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock012, Function | MediumTest | Level1)1550 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendUnblock012, Function | MediumTest | Level1)
1551 {
1552     std::string testName = "a@%";
1553     int32_t ret;
1554     for (int i = 0; i < 5; i++) {
1555         g_powerInterface->SuspendBlock(testName);
1556         sleep(WAIT_TIME);
1557         ret = g_powerInterface->SuspendUnblock(testName);
1558         EXPECT_EQ(0, ret);
1559     }
1560 
1561     char unLockBuf[MAX_PATH] = {0};
1562     std::string unLockBufS;
1563     std::string unLockValue;
1564 
1565     ret = snprintf_s(unLockBuf, MAX_PATH, sizeof(unLockBuf) - 1, UNLOCK_PATH.c_str());
1566     unLockBufS = unLockBuf;
1567     sleep(WAIT_TIME);
1568     ret = HdfPowerHdiTestAdditional::ReadFile(unLockBufS, unLockValue, MAX_FILE);
1569     EXPECT_EQ(0, ret);
1570     EXPECT_FALSE(unLockValue.empty());
1571     auto pos = unLockValue.find(testName);
1572     EXPECT_TRUE(pos != std::string::npos) << "testSuspendUnblock012 failed unLock: " << unLockValue;
1573 }
1574 
1575 /**
1576  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0300
1577  * @tc.name   : testSuspendBlock001
1578  * @tc.desc   : check SuspendBlock,testName = "testSuspendBlock001"
1579  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock001, Function | MediumTest | Level1)1580 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock001, Function | MediumTest | Level1)
1581 {
1582     std::string testName = "testSuspendBlock001";
1583     g_powerInterface->SuspendUnblock(testName);
1584     sleep(WAIT_TIME);
1585     int32_t ret = g_powerInterface->SuspendBlock(testName);
1586     EXPECT_EQ(0, ret);
1587 
1588     char lockBuf[MAX_PATH] = {0};
1589     std::string lockBufS;
1590     std::string lockValue;
1591 
1592     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1593     lockBufS = lockBuf;
1594     sleep(WAIT_TIME);
1595     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1596     EXPECT_EQ(0, ret);
1597     EXPECT_FALSE(lockValue.empty());
1598     auto pos = lockValue.find(testName);
1599     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock001 failed lock: " << lockValue;
1600 }
1601 
1602 /**
1603  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0400
1604  * @tc.name   : testSuspendBlock002
1605  * @tc.desc   : check SuspendBlock,testName = "0"
1606  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock002, Function | MediumTest | Level1)1607 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock002, Function | MediumTest | Level1)
1608 {
1609     std::string testName = "0";
1610     g_powerInterface->SuspendUnblock(testName);
1611     sleep(WAIT_TIME);
1612     int32_t ret = g_powerInterface->SuspendBlock(testName);
1613     EXPECT_EQ(0, ret);
1614 
1615     char lockBuf[MAX_PATH] = {0};
1616     std::string lockBufS;
1617     std::string lockValue;
1618 
1619     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1620     lockBufS = lockBuf;
1621     sleep(WAIT_TIME);
1622     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1623     EXPECT_EQ(0, ret);
1624     EXPECT_FALSE(lockValue.empty());
1625     auto pos = lockValue.find(testName);
1626     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock002 failed lock: " << lockValue;
1627 }
1628 
1629 /**
1630  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0500
1631  * @tc.name   : testSuspendBlock003
1632  * @tc.desc   : check SuspendBlock,testName = "QWER"
1633  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock003, Function | MediumTest | Level1)1634 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock003, Function | MediumTest | Level1)
1635 {
1636     std::string testName = "QWER";
1637     g_powerInterface->SuspendUnblock(testName);
1638     sleep(WAIT_TIME);
1639     int32_t ret = g_powerInterface->SuspendBlock(testName);
1640     EXPECT_EQ(0, ret);
1641 
1642     char lockBuf[MAX_PATH] = {0};
1643     std::string lockBufS;
1644     std::string lockValue;
1645 
1646     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1647     lockBufS = lockBuf;
1648     sleep(WAIT_TIME);
1649     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1650     EXPECT_EQ(0, ret);
1651     EXPECT_FALSE(lockValue.empty());
1652     auto pos = lockValue.find(testName);
1653     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock003 failed lock: " << lockValue;
1654 }
1655 
1656 /**
1657  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0600
1658  * @tc.name   : testSuspendBlock004
1659  * @tc.desc   : check SuspendBlock,testName = ""
1660  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock004, Function | MediumTest | Level1)1661 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock004, Function | MediumTest | Level1)
1662 {
1663     std::string testName = "";
1664     g_powerInterface->SuspendUnblock(testName);
1665     sleep(WAIT_TIME);
1666     int32_t ret = g_powerInterface->SuspendBlock(testName);
1667     EXPECT_NE(0, ret);
1668 
1669     char lockBuf[MAX_PATH] = {0};
1670     std::string lockBufS;
1671     std::string lockValue;
1672 
1673     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1674     lockBufS = lockBuf;
1675     sleep(WAIT_TIME);
1676     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1677     EXPECT_EQ(0, ret);
1678     EXPECT_FALSE(lockValue.empty());
1679     auto pos = lockValue.find(testName);
1680     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock004 failed lock: " << lockValue;
1681 }
1682 
1683 /**
1684  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0700
1685  * @tc.name   : testSuspendBlock005
1686  * @tc.desc   : check SuspendBlock,testName = "//,,"
1687  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock005, Function | MediumTest | Level1)1688 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock005, Function | MediumTest | Level1)
1689 {
1690     std::string testName = "//,,";
1691     g_powerInterface->SuspendUnblock(testName);
1692     sleep(WAIT_TIME);
1693     int32_t ret = g_powerInterface->SuspendBlock(testName);
1694     EXPECT_EQ(0, ret);
1695 
1696     char lockBuf[MAX_PATH] = {0};
1697     std::string lockBufS;
1698     std::string lockValue;
1699 
1700     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1701     lockBufS = lockBuf;
1702     sleep(WAIT_TIME);
1703     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1704     EXPECT_EQ(0, ret);
1705     EXPECT_FALSE(lockValue.empty());
1706     auto pos = lockValue.find(testName);
1707     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock005 failed lock: " << lockValue;
1708 }
1709 
1710 /**
1711  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0800
1712  * @tc.name   : testSuspendBlock006
1713  * @tc.desc   : check SuspendBlock,testName = "a@%"
1714  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock006, Function | MediumTest | Level1)1715 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock006, Function | MediumTest | Level1)
1716 {
1717     std::string testName = "a@%";
1718     g_powerInterface->SuspendUnblock(testName);
1719     sleep(WAIT_TIME);
1720     int32_t ret = g_powerInterface->SuspendBlock(testName);
1721     EXPECT_EQ(0, ret);
1722 
1723     char lockBuf[MAX_PATH] = {0};
1724     std::string lockBufS;
1725     std::string lockValue;
1726 
1727     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1728     lockBufS = lockBuf;
1729     sleep(WAIT_TIME);
1730     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1731     EXPECT_EQ(0, ret);
1732     EXPECT_FALSE(lockValue.empty());
1733     auto pos = lockValue.find(testName);
1734     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock006 failed lock: " << lockValue;
1735 }
1736 
1737 /**
1738  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_0900
1739  * @tc.name   : testSuspendBlock007
1740  * @tc.desc   : check SuspendBlock,testName = "testSuspendBlock001",cycle 5 times
1741  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock007, Function | MediumTest | Level1)1742 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock007, Function | MediumTest | Level1)
1743 {
1744     std::string testName = "testSuspendBlock001";
1745     int32_t ret;
1746     for (int i = 0; i < 5; i++) {
1747         g_powerInterface->SuspendUnblock(testName);
1748         sleep(WAIT_TIME);
1749         ret = g_powerInterface->SuspendBlock(testName);
1750         EXPECT_EQ(0, ret);
1751     }
1752 
1753     char lockBuf[MAX_PATH] = {0};
1754     std::string lockBufS;
1755     std::string lockValue;
1756 
1757     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1758     lockBufS = lockBuf;
1759     sleep(WAIT_TIME);
1760     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1761     EXPECT_EQ(0, ret);
1762     EXPECT_FALSE(lockValue.empty());
1763     auto pos = lockValue.find(testName);
1764     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock007 failed lock: " << lockValue;
1765 }
1766 
1767 /**
1768  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_1000
1769  * @tc.name   : testSuspendBlock008
1770  * @tc.desc   : check SuspendBlock,testName = "0",cycle 5 times
1771  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock008, Function | MediumTest | Level1)1772 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock008, Function | MediumTest | Level1)
1773 {
1774     std::string testName = "0";
1775     int32_t ret;
1776     for (int i = 0; i < 5; i++) {
1777         g_powerInterface->SuspendUnblock(testName);
1778         sleep(WAIT_TIME);
1779         ret = g_powerInterface->SuspendBlock(testName);
1780         EXPECT_EQ(0, ret);
1781     }
1782 
1783     char lockBuf[MAX_PATH] = {0};
1784     std::string lockBufS;
1785     std::string lockValue;
1786 
1787     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1788     lockBufS = lockBuf;
1789     sleep(WAIT_TIME);
1790     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1791     EXPECT_EQ(0, ret);
1792     EXPECT_FALSE(lockValue.empty());
1793     auto pos = lockValue.find(testName);
1794     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock008 failed lock: " << lockValue;
1795 }
1796 
1797 /**
1798  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_1100
1799  * @tc.name   : testSuspendBlock009
1800  * @tc.desc   : check SuspendBlock,testName = "QWER",cycle 5 times
1801  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock009, Function | MediumTest | Level1)1802 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock009, Function | MediumTest | Level1)
1803 {
1804     std::string testName = "QWER";
1805     int32_t ret;
1806     for (int i = 0; i < 5; i++) {
1807         g_powerInterface->SuspendUnblock(testName);
1808         sleep(WAIT_TIME);
1809         ret = g_powerInterface->SuspendBlock(testName);
1810         EXPECT_EQ(0, ret);
1811     }
1812 
1813     char lockBuf[MAX_PATH] = {0};
1814     std::string lockBufS;
1815     std::string lockValue;
1816 
1817     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1818     lockBufS = lockBuf;
1819     sleep(WAIT_TIME);
1820     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1821     EXPECT_EQ(0, ret);
1822     EXPECT_FALSE(lockValue.empty());
1823     auto pos = lockValue.find(testName);
1824     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock009 failed lock: " << lockValue;
1825 }
1826 
1827 /**
1828  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_1200
1829  * @tc.name   : testSuspendBlock010
1830  * @tc.desc   : check SuspendBlock,testName = "",cycle 5 times
1831  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock010, Function | MediumTest | Level1)1832 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock010, Function | MediumTest | Level1)
1833 {
1834     std::string testName = "";
1835     int32_t ret;
1836     for (int i = 0; i < 5; i++) {
1837         g_powerInterface->SuspendUnblock(testName);
1838         sleep(WAIT_TIME);
1839         ret = g_powerInterface->SuspendBlock(testName);
1840         EXPECT_NE(0, ret);
1841     }
1842 
1843     char lockBuf[MAX_PATH] = {0};
1844     std::string lockBufS;
1845     std::string lockValue;
1846 
1847     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1848     lockBufS = lockBuf;
1849     sleep(WAIT_TIME);
1850     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1851     EXPECT_EQ(0, ret);
1852     EXPECT_FALSE(lockValue.empty());
1853     auto pos = lockValue.find(testName);
1854     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock010 failed lock: " << lockValue;
1855 }
1856 
1857 /**
1858  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_1300
1859  * @tc.name   : testSuspendBlock011
1860  * @tc.desc   : check SuspendBlock,testName = "//,,",cycle 5 times
1861  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock011, Function | MediumTest | Level1)1862 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock011, Function | MediumTest | Level1)
1863 {
1864     std::string testName = "//,,";
1865     int32_t ret;
1866     for (int i = 0; i < 5; i++) {
1867         g_powerInterface->SuspendUnblock(testName);
1868         sleep(WAIT_TIME);
1869         ret = g_powerInterface->SuspendBlock(testName);
1870         EXPECT_EQ(0, ret);
1871     }
1872 
1873     char lockBuf[MAX_PATH] = {0};
1874     std::string lockBufS;
1875     std::string lockValue;
1876 
1877     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1878     lockBufS = lockBuf;
1879     sleep(WAIT_TIME);
1880     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1881     EXPECT_EQ(0, ret);
1882     EXPECT_FALSE(lockValue.empty());
1883     auto pos = lockValue.find(testName);
1884     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock011 failed lock: " << lockValue;
1885 }
1886 
1887 /**
1888  * @tc.number : SUB_Powermgr_Power_HDI_SuspendBlock_1400
1889  * @tc.name   : testSuspendBlock012
1890  * @tc.desc   : check SuspendBlock,testName = "a@%",cycle 5 times
1891  */
HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock012, Function | MediumTest | Level1)1892 HWTEST_F(HdfPowerHdiTestAdditional, testSuspendBlock012, Function | MediumTest | Level1)
1893 {
1894     std::string testName = "a@%";
1895     int32_t ret;
1896     for (int i = 0; i < 5; i++) {
1897         g_powerInterface->SuspendUnblock(testName);
1898         sleep(WAIT_TIME);
1899         ret = g_powerInterface->SuspendBlock(testName);
1900         EXPECT_EQ(0, ret);
1901     }
1902 
1903     char lockBuf[MAX_PATH] = {0};
1904     std::string lockBufS;
1905     std::string lockValue;
1906 
1907     ret = snprintf_s(lockBuf, MAX_PATH, sizeof(lockBuf) - 1, LOCK_PATH.c_str());
1908     lockBufS = lockBuf;
1909     sleep(WAIT_TIME);
1910     ret = HdfPowerHdiTestAdditional::ReadFile(lockBufS, lockValue, MAX_PATH);
1911     EXPECT_EQ(0, ret);
1912     EXPECT_FALSE(lockValue.empty());
1913     auto pos = lockValue.find(testName);
1914     EXPECT_TRUE(pos != std::string::npos) << "testSuspendBlock012 failed lock: " << lockValue;
1915 }
1916 
1917 /**
1918  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_0500
1919  * @tc.name   : testUnholdRunningLock001
1920  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_PHONE
1921  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock001, Function | MediumTest | Level1)1922 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock001, Function | MediumTest | Level1)
1923 {
1924     struct RunningLockInfo info = {
1925         .name = "",
1926         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
1927         .timeoutMs = -1,
1928         .pid = 0,
1929         .uid = 0,
1930     };
1931     std::string lockName = "acts_test";
1932 
1933     info.name = lockName;
1934     int32_t ret = g_powerInterface->HoldRunningLock(info);
1935     EXPECT_TRUE(HDF_SUCCESS == ret);
1936 
1937     ret = g_powerInterface->UnholdRunningLock(info);
1938     EXPECT_TRUE(HDF_SUCCESS == ret);
1939 }
1940 /**
1941  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_0600
1942  * @tc.name   : testUnholdRunningLock002
1943  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_AUDIO
1944  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock002, Function | MediumTest | Level1)1945 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock002, Function | MediumTest | Level1)
1946 {
1947     struct RunningLockInfo info = {
1948         .name = "",
1949         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
1950         .timeoutMs = -1,
1951         .pid = 0,
1952         .uid = 0,
1953     };
1954     std::string lockName = "acts_test";
1955 
1956     info.name = lockName;
1957     int32_t ret = g_powerInterface->HoldRunningLock(info);
1958     EXPECT_TRUE(HDF_SUCCESS == ret);
1959 
1960     ret = g_powerInterface->UnholdRunningLock(info);
1961     EXPECT_TRUE(HDF_SUCCESS == ret);
1962 }
1963 /**
1964  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_0700
1965  * @tc.name   : testUnholdRunningLock003
1966  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_SPORT
1967  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock003, Function | MediumTest | Level1)1968 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock003, Function | MediumTest | Level1)
1969 {
1970     struct RunningLockInfo info = {
1971         .name = "",
1972         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
1973         .timeoutMs = -1,
1974         .pid = 0,
1975         .uid = 0,
1976     };
1977     std::string lockName = "acts_test";
1978 
1979     info.name = lockName;
1980     int32_t ret = g_powerInterface->HoldRunningLock(info);
1981     EXPECT_TRUE(HDF_SUCCESS == ret);
1982 
1983     ret = g_powerInterface->UnholdRunningLock(info);
1984     EXPECT_TRUE(HDF_SUCCESS == ret);
1985 }
1986 /**
1987  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_0800
1988  * @tc.name   : testUnholdRunningLock004
1989  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_NAVIGATION
1990  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock004, Function | MediumTest | Level1)1991 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock004, Function | MediumTest | Level1)
1992 {
1993     struct RunningLockInfo info = {
1994         .name = "",
1995         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
1996         .timeoutMs = -1,
1997         .pid = 0,
1998         .uid = 0,
1999     };
2000     std::string lockName = "acts_test";
2001 
2002     info.name = lockName;
2003     int32_t ret = g_powerInterface->HoldRunningLock(info);
2004     EXPECT_TRUE(HDF_SUCCESS == ret);
2005 
2006     ret = g_powerInterface->UnholdRunningLock(info);
2007     EXPECT_TRUE(HDF_SUCCESS == ret);
2008 }
2009 /**
2010  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_0900
2011  * @tc.name   : testUnholdRunningLock005
2012  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_TASK
2013  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock005, Function | MediumTest | Level1)2014 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock005, Function | MediumTest | Level1)
2015 {
2016     struct RunningLockInfo info = {
2017         .name = "",
2018         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
2019         .timeoutMs = -1,
2020         .pid = 0,
2021         .uid = 0,
2022     };
2023     std::string lockName = "acts_test";
2024 
2025     info.name = lockName;
2026     int32_t ret = g_powerInterface->HoldRunningLock(info);
2027     EXPECT_TRUE(HDF_SUCCESS == ret);
2028 
2029     ret = g_powerInterface->UnholdRunningLock(info);
2030     EXPECT_TRUE(HDF_SUCCESS == ret);
2031 }
2032 /**
2033  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1000
2034  * @tc.name   : testUnholdRunningLock006
2035  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_PHONE
2036  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock006, Function | MediumTest | Level1)2037 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock006, Function | MediumTest | Level1)
2038 {
2039     struct RunningLockInfo info = {
2040         .name = "",
2041         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
2042         .timeoutMs = 3000,
2043         .pid = -1,
2044         .uid = -1,
2045     };
2046     std::string lockName = "acts_test";
2047 
2048     info.name = lockName;
2049     int32_t ret = g_powerInterface->HoldRunningLock(info);
2050     EXPECT_TRUE(HDF_SUCCESS == ret);
2051 
2052     ret = g_powerInterface->UnholdRunningLock(info);
2053     EXPECT_TRUE(HDF_SUCCESS == ret);
2054 }
2055 /**
2056  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1100
2057  * @tc.name   : testUnholdRunningLock007
2058  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_NOTIFICATION
2059  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock007, Function | MediumTest | Level1)2060 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock007, Function | MediumTest | Level1)
2061 {
2062     struct RunningLockInfo info = {
2063         .name = "",
2064         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
2065         .timeoutMs = 3000,
2066         .pid = -1,
2067         .uid = -1,
2068     };
2069     std::string lockName = "acts_test";
2070 
2071     info.name = lockName;
2072     int32_t ret = g_powerInterface->HoldRunningLock(info);
2073     EXPECT_TRUE(HDF_SUCCESS == ret);
2074 
2075     ret = g_powerInterface->UnholdRunningLock(info);
2076     EXPECT_TRUE(HDF_SUCCESS == ret);
2077 }
2078 /**
2079  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1200
2080  * @tc.name   : testUnholdRunningLock008
2081  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_AUDIO
2082  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock008, Function | MediumTest | Level1)2083 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock008, Function | MediumTest | Level1)
2084 {
2085     struct RunningLockInfo info = {
2086         .name = "",
2087         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
2088         .timeoutMs = 3000,
2089         .pid = -1,
2090         .uid = -1,
2091     };
2092     std::string lockName = "acts_test";
2093 
2094     info.name = lockName;
2095     int32_t ret = g_powerInterface->HoldRunningLock(info);
2096     EXPECT_TRUE(HDF_SUCCESS == ret);
2097 
2098     ret = g_powerInterface->UnholdRunningLock(info);
2099     EXPECT_TRUE(HDF_SUCCESS == ret);
2100 }
2101 /**
2102  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1300
2103  * @tc.name   : testUnholdRunningLock009
2104  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_SPORT
2105  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock009, Function | MediumTest | Level1)2106 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock009, Function | MediumTest | Level1)
2107 {
2108     struct RunningLockInfo info = {
2109         .name = "",
2110         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
2111         .timeoutMs = 3000,
2112         .pid = -1,
2113         .uid = -1,
2114     };
2115     std::string lockName = "acts_test";
2116 
2117     info.name = lockName;
2118     int32_t ret = g_powerInterface->HoldRunningLock(info);
2119     EXPECT_TRUE(HDF_SUCCESS == ret);
2120 
2121     ret = g_powerInterface->UnholdRunningLock(info);
2122     EXPECT_TRUE(HDF_SUCCESS == ret);
2123 }
2124 /**
2125  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1400
2126  * @tc.name   : testUnholdRunningLock010
2127  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_NAVIGATION
2128  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock010, Function | MediumTest | Level1)2129 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock010, Function | MediumTest | Level1)
2130 {
2131     struct RunningLockInfo info = {
2132         .name = "",
2133         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
2134         .timeoutMs = 3000,
2135         .pid = -1,
2136         .uid = -1,
2137     };
2138     std::string lockName = "acts_test";
2139 
2140     info.name = lockName;
2141     int32_t ret = g_powerInterface->HoldRunningLock(info);
2142     EXPECT_TRUE(HDF_SUCCESS == ret);
2143 
2144     ret = g_powerInterface->UnholdRunningLock(info);
2145     EXPECT_TRUE(HDF_SUCCESS == ret);
2146 }
2147 /**
2148  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1500
2149  * @tc.name   : testUnholdRunningLock011
2150  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_TASK
2151  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock011, Function | MediumTest | Level1)2152 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock011, Function | MediumTest | Level1)
2153 {
2154     struct RunningLockInfo info = {
2155         .name = "",
2156         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
2157         .timeoutMs = 3000,
2158         .pid = -1,
2159         .uid = -1,
2160     };
2161     std::string lockName = "acts_test";
2162 
2163     info.name = lockName;
2164     int32_t ret = g_powerInterface->HoldRunningLock(info);
2165     EXPECT_TRUE(HDF_SUCCESS == ret);
2166 
2167     ret = g_powerInterface->UnholdRunningLock(info);
2168     EXPECT_TRUE(HDF_SUCCESS == ret);
2169 }
2170 /**
2171  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1600
2172  * @tc.name   : testUnholdRunningLock012
2173  * @tc.desc   : UnholdRunningLock type is RUNNINGLOCK_BACKGROUND_PHONE
2174  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock012, Function | MediumTest | Level1)2175 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock012, Function | MediumTest | Level1)
2176 {
2177     struct RunningLockInfo info = {
2178         .name = "",
2179         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
2180         .timeoutMs = -1,
2181         .pid = 0,
2182         .uid = 0,
2183     };
2184     std::string lockName = "acts_test";
2185 
2186     info.name = lockName;
2187     int32_t ret = g_powerInterface->HoldRunningLock(info);
2188     EXPECT_TRUE(HDF_SUCCESS == ret);
2189     info.type = static_cast<RunningLockType>(100);
2190     ret = g_powerInterface->UnholdRunningLock(info);
2191     EXPECT_FALSE(HDF_SUCCESS == ret);
2192     info.type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE;
2193     ret = g_powerInterface->UnholdRunningLock(info);
2194 }
2195 /**
2196  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1700
2197  * @tc.name   : testUnholdRunningLock013
2198  * @tc.desc   : UnholdRunningLock type is invaild
2199  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock013, Function | MediumTest | Level1)2200 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock013, Function | MediumTest | Level1)
2201 {
2202     struct RunningLockInfo info = {
2203         .name = "",
2204         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
2205         .timeoutMs = -1,
2206         .pid = 0,
2207         .uid = 0,
2208     };
2209     std::string lockName = "acts_test";
2210 
2211     info.name = lockName;
2212     int32_t ret = g_powerInterface->HoldRunningLock(info);
2213     EXPECT_TRUE(HDF_SUCCESS == ret);
2214     info.type = static_cast<RunningLockType>(100);
2215     ret = g_powerInterface->UnholdRunningLock(info);
2216     EXPECT_FALSE(HDF_SUCCESS == ret);
2217     info.type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO;
2218     ret = g_powerInterface->UnholdRunningLock(info);
2219 }
2220 /**
2221  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1800
2222  * @tc.name   : testUnholdRunningLock014
2223  * @tc.desc   : UnholdRunningLock type is invaild
2224  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock014, Function | MediumTest | Level1)2225 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock014, Function | MediumTest | Level1)
2226 {
2227     struct RunningLockInfo info = {
2228         .name = "",
2229         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
2230         .timeoutMs = -1,
2231         .pid = 0,
2232         .uid = 0,
2233     };
2234     std::string lockName = "acts_test";
2235 
2236     info.name = lockName;
2237     int32_t ret = g_powerInterface->HoldRunningLock(info);
2238     EXPECT_TRUE(HDF_SUCCESS == ret);
2239     info.type = static_cast<RunningLockType>(100);
2240     ret = g_powerInterface->UnholdRunningLock(info);
2241     EXPECT_FALSE(HDF_SUCCESS == ret);
2242     info.type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT;
2243     ret = g_powerInterface->UnholdRunningLock(info);
2244 }
2245 /**
2246  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_1900
2247  * @tc.name   : testUnholdRunningLock015
2248  * @tc.desc   : UnholdRunningLock type is invaild
2249  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock015, Function | MediumTest | Level1)2250 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock015, Function | MediumTest | Level1)
2251 {
2252     struct RunningLockInfo info = {
2253         .name = "",
2254         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
2255         .timeoutMs = -1,
2256         .pid = 0,
2257         .uid = 0,
2258     };
2259     std::string lockName = "acts_test";
2260 
2261     info.name = lockName;
2262     int32_t ret = g_powerInterface->HoldRunningLock(info);
2263     EXPECT_TRUE(HDF_SUCCESS == ret);
2264     info.type = static_cast<RunningLockType>(100);
2265     ret = g_powerInterface->UnholdRunningLock(info);
2266     EXPECT_FALSE(HDF_SUCCESS == ret);
2267     info.type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION;
2268     ret = g_powerInterface->UnholdRunningLock(info);
2269 }
2270 /**
2271  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2000
2272  * @tc.name   : testUnholdRunningLock016
2273  * @tc.desc   : UnholdRunningLock type is invaild
2274  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock016, Function | MediumTest | Level1)2275 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock016, Function | MediumTest | Level1)
2276 {
2277     struct RunningLockInfo info = {
2278         .name = "",
2279         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
2280         .timeoutMs = -1,
2281         .pid = 0,
2282         .uid = 0,
2283     };
2284     std::string lockName = "acts_test";
2285 
2286     info.name = lockName;
2287     int32_t ret = g_powerInterface->HoldRunningLock(info);
2288     EXPECT_TRUE(HDF_SUCCESS == ret);
2289     info.type = static_cast<RunningLockType>(100);
2290     ret = g_powerInterface->UnholdRunningLock(info);
2291     EXPECT_FALSE(HDF_SUCCESS == ret);
2292     info.type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK;
2293     ret = g_powerInterface->UnholdRunningLock(info);
2294 }
2295 /**
2296  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2100
2297  * @tc.name   : testUnholdRunningLock017
2298  * @tc.desc   : UnholdRunningLock different names
2299  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock017, Function | MediumTest | Level2)2300 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock017, Function | MediumTest | Level2)
2301 {
2302     struct RunningLockInfo info = {
2303         .name = "",
2304         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
2305         .timeoutMs = -1,
2306         .pid = 0,
2307         .uid = 0,
2308     };
2309     std::string lockName = "acts_test";
2310     std::string errorLockName = "error_acts_test";
2311 
2312     info.name = lockName;
2313     int32_t ret = g_powerInterface->HoldRunningLock(info);
2314     EXPECT_TRUE(HDF_SUCCESS == ret);
2315     info.name = errorLockName;
2316     ret = g_powerInterface->UnholdRunningLock(info);
2317     EXPECT_FALSE(HDF_SUCCESS == ret);
2318 }
2319 /**
2320  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2200
2321  * @tc.name   : testUnholdRunningLock018
2322  * @tc.desc   : UnholdRunningLock different names
2323  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock018, Function | MediumTest | Level2)2324 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock018, Function | MediumTest | Level2)
2325 {
2326     struct RunningLockInfo info = {
2327         .name = "",
2328         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
2329         .timeoutMs = -1,
2330         .pid = 0,
2331         .uid = 0,
2332     };
2333     std::string lockName = "111";
2334     std::string errorLockName = "error_acts_test";
2335 
2336     info.name = lockName;
2337     int32_t ret = g_powerInterface->HoldRunningLock(info);
2338     EXPECT_TRUE(HDF_SUCCESS == ret);
2339     info.name = errorLockName;
2340     ret = g_powerInterface->UnholdRunningLock(info);
2341     EXPECT_FALSE(HDF_SUCCESS == ret);
2342 }
2343 /**
2344  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2300
2345  * @tc.name   : testUnholdRunningLock019
2346  * @tc.desc   : UnholdRunningLock different names
2347  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock019, Function | MediumTest | Level2)2348 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock019, Function | MediumTest | Level2)
2349 {
2350     struct RunningLockInfo info = {
2351         .name = "",
2352         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
2353         .timeoutMs = -1,
2354         .pid = 0,
2355         .uid = 0,
2356     };
2357     std::string lockName = "acts_test";
2358     std::string errorLockName = "error_acts_test";
2359 
2360     info.name = lockName;
2361     int32_t ret = g_powerInterface->HoldRunningLock(info);
2362     EXPECT_TRUE(HDF_SUCCESS == ret);
2363     info.name = errorLockName;
2364     ret = g_powerInterface->UnholdRunningLock(info);
2365     EXPECT_FALSE(HDF_SUCCESS == ret);
2366 }
2367 /**
2368  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2400
2369  * @tc.name   : testUnholdRunningLock020
2370  * @tc.desc   : UnholdRunningLock different names
2371  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock020, Function | MediumTest | Level2)2372 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock020, Function | MediumTest | Level2)
2373 {
2374     struct RunningLockInfo info = {
2375         .name = "",
2376         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
2377         .timeoutMs = -1,
2378         .pid = 0,
2379         .uid = 0,
2380     };
2381     std::string lockName = "acts_test";
2382     std::string errorLockName = "error_acts_test";
2383 
2384     info.name = lockName;
2385     int32_t ret = g_powerInterface->HoldRunningLock(info);
2386     EXPECT_TRUE(HDF_SUCCESS == ret);
2387     info.name = errorLockName;
2388     ret = g_powerInterface->UnholdRunningLock(info);
2389     EXPECT_FALSE(HDF_SUCCESS == ret);
2390 }
2391 /**
2392  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2500
2393  * @tc.name   : testUnholdRunningLock021
2394  * @tc.desc   : UnholdRunningLock different names
2395  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock021, Function | MediumTest | Level2)2396 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock021, Function | MediumTest | Level2)
2397 {
2398     struct RunningLockInfo info = {
2399         .name = "",
2400         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
2401         .timeoutMs = -1,
2402         .pid = 0,
2403         .uid = 0,
2404     };
2405     std::string lockName = "acts_test";
2406     std::string errorLockName = "error_acts_test";
2407 
2408     info.name = lockName;
2409     int32_t ret = g_powerInterface->HoldRunningLock(info);
2410     EXPECT_TRUE(HDF_SUCCESS == ret);
2411     info.name = errorLockName;
2412     ret = g_powerInterface->UnholdRunningLock(info);
2413     EXPECT_FALSE(HDF_SUCCESS == ret);
2414 }
2415 /**
2416  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2600
2417  * @tc.name   : testUnholdRunningLock022
2418  * @tc.desc   : UnholdRunningLock name is null
2419  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock022, Function | MediumTest | Level2)2420 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock022, Function | MediumTest | Level2)
2421 {
2422     struct RunningLockInfo info = {
2423         .name = "",
2424         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE,
2425         .timeoutMs = -1,
2426         .pid = 0,
2427         .uid = 0,
2428     };
2429     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2430     EXPECT_FALSE(HDF_SUCCESS == ret);
2431 }
2432 /**
2433  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2700
2434  * @tc.name   : testUnholdRunningLock023
2435  * @tc.desc   : UnholdRunningLock name is null
2436  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock023, Function | MediumTest | Level2)2437 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock023, Function | MediumTest | Level2)
2438 {
2439     struct RunningLockInfo info = {
2440         .name = "",
2441         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION,
2442         .timeoutMs = -1,
2443         .pid = 0,
2444         .uid = 0,
2445     };
2446     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2447     EXPECT_FALSE(HDF_SUCCESS == ret);
2448 }
2449 /**
2450  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2800
2451  * @tc.name   : testUnholdRunningLock024
2452  * @tc.desc   : UnholdRunningLock name is null
2453  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock024, Function | MediumTest | Level2)2454 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock024, Function | MediumTest | Level2)
2455 {
2456     struct RunningLockInfo info = {
2457         .name = "",
2458         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO,
2459         .timeoutMs = -1,
2460         .pid = 0,
2461         .uid = 0,
2462     };
2463     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2464     EXPECT_FALSE(HDF_SUCCESS == ret);
2465 }
2466 /**
2467  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_2900
2468  * @tc.name   : testUnholdRunningLock025
2469  * @tc.desc   : UnholdRunningLock name is null
2470  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock025, Function | MediumTest | Level2)2471 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock025, Function | MediumTest | Level2)
2472 {
2473     struct RunningLockInfo info = {
2474         .name = "",
2475         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT,
2476         .timeoutMs = -1,
2477         .pid = 0,
2478         .uid = 0,
2479     };
2480     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2481     EXPECT_FALSE(HDF_SUCCESS == ret);
2482 }
2483 /**
2484  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_3000
2485  * @tc.name   : testUnholdRunningLock026
2486  * @tc.desc   : UnholdRunningLock name is null
2487  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock026, Function | MediumTest | Level2)2488 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock026, Function | MediumTest | Level2)
2489 {
2490     struct RunningLockInfo info = {
2491         .name = "",
2492         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION,
2493         .timeoutMs = -1,
2494         .pid = 0,
2495         .uid = 0,
2496     };
2497     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2498     EXPECT_FALSE(HDF_SUCCESS == ret);
2499 }
2500 /**
2501  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_3100
2502  * @tc.name   : testUnholdRunningLock027
2503  * @tc.desc   : UnholdRunningLock name is null
2504  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock027, Function | MediumTest | Level2)2505 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock027, Function | MediumTest | Level2)
2506 {
2507     struct RunningLockInfo info = {
2508         .name = "",
2509         .type = RunningLockType::RUNNINGLOCK_BACKGROUND_TASK,
2510         .timeoutMs = -1,
2511         .pid = 0,
2512         .uid = 0,
2513     };
2514     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2515     EXPECT_FALSE(HDF_SUCCESS == ret);
2516 }
2517 /**
2518  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_3200
2519  * @tc.name   : testUnholdRunningLock028
2520  * @tc.desc   : UnholdRunningLock type is invaild
2521  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock028, Function | MediumTest | Level2)2522 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock028, Function | MediumTest | Level2)
2523 {
2524     struct RunningLockInfo info = {
2525         .name = "acts_test",
2526         .type = static_cast<RunningLockType>(100),
2527         .timeoutMs = -1,
2528         .pid = 0,
2529         .uid = 0,
2530     };
2531     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2532     EXPECT_FALSE(HDF_SUCCESS == ret);
2533 }
2534 /**
2535  * @tc.number : SUB_Powermgr_Power_HDI_UnholdRunningLock_3300
2536  * @tc.name   : testUnholdRunningLock029
2537  * @tc.desc   : UnholdRunningLock only type in info
2538  */
HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock029, Function | MediumTest | Level2)2539 HWTEST_F(HdfPowerHdiTestAdditional, testUnholdRunningLock029, Function | MediumTest | Level2)
2540 {
2541     struct RunningLockInfo info = {
2542         .type = static_cast<RunningLockType>(100),
2543     };
2544     int32_t ret = g_powerInterface->UnholdRunningLock(info);
2545     EXPECT_FALSE(HDF_SUCCESS == ret);
2546 }
2547 } // namespace