提交 9fc4f2a8 编写于 作者: Z zhaoruiyuan

feat: add performance test

Signed-off-by: Nzhaoruiyuan <zhaoruiyuan2@huawei.com>
上级 93d6843a
......@@ -15,4 +15,5 @@
require('./battery_unit.test.js')
require('./battery_common_event.test.js')
require('./power_manager_running_lock.test.js')
require('./system_battery.test.js')
\ No newline at end of file
require('./system_battery.test.js')
require('./batterymanager_performance.test.js')
\ No newline at end of file
+137/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
/*
* Copyright (C) 2022 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
......@@ -20,374 +20,374 @@ import brightness from '@ohos.brightness';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('appInfoTest', function () {
console.log("*************Battery Unit Test Begin*************");
/**
* @tc.number battery_manager_js_0100
* @tc.name battery_soc_test
* @tc.desc Battery acquisition kit
*/
it('battery_soc_test', 0, function () {
let batterySoc = batteryInfo.batterySOC;
console.info('batterySoc = ' + batterySoc);
expect(batterySoc >= -1 && batterySoc <= 100).assertTrue()
})
/**
* @tc.number battery_manager_js_0200
* @tc.name charging_status_test
* @tc.desc Battery charging kit
*/
it('charging_status_test', 0, function () {
let chargingStatus = batteryInfo.chargingStatus;
console.info('chargingStatus = ' + chargingStatus);
expect(chargingStatus >= 0 && chargingStatus <= 4).assertTrue()
})
/**
* @tc.number battery_manager_js_0300
* @tc.name health_status_test
* @tc.desc Get Battery Health Get KIT
*/
it('health_status_test', 0, function () {
let healthStatus = batteryInfo.healthStatus;
console.info('healthStatus = ' + healthStatus);
expect(healthStatus >= 0 && healthStatus <= 6).assertTrue()
})
/**
* @tc.number battery_manager_js_0400
* @tc.name plugged_type_test
* @tc.desc Obtaining the USB Connection Type KIT
*/
it('plugged_type_test', 0, function () {
let pluggedType = batteryInfo.pluggedType;
console.info('pluggedType = ' + pluggedType);
expect(pluggedType >= 0 && pluggedType <= 4).assertTrue()
})
/**
* @tc.number battery_manager_js_0500
* @tc.name voltage_test
* @tc.desc Obtaining the Voltage Interface KIT
*/
it('voltage_test', 0, function () {
let voltage = batteryInfo.voltage;
console.info('voltage = ' + voltage);
expect(voltage >= -1).assertTrue()
})
/**
* @tc.number battery_manager_js_0600
* @tc.name technology_test
* @tc.desc Obtaining the Battery Technology Interface KIT
*/
it('technology_test', 0, function () {
let technology = batteryInfo.technology;
console.info('technology = ' + technology);
expect(technology !== null).assertTrue()
})
/**
* @tc.number battery_manager_js_0700
* @tc.name battery_temperature_test
* @tc.desc BatteryTemperature values Interface Test
*/
it('battery_temperature_test', 0, function () {
let batteryTemperature = batteryInfo.batteryTemperature;
console.info('batteryTemperature = ' + batteryTemperature);
expect(batteryTemperature <= 700).assertTrue()
})
/**
* @tc.number battery_manager_js_0800
* @tc.name enum_health_state_test_unknown
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_unknown', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.UNKNOWN;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 0).assertTrue()
})
/**
* @tc.number battery_manager_js_0900
* @tc.name enum_health_state_test_good
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_good', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.GOOD;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 1).assertTrue()
})
/**
* @tc.number battery_manager_js_1000
* @tc.name enum_health_state_test_overheat
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_overheat', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.OVERHEAT;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 2).assertTrue()
})
/**
* @tc.number battery_manager_js_1100
* @tc.name enum_health_state_test_overvoltage
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_overvoltage', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.OVERVOLTAGE;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 3).assertTrue()
})
/**
* @tc.number battery_manager_js_1200
* @tc.name enum_health_state_test_cold
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_cold', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.COLD;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 4).assertTrue()
})
/**
* @tc.number battery_manager_js_1300
* @tc.name enum_health_state_test_dead
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_dead', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.DEAD;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 5).assertTrue()
})
/**
* @tc.number battery_manager_js_1400
* @tc.name enum_charge_state_test_none
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_none', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.NONE;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 0).assertTrue()
})
/**
* @tc.number battery_manager_js_1500
* @tc.name enum_charge_state_test_enable
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_enable', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.ENABLE;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 1).assertTrue()
})
/**
* @tc.number battery_manager_js_1600
* @tc.name enum_charge_state_test_disable
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_disable', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.DISABLE;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 2).assertTrue()
})
/**
* @tc.number battery_manager_js_1700
* @tc.name enum_charge_state_test_full
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_full', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.FULL;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 3).assertTrue()
})
/**
* @tc.number battery_manager_js_1800
* @tc.name enum_plugged_type_test_none
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_none', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.NONE;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 0).assertTrue()
})
/**
* @tc.number battery_manager_js_1900
* @tc.name enum_plugged_type_test_ac
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_ac', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.AC;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 1).assertTrue()
})
/**
* @tc.number battery_manager_js_2000
* @tc.name enum_plugged_type_test_usb
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_usb', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.USB;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 2).assertTrue()
})
/**
* @tc.number battery_manager_js_2100
* @tc.name enum_plugged_type_test_wireless
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_wireless', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.WIRELESS;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 3).assertTrue()
})
/**
* @tc.number battery_manager_js_2200
* @tc.name brightness_test
* @tc.desc Set Value Interface Test
*/
it('brightness_test', 0, function () {
brightness.setValue(10);
brightness.setValue(0);
brightness.setValue(255);
expect(0 == 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2300
* @tc.name is_battery_present_test
* @tc.desc Battry Present Interface Test
*/
it('is_battery_present_test', 0, function () {
let isBatteryPresent = batteryInfo.isBatteryPresent;
console.info('isBatteryPresent = ' + isBatteryPresent);
if (isBatteryPresent) {
expect(isBatteryPresent).assertTrue();
} else {
expect(isBatteryPresent).assertFalse();
}
})
/**
* @tc.number battery_manager_js_2400
* @tc.name nowCurrent_test
* @tc.desc Battry Present Interface Test
*/
it('nowCurrent_test', 0, function () {
let nowCurrent = batteryInfo.nowCurrent;
console.info('nowCurrent = ' + nowCurrent);
expect(nowCurrent >= 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2500
* @tc.name remainingEnergy_test
* @tc.desc Battry Present Interface Test
*/
it('remainingEnergy_test', 0, function () {
let remainingEnergy = batteryInfo.remainingEnergy;
console.info('remEnergy = ' + remainingEnergy);
expect(remainingEnergy >= 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2600
* @tc.name totalEnergy_test
* @tc.desc Battry Present Interface Test
*/
it('totalEnergy_test', 0, function () {
let totalEnergy = batteryInfo.totalEnergy;
console.info('totalenergy = ' + totalEnergy);
expect(totalEnergy >= 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2700
* @tc.name batterylevel_test
* @tc.desc Battry Present Interface Test
*/
it('batterylevel_test', 0, function () {
let batteryLevel = batteryInfo.batteryCapacityLevel;
console.info('batteryLevel = ' + batteryLevel);
expect(batteryLevel >= batteryInfo.BatteryCapacityLevel.LEVEL_NONE &&
batteryLevel <= batteryInfo.BatteryCapacityLevel.LEVEL_CRITICAL).assertTrue();
})
/**
* @tc.number battery_manager_js_2800
* @tc.name enum_level_state_test_none
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_none', 0, function () {
let batterylevelState = batteryInfo.BatteryCapacityLevel.LEVEL_NONE;
console.info('batterylevelState = ' + batterylevelState);
expect(batterylevelState == 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2900
* @tc.name enum_level_state_test_full
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_full', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_FULL;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 1).assertTrue();
})
/**
* @tc.number battery_manager_js_3000
* @tc.name enum_level_state_test_high
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_high', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_HIGH;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 2).assertTrue();
})
/**
* @tc.number battery_manager_js_3100
* @tc.name enum_level_state_test_normal
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_normal', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_NORMAL;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 3).assertTrue();
})
/**
* @tc.number battery_manager_js_3200
* @tc.name enum_level_state_test_low
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_low', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_LOW;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 4).assertTrue();
})
/**
* @tc.number battery_manager_js_3300
* @tc.name enum_level_state_test_emergency
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_emergency', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_CRITICAL;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 5).assertTrue();
})
})
\ No newline at end of file
console.log("*************Battery Unit Test Begin*************");
/**
* @tc.number battery_manager_js_0100
* @tc.name battery_soc_test
* @tc.desc Battery acquisition kit
*/
it('battery_soc_test', 0, function () {
let batterySoc = batteryInfo.batterySOC;
console.info('batterySoc = ' + batterySoc);
expect(batterySoc >= -1 && batterySoc <= 100).assertTrue()
})
/**
* @tc.number battery_manager_js_0200
* @tc.name charging_status_test
* @tc.desc Battery charging kit
*/
it('charging_status_test', 0, function () {
let chargingStatus = batteryInfo.chargingStatus;
console.info('chargingStatus = ' + chargingStatus);
expect(chargingStatus >= 0 && chargingStatus <= 4).assertTrue()
})
/**
* @tc.number battery_manager_js_0300
* @tc.name health_status_test
* @tc.desc Get Battery Health Get KIT
*/
it('health_status_test', 0, function () {
let healthStatus = batteryInfo.healthStatus;
console.info('healthStatus = ' + healthStatus);
expect(healthStatus >= 0 && healthStatus <= 6).assertTrue()
})
/**
* @tc.number battery_manager_js_0400
* @tc.name plugged_type_test
* @tc.desc Obtaining the USB Connection Type KIT
*/
it('plugged_type_test', 0, function () {
let pluggedType = batteryInfo.pluggedType;
console.info('pluggedType = ' + pluggedType);
expect(pluggedType >= 0 && pluggedType <= 4).assertTrue()
})
/**
* @tc.number battery_manager_js_0500
* @tc.name voltage_test
* @tc.desc Obtaining the Voltage Interface KIT
*/
it('voltage_test', 0, function () {
let voltage = batteryInfo.voltage;
console.info('voltage = ' + voltage);
expect(voltage >= -1).assertTrue()
})
/**
* @tc.number battery_manager_js_0600
* @tc.name technology_test
* @tc.desc Obtaining the Battery Technology Interface KIT
*/
it('technology_test', 0, function () {
let technology = batteryInfo.technology;
console.info('technology = ' + technology);
expect(technology !== null).assertTrue()
})
/**
* @tc.number battery_manager_js_0700
* @tc.name battery_temperature_test
* @tc.desc BatteryTemperature values Interface Test
*/
it('battery_temperature_test', 0, function () {
let batteryTemperature = batteryInfo.batteryTemperature;
console.info('batteryTemperature = ' + batteryTemperature);
expect(batteryTemperature <= 700).assertTrue()
})
/**
* @tc.number battery_manager_js_0800
* @tc.name enum_health_state_test_unknown
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_unknown', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.UNKNOWN;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 0).assertTrue()
})
/**
* @tc.number battery_manager_js_0900
* @tc.name enum_health_state_test_good
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_good', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.GOOD;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 1).assertTrue()
})
/**
* @tc.number battery_manager_js_1000
* @tc.name enum_health_state_test_overheat
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_overheat', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.OVERHEAT;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 2).assertTrue()
})
/**
* @tc.number battery_manager_js_1100
* @tc.name enum_health_state_test_overvoltage
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_overvoltage', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.OVERVOLTAGE;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 3).assertTrue()
})
/**
* @tc.number battery_manager_js_1200
* @tc.name enum_health_state_test_cold
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_cold', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.COLD;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 4).assertTrue()
})
/**
* @tc.number battery_manager_js_1300
* @tc.name enum_health_state_test_dead
* @tc.desc BatteryHealthState values Interface Test
*/
it('enum_health_state_test_dead', 0, function () {
let batteryHealthState = batteryInfo.BatteryHealthState.DEAD;
console.info('batteryHealthState = ' + batteryHealthState);
expect(batteryHealthState == 5).assertTrue()
})
/**
* @tc.number battery_manager_js_1400
* @tc.name enum_charge_state_test_none
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_none', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.NONE;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 0).assertTrue()
})
/**
* @tc.number battery_manager_js_1500
* @tc.name enum_charge_state_test_enable
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_enable', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.ENABLE;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 1).assertTrue()
})
/**
* @tc.number battery_manager_js_1600
* @tc.name enum_charge_state_test_disable
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_disable', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.DISABLE;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 2).assertTrue()
})
/**
* @tc.number battery_manager_js_1700
* @tc.name enum_charge_state_test_full
* @tc.desc BatteryChargeState values Interface Test
*/
it('enum_charge_state_test_full', 0, function () {
let batteryChargeState = batteryInfo.BatteryChargeState.FULL;
console.info('batteryChargeState = ' + batteryChargeState);
expect(batteryChargeState == 3).assertTrue()
})
/**
* @tc.number battery_manager_js_1800
* @tc.name enum_plugged_type_test_none
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_none', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.NONE;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 0).assertTrue()
})
/**
* @tc.number battery_manager_js_1900
* @tc.name enum_plugged_type_test_ac
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_ac', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.AC;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 1).assertTrue()
})
/**
* @tc.number battery_manager_js_2000
* @tc.name enum_plugged_type_test_usb
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_usb', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.USB;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 2).assertTrue()
})
/**
* @tc.number battery_manager_js_2100
* @tc.name enum_plugged_type_test_wireless
* @tc.desc BatteryPluggedType values Interface Test
*/
it('enum_plugged_type_test_wireless', 0, function () {
let batteryPluggedType = batteryInfo.BatteryPluggedType.WIRELESS;
console.info('batteryPluggedType = ' + batteryPluggedType);
expect(batteryPluggedType == 3).assertTrue()
})
/**
* @tc.number battery_manager_js_2200
* @tc.name brightness_test
* @tc.desc Set Value Interface Test
*/
it('brightness_test', 0, function () {
brightness.setValue(10);
brightness.setValue(0);
brightness.setValue(255);
expect(0 == 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2300
* @tc.name is_battery_present_test
* @tc.desc Battry Present Interface Test
*/
it('is_battery_present_test', 0, function () {
let isBatteryPresent = batteryInfo.isBatteryPresent;
console.info('isBatteryPresent = ' + isBatteryPresent);
if (isBatteryPresent) {
expect(isBatteryPresent).assertTrue();
} else {
expect(isBatteryPresent).assertFalse();
}
})
/**
* @tc.number battery_manager_js_2400
* @tc.name nowCurrent_test
* @tc.desc Battry Present Interface Test
*/
it('nowCurrent_test', 0, function () {
let nowCurrent = batteryInfo.nowCurrent;
console.info('nowCurrent = ' + nowCurrent);
expect(nowCurrent >= 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2500
* @tc.name remainingEnergy_test
* @tc.desc Battry Present Interface Test
*/
it('remainingEnergy_test', 0, function () {
let remainingEnergy = batteryInfo.remainingEnergy;
console.info('remEnergy = ' + remainingEnergy);
expect(remainingEnergy >= 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2600
* @tc.name totalEnergy_test
* @tc.desc Battry Present Interface Test
*/
it('totalEnergy_test', 0, function () {
let totalEnergy = batteryInfo.totalEnergy;
console.info('totalenergy = ' + totalEnergy);
expect(totalEnergy >= 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2700
* @tc.name batterylevel_test
* @tc.desc Battry Present Interface Test
*/
it('batterylevel_test', 0, function () {
let batteryLevel = batteryInfo.batteryCapacityLevel;
console.info('batteryLevel = ' + batteryLevel);
expect(batteryLevel >= batteryInfo.BatteryCapacityLevel.LEVEL_NONE &&
batteryLevel <= batteryInfo.BatteryCapacityLevel.LEVEL_CRITICAL).assertTrue();
})
/**
* @tc.number battery_manager_js_2800
* @tc.name enum_level_state_test_none
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_none', 0, function () {
let batterylevelState = batteryInfo.BatteryCapacityLevel.LEVEL_NONE;
console.info('batterylevelState = ' + batterylevelState);
expect(batterylevelState == 0).assertTrue();
})
/**
* @tc.number battery_manager_js_2900
* @tc.name enum_level_state_test_full
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_full', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_FULL;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 1).assertTrue();
})
/**
* @tc.number battery_manager_js_3000
* @tc.name enum_level_state_test_high
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_high', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_HIGH;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 2).assertTrue();
})
/**
* @tc.number battery_manager_js_3100
* @tc.name enum_level_state_test_normal
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_normal', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_NORMAL;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 3).assertTrue();
})
/**
* @tc.number battery_manager_js_3200
* @tc.name enum_level_state_test_low
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_low', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_LOW;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 4).assertTrue();
})
/**
* @tc.number battery_manager_js_3300
* @tc.name enum_level_state_test_emergency
* @tc.desc Battry Present Interface Test
*/
it('enum_level_state_test_emergency', 0, function () {
let batteryLevelState = batteryInfo.BatteryCapacityLevel.LEVEL_CRITICAL;
console.info('batteryLevelState = ' + batteryLevelState);
expect(batteryLevelState == 5).assertTrue();
})
})
/*
* Copyright (C) 2022 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 batteryInfo from '@ohos.batteryInfo';
import {describe, it, expect} from 'deccjsunit/index';
describe('appInfoTest', function () {
console.log("*************Edited Battery Performance Test Begin*************");
const MAXNUM = 1000;
const MS_TO_US = 1000;
const LIMIT_TIME = 1000;
const HEALTH_LIMIT_TIME = 350;
/**
* @tc.number BatteryPerformance_001
* @tc.name battery_temperature_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_001', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.batteryTemperature;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BATTERY_Performance_001: Promise: batteryInfo.batteryTemperature Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_002
* @tc.name battery_chargingstatus_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_002', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.chargingStatus;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BATTERY_Performance_002: Promise: batteryInfo.chargingStatus Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_003
* @tc.name battery_healthstatus_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_003', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.healthStatus;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_003: Promise: batteryInfo.healthStatus Average Time : ${waitTime}`);
avgTime < HEALTH_LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_004
* @tc.name battery_pluggedtype_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_004', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.pluggedType;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_004: Promise: batteryInfo.pluggedType Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_005
* @tc.name battery_technology_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_005', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.technology;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_005: Promise: batteryInfo.technology Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_006
* @tc.name battery_capacity_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_006', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.batterySOC;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_006: Promise: batteryInfo.batterySOC Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_007
* @tc.name battery_voltage_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_007', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.voltage;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_007: Promise: batteryInfo.voltage Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_008
* @tc.name is_battery_present_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_008', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.isBatteryPresent;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_008: Promise: batteryInfo.isBatteryPresent Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_009
* @tc.name battery_capacity_level_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_009', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.batteryCapacityLevel;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_009: Promise: batteryInfo.batteryCapacityLevel Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_010
* @tc.name estimated_remaining_chargeTime_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_010', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.estimatedRemainingChargeTime;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_010: Promise: batteryInfo.estimatedRemainingChargeTime
Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_011
* @tc.name total_energy_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_011', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.totalEnergy;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_011: Promise: batteryInfo.totalEnergy Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_012
* @tc.name now_current_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_012', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.nowCurrent;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_012: Promise: batteryInfo.nowCurrent Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_013
* @tc.name remaining_energy_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_013', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.remainingEnergy;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_013: Promise: batteryInfo.remainingEnergy Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
})
......@@ -14,3 +14,4 @@
*/
require('./power_manager_running_lock.test.js')
require('./power_manager_power.test.js')
require('./power_performance_test.js')
/*
* Copyright (C) 2022 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 runningLock from '@ohos.runningLock';
import power from '@ohos.power';
import brightness from '@ohos.brightness';
import {describe, it, expect} from 'deccjsunit/index';
describe('appInfoTest', function () {
console.log("*************Power Performance Test Begin*************");
const MAXNUM = 1000;
const MIDNUM =100;
const MS_TO_US = 1000;
const LIMIT_TIME = 1500;
const LIMIT_TIME_LONG = 4000;
/**
* @tc.number PowerPerformance_001
* @tc.name createRunningLock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_001', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MIDNUM; i++) {
await runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MIDNUM * MS_TO_US; //us
console.info(`POWER_Performance_001: Promise: runningLock.createRunningLock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME_LONG ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_002
* @tc.name isUsed_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_002', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.isUsed();
}
let waitTime = new Date().getTime() - startTime;
avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_002: Promise: runningLock.isUsed Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
} else {
console.log('PowerPerformance_002: ' + error);
console.info('PowerPerformance_002: isUsed is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_003
* @tc.name lock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_003', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.lock(500);
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_003: Promise: runningLock.lock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
runningLock.unlock();
done();
} else {
console.log('PowerPerformance_003: ' + error);
console.info('PowerPerformance_003: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_004
* @tc.name unlock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_004', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
runningLock.lock(500);
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.unlock();
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_004: Promise: runningLock.unlock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
} else {
console.log('PowerPerformance_004: ' + error);
console.info('PowerPerformance_004: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_005
* @tc.name isProximitySupported_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_005', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_005: Promise: await runningLock.isRunningLockTypeSupported Wait Time :
${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_006
* @tc.name isScreenOn_test
* @tc.desc AsyncCallback<boolean> judge whether the screen is lit and return to true
*/
it('PowerPerformance_006', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await power.isScreenOn()
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_006: Promise: await power.isScreenOn Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_007
* @tc.name setValue_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_007', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
brightness.setValue(100);
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_007: Promise: brightness.setValue Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
})
......@@ -14,6 +14,7 @@
*/
require('./WorkScheduler.test.js')
require('./WorkSchedulerJs.performance.js')
......
/*
* Copyright (C) 2022 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 workscheduler from '@ohos.workScheduler'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe("WorkSchedulerJsTest", function () {
console.log("**********WorkScheduler Performance Test Begin**********")
performanceStartWork()
performanceStopWork()
performanceGetWorkStatusCallback()
performanceGetWorkStatusPromise()
performanceObtainAllWorksCallback()
performanceObtainAllWorksPromise()
performanceIsLastWorkTimeOutCallback()
performanceIsLastWorkTimeOutPromise()
performanceStopAndClearWorks()
console.log("**********WorkScheduler Performance Test End**********")
})
function performanceStartWork() {
it('WorkSchedulerPerformance_001', 0, async function(done) {
let totalTime = 0
let workInfo = {
workId: 201,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.startWork(workInfo)
totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_001: startWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceStopWork() {
it('WorkSchedulerPerformance_002', 0, async function(done) {
let totalTime = 0
let workingInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workingInfo)
let workInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.stopWork(workInfo, false)
totalTime= new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_002: stopWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceGetWorkStatusCallback() {
it('WorkSchedulerPerformance_003', 0, async function(done) {
let workInfo = {
workId: 203,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.getWorkStatus(203, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_003: getWorkStatus callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceGetWorkStatusPromise() {
it('WorkSchedulerPerformance_004', 0, async function(done) {
let workInfo = {
workId: 204,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
startTime = new Date().getTime()
await workscheduler.getWorkStatus(204)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_004: getWorkStatus promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceObtainAllWorksCallback() {
it('WorkSchedulerPerformance_005', 0, async function(done) {
let workInfo = {
workId: 205,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks((err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_005: obtainAllWorks callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceObtainAllWorksPromise() {
it('WorkSchedulerPerformance_006', 0, async function(done) {
let workInfo = {
workId: 206,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks()
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_006: obtainAllWorks promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceIsLastWorkTimeOutCallback() {
it('WorkSchedulerPerformance_007', 0, async function(done) {
let workInfo = {
workId: 207,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(207, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_007: isLastWorkTimeOut callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceIsLastWorkTimeOutPromise() {
it('WorkSchedulerPerformance_008', 0, async function(done) {
let workInfo = {
workId: 208,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(208)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_008: isLastWorkTimeOut promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceStopAndClearWorks() {
it('WorkSchedulerPerformance_009', 0, function() {
let workInfo = {
workId: 209,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
workscheduler.stopAndClearWorks()
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_009: stopAndClearWorks WaitTime: ' + totalTime + 'ms')
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册