• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2025 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
16import runningLock from '@ohos.runningLock'
17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium';
18
19export default function RunningLockTest() {
20  describe('RunningLockTest', function () {
21    // Defines a test suite. Two parameters are supported: test suite name and test suite function.
22    beforeAll(() => {
23      // Presets an action, which is performed only once before all test cases of the test suite start.
24      // This API supports only one parameter: preset action function.
25    })
26    beforeEach(() => {
27      // Presets an action, which is performed before each unit test case starts.
28      // The number of execution times is the same as the number of test cases defined by **it**.
29      // This API supports only one parameter: preset action function.
30    })
31    afterEach(() => {
32      // Presets a clear action, which is performed after each unit test case ends.
33      // The number of execution times is the same as the number of test cases defined by **it**.
34      // This API supports only one parameter: clear action function.
35    })
36    afterAll(() => {
37      // Presets a clear action, which is performed after all test cases of the test suite end.
38      // This API supports only one parameter: clear action function.
39    })
40
41    /**
42     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0010
43     * @tc.name testRunningLockTest_0100
44     * @tc.desc createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
45     * @tc.level: Level 1
46     * @tc.type: Function
47     * @tc.size: MediumTest
48     */
49    it('RunningLockTest_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, async function (done) {
50      let TAG = 'RunningLockTest_0100'
51      runningLock.createRunningLock(TAG, runningLock.RunningLockType.BACKGROUND)
52        .then(lock => {
53          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
54          expect(lock).not().assertUndefined();
55          let isUsed = lock.isUsed();
56          console.info(`${TAG} isUsed: ${isUsed}`);
57          expect(isUsed).assertFalse();
58          lock.lock(1000);
59          isUsed = lock.isUsed();
60          console.info(`${TAG} locked isUsed: ${isUsed}`);
61          expect(isUsed).assertTrue();
62          done();
63        })
64        .catch(error => {
65          console.error(`${TAG} error: ${JSON.stringify(error)}`);
66          expect().assertFail();
67          done();
68        })
69    })
70
71    /**
72     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0020
73     * @tc.name testRunningLockTest_0200
74     * @tc.desc createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
75     * @tc.level: Level 1
76     * @tc.type: Function
77     * @tc.size: MediumTest
78     */
79    it('RunningLockTest_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, async function (done) {
80      let TAG = 'RunningLockTest_0200'
81      runningLock.createRunningLock(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
82        .then(lock => {
83          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
84          expect(lock).not().assertUndefined();
85          let isUsed = lock.isUsed();
86          console.info(`${TAG} isUsed: ${isUsed}`);
87          expect(isUsed).assertFalse();
88          done();
89        })
90        .catch(error => {
91          console.error(`${TAG} error: ${JSON.stringify(error)}`);
92          expect().assertFail();
93          done();
94        })
95        .finally(() => {
96          console.info(`${TAG} finally!`);
97        })
98    })
99
100    /**
101     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0030
102     * @tc.name testRunningLockTest_0300
103     * @tc.desc createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
104     * @tc.level: Level 1
105     * @tc.type: Function
106     * @tc.size: MediumTest
107     */
108    it('RunningLockTest_0300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, async function (done) {
109      let TAG = 'RunningLockTest_0300'
110      runningLock.createRunningLock(TAG, runningLock.RunningLockType.BACKGROUND)
111        .then(lock => {
112          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
113          expect(lock).not().assertUndefined();
114          let isUsed = lock.isUsed();
115          console.info(`${TAG} isUsed: ${isUsed}`);
116          expect(isUsed).assertFalse();
117          lock.lock(2000);
118          isUsed = lock.isUsed();
119          console.info(`${TAG} locked isUsed: ${isUsed}`);
120          expect(isUsed).assertTrue();
121          lock.unlock();
122          isUsed = lock.isUsed();
123          console.info(`${TAG} unlocked isUsed: ${isUsed}`);
124          expect(isUsed).assertFalse();
125          done();
126        })
127        .catch(error => {
128          console.error(`${TAG} error: ${JSON.stringify(error)}`);
129          expect().assertFail();
130          done();
131        })
132    })
133
134    /**
135     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0040
136     * @tc.name testRunningLockTest_0400
137     * @tc.desc createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
138     * @tc.level: Level 3
139     * @tc.type: Function
140     * @tc.size: MediumTest
141     */
142    it('RunningLockTest_0400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
143      let TAG = 'RunningLockTest_0400'
144      runningLock.createRunningLock(TAG, runningLock.RunningLockType.BACKGROUND, (error, lock) => {
145        if (error) {
146          console.error(`${TAG} error: ${JSON.stringify(error)}`);
147          expect().assertFail();
148          done();
149        } else {
150          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
151          expect(lock).not().assertUndefined();
152          let isUsed = lock.isUsed();
153          console.info(`${TAG} isUsed: ${isUsed}`);
154          expect(isUsed).assertFalse();
155          lock.lock(1000);
156          isUsed = lock.isUsed();
157          console.info(`${TAG} locked isUsed: ${isUsed}`);
158          expect(isUsed).assertTrue();
159          done();
160        }
161      })
162    })
163
164    /**
165     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0050
166     * @tc.name testRunningLockTest_0500
167     * @tc.desc createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
168     * @tc.level: Level 3
169     * @tc.type: Function
170     * @tc.size: MediumTest
171     */
172    it('RunningLockTest_0500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
173      let TAG = 'RunningLockTest_0500'
174      runningLock.createRunningLock(TAG, runningLock.RunningLockType.BACKGROUND, (error, lock) => {
175        if (error) {
176          console.error(`${TAG} error: ${JSON.stringify(error)}`);
177          expect().assertFail();
178          done();
179        } else {
180          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
181          expect(lock).not().assertUndefined();
182          let isUsed = lock.isUsed();
183          console.info(`${TAG} isUsed: ${isUsed}`);
184          expect(isUsed).assertFalse();
185          lock.lock(1000);
186          isUsed = lock.isUsed();
187          console.info(`${TAG} locked isUsed: ${isUsed}`);
188          expect(isUsed).assertTrue();
189          lock.unlock();
190          isUsed = lock.isUsed();
191          console.info(`${TAG} unlocked isUsed: ${isUsed}`);
192          expect(isUsed).assertFalse();
193          done();
194        }
195      })
196    })
197
198    /**
199     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0060
200     * @tc.name testRunningLockTest_0600
201     * @tc.desc isSupported(type: RunningLockType): boolean;
202     * @tc.level: Level 3
203     * @tc.type: Function
204     * @tc.size: MediumTest
205     */
206    it('RunningLockTest_0600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
207      let TAG = 'RunningLockTest_0600';
208      try {
209        let background = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND);
210        console.info(`${TAG} background: ${background}`);
211        expect(background).assertTrue();
212        done();
213      } catch (error) {
214        console.error(`${TAG} error: ${JSON.stringify(error)}`);
215        expect().assertFail();
216        done();
217      }
218    })
219
220    /**
221     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0070
222     * @tc.name testRunningLockTest_0700
223     * @tc.desc isSupported(type: RunningLockType): boolean;
224     * @tc.level: Level 3
225     * @tc.type: Function
226     * @tc.size: MediumTest
227     */
228    it('RunningLockTest_0700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
229      let TAG = 'RunningLockTest_0700';
230      try {
231        let proximity = runningLock.isSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL);
232        console.info(`${TAG} proximity: ${proximity}`);
233        expect(proximity).assertTrue();
234        done();
235      } catch (error) {
236        console.error(`${TAG} error: ${JSON.stringify(error)}`);
237        expect().assertFail();
238        done();
239      }
240    })
241
242    /**
243     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0080
244     * @tc.name testRunningLockTest_0800
245     * @tc.desc isSupported(type: RunningLockType): boolean;
246     * @tc.level: Level 3
247     * @tc.type: Function
248     * @tc.size: MediumTest
249     */
250    it('RunningLockTest_0800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
251      let TAG = 'RunningLockTest_0800';
252      try {
253        let other = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND - 1);
254        console.info(`${TAG} other: ${other}`);
255        expect(other).assertFalse();
256        done();
257      } catch (error) {
258        console.error(`${TAG} error: ${JSON.stringify(error)}`);
259        expect().assertFail();
260        done();
261      }
262    })
263
264    /**
265     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0090
266     * @tc.name testRunningLockTest_0900
267     * @tc.desc isSupported(type: RunningLockType): boolean;
268     * @tc.level: Level 3
269     * @tc.type: Function
270     * @tc.size: MediumTest
271     */
272    it('RunningLockTest_0900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
273      let TAG = 'RunningLockTest_0900';
274      try {
275        let other = runningLock.isSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1);
276        console.info(`${TAG} other: ${other}`);
277        expect(other).assertFalse();
278        done();
279      } catch (error) {
280        console.error(`${TAG} error: ${JSON.stringify(error)}`);
281        expect().assertFail();
282        done();
283      }
284    })
285
286    /**
287     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0100
288     * @tc.name testRunningLockTest_1000
289     * @tc.desc isSupported(type: RunningLockType): boolean;
290     * @tc.level: Level 3
291     * @tc.type: Function
292     * @tc.size: MediumTest
293     */
294    it('RunningLockTest_1000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
295      let TAG = 'RunningLockTest_1000';
296      try {
297        let isSupported = runningLock.isSupported('PROXIMITY_SCREEN_CONTROL');
298        console.info(`${TAG} isSupported: ${isSupported}`);
299        expect(isSupported).assertUndefined();
300        done();
301      } catch (error) {
302        console.error(`${TAG} error: ${JSON.stringify(error)}`);
303        expect(error.code).assertEqual(401);
304        done();
305      }
306    })
307
308    /**
309     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0110
310     * @tc.name testRunningLockTest_1100
311     * @tc.desc isSupported(type: RunningLockType): boolean;
312     * @tc.level: Level 3
313     * @tc.type: Function
314     * @tc.size: MediumTest
315     */
316    it('RunningLockTest_1100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
317      let TAG = 'RunningLockTest_1100';
318      try {
319        let isSupported = runningLock.isSupported(false);
320        console.info(`${TAG} isSupported: ${isSupported}`);
321        expect(isSupported).assertUndefined();
322        done();
323      } catch (error) {
324        console.error(`${TAG} error: ${JSON.stringify(error)}`);
325        expect(error.code).assertEqual(401);
326        done();
327      }
328    })
329
330    /**
331     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0120
332     * @tc.name testRunningLockTest_1200
333     * @tc.desc isSupported(type: RunningLockType): boolean;
334     * @tc.level: Level 3
335     * @tc.type: Function
336     * @tc.size: MediumTest
337     */
338    it('RunningLockTest_1200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
339      let TAG = 'RunningLockTest_1200';
340      try {
341        let isSupported = runningLock.isSupported({
342          RunningLockType: runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL
343        });
344        console.info(`${TAG} isSupported: ${isSupported}`);
345        expect(isSupported).assertUndefined();
346        done();
347      } catch (error) {
348        console.error(`${TAG} error: ${JSON.stringify(error)}`);
349        expect(error.code).assertEqual(401);
350        done();
351      }
352    })
353
354    /**
355     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0130
356     * @tc.name testRunningLockTest_1300
357     * @tc.desc isSupported(type: RunningLockType): boolean;
358     * @tc.level: Level 3
359     * @tc.type: Function
360     * @tc.size: MediumTest
361     */
362    it('RunningLockTest_1300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
363      let TAG = 'RunningLockTest_1300';
364      try {
365        let isSupported = runningLock.isSupported();
366        console.info(`${TAG} isSupported: ${isSupported}`);
367        expect(isSupported).assertUndefined();
368        done();
369      } catch (error) {
370        console.error(`${TAG} error: ${JSON.stringify(error)}`);
371        expect(error.code).assertEqual(401);
372        done();
373      }
374    })
375
376    /**
377     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0140
378     * @tc.name testRunningLockTest_1400
379     * @tc.desc create(name: string, type: RunningLockType): Promise<RunningLock>
380     * @tc.level: Level 3
381     * @tc.type: Function
382     * @tc.size: MediumTest
383     */
384    it('RunningLockTest_1400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
385      let TAG = 'RunningLockTest_1400'
386      runningLock.create(TAG, runningLock.RunningLockType.BACKGROUND)
387        .then(lock => {
388          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
389          expect(lock).not().assertUndefined();
390          let isHolding = lock.isHolding();
391          console.info(`${TAG} isHolding: ${isHolding}`);
392          expect(isHolding).assertFalse();
393          lock.hold(0);
394          isHolding = lock.isHolding();
395          console.info(`${TAG} hold isHolding: ${isHolding}`);
396          expect(isHolding).assertTrue();
397          done();
398        })
399        .catch(error => {
400          console.error(`${TAG} error: ${JSON.stringify(error)}`);
401          expect().assertFail();
402          done();
403        })
404    })
405
406    /**
407     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0150
408     * @tc.name testRunningLockTest_1500
409     * @tc.desc create(name: string, type: RunningLockType): Promise<RunningLock>
410     * @tc.level: Level 3
411     * @tc.type: Function
412     * @tc.size: MediumTest
413     */
414    it('RunningLockTest_1500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
415      let TAG = 'RunningLockTest_1500'
416      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
417        .then(lock => {
418          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
419          expect(lock).not().assertUndefined();
420          let isHolding = lock.isHolding();
421          console.info(`${TAG} isHolding: ${isHolding}`);
422          expect(isHolding).assertFalse();
423          lock.hold(1000);
424          isHolding = lock.isHolding();
425          console.info(`${TAG} hold isHolding: ${isHolding}`);
426          expect(isHolding).assertTrue();
427          lock.unhold();
428          isHolding = lock.isHolding();
429          console.info(`${TAG} unhold isHolding: ${isHolding}`);
430          expect(isHolding).assertFalse();
431          done();
432        })
433        .catch(error => {
434          console.error(`${TAG} error: ${JSON.stringify(error)}`);
435          expect().assertFail();
436          done();
437        })
438    })
439
440    /**
441     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0160
442     * @tc.name testRunningLockTest_1600
443     * @tc.desc create(name: string, type: RunningLockType): Promise<RunningLock>
444     * @tc.level: Level 3
445     * @tc.type: Function
446     * @tc.size: MediumTest
447     */
448    it('RunningLockTest_1600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
449      let TAG = 'RunningLockTest_1600'
450      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
451        .then(lock => {
452          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
453          expect(lock).not().assertUndefined();
454          let isHolding = lock.isHolding();
455          console.info(`${TAG} isHolding: ${isHolding}`);
456          expect(isHolding).assertFalse();
457          lock.unhold();
458          isHolding = lock.isHolding();
459          console.info(`${TAG} unhold isHolding: ${isHolding}`);
460          expect(isHolding).assertFalse();
461          done();
462        })
463        .catch(error => {
464          console.error(`${TAG} error: ${JSON.stringify(error)}`);
465          expect().assertFail();
466          done();
467        })
468    })
469
470    /**
471     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0170
472     * @tc.name testRunningLockTest_1700
473     * @tc.desc create(name: string, type: RunningLockType): Promise<RunningLock>
474     * @tc.level: Level 3
475     * @tc.type: Function
476     * @tc.size: MediumTest
477     */
478    it('RunningLockTest_1700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
479      let TAG = 'RunningLockTest_1700'
480      runningLock.create(TAG, runningLock.RunningLockType.BACKGROUND)
481        .then(lock => {
482          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
483          expect(lock).not().assertUndefined();
484          let isHolding = lock.isHolding();
485          console.info(`${TAG} isHolding: ${isHolding}`);
486          expect(isHolding).assertFalse();
487          lock.hold(-1);
488          isHolding = lock.isHolding();
489          console.info(`${TAG} hold isHolding: ${isHolding}`);
490          expect(isHolding).assertTrue();
491          lock.unhold();
492          isHolding = lock.isHolding();
493          console.info(`${TAG} unhold isHolding: ${isHolding}`);
494          expect(isHolding).assertFalse();
495          done();
496        })
497        .catch(error => {
498          console.error(`${TAG} error: ${JSON.stringify(error)}`);
499          expect().assertFail();
500          done();
501        })
502    })
503
504    /**
505     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0180
506     * @tc.name testRunningLockTest_1800
507     * @tc.desc create(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
508     * @tc.level: Level 3
509     * @tc.type: Function
510     * @tc.size: MediumTest
511     */
512    it('RunningLockTest_1800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
513      let TAG = 'RunningLockTest_1800'
514      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL, (error, lock) => {
515        if (error) {
516          console.error(`${TAG} error: ${JSON.stringify(error)}`);
517          expect().assertFail();
518          done();
519        } else {
520          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
521          expect(lock).not().assertUndefined();
522          let isHolding = lock.isHolding();
523          console.info(`${TAG} isHolding: ${isHolding}`);
524          expect(isHolding).assertFalse();
525          lock.hold(0);
526          isHolding = lock.isHolding();
527          console.info(`${TAG} hold isHolding: ${isHolding}`);
528          expect(isHolding).assertTrue();
529          done();
530        }
531      })
532    })
533
534    /**
535     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0190
536     * @tc.name testRunningLockTest_1900
537     * @tc.desc create(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
538     * @tc.level: Level 3
539     * @tc.type: Function
540     * @tc.size: MediumTest
541     */
542    it('RunningLockTest_1900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
543      let TAG = 'RunningLockTest_1900'
544      runningLock.create(TAG, runningLock.RunningLockType.BACKGROUND, (error, lock) => {
545        if (error) {
546          console.error(`${TAG} error: ${JSON.stringify(error)}`);
547          expect().assertFail();
548          done();
549        } else {
550          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
551          expect(lock).not().assertUndefined();
552          let isHolding = lock.isHolding();
553          console.info(`${TAG} isHolding: ${isHolding}`);
554          expect(isHolding).assertFalse();
555          lock.hold(1000);
556          isHolding = lock.isHolding();
557          console.info(`${TAG} hold isHolding: ${isHolding}`);
558          expect(isHolding).assertTrue();
559          lock.unhold();
560          isHolding = lock.isHolding();
561          console.info(`${TAG} unhold isHolding: ${isHolding}`);
562          expect(isHolding).assertFalse();
563          done();
564        }
565      })
566    })
567
568    /**
569     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0200
570     * @tc.name testRunningLockTest_2000
571     * @tc.desc create(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
572     * @tc.level: Level 3
573     * @tc.type: Function
574     * @tc.size: MediumTest
575     */
576    it('RunningLockTest_2000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
577      let TAG = 'RunningLockTest_2000'
578      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL, (error, lock) => {
579        if (error) {
580          console.error(`${TAG} error: ${JSON.stringify(error)}`);
581          expect().assertFail();
582          done();
583        } else {
584          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
585          expect(lock).not().assertUndefined();
586          let isHolding = lock.isHolding();
587          console.info(`${TAG} isHolding: ${isHolding}`);
588          expect(isHolding).assertFalse();
589          lock.unhold();
590          isHolding = lock.isHolding();
591          console.info(`${TAG} unhold isHolding: ${isHolding}`);
592          expect(isHolding).assertFalse();
593          done();
594        }
595      })
596    })
597
598    /**
599     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0210
600     * @tc.name testRunningLockTest_2100
601     * @tc.desc create(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
602     * @tc.level: Level 3
603     * @tc.type: Function
604     * @tc.size: MediumTest
605     */
606    it('RunningLockTest_2100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
607      let TAG = 'RunningLockTest_2100'
608      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL, (error, lock) => {
609        if (error) {
610          console.error(`${TAG} error: ${JSON.stringify(error)}`);
611          expect().assertFail();
612          done();
613        } else {
614          console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
615          expect(lock).not().assertUndefined();
616          let isHolding = lock.isHolding();
617          console.info(`${TAG} isHolding: ${isHolding}`);
618          expect(isHolding).assertFalse();
619          lock.hold(-1);
620          isHolding = lock.isHolding();
621          console.info(`${TAG} hold isHolding: ${isHolding}`);
622          expect(isHolding).assertTrue();
623          lock.unhold();
624          isHolding = lock.isHolding();
625          console.info(`${TAG} unhold isHolding: ${isHolding}`);
626          expect(isHolding).assertFalse();
627          done();
628        }
629      })
630    })
631
632    /**
633     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0220
634     * @tc.name testRunningLockTest_2200
635     * @tc.desc hold lock, is holding
636     * @tc.level: Level 3
637     * @tc.type: Function
638     * @tc.size: MediumTest
639     */
640    it('RunningLockTest_2200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
641      let TAG = 'RunningLockTest_2200';
642      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
643        .then((lock) => {
644          expect(lock).not().assertUndefined();
645          let holding = lock.isHolding();
646          console.info(`${TAG} holding: ${holding}`);
647          expect(holding).assertFalse();
648          lock.hold('hold');
649          let isHolding = lock.isHolding();
650          console.info(`${TAG} isHolding: ${isHolding}`);
651          expect(isHolding).assertFalse();
652          done();
653        })
654        .catch((error) => {
655          console.error(`${TAG} error: ${error.code} ${error.message}`);
656          expect(error.code).assertEqual(401);
657          done();
658        })
659        .finally(() => {
660          console.info(`${TAG} finally`);
661          done();
662        })
663    })
664
665    /**
666     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0230
667     * @tc.name testRunningLockTest_2300
668     * @tc.desc hold(timeout: number): void
669     * @tc.level: Level 3
670     * @tc.type: Function
671     * @tc.size: MediumTest
672     */
673    it('RunningLockTest_2300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
674      let TAG = 'RunningLockTest_2300';
675      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL, (error, lock) => {
676        if (error) {
677          console.error(`${TAG} error: ${error.code} ${error.message}`);
678          expect().assertFail();
679          done();
680        } else {
681          expect(lock).not().assertUndefined();
682          let holding = lock.isHolding();
683          console.info(`${TAG} holding: ${holding}`);
684          expect(holding).assertFalse();
685          try {
686            lock.hold({
687              timeout: 500
688            });
689          } catch (error) {
690            console.error(`${TAG} error: ${error.code} ${error.message}`);
691            expect(error.code).assertEqual(401);
692            let isHolding = lock.isHolding();
693            console.info(`${TAG} isHolding: ${isHolding}`);
694            expect(isHolding).assertFalse();
695            done();
696          }
697        }
698      })
699    })
700
701    /**
702     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0240
703     * @tc.name testRunningLockTest_2400
704     * @tc.desc hold(timeout: number): void
705     * @tc.level: Level 3
706     * @tc.type: Function
707     * @tc.size: MediumTest
708     */
709    it('RunningLockTest_2400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
710      let TAG = 'RunningLockTest_2400';
711      runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
712        .then((lock) => {
713          expect(lock).not().assertUndefined();
714          let holding = lock.isHolding();
715          console.info(`${TAG} holding: ${holding}`);
716          expect(holding).assertFalse();
717          lock.hold(true);
718          let isHolding = lock.isHolding();
719          console.info(`${TAG} isHolding: ${isHolding}`);
720          expect(isHolding).assertFalse();
721          done();
722        })
723        .catch((error) => {
724          console.error(`${TAG} error: ${error.code} ${error.message}`);
725          expect(error.code).assertEqual(401);
726          done();
727        })
728        .finally(() => {
729          console.info(`${TAG} finally`);
730          done();
731        })
732    })
733
734    /**
735     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0250
736     * @tc.name testRunningLockTest_2500
737     * @tc.desc hold(timeout: number): void
738     * @tc.level: Level 3
739     * @tc.type: Function
740     * @tc.size: MediumTest
741     */
742    it('RunningLockTest_2500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
743      let TAG = 'RunningLockTest_2500';
744      try {
745        runningLock.create(100, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
746          .then((lock) => {
747            expect(lock).not().assertUndefined();
748            let holding = lock.isHolding();
749            console.info(`${TAG} holding: ${holding}`);
750            expect(holding).assertFalse();
751            lock.hold(0);
752            let isHolding = lock.isHolding();
753            console.info(`${TAG} isHolding: ${isHolding}`);
754            expect(isHolding).assertFalse();
755            done();
756          })
757          .catch((error) => {
758            console.error(`${TAG} error: ${error.code} ${error.message}`);
759            expect(error.code).assertEqual(401);
760            done();
761          })
762          .finally(() => {
763            console.info(`${TAG} finally`);
764            done();
765          })
766      } catch (error) {
767        console.error(`${TAG} error: ${error.code} ${error.message}`);
768        expect(error.code).assertEqual(401);
769        done();
770      }
771    })
772
773    /**
774     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0260
775     * @tc.name testRunningLockTest_2600
776     * @tc.desc hold(timeout: number): void
777     * @tc.level: Level 3
778     * @tc.type: Function
779     * @tc.size: MediumTest
780     */
781    it('RunningLockTest_2600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
782      let TAG = 'RunningLockTest_2600';
783      try {
784        runningLock.create(TAG, runningLock.RunningLockType.BACKGROUND - 1)
785          .then((lock) => {
786            expect(lock).not().assertUndefined();
787            let holding = lock.isHolding();
788            console.info(`${TAG} holding: ${holding}`);
789            expect(holding).assertFalse();
790            lock.hold(0);
791            let isHolding = lock.isHolding();
792            console.info(`${TAG} isHolding: ${isHolding}`);
793            expect(isHolding).assertFalse();
794            done();
795          })
796          .catch((error) => {
797            console.error(`${TAG} error: ${error.code} ${error.message}`);
798            expect(error.code).assertEqual(401);
799            done();
800          })
801          .finally(() => {
802            console.info(`${TAG} finally`);
803            done();
804          })
805      } catch (error) {
806        console.error(`${TAG} error: ${error.code} ${error.message}`);
807        expect(error.code).assertEqual(401);
808        done();
809      }
810    })
811
812    /**
813     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0270
814     * @tc.name testRunningLockTest_2700
815     * @tc.desc hold(timeout: number): void
816     * @tc.level: Level 3
817     * @tc.type: Function
818     * @tc.size: MediumTest
819     */
820    it('RunningLockTest_2700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
821      let TAG = 'RunningLockTest_2700';
822      try {
823        runningLock.create(false, runningLock.RunningLockType.BACKGROUND, (error, lock) => {
824          if (error) {
825            console.error(`${TAG} error: ${error.code} ${error.message}`);
826            expect(error.code).assertEqual(401);
827            done();
828          } else {
829            expect(lock).not().assertUndefined();
830            let holding = lock.isHolding();
831            console.info(`${TAG} holding: ${holding}`);
832            expect(holding).assertFalse();
833            lock.hold(0);
834            let isHolding = lock.isHolding();
835            console.info(`${TAG} isHolding: ${isHolding}`);
836            expect(isHolding).assertFalse();
837            done();
838          }
839        })
840      } catch (error) {
841        console.error(`${TAG} error: ${error.code} ${error.message}`);
842        expect(error.code).assertEqual(401);
843        done();
844      }
845    })
846
847    /**
848     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0280
849     * @tc.name testRunningLockTest_2800
850     * @tc.desc hold(timeout: number): void
851     * @tc.level: Level 3
852     * @tc.type: Function
853     * @tc.size: MediumTest
854     */
855    it('RunningLockTest_2800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
856      let TAG = 'RunningLockTest_2800';
857      try {
858        runningLock.create(TAG, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1)
859          .then((lock) => {
860            expect(lock).not().assertUndefined();
861            let holding = lock.isHolding();
862            console.info(`${TAG} holding: ${holding}`);
863            expect(holding).assertFalse();
864            lock.hold(0);
865            let isHolding = lock.isHolding();
866            console.info(`${TAG} isHolding: ${isHolding}`);
867            expect(isHolding).assertFalse();
868            done();
869          })
870          .catch((error) => {
871            console.error(`${TAG} error: ${error.code} ${error.message}`);
872            expect(error.code).assertEqual(401);
873            done();
874          })
875          .finally(() => {
876            console.info(`${TAG} finally`);
877            done();
878          })
879      } catch (error) {
880        console.error(`${TAG} error: ${error.code} ${error.message}`);
881        expect(error.code).assertEqual(401);
882        done();
883      }
884    })
885
886    /**
887     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0290
888     * @tc.name testRunningLockTest_2900
889     * @tc.desc Create lock input invalid value
890     * @tc.level: Level 3
891     * @tc.type: Function
892     * @tc.size: MediumTest
893     */
894    it('RunningLockTest_2900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
895      let TAG = 'RunningLockTest_2900';
896      try {
897        runningLock.create(runningLock.RunningLockType.BACKGROUND,
898          runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1, (error, lock) => {
899            console.error(`${TAG} error: ${error.code} ${error.message}`);
900            expect(error.code).assertEqual(401);
901            console.info(`${TAG} lock: ${JSON.stringify(lock)}`);
902            expect(lock).assertUndefined();
903            done();
904          });
905      } catch (error) {
906        console.error(`${TAG} error: ${error.code} ${error.message}`);
907        // 401: Invalid input parameter
908        expect(error.code).assertEqual(401);
909        done();
910      }
911    })
912
913    /**
914     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0300
915     * @tc.name testRunningLockTest_3000
916     * @tc.desc Create lock input invalid value
917     * @tc.level: Level 3
918     * @tc.type: Function
919     * @tc.size: MediumTest
920     */
921    it('RunningLockTest_3000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
922      let TAG = 'RunningLockTest_3000';
923      try {
924        runningLock.create(false, runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1)
925          .then((lock) => {
926            expect(lock).not().assertUndefined();
927            let holding = lock.isHolding();
928            console.info(`${TAG} holding: ${holding}`);
929            expect(holding).assertFalse();
930            lock.hold(0);
931            let isHolding = lock.isHolding();
932            console.info(`${TAG} isHolding: ${isHolding}`);
933            expect(isHolding).assertFalse();
934            done();
935          })
936          .catch((error) => {
937            console.error(`${TAG} error: ${error.code} ${error.message}`);
938            expect(error.code).assertEqual(401);
939            done();
940          })
941          .finally(() => {
942            console.info(`${TAG} finally`);
943            done();
944          })
945      } catch (error) {
946        console.error(`${TAG} error: ${error.code} ${error.message}`);
947        expect(error.code).assertEqual(401);
948        done();
949      }
950    })
951
952    /**
953     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0310
954     * @tc.name testRunningLockTest_3100
955     * @tc.desc The lock type is BACKGROUND
956     * @tc.level: Level 3
957     * @tc.type: Function
958     * @tc.size: MediumTest
959     */
960    it('RunningLockTest_3100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
961      let TAG = 'RunningLockTest_3100';
962      try {
963        let runningLockType = runningLock.RunningLockType.BACKGROUND;
964        console.info(`${TAG} runningLockType: ${runningLockType}`);
965        expect(runningLockType).assertEqual(1);
966        done();
967      } catch (error) {
968        console.error(`${TAG} error: ${JSON.stringify(error)}`);
969        expect().assertFail();
970        done();
971      }
972    })
973
974    /**
975     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0320
976     * @tc.name testRunningLockTest_3200
977     * @tc.desc The lock type is BACKGROUND
978     * @tc.level: Level 3
979     * @tc.type: Function
980     * @tc.size: MediumTest
981     */
982    it('RunningLockTest_3200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
983      let TAG = 'RunningLockTest_3200';
984      try {
985        let runningLockType = runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL;
986        console.info(`${TAG} runningLockType: ${runningLockType}`);
987        expect(runningLockType).assertEqual(2);
988        done();
989      } catch (error) {
990        console.error(`${TAG} error: ${JSON.stringify(error)}`);
991        expect().assertFail();
992        done();
993      }
994    })
995
996    /**
997     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0330
998     * @tc.name testRunningLockTest_3300
999     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1000     * @tc.level: Level 3
1001     * @tc.type: Function
1002     * @tc.size: MediumTest
1003     */
1004    it('RunningLockTest_3300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1005      let TAG = 'RunningLockTest_3300';
1006      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND)
1007        .then(supported => {
1008          console.info(`${TAG} supported: ${supported}`);
1009          expect(supported).assertTrue();
1010          done();
1011        })
1012        .catch(error => {
1013          console.error(`${TAG} error: ${JSON.stringify(error)}`);
1014          expect().assertFail();
1015          done();
1016        })
1017    })
1018
1019    /**
1020     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0340
1021     * @tc.name testRunningLockTest_3400
1022     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1023     * @tc.level: Level 3
1024     * @tc.type: Function
1025     * @tc.size: MediumTest
1026     */
1027    it('RunningLockTest_3400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1028      let TAG = 'RunningLockTest_3400';
1029      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
1030        .then(supported => {
1031          console.info(`${TAG} supported: ${supported}`);
1032          expect(supported).assertTrue();
1033          done();
1034        })
1035        .catch(error => {
1036          console.error(`${TAG} error: ${JSON.stringify(error)}`);
1037          expect().assertFail();
1038          done();
1039        })
1040    })
1041
1042    /**
1043     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0350
1044     * @tc.name testRunningLockTest_3500
1045     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1046     * @tc.level: Level 3
1047     * @tc.type: Function
1048     * @tc.size: MediumTest
1049     */
1050    it('RunningLockTest_3500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1051      let TAG = 'RunningLockTest_3500';
1052      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, isSupported) => {
1053        if (error) {
1054          console.error(`${TAG} error: ${JSON.stringify(error)}`);
1055          expect().assertFail();
1056          done();
1057        } else {
1058          console.info(`${TAG} isSupported: ${isSupported}`);
1059          expect(isSupported).assertTrue();
1060          done();
1061        }
1062      })
1063    })
1064
1065    /**
1066     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0360
1067     * @tc.name testRunningLockTest_3600
1068     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1069     * @tc.level: Level 3
1070     * @tc.type: Function
1071     * @tc.size: MediumTest
1072     */
1073    it('RunningLockTest_3600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1074      let TAG = 'RunningLockTest_3600';
1075      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL,
1076        (error, isSupported) => {
1077          if (error) {
1078            console.error(`${TAG} error: ${JSON.stringify(error)}`);
1079            expect().assertFail();
1080            done();
1081          } else {
1082            console.info(`${TAG} isSupported: ${isSupported}`);
1083            expect(isSupported).assertTrue();
1084            done();
1085          }
1086        })
1087    })
1088
1089    /**
1090     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0370
1091     * @tc.name testRunningLockTest_3700
1092     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1093     * @tc.level: Level 3
1094     * @tc.type: Function
1095     * @tc.size: MediumTest
1096     */
1097    it('RunningLockTest_3700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1098      let TAG = 'RunningLockTest_3700';
1099      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND - 1,
1100        (error, isSupported) => {
1101          if (error) {
1102            console.error(`${TAG} error: ${JSON.stringify(error)}`);
1103            expect().assertFail();
1104            done();
1105          } else {
1106            console.info(`${TAG} isSupported: ${isSupported}`);
1107            expect(isSupported).assertFalse();
1108            done();
1109          }
1110        })
1111    })
1112
1113    /**
1114     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0380
1115     * @tc.name testRunningLockTest_3800
1116     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1117     * @tc.level: Level 3
1118     * @tc.type: Function
1119     * @tc.size: MediumTest
1120     */
1121    it('RunningLockTest_3800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1122      let TAG = 'RunningLockTest_3800';
1123      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1,
1124        (error, isSupported) => {
1125          if (error) {
1126            console.error(`${TAG} error: ${JSON.stringify(error)}`);
1127            expect().assertFail();
1128            done();
1129          } else {
1130            console.info(`${TAG} isSupported: ${isSupported}`);
1131            expect(isSupported).assertFalse();
1132            done();
1133          }
1134        })
1135    })
1136
1137    /**
1138     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0390
1139     * @tc.name testRunningLockTest_3900
1140     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1141     * @tc.level: Level 3
1142     * @tc.type: Function
1143     * @tc.size: MediumTest
1144     */
1145    it('RunningLockTest_3900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1146      let TAG = 'RunningLockTest_3900';
1147      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND - 1)
1148        .then(supported => {
1149          console.info(`${TAG} supported: ${supported}`);
1150          expect(supported).assertFalse();
1151          done();
1152        })
1153        .catch(error => {
1154          console.error(`${TAG} error: ${JSON.stringify(error)}`);
1155          expect().assertFail();
1156          done();
1157        })
1158    })
1159
1160    /**
1161     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0400
1162     * @tc.name testRunningLockTest_4000
1163     * @tc.desc Checks whether the specified RunningLockType is supported (deprecated since 9)
1164     * @tc.level: Level 3
1165     * @tc.type: Function
1166     * @tc.size: MediumTest
1167     */
1168    it('RunningLockTest_4000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1169      let TAG = 'RunningLockTest_4000';
1170      runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1)
1171        .then(supported => {
1172          console.info(`${TAG} supported: ${supported}`);
1173          expect(supported).assertFalse();
1174          done();
1175        })
1176        .catch(error => {
1177          console.error(`${TAG} error: ${JSON.stringify(error)}`);
1178          expect().assertFail();
1179          done();
1180        })
1181    })
1182
1183    /**
1184     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0410
1185     * @tc.name testRunningLockTest_4100
1186     * @tc.desc Checks whether the specified RunningLockType is supported.
1187     * @tc.level: Level 3
1188     * @tc.type: Function
1189     * @tc.size: MediumTest
1190     */
1191    it('RunningLockTest_4100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1192      let TAG = 'RunningLockTest_4100';
1193      try {
1194        let isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND);
1195        console.info(`${TAG} isSupported: ${isSupported}`);
1196        expect(isSupported).assertTrue();
1197        done();
1198      } catch (error) {
1199        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1200        expect().assertFail();
1201        done();
1202      }
1203    })
1204
1205    /**
1206     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0420
1207     * @tc.name testRunningLockTest_4200
1208     * @tc.desc Checks whether the specified RunningLockType is supported.
1209     * @tc.level: Level 3
1210     * @tc.type: Function
1211     * @tc.size: MediumTest
1212     */
1213    it('RunningLockTest_4200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1214      let TAG = 'RunningLockTest_4200';
1215      try {
1216        let isSupported = runningLock.isSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL);
1217        console.info(`${TAG} isSupported: ${isSupported}`);
1218        expect(isSupported).assertTrue();
1219        done();
1220      } catch (error) {
1221        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1222        expect().assertFail();
1223        done();
1224      }
1225    })
1226
1227    /**
1228     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0430
1229     * @tc.name testRunningLockTest_4300
1230     * @tc.desc Checks whether the specified RunningLockType is supported.
1231     * @tc.level: Level 3
1232     * @tc.type: Function
1233     * @tc.size: MediumTest
1234     */
1235    it('RunningLockTest_4300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1236      let TAG = 'RunningLockTest_4300';
1237      try {
1238        let isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND - 1);
1239        console.info(`${TAG} isSupported: ${isSupported}`);
1240        expect(isSupported).assertFalse();
1241        done();
1242      } catch (error) {
1243        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1244        expect().assertFail();
1245        done();
1246      }
1247    })
1248
1249    /**
1250     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0440
1251     * @tc.name testRunningLockTest_4400
1252     * @tc.desc Checks whether the specified RunningLockType is supported.
1253     * @tc.level: Level 3
1254     * @tc.type: Function
1255     * @tc.size: MediumTest
1256     */
1257    it('RunningLockTest_4400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1258      let TAG = 'RunningLockTest_4400';
1259      try {
1260        let isSupported = runningLock.isSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL + 1);
1261        console.info(`${TAG} isSupported: ${isSupported}`);
1262        expect(isSupported).assertFalse();
1263        done();
1264      } catch (error) {
1265        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1266        expect().assertFail();
1267        done();
1268      }
1269    })
1270
1271    /**
1272     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0450
1273     * @tc.name testRunningLockTest_4500
1274     * @tc.desc Checks whether the specified RunningLockType is supported.
1275     * @tc.level: Level 3
1276     * @tc.type: Function
1277     * @tc.size: MediumTest
1278     */
1279    it('RunningLockTest_4500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1280      let TAG = 'RunningLockTest_4500';
1281      try {
1282        let isSupported = runningLock.isSupported('PROXIMITY_SCREEN_CONTROL');
1283        console.info(`${TAG} isSupported: ${isSupported}`);
1284        expect(isSupported).assertUndefined();
1285        done();
1286      } catch (error) {
1287        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1288        expect(error.code).assertEqual(401);
1289        done();
1290      }
1291    })
1292
1293    /**
1294     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0460
1295     * @tc.name testRunningLockTest_4600
1296     * @tc.desc Checks whether the specified RunningLockType is supported.
1297     * @tc.level: Level 3
1298     * @tc.type: Function
1299     * @tc.size: MediumTest
1300     */
1301    it('RunningLockTest_4600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1302      let TAG = 'RunningLockTest_4600';
1303      try {
1304        let isSupported = runningLock.isSupported(true);
1305        console.info(`${TAG} isSupported: ${isSupported}`);
1306        expect(isSupported).assertUndefined();
1307        done();
1308      } catch (error) {
1309        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1310        expect(error.code).assertEqual(401);
1311        done();
1312      }
1313    })
1314
1315    /**
1316     * @tc.number SUB_PowerSystem_RunningLock_JSTest_0470
1317     * @tc.name testRunningLockTest_4700
1318     * @tc.desc Checks whether the specified RunningLockType is supported.
1319     * @tc.level: Level 3
1320     * @tc.type: Function
1321     * @tc.size: MediumTest
1322     */
1323    it('RunningLockTest_4700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
1324      let TAG = 'RunningLockTest_4700';
1325      try {
1326        let isSupported = runningLock.isSupported({
1327          type: runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL
1328        });
1329        console.info(`${TAG} isSupported: ${isSupported}`);
1330        expect(isSupported).assertUndefined();
1331        done();
1332      } catch (error) {
1333        console.error(`${TAG} error: ${JSON.stringify(error)}`);
1334        expect(error.code).assertEqual(401);
1335        done();
1336      }
1337    })
1338  })
1339}
1340