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