Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ee58c906
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ee58c906
编写于
2月 28, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2062 Modify thermal xts
Merge pull request !2062 from yu.xu/master
上级
57025d8c
296b5c12
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
289 addition
and
82 deletion
+289
-82
powermgr/BUILD.gn
powermgr/BUILD.gn
+4
-1
powermgr/powermgrthermal/README_zh.md
powermgr/powermgrthermal/README_zh.md
+15
-0
powermgr/powermgrthermal/Test.json
powermgr/powermgrthermal/Test.json
+2
-2
powermgr/powermgrthermal/src/main/js/default/pages/index/index.js
.../powermgrthermal/src/main/js/default/pages/index/index.js
+21
-20
powermgr/powermgrthermal/src/main/js/default/test/thermal_common_event.test.js
...mal/src/main/js/default/test/thermal_common_event.test.js
+73
-0
powermgr/powermgrthermal/src/main/js/default/test/thermal_performance.test.js
...rmal/src/main/js/default/test/thermal_performance.test.js
+84
-0
powermgr/powermgrthermal/src/main/js/default/test/thermal_uint.test.js
...rmgrthermal/src/main/js/default/test/thermal_uint.test.js
+74
-44
powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js
...thermal/src/main/js/default/test/thermal_unittest.test.js
+5
-3
powermgr/powermgrthermal/temp.sh
powermgr/powermgrthermal/temp.sh
+11
-12
未找到文件。
powermgr/BUILD.gn
浏览文件 @
ee58c906
...
@@ -15,7 +15,10 @@ group("powermgr") {
...
@@ -15,7 +15,10 @@ group("powermgr") {
testonly = true
testonly = true
if (device_name == "rk3568") {
if (device_name == "rk3568") {
if (is_standard_system) {
if (is_standard_system) {
deps = [ "powermgrbattery_rk3568:powermgr_battery_test_rk3568" ]
deps = [
"powermgrbattery_rk3568:powermgr_battery_test_rk3568",
"powermgrthermal:powermgr_thermal_test",
]
}
}
} else {
} else {
if (is_standard_system) {
if (is_standard_system) {
...
...
powermgr/powermgrthermal/README_zh.md
0 → 100644
浏览文件 @
ee58c906
# 热管理服务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
powermgr/powermgrthermal/Test.json
浏览文件 @
ee58c906
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
"description"
:
"Configuration for powermgr thermal Tests"
,
"description"
:
"Configuration for powermgr thermal Tests"
,
"driver"
:
{
"driver"
:
{
"type"
:
"JSUnitTest"
,
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
6
0000"
,
"test-timeout"
:
"
12
0000"
,
"package"
:
"com.example.mythermalapp"
,
"package"
:
"com.example.mythermalapp"
,
"shell-timeout"
:
"
6
0000"
"shell-timeout"
:
"
12
0000"
},
},
"kits"
:
[
"kits"
:
[
{
{
...
...
powermgr/powermgrthermal/src/main/js/default/pages/index/index.js
浏览文件 @
ee58c906
...
@@ -12,31 +12,32 @@
...
@@ -12,31 +12,32 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import
app
from
'
@system.app
'
import
device
from
'
@system.device
'
;
import
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
import
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
const
core
=
Core
.
getInstance
();
core
.
init
()
require
(
'
../../test/List.test
'
)
core
.
execute
()
export
default
{
export
default
{
data
:
{
data
:
{
title
:
"
world
"
,
title
:
""
width
:
0
,
height
:
0
},
},
onInit
()
{
onInit
()
{
device
.
getInfo
({
this
.
title
=
this
.
$t
(
'
strings.world
'
);
success
:(
data
)
=>
{
},
this
.
width
=
data
.
windowWidth
;
onShow
()
{
this
.
height
=
data
.
windowHeight
;
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
()
{
},
}
}
powermgr/powermgrthermal/src/main/js/default/test/thermal_common_event.test.js
0 → 100644
浏览文件 @
ee58c906
/*
* 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
powermgr/powermgrthermal/src/main/js/default/test/thermal_performance.test.js
0 → 100644
浏览文件 @
ee58c906
/*
* 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
powermgr/powermgrthermal/src/main/js/default/test/thermal_uint.test.js
浏览文件 @
ee58c906
// @ts-nocheck
/*
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
...
@@ -20,7 +21,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
...
@@ -20,7 +21,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe
(
'
appInfoTest
'
,
function
()
{
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************Thermal API Test Begin*************
"
);
console
.
log
(
"
*************Thermal API Test Begin*************
"
);
const
MSEC_1000
=
1000
;
test1
();
test1
();
test2
();
test2
();
test3
();
test3
();
...
@@ -34,9 +34,11 @@ describe('appInfoTest', function () {
...
@@ -34,9 +34,11 @@ describe('appInfoTest', function () {
test11
();
test11
();
test12
();
test12
();
test13
();
test13
();
console
.
log
(
"
*************Thermal API Test End*************
"
);
})
})
function
test1
()
{
function
test1
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_001
/* @tc.number thermal_manager_js_001
* @tc.name Thermal_001
* @tc.name Thermal_001
...
@@ -48,34 +50,36 @@ function test1() {
...
@@ -48,34 +50,36 @@ function test1() {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
var
cold
=
thermal
.
getThermalLevel
();
var
cold
=
thermal
.
getThermalLevel
();
console
.
info
(
"
cold level is:
"
+
cold
);
console
.
info
(
"
cold level is:
"
+
cold
);
expect
(
cold
>=
0
&&
cold
<=
6
).
assertTrue
();
expect
(
cold
>=
thermal
.
ThermalLevel
.
COOL
&&
cold
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
resolve
();
},
MSEC_1000
*
4
);
})
done
();
done
();
},
MSEC_1000
*
1
);
})
})
})
}
}
function
test2
()
{
function
test2
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_002
/* @tc.number thermal_manager_js_002
* @tc.name Thermal_002
* @tc.name Thermal_002
* @tc.desc Thermal acquisition kit
* @tc.desc Thermal acquisition kit
*/
*/
it
(
'
Thermal_002
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_002
'
,
0
,
async
function
(
done
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
var
warm
=
thermal
.
getThermalLevel
();
var
warm
=
thermal
.
getThermalLevel
();
console
.
info
(
"
warm level is:
"
+
warm
);
console
.
info
(
"
warm level is:
"
+
warm
);
expect
(
warm
>=
0
&&
warm
<=
6
).
assertTrue
();
expect
(
warm
>=
thermal
.
ThermalLevel
.
COOL
&&
warm
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
resolve
();
},
MSEC_1000
*
4
);
})
done
();
done
();
},
MSEC_1000
*
1
);
})
})
})
}
}
function
test3
()
{
function
test3
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_003
/* @tc.number thermal_manager_js_003
* @tc.name Thermal_003
* @tc.name Thermal_003
...
@@ -86,15 +90,16 @@ function test3() {
...
@@ -86,15 +90,16 @@ function test3() {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
var
hot
=
thermal
.
getThermalLevel
();
var
hot
=
thermal
.
getThermalLevel
();
console
.
info
(
"
hot level is:
"
+
hot
);
console
.
info
(
"
hot level is:
"
+
hot
);
expect
(
hot
>=
0
&&
hot
<=
6
).
assertTrue
();
expect
(
hot
>=
thermal
.
ThermalLevel
.
COOL
&&
hot
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
resolve
();
},
MSEC_1000
*
4
);
})
done
();
done
();
},
MSEC_1000
*
1
);
})
})
})
}
}
function
test4
()
{
function
test4
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_004
/* @tc.number thermal_manager_js_004
* @tc.name Thermal_004
* @tc.name Thermal_004
...
@@ -105,15 +110,17 @@ function test4() {
...
@@ -105,15 +110,17 @@ function test4() {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
var
overheated
=
thermal
.
getThermalLevel
();
var
overheated
=
thermal
.
getThermalLevel
();
console
.
info
(
"
overheated level is:
"
+
overheated
);
console
.
info
(
"
overheated level is:
"
+
overheated
);
expect
(
overheated
>=
0
&&
overheated
<=
6
).
assertTrue
();
expect
(
overheated
>=
thermal
.
ThermalLevel
.
COOL
&&
overheated
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
resolve
();
},
MSEC_1000
*
4
);
})
done
();
done
();
},
MSEC_1000
*
1
);
})
})
})
}
}
function
test5
()
{
function
test5
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_005
/* @tc.number thermal_manager_js_005
* @tc.name Thermal_005
* @tc.name Thermal_005
...
@@ -124,15 +131,16 @@ function test5() {
...
@@ -124,15 +131,16 @@ function test5() {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
var
warning
=
thermal
.
getThermalLevel
();
var
warning
=
thermal
.
getThermalLevel
();
console
.
info
(
"
warning level is:
"
+
warning
);
console
.
info
(
"
warning level is:
"
+
warning
);
expect
(
warning
>=
0
&&
warning
<=
6
).
assertTrue
();
expect
(
warning
>=
thermal
.
ThermalLevel
.
COOL
&&
warning
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
resolve
();
},
MSEC_1000
*
4
);
})
done
();
done
();
},
MSEC_1000
*
1
);
})
})
})
}
}
function
test6
()
{
function
test6
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_006
/* @tc.number thermal_manager_js_006
* @tc.name Thermal_006
* @tc.name Thermal_006
...
@@ -143,15 +151,17 @@ function test6() {
...
@@ -143,15 +151,17 @@ function test6() {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
var
emergency
=
thermal
.
getThermalLevel
();
var
emergency
=
thermal
.
getThermalLevel
();
console
.
info
(
"
emergency level is:
"
+
emergency
);
console
.
info
(
"
emergency level is:
"
+
emergency
);
expect
(
emergency
>=
0
&&
emergency
<=
6
).
assertTrue
();
expect
(
emergency
>=
thermal
.
ThermalLevel
.
COOL
&&
emergency
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
resolve
();
},
MSEC_1000
*
4
);
})
done
();
done
();
},
MSEC_1000
*
1
);
})
})
})
}
}
function
test7
()
{
function
test7
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_007
/* @tc.number thermal_manager_js_007
* @tc.name Thermal_007
* @tc.name Thermal_007
...
@@ -159,21 +169,23 @@ function test7() {
...
@@ -159,21 +169,23 @@ function test7() {
*/
*/
it
(
'
Thermal_007
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_007
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
cool
)
=>
{
thermal
.
subscribeThermalLevel
((
cool
)
=>
{
console
.
info
(
"
cool
level is:
"
+
cool
);
console
.
info
(
"
warm
level is:
"
+
cool
);
count
++
;
expect
(
cool
>=
thermal
.
ThermalLevel
.
COOL
&&
cool
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
()
;
expect
(
cool
>=
0
&&
cool
<=
6
).
assertTru
e
();
don
e
();
})
})
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
function
test8
()
{
function
test8
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_008
/* @tc.number thermal_manager_js_008
* @tc.name Thermal_008
* @tc.name Thermal_008
...
@@ -181,20 +193,23 @@ function test8() {
...
@@ -181,20 +193,23 @@ function test8() {
*/
*/
it
(
'
Thermal_008
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_008
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
warm
)
=>
{
thermal
.
subscribeThermalLevel
((
warm
)
=>
{
console
.
info
(
"
cool level is:
"
+
warm
);
console
.
info
(
"
warm level is:
"
+
warm
);
expect
(
warm
>=
0
&&
warm
<=
6
).
assertTrue
();
expect
(
warm
>=
thermal
.
ThermalLevel
.
COOL
&&
warm
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
})
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
function
test9
()
{
function
test9
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_009
/* @tc.number thermal_manager_js_009
* @tc.name Thermal_009
* @tc.name Thermal_009
...
@@ -203,20 +218,23 @@ function test9() {
...
@@ -203,20 +218,23 @@ function test9() {
it
(
'
Thermal_009
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_009
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
hot
)
=>
{
thermal
.
subscribeThermalLevel
((
hot
)
=>
{
console
.
info
(
"
hot level is:
"
+
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
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
2
);
},
MSEC_1000
*
2
);
})
})
done
();
})
})
}
}
function
test10
()
{
function
test10
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_010
/* @tc.number thermal_manager_js_010
* @tc.name Thermal_010
* @tc.name Thermal_010
...
@@ -225,19 +243,23 @@ function test10() {
...
@@ -225,19 +243,23 @@ function test10() {
it
(
'
Thermal_010
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_010
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
overheated
)
=>
{
thermal
.
subscribeThermalLevel
((
overheated
)
=>
{
console
.
info
(
"
overheated level is:
"
+
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
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
2
);
},
MSEC_1000
*
2
);
})
})
done
();
})
})
}
}
function
test11
()
{
function
test11
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_011
/* @tc.number thermal_manager_js_011
* @tc.name Thermal_011
* @tc.name Thermal_011
...
@@ -246,19 +268,22 @@ function test11() {
...
@@ -246,19 +268,22 @@ function test11() {
it
(
'
Thermal_011
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_011
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
warning
)
=>
{
thermal
.
subscribeThermalLevel
((
warning
)
=>
{
console
.
info
(
"
warning level is:
"
+
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
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
function
test12
()
{
function
test12
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_012
/* @tc.number thermal_manager_js_012
* @tc.name Thermal_012
* @tc.name Thermal_012
...
@@ -267,19 +292,22 @@ function test12() {
...
@@ -267,19 +292,22 @@ function test12() {
it
(
'
Thermal_012
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_012
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
emergency
)
=>
{
thermal
.
subscribeThermalLevel
((
emergency
)
=>
{
console
.
info
(
"
emergency level is:
"
+
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
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
function
test13
()
{
function
test13
()
{
const
MSEC_1000
=
1000
;
/* @tc.number thermal_manager_js_013
/* @tc.number thermal_manager_js_013
* @tc.name Thermal_013
* @tc.name Thermal_013
...
@@ -288,14 +316,16 @@ function test13() {
...
@@ -288,14 +316,16 @@ function test13() {
it
(
'
Thermal_013
'
,
0
,
async
function
(
done
)
{
it
(
'
Thermal_013
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
cool
)
=>
{
thermal
.
subscribeThermalLevel
((
cool
)
=>
{
console
.
info
(
"
cool level is:
"
+
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
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
\ No newline at end of file
powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js
浏览文件 @
ee58c906
...
@@ -39,9 +39,9 @@ function test14() {
...
@@ -39,9 +39,9 @@ function test14() {
console
.
info
(
"
level is:
"
+
level
);
console
.
info
(
"
level is:
"
+
level
);
expect
(
level
==
-
1
).
assertTrue
();
expect
(
level
==
-
1
).
assertTrue
();
resolve
();
resolve
();
done
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
...
@@ -55,13 +55,15 @@ function test15() {
...
@@ -55,13 +55,15 @@ function test15() {
thermal
.
subscribeThermalLevel
((
level
)
=>
{
thermal
.
subscribeThermalLevel
((
level
)
=>
{
console
.
info
(
"
level is:
"
+
level
);
console
.
info
(
"
level is:
"
+
level
);
expect
(
level
==
-
1
).
assertTrue
();
expect
(
level
==
-
1
).
assertTrue
();
done
();
})
})
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
();
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
resolve
();
},
MSEC_1000
*
4
);
},
MSEC_1000
*
4
);
})
})
done
();
})
})
}
}
\ No newline at end of file
powermgr/powermgrthermal/temp.sh
浏览文件 @
ee58c906
...
@@ -13,24 +13,23 @@
...
@@ -13,24 +13,23 @@
# limitations under the License.
# limitations under the License.
count
=
0
count
=
0
coldTemp
=
-22000
highTemp
=
40100
output
=
/data/sensor/battery/temp
output
=
/data/sensor/battery/temp
while
((
count < 100
))
while
((
count < 100
))
do
do
if
[
$((
$count
%
4
))
==
0
]
;
then
if
[
$((
$count
%
2
))
==
0
]
;
then
temp
=
-21000
let
"coldTemp = coldTemp + 1000"
let
"temp = temp + 2000"
echo
$coldTemp
echo
$temp
echo
$coldTemp
>
$output
echo
$temp
>
$output
sleep
5
sleep
10
else
else
temp
=
40100
let
"highTemp = highTemp + 1000"
let
"temp = temp + 2000"
echo
$highTemp
echo
$temp
echo
$highTemp
>
$output
echo
$temp
>
$output
sleep
5
sleep
10
fi
fi
let
"count = count + 1"
let
"count = count + 1"
echo
$count
cat
$output
cat
$output
done
done
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录