From 8dee81b74c78d0a8a998ff26da482fdcbdbe1939 Mon Sep 17 00:00:00 2001 From: yangziyong Date: Fri, 5 May 2023 19:01:35 +0800 Subject: [PATCH] feat: support suspend immediately Signed-off-by: yangziyong --- .../src/main/js/test/List.test.js | 2 + .../test/power_manager_forcesuspend.test.js | 38 ++++++++++++++++ .../main/js/test/power_manager_power.test.js | 45 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 powermgr/power_manager/src/main/js/test/power_manager_forcesuspend.test.js diff --git a/powermgr/power_manager/src/main/js/test/List.test.js b/powermgr/power_manager/src/main/js/test/List.test.js index 44e6983f3..a3b9ed6a8 100644 --- a/powermgr/power_manager/src/main/js/test/List.test.js +++ b/powermgr/power_manager/src/main/js/test/List.test.js @@ -16,9 +16,11 @@ import powerManagerPowerTest from './power_manager_power.test.js' import powerManagerRebootShutTest from './power_manager_rebootshut.test.js' import powerManagerRunningLockTest from './power_manager_running_lock.test.js' import powerPerformanceTest from './power_performance.test.js' +import powerManagerSuspendTest from './power_manager_forcesuspend.test.js' export default function testsuite() { powerManagerPowerTest() //powerManagerRebootShutTest() powerManagerRunningLockTest() //powerPerformanceTest() + //powerManagerSuspendTest() } diff --git a/powermgr/power_manager/src/main/js/test/power_manager_forcesuspend.test.js b/powermgr/power_manager/src/main/js/test/power_manager_forcesuspend.test.js new file mode 100644 index 000000000..ef287f11d --- /dev/null +++ b/powermgr/power_manager/src/main/js/test/power_manager_forcesuspend.test.js @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import power from '@ohos.power'; + +import { describe, it, expect } from '@ohos/hypium' + +export default function powerManagerSuspendTest() { +describe('powerManagerSuspendTest', function () { + console.log("*************Power Suspend Unit Test Begin*************"); + + /** + * @tc.number power_js_001 + * @tc.name power_Suspend_Device_JSTest001 + * @tc.desc Device reboot interface verification + */ + it('power_Suspend_Device_JSTest001', 0, async function (done) { + console.info('forcesuspend start'); + power.wakeupDevice("power_Suspend_Device_JSTest001"); + power.suspend(true); + let isScreenOn = await power.isScreenOn(); + console.info('power_Suspend_Device_JSTest001' + isScreenOn); + expect(isScreenOn).assertFalse(); + done(); + }) +})} diff --git a/powermgr/power_manager/src/main/js/test/power_manager_power.test.js b/powermgr/power_manager/src/main/js/test/power_manager_power.test.js index b893b73f7..1130d41c5 100644 --- a/powermgr/power_manager/src/main/js/test/power_manager_power.test.js +++ b/powermgr/power_manager/src/main/js/test/power_manager_power.test.js @@ -141,5 +141,50 @@ describe('PowerManagerPowerTest', function () { console.info('MODE_EXTREME_POWER_SAVE = ' + devicePowerMode); expect(devicePowerMode === 603).assertTrue(); }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0091 + * @tc.name power_Suspend_Device_JSTest091 + * @tc.desc Device suspend interface verification + */ + it('power_Suspend_Device_JSTest091', 0, async function (done) { + power.wakeupDevice("power_Suspend_Device_JSTest091"); + power.suspend(undefined); + let isScreenOn = await power.isScreenOn(); + console.info('power_Suspend_Device_JSTest091 ' + isScreenOn); + expect(isScreenOn).assertFalse(); + console.info('suspend success done'); + done(); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0092 + * @tc.name power_Suspend_Device_JSTest092 + * @tc.desc Device suspend interface verification + */ + it('power_Suspend_Device_JSTest092', 0, async function (done) { + power.wakeupDevice("power_Suspend_Device_JSTest092"); + power.suspend(); + let isScreenOn = await power.isScreenOn(); + console.info('power_Suspend_Device_JSTest092 ' + isScreenOn); + expect(isScreenOn).assertFalse(); + console.info('suspend success done'); + done(); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0093 + * @tc.name power_Suspend_Device_JSTest093 + * @tc.desc Device suspend interface verification + */ + it('power_Suspend_Device_JSTest093', 0, async function (done) { + power.wakeupDevice("power_Suspend_Device_JSTest093"); + power.suspend(false); + let isScreenOn = await power.isScreenOn(); + console.info('power_Suspend_Device_JSTest093 ' + isScreenOn); + expect(isScreenOn).assertFalse(); + console.info('suspend success done'); + done(); + }) }) } -- GitLab