提交 296b5c12 编写于 作者: Y yu.xu

Modify thermal xts

Signed-off-by: Nyu.xu <yu.xu@neusoft.com>
上级 70adb131
......@@ -15,7 +15,10 @@ group("powermgr") {
testonly = true
if (device_name == "rk3568") {
if (is_standard_system) {
deps = [ "powermgrbattery_rk3568:powermgr_battery_test_rk3568" ]
deps = [
"powermgrbattery_rk3568:powermgr_battery_test_rk3568",
"powermgrthermal:powermgr_thermal_test",
]
}
} else {
if (is_standard_system) {
......
# 热管理服务XTS
- [描述](#section0056945901)
## 描述<a name="section0056945901"></a>
### 执行性能测试(thermal_common_event.test.js), 单元测试用例(thermal_unittest.test.js)和接收公共事件用例(thermal_common_event.test.js)前, 请手动执行temp.sh
步骤:
$ hdc_std file send temp.sh /data
$ sh temp.sh
......@@ -2,9 +2,9 @@
"description": "Configuration for powermgr thermal Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"test-timeout": "120000",
"package": "com.example.mythermalapp",
"shell-timeout": "60000"
"shell-timeout": "120000"
},
"kits": [
{
......
......@@ -12,31 +12,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import device from '@system.device';
import app from '@system.app'
import {Core, ExpectExtend} from 'deccjsunit/index'
const core = Core.getInstance();
core.init()
require('../../test/List.test')
core.execute()
export default {
data: {
title: "world",
width:0,
height: 0
title: ""
},
onInit() {
device.getInfo({
success:(data) =>{
this.width = data.windowWidth;
this.height = data.windowHeight;
}
});
}
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* 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 commonEvent from '@ohos.commonEvent';
import thermal from "@ohos.thermal"
describe('appInfoTest', function () {
console.log("*************Thermal commonEvent Test Begin*************");
/**
* @tc.number ThermalCommonEventTest_001
* @tc.name subscribe thermal level changed common event
* @tc.desc Thermal acquisition kit
*/
it('ThermalCommonEventTest_001', 0, function (done) {
createSubscriber();
done();
})
console.log("*************Thermal commonEvent Test End*************");
})
function createSubscriber() {
var commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_THERMAL_LEVEL_CHANGED],
};
commonEvent.createSubscriber(commonEventSubscribeInfo)
.then(subscriber => {
console.info('createSubscriber success');
var mySubscriber = subscriber;
console.log(subscriber);
if (subscriber == "" || subscriber == undefined || subscriber == null) {
console.info("createSubscriber failed");
}
mySubscriber.getCode()
.then((data) => {
console.info('Subscriber getCode success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getCode error because: ' + JSON.stringify(error));
})
mySubscriber.getData()
.then((data) => {
console.info('Subscriber getData success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getData error because: ' + JSON.stringify(error));
})
console.info('subscribe begin ');
commonEvent.subscribe(mySubscriber, (error, commonEventData) => {
console.error('err code: ' + JSON.stringify(error));
console.info('subscribe callback: ' + JSON.stringify(commonEventData));
console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]);
var level = -1;
expect(level >= thermal.ThermalLevel.COOL && warm <= level.ThermalLevel.EMERGENCY).assertTrue();
});
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
}
\ No newline at end of file
/*
* 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 thermal from "@ohos.thermal"
import {describe, it, expect} from 'deccjsunit/index';
describe('appInfoTest', function () {
console.log("*************Thermal Performance Test Begin*************");
performanceTest1();
performanceTest2();
performanceTest3();
console.log("*************Thermal Performance Test End*************");
})
function performanceTest1() {
var MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_001
* @tc.name test get thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_001', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
var level = thermal.getThermalLevel();
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_001: Promise: getlevel Wait Time : ${waitTime}`);
})
}
function performanceTest2() {
var MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_002
* @tc.name subscribe thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_002', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
thermal.subscribeThermalLevel((level) => {
console.info("hot level is: " + level);
})
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_002: Promise: subscribeThermalLevel Wait Time : ${waitTime}`);
})
}
function performanceTest3() {
var MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_002
* @tc.name subscribe thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_003', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
thermal.unsubscribeThermalLevel();
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_003: Promise: unsubscribeThermalLevel Wait Time : ${waitTime}`);
})
}
\ No newline at end of file
// @ts-nocheck
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -20,7 +21,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('appInfoTest', function () {
console.log("*************Thermal API Test Begin*************");
const MSEC_1000 = 1000;
test1();
test2();
test3();
......@@ -34,9 +34,11 @@ describe('appInfoTest', function () {
test11();
test12();
test13();
console.log("*************Thermal API Test End*************");
})
function test1() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_001
* @tc.name Thermal_001
......@@ -48,34 +50,36 @@ function test1() {
setTimeout(()=>{
var cold = thermal.getThermalLevel();
console.info("cold level is: " + cold);
expect(cold >= 0 && cold <= 6).assertTrue();
expect(cold >= thermal.ThermalLevel.COOL && cold <= thermal.ThermalLevel.EMERGENCY).assertTrue();
resolve();
}, MSEC_1000 * 4);
done();
}, MSEC_1000 * 1);
})
done();
})
}
function test2() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_002
* @tc.name Thermal_002
* @tc.desc Thermal acquisition kit
*/
it('Thermal_002', 0, async function (done) {
await new Promise((resolve, reject) => {
await new Promise((resolve, reject) =>{
setTimeout(()=>{
var warm = thermal.getThermalLevel();
console.info("warm level is: " + warm);
expect(warm >= 0 && warm <= 6).assertTrue();
expect(warm >= thermal.ThermalLevel.COOL && warm <= thermal.ThermalLevel.EMERGENCY).assertTrue();
resolve();
}, MSEC_1000 * 4);
done();
}, MSEC_1000 * 1);
})
done();
})
}
function test3() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_003
* @tc.name Thermal_003
......@@ -86,15 +90,16 @@ function test3() {
setTimeout(()=>{
var hot = thermal.getThermalLevel();
console.info("hot level is: " + hot);
expect(hot >= 0 && hot <= 6).assertTrue();
expect(hot >= thermal.ThermalLevel.COOL && hot <= thermal.ThermalLevel.EMERGENCY).assertTrue();
resolve();
}, MSEC_1000 * 4);
done();
}, MSEC_1000 * 1);
})
done();
})
}
function test4() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_004
* @tc.name Thermal_004
......@@ -105,15 +110,17 @@ function test4() {
setTimeout(()=>{
var overheated = thermal.getThermalLevel();
console.info("overheated level is: " + overheated);
expect(overheated >= 0 && overheated <= 6).assertTrue();
expect(overheated >= thermal.ThermalLevel.COOL &&
overheated <= thermal.ThermalLevel.EMERGENCY).assertTrue();
resolve();
}, MSEC_1000 * 4);
done();
}, MSEC_1000 * 1);
})
done();
})
}
function test5() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_005
* @tc.name Thermal_005
......@@ -124,15 +131,16 @@ function test5() {
setTimeout(()=>{
var warning = thermal.getThermalLevel();
console.info("warning level is: " + warning);
expect(warning >= 0 && warning <= 6).assertTrue();
expect(warning >= thermal.ThermalLevel.COOL && warning <= thermal.ThermalLevel.EMERGENCY).assertTrue();
resolve();
}, MSEC_1000 * 4);
done();
}, MSEC_1000 * 1);
})
done();
})
}
function test6() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_006
* @tc.name Thermal_006
......@@ -143,15 +151,17 @@ function test6() {
setTimeout(()=>{
var emergency = thermal.getThermalLevel();
console.info("emergency level is: " + emergency);
expect(emergency >= 0 && emergency <= 6).assertTrue();
expect(emergency >= thermal.ThermalLevel.COOL &&
emergency <= thermal.ThermalLevel.EMERGENCY).assertTrue();
resolve();
}, MSEC_1000 * 4);
done();
}, MSEC_1000 * 1);
})
done();
})
}
function test7() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_007
* @tc.name Thermal_007
......@@ -159,21 +169,23 @@ function test7() {
*/
it('Thermal_007', 0, async function (done) {
thermal.subscribeThermalLevel((cool) => {
console.info("cool level is: " + cool);
count ++;
expect(cool >= 0 && cool <= 6).assertTrue();
console.info("warm level is: " + cool);
expect(cool >= thermal.ThermalLevel.COOL && cool <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 4);
})
done();
})
}
function test8() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_008
* @tc.name Thermal_008
......@@ -181,20 +193,23 @@ function test8() {
*/
it('Thermal_008', 0, async function (done) {
thermal.subscribeThermalLevel((warm) => {
console.info("cool level is: " + warm);
expect(warm >= 0 && warm <= 6).assertTrue();
console.info("warm level is: " + warm);
expect(warm >= thermal.ThermalLevel.COOL && warm <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 4);
})
done();
})
}
function test9() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_009
* @tc.name Thermal_009
......@@ -203,20 +218,23 @@ function test9() {
it('Thermal_009', 0, async function (done) {
thermal.subscribeThermalLevel((hot) => {
console.info("hot level is: " + hot);
expect(hot >= 0 && hot <= 6).assertTrue();
expect(hot >= thermal.ThermalLevel.COOL && hot <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 2);
})
done();
})
}
function test10() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_010
* @tc.name Thermal_010
......@@ -225,19 +243,23 @@ function test10() {
it('Thermal_010', 0, async function (done) {
thermal.subscribeThermalLevel((overheated) => {
console.info("overheated level is: " + overheated);
expect(overheated >= 0 && overheated <= 6).assertTrue();
expect(overheated >= thermal.ThermalLevel.COOL &&
overheated <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 2);
})
done();
})
}
function test11() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_011
* @tc.name Thermal_011
......@@ -246,19 +268,22 @@ function test11() {
it('Thermal_011', 0, async function (done) {
thermal.subscribeThermalLevel((warning) => {
console.info("warning level is: " + warning);
expect(warning >= 0 && warning <= 6).assertTrue();
expect(warning >= thermal.ThermalLevel.COOL && warning <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 4);
})
done();
})
}
function test12() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_012
* @tc.name Thermal_012
......@@ -267,19 +292,22 @@ function test12() {
it('Thermal_012', 0, async function (done) {
thermal.subscribeThermalLevel((emergency) => {
console.info("emergency level is: " + emergency);
expect(emergency >= 0 && emergency <= 6).assertTrue();
expect(emergency >= thermal.ThermalLevel.COOL && emergency <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 4);
})
done();
})
}
function test13() {
const MSEC_1000 = 1000;
/* @tc.number thermal_manager_js_013
* @tc.name Thermal_013
......@@ -288,14 +316,16 @@ function test13() {
it('Thermal_013', 0, async function (done) {
thermal.subscribeThermalLevel((cool) => {
console.info("cool level is: " + cool);
expect(cool >= 0 && cool <= 6).assertTrue();
expect(cool >= thermal.ThermalLevel.COOL && cool <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 4);
})
done();
})
}
\ No newline at end of file
......@@ -39,9 +39,9 @@ function test14() {
console.info("level is: " + level);
expect(level == -1).assertTrue();
resolve();
done();
}, MSEC_1000 * 4);
})
done();
})
}
......@@ -55,13 +55,15 @@ function test15() {
thermal.subscribeThermalLevel((level) => {
console.info("level is: " + level);
expect(level == -1).assertTrue();
done();
})
await new Promise((resolve, reject)=>{
setTimeout(()=>{
thermal.unsubscribeThermalLevel();
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe successfully!");
});
resolve();
}, MSEC_1000 * 4);
})
done();
})
}
\ No newline at end of file
......@@ -13,24 +13,23 @@
# limitations under the License.
count=0
coldTemp=-22000
highTemp=40100
output=/data/sensor/battery/temp
while ((count < 100))
do
if [ $(($count%4)) == 0 ]; then
temp=-21000
let "temp = temp + 2000"
echo $temp
echo $temp > $output
sleep 10
if [ $(($count%2)) == 0 ]; then
let "coldTemp = coldTemp + 1000"
echo $coldTemp
echo $coldTemp > $output
sleep 5
else
temp=40100
let "temp = temp + 2000"
echo $temp
echo $temp > $output
sleep 10
let "highTemp = highTemp + 1000"
echo $highTemp
echo $highTemp > $output
sleep 5
fi
let "count = count + 1"
echo $count
cat $output
done
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册