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