From 1fa1aca1d8b7bacf87d7bdc23dbd34dae21112ba Mon Sep 17 00:00:00 2001 From: qiuxiangdong Date: Fri, 18 Nov 2022 14:51:24 +0800 Subject: [PATCH] test: add create runninglock invalid case Signed-off-by: qiuxiangdong Change-Id: I7680edff91642cf3075762728397a5b8a1cf242c --- .../test/power_manager_running_lock.test.js | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js b/powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js index da233a5db..5390acca2 100644 --- a/powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js +++ b/powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js @@ -305,12 +305,31 @@ describe('PowerManagerRunningLockTest', function () { done(); }) + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0140 + * @tc.name Create_Running_Lock_Promise_Invalid_JSTest0130 + * @tc.desc Create lock input invalid value + */ + it('Create_Running_Lock_Promise_Invalid_JSTest0130', 0, async function (done) { + try { + runningLock.create(0, runningLock.RunningLockType.BACKGROUND) + .then((runninglock) => { + expect().assertFail(); + }) + } catch (e) { + console.info('Create_Running_Lock_Promise_Invalid_JSTest0130 code:' + e.code + "msg:" + e.message); + // 401: Invalid input parameter + expect(e.code === 401).assertTrue(); + } + done(); + }) + /** * @tc.number SUB_PowerSystem_PowerManager_JSTest_0140 * @tc.name Create_Running_Lock_Callback_JSTest0140 * @tc.desc Create lock callback */ - it('Create_Running_Lock_Callback_JSTest0140', 0, async function (done) { + it('Create_Running_Lock_Callback_JSTest0140', 0, async function (done) { try { runningLock.create("Create_Running_Lock_Callback_JSTest0140", runningLock.RunningLockType.BACKGROUND, (error, runninglock) => { @@ -324,5 +343,24 @@ describe('PowerManagerRunningLockTest', function () { } done(); }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0150 + * @tc.name Create_Running_Lock_Callback_JSTest0150 + * @tc.desc Create lock input invalid value + */ + it('Create_Running_Lock_Callback_Invalid_JSTest0150', 0, async function (done) { + try { + runningLock.create("Create_Running_Lock_Callback_Invalid_JSTest0150", "invalid", + (error, runninglock) => { + expect().assertFail(); + }); + } catch (e) { + console.info('Create_Running_Lock_Callback_Invalid_JSTest0150 code:' + e.code + "msg:" + e.message); + // 401: Invalid input parameter + expect(e.code === 401).assertTrue(); + } + done(); + }) }) } -- GitLab