Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
80bb7311
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
80bb7311
编写于
3月 22, 2022
作者:
L
logic42
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
0d16d76d
from
https://gitee.com/logic42/xts_acts/pulls/2785
change testcase Signed-off-by:
N
logic42
<
wanglong108@huawei.com
>
上级
00e221ba
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
432 addition
and
432 deletion
+432
-432
multimodalinput/input_js_standard/src/main/js/default/test/InputDevice.test.js
..._js_standard/src/main/js/default/test/InputDevice.test.js
+2
-2
powermgr/powermgrbattery/src/main/js/default/test/battery_unit.test.js
...rmgrbattery/src/main/js/default/test/battery_unit.test.js
+27
-27
powermgr/powermgrbattery/src/main/js/default/test/power_manager_running_lock.test.js
...c/main/js/default/test/power_manager_running_lock.test.js
+98
-98
powermgr/powermgrbattery_rk3568/src/main/js/default/test/battery_unit.test.js
...tery_rk3568/src/main/js/default/test/battery_unit.test.js
+27
-27
powermgr/powermgrbattery_rk3568/src/main/js/default/test/power_manager_running_lock.test.js
...c/main/js/default/test/power_manager_running_lock.test.js
+112
-112
powermgr/powermgrbatterystats/src/main/js/default/test/batterystats_uint.test.js
...ystats/src/main/js/default/test/batterystats_uint.test.js
+57
-57
powermgr/powermgrthermal/src/main/js/default/test/thermal_common_event.test.js
...mal/src/main/js/default/test/thermal_common_event.test.js
+11
-11
powermgr/powermgrthermal/src/main/js/default/test/thermal_performance.test.js
...rmal/src/main/js/default/test/thermal_performance.test.js
+5
-5
powermgr/powermgrthermal/src/main/js/default/test/thermal_uint.test.js
...rmgrthermal/src/main/js/default/test/thermal_uint.test.js
+35
-35
powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js
...thermal/src/main/js/default/test/thermal_unittest.test.js
+6
-6
sensors/sensor_standard/src/main/js/default/test/SensorGeneralalgorithm.test.js
...d/src/main/js/default/test/SensorGeneralalgorithm.test.js
+30
-30
sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js
...rd/src/main/js/default/test/SensorGeomagneticTest.test.js
+20
-20
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
...standard/src/main/js/default/test/SensorOnOffTest.test.js
+2
-2
未找到文件。
multimodalinput/input_js_standard/src/main/js/default/test/InputDevice.test.js
浏览文件 @
80bb7311
...
...
@@ -73,7 +73,7 @@ describe('MultimodalInput_test', function () {
expect
(
false
).
assertTrue
();
}
else
{
let
arr
=
[];
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
inputDevice
.
getDevice
(
data
[
i
],
(
res
,
err
)
=>
{
console
.
log
(
`getDevice:data_i
${
JSON
.
stringify
(
data
[
i
])}
`
)
console
.
log
(
`getDevice:data
${
JSON
.
stringify
(
data
)}
`
)
...
...
@@ -94,7 +94,7 @@ describe('MultimodalInput_test', function () {
expect
(
false
).
assertTrue
();
}
else
{
let
arr
=
[];
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
inputDevice
.
getDevice
(
data
[
i
],
(
res
,
err
)
=>
{
console
.
log
(
`getDevice:data_i
${
JSON
.
stringify
(
data
[
i
])}
`
)
console
.
log
(
`getDevice:data
${
JSON
.
stringify
(
data
)}
`
)
...
...
powermgr/powermgrbattery/src/main/js/default/test/battery_unit.test.js
浏览文件 @
80bb7311
...
...
@@ -17,18 +17,18 @@ import app from '@system.app'
import
Context
from
'
@ohos.napi_context
'
import
batteryInfo
from
'
@ohos.batteryInfo
'
;
import
brightness
from
'
@ohos.brightness
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
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
()
{
var
batterySoc
=
batteryInfo
.
batterySOC
;
let
batterySoc
=
batteryInfo
.
batterySOC
;
console
.
info
(
'
batterySoc =
'
+
batterySoc
);
expect
(
batterySoc
>=
-
1
&&
batterySoc
<=
100
).
assertTrue
()
})
...
...
@@ -39,7 +39,7 @@ describe('appInfoTest', function () {
* @tc.desc Battery charging kit
*/
it
(
'
charging_status_test
'
,
0
,
function
()
{
var
chargingStatus
=
batteryInfo
.
chargingStatus
;
let
chargingStatus
=
batteryInfo
.
chargingStatus
;
console
.
info
(
'
chargingStatus =
'
+
chargingStatus
);
expect
(
chargingStatus
>=
0
&&
chargingStatus
<=
4
).
assertTrue
()
})
...
...
@@ -50,7 +50,7 @@ describe('appInfoTest', function () {
* @tc.desc Get Battery Health Get KIT
*/
it
(
'
health_status_test
'
,
0
,
function
()
{
var
healthStatus
=
batteryInfo
.
healthStatus
;
let
healthStatus
=
batteryInfo
.
healthStatus
;
console
.
info
(
'
healthStatus =
'
+
healthStatus
);
expect
(
healthStatus
>=
0
&&
healthStatus
<=
6
).
assertTrue
()
})
...
...
@@ -61,7 +61,7 @@ describe('appInfoTest', function () {
* @tc.desc Obtaining the USB Connection Type KIT
*/
it
(
'
plugged_type_test
'
,
0
,
function
()
{
var
pluggedType
=
batteryInfo
.
pluggedType
;
let
pluggedType
=
batteryInfo
.
pluggedType
;
console
.
info
(
'
pluggedType =
'
+
pluggedType
);
expect
(
pluggedType
>=
0
&&
pluggedType
<=
4
).
assertTrue
()
})
...
...
@@ -72,7 +72,7 @@ describe('appInfoTest', function () {
* @tc.desc Obtaining the Voltage Interface KIT
*/
it
(
'
voltage_test
'
,
0
,
function
()
{
var
voltage
=
batteryInfo
.
voltage
;
let
voltage
=
batteryInfo
.
voltage
;
console
.
info
(
'
voltage =
'
+
voltage
);
expect
(
voltage
>=
-
1
).
assertTrue
()
})
...
...
@@ -83,7 +83,7 @@ describe('appInfoTest', function () {
* @tc.desc Obtaining the Battery Technology Interface KIT
*/
it
(
'
technology_test
'
,
0
,
function
()
{
var
technology
=
batteryInfo
.
technology
;
let
technology
=
batteryInfo
.
technology
;
console
.
info
(
'
technology =
'
+
technology
);
expect
(
technology
!==
null
).
assertTrue
()
})
...
...
@@ -94,7 +94,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryTemperature values Interface Test
*/
it
(
'
battery_temperature_test
'
,
0
,
function
()
{
var
batteryTemperature
=
batteryInfo
.
batteryTemperature
;
let
batteryTemperature
=
batteryInfo
.
batteryTemperature
;
console
.
info
(
'
batteryTemperature =
'
+
batteryTemperature
);
expect
(
batteryTemperature
<=
700
).
assertTrue
()
})
...
...
@@ -105,7 +105,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_unknown
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
UNKNOWN
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
UNKNOWN
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
0
).
assertTrue
()
})
...
...
@@ -116,7 +116,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_good
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
GOOD
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
GOOD
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
1
).
assertTrue
()
})
...
...
@@ -127,7 +127,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_overheat
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERHEAT
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERHEAT
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
2
).
assertTrue
()
})
...
...
@@ -138,7 +138,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_overvoltage
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERVOLTAGE
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERVOLTAGE
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
3
).
assertTrue
()
})
...
...
@@ -149,7 +149,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_cold
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
COLD
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
COLD
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
4
).
assertTrue
()
})
...
...
@@ -160,7 +160,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_dead
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
DEAD
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
DEAD
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
5
).
assertTrue
()
})
...
...
@@ -171,7 +171,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_none
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
NONE
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
NONE
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
0
).
assertTrue
()
})
...
...
@@ -182,7 +182,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_enable
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
ENABLE
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
ENABLE
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
1
).
assertTrue
()
})
...
...
@@ -193,7 +193,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_disable
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
DISABLE
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
DISABLE
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
2
).
assertTrue
()
})
...
...
@@ -204,7 +204,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_full
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
FULL
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
FULL
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
3
).
assertTrue
()
})
...
...
@@ -215,7 +215,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_none
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
NONE
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
NONE
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
0
).
assertTrue
()
})
...
...
@@ -226,7 +226,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_ac
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
AC
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
AC
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
1
).
assertTrue
()
})
...
...
@@ -237,7 +237,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_usb
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
USB
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
USB
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
2
).
assertTrue
()
})
...
...
@@ -248,7 +248,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_wireless
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
WIRELESS
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
WIRELESS
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
3
).
assertTrue
()
})
...
...
@@ -271,12 +271,12 @@ describe('appInfoTest', function () {
* @tc.desc Battry Present Interface Test
*/
it
(
'
is_battery_present_test
'
,
0
,
function
()
{
var
isBatteryPresent
=
batteryInfo
.
isBatteryPresent
;
let
isBatteryPresent
=
batteryInfo
.
isBatteryPresent
;
console
.
info
(
'
isBatteryPresent =
'
+
isBatteryPresent
);
if
(
isBatteryPresent
)
{
expect
(
isBatteryPresent
).
assertTrue
();
}
else
{
expect
(
isBatteryPresent
).
assertFalse
();
expect
(
isBatteryPresent
).
assertTrue
();
}
else
{
expect
(
isBatteryPresent
).
assertFalse
();
}
})
})
\ No newline at end of file
powermgr/powermgrbattery/src/main/js/default/test/power_manager_running_lock.test.js
浏览文件 @
80bb7311
...
...
@@ -19,23 +19,23 @@ import runningLock from '@ohos.runningLock';
import
power
from
'
@ohos.power
'
;
import
'
@ohos.permission.RUNNING_LOCK
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************Power Unit Test Begin*************
"
);
//createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
it
(
'
create_running_lock_promise_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_1
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
create_running_lock_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
create_running_lock_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
create_running_lock_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
create_running_lock_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>)
it
(
'
create_running_lock_callback_test
'
,
0
,
async
function
(
done
)
{
...
...
@@ -43,7 +43,7 @@ describe('appInfoTest', function () {
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
create_running_lock_callback_test: runningLock is
'
+
runninglock
);
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
create_running_lock_callback_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
...
...
@@ -62,76 +62,76 @@ describe('appInfoTest', function () {
//lock(timeout: number)
it
(
'
running_lock_lock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_3
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
running_lock_lock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_lock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
running_lock_lock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_lock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isUsed()
it
(
'
running_lock_isused_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_4
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_isused_test used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_isused_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_isused_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_isused_test used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_isused_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_isused_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//unlock()
it
(
'
running_lock_unlock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_5
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
runninglock
.
unlock
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after unlock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_unlock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_unlock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
runninglock
.
unlock
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after unlock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_unlock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_unlock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//Runninglock锁的类型为BACKGROUND
it
(
'
enum_runningLock_type_background_test
'
,
0
,
function
()
{
var
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
let
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
1
).
assertTrue
();
console
.
info
(
'
enum_runningLock_type_background_test success
'
);
})
//Runninglock锁的类型为PROXIMITY_SCREEN_CONTROL
it
(
'
enum_runningLock_type_proximityscreencontrol_test
'
,
0
,
function
()
{
var
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
let
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
2
).
assertTrue
();
console
.
info
(
'
enum_runningLock_type_proximityscreencontrol_test success
'
);
...
...
@@ -139,32 +139,32 @@ describe('appInfoTest', function () {
//isRunningLockTypeSupported(type: RunningLockType): Promise<boolean>
it
(
'
is_runninglock_type_supported_promise_test_1
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
)
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_test_1 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_test_1 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_test_1 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_test_1 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isRunningLockTypeSupported(type: RunningLockType) 多余
it
(
'
is_runninglock_type_supported_promise_test_2
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_promise_test_2 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_promise_test_2 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boolean>)
it
(
'
is_runninglock_type_supported_callback_test_3
'
,
0
,
async
function
(
done
)
{
...
...
@@ -183,17 +183,17 @@ describe('appInfoTest', function () {
})
it
(
'
power_is_screen_on_promise_test
'
,
0
,
async
function
(
done
)
{
//isScreenOn(): Promise<boolean>
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
power_is_screen_on_promise_test screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
power_is_screen_on_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
power_is_screen_on_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
screenOn
=>
{
console
.
info
(
'
power_is_screen_on_promise_test screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
power_is_screen_on_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
power_is_screen_on_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
it
(
'
power_is_screen_on_callback_test
'
,
0
,
async
function
(
done
)
{
//isScreenOn(callback: AsyncCallback<boolean>)
power
.
isScreenOn
((
error
,
screenOn
)
=>
{
...
...
powermgr/powermgrbattery_rk3568/src/main/js/default/test/battery_unit.test.js
浏览文件 @
80bb7311
...
...
@@ -17,18 +17,18 @@ import app from '@system.app'
import
Context
from
'
@ohos.napi_context
'
import
batteryInfo
from
'
@ohos.batteryInfo
'
;
import
brightness
from
'
@ohos.brightness
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
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
()
{
var
batterySoc
=
batteryInfo
.
batterySOC
;
let
batterySoc
=
batteryInfo
.
batterySOC
;
console
.
info
(
'
batterySoc =
'
+
batterySoc
);
expect
(
batterySoc
>=
-
1
&&
batterySoc
<=
100
).
assertTrue
()
})
...
...
@@ -39,7 +39,7 @@ describe('appInfoTest', function () {
* @tc.desc Battery charging kit
*/
it
(
'
charging_status_test
'
,
0
,
function
()
{
var
chargingStatus
=
batteryInfo
.
chargingStatus
;
let
chargingStatus
=
batteryInfo
.
chargingStatus
;
console
.
info
(
'
chargingStatus =
'
+
chargingStatus
);
expect
(
chargingStatus
>=
0
&&
chargingStatus
<=
4
).
assertTrue
()
})
...
...
@@ -50,7 +50,7 @@ describe('appInfoTest', function () {
* @tc.desc Get Battery Health Get KIT
*/
it
(
'
health_status_test
'
,
0
,
function
()
{
var
healthStatus
=
batteryInfo
.
healthStatus
;
let
healthStatus
=
batteryInfo
.
healthStatus
;
console
.
info
(
'
healthStatus =
'
+
healthStatus
);
expect
(
healthStatus
>=
0
&&
healthStatus
<=
6
).
assertTrue
()
})
...
...
@@ -61,7 +61,7 @@ describe('appInfoTest', function () {
* @tc.desc Obtaining the USB Connection Type KIT
*/
it
(
'
plugged_type_test
'
,
0
,
function
()
{
var
pluggedType
=
batteryInfo
.
pluggedType
;
let
pluggedType
=
batteryInfo
.
pluggedType
;
console
.
info
(
'
pluggedType =
'
+
pluggedType
);
expect
(
pluggedType
>=
0
&&
pluggedType
<=
4
).
assertTrue
()
})
...
...
@@ -72,7 +72,7 @@ describe('appInfoTest', function () {
* @tc.desc Obtaining the Voltage Interface KIT
*/
it
(
'
voltage_test
'
,
0
,
function
()
{
var
voltage
=
batteryInfo
.
voltage
;
let
voltage
=
batteryInfo
.
voltage
;
console
.
info
(
'
voltage =
'
+
voltage
);
expect
(
voltage
>=
-
1
).
assertTrue
()
})
...
...
@@ -83,7 +83,7 @@ describe('appInfoTest', function () {
* @tc.desc Obtaining the Battery Technology Interface KIT
*/
it
(
'
technology_test
'
,
0
,
function
()
{
var
technology
=
batteryInfo
.
technology
;
let
technology
=
batteryInfo
.
technology
;
console
.
info
(
'
technology =
'
+
technology
);
expect
(
technology
!==
null
).
assertTrue
()
})
...
...
@@ -94,7 +94,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryTemperature values Interface Test
*/
it
(
'
battery_temperature_test
'
,
0
,
function
()
{
var
batteryTemperature
=
batteryInfo
.
batteryTemperature
;
let
batteryTemperature
=
batteryInfo
.
batteryTemperature
;
console
.
info
(
'
batteryTemperature =
'
+
batteryTemperature
);
expect
(
batteryTemperature
<=
700
).
assertTrue
()
})
...
...
@@ -105,7 +105,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_unknown
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
UNKNOWN
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
UNKNOWN
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
0
).
assertTrue
()
})
...
...
@@ -116,7 +116,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_good
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
GOOD
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
GOOD
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
1
).
assertTrue
()
})
...
...
@@ -127,7 +127,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_overheat
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERHEAT
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERHEAT
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
2
).
assertTrue
()
})
...
...
@@ -138,7 +138,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_overvoltage
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERVOLTAGE
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
OVERVOLTAGE
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
3
).
assertTrue
()
})
...
...
@@ -149,7 +149,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_cold
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
COLD
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
COLD
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
4
).
assertTrue
()
})
...
...
@@ -160,7 +160,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryHealthState values Interface Test
*/
it
(
'
enum_health_state_test_dead
'
,
0
,
function
()
{
var
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
DEAD
;
let
batteryHealthState
=
batteryInfo
.
BatteryHealthState
.
DEAD
;
console
.
info
(
'
batteryHealthState =
'
+
batteryHealthState
);
expect
(
batteryHealthState
==
5
).
assertTrue
()
})
...
...
@@ -171,7 +171,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_none
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
NONE
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
NONE
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
0
).
assertTrue
()
})
...
...
@@ -182,7 +182,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_enable
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
ENABLE
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
ENABLE
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
1
).
assertTrue
()
})
...
...
@@ -193,7 +193,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_disable
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
DISABLE
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
DISABLE
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
2
).
assertTrue
()
})
...
...
@@ -204,7 +204,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryChargeState values Interface Test
*/
it
(
'
enum_charge_state_test_full
'
,
0
,
function
()
{
var
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
FULL
;
let
batteryChargeState
=
batteryInfo
.
BatteryChargeState
.
FULL
;
console
.
info
(
'
batteryChargeState =
'
+
batteryChargeState
);
expect
(
batteryChargeState
==
3
).
assertTrue
()
})
...
...
@@ -215,7 +215,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_none
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
NONE
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
NONE
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
0
).
assertTrue
()
})
...
...
@@ -226,7 +226,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_ac
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
AC
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
AC
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
1
).
assertTrue
()
})
...
...
@@ -237,7 +237,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_usb
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
USB
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
USB
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
2
).
assertTrue
()
})
...
...
@@ -248,7 +248,7 @@ describe('appInfoTest', function () {
* @tc.desc BatteryPluggedType values Interface Test
*/
it
(
'
enum_plugged_type_test_wireless
'
,
0
,
function
()
{
var
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
WIRELESS
;
let
batteryPluggedType
=
batteryInfo
.
BatteryPluggedType
.
WIRELESS
;
console
.
info
(
'
batteryPluggedType =
'
+
batteryPluggedType
);
expect
(
batteryPluggedType
==
3
).
assertTrue
()
})
...
...
@@ -271,12 +271,12 @@ describe('appInfoTest', function () {
* @tc.desc Battry Present Interface Test
*/
it
(
'
is_battery_present_test
'
,
0
,
function
()
{
var
isBatteryPresent
=
batteryInfo
.
isBatteryPresent
;
let
isBatteryPresent
=
batteryInfo
.
isBatteryPresent
;
console
.
info
(
'
isBatteryPresent =
'
+
isBatteryPresent
);
if
(
isBatteryPresent
)
{
expect
(
isBatteryPresent
).
assertTrue
();
}
else
{
expect
(
isBatteryPresent
).
assertFalse
();
expect
(
isBatteryPresent
).
assertTrue
();
}
else
{
expect
(
isBatteryPresent
).
assertFalse
();
}
})
})
\ No newline at end of file
powermgr/powermgrbattery_rk3568/src/main/js/default/test/power_manager_running_lock.test.js
浏览文件 @
80bb7311
...
...
@@ -19,120 +19,120 @@ import runningLock from '@ohos.runningLock';
import
power
from
'
@ohos.power
'
;
import
'
@ohos.permission.RUNNING_LOCK
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************Power Unit Test Begin*************
"
);
//createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
it
(
'
create_running_lock_promise_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_1
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
create_running_lock_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
create_running_lock_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
create_running_lock_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
create_running_lock_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>)
it
(
'
create_running_lock_callback_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_2
"
,
runningLock
.
RunningLockType
.
BACKGROUND
,
(
error
,
runninglock
)
=>
{
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
create_running_lock_callback_test: runningLock is
'
+
runninglock
);
(
error
,
runninglock
)
=>
{
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
create_running_lock_callback_test: runningLock is
'
+
runninglock
);
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
create_running_lock_callback_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock create_running_lock_callback_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
create_running_lock_callback_test success
'
);
done
();
}
else
{
console
.
log
(
'
create_running_lock_callback_test:
'
+
error
);
expect
().
assertFail
();
done
();
}
})
})
//lock(timeout: number)
it
(
'
running_lock_lock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_3
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
create_running_lock_callba
ck_test is used:
'
+
used
);
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_lo
ck_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock
create_running_lock_callba
ck_test is used:
'
+
used
);
console
.
info
(
'
after lock
running_lock_lo
ck_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
create_running_lock_callba
ck_test success
'
);
console
.
info
(
'
running_lock_lo
ck_test success
'
);
done
();
}
else
{
console
.
log
(
'
create_running_lock_callback_test:
'
+
error
);
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_lock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
}
})
})
//lock(timeout: number)
it
(
'
running_lock_lock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_3
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
running_lock_lock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_lock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
})
//isUsed()
it
(
'
running_lock_isused_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_4
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_isused_test used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_isused_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_isused_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_isused_test used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_isused_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_isused_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//unlock()
it
(
'
running_lock_unlock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_5
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
runninglock
.
unlock
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after unlock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_unlock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_unlock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
runninglock
.
unlock
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after unlock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_unlock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_unlock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//Runninglock锁的类型为BACKGROUND
it
(
'
enum_runningLock_type_background_test
'
,
0
,
function
()
{
var
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
let
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
1
).
assertTrue
();
console
.
info
(
'
enum_runningLock_type_background_test success
'
);
})
//Runninglock锁的类型为PROXIMITY_SCREEN_CONTROL
it
(
'
enum_runningLock_type_proximityscreencontrol_test
'
,
0
,
function
()
{
var
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
let
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
2
).
assertTrue
();
console
.
info
(
'
enum_runningLock_type_proximityscreencontrol_test success
'
);
...
...
@@ -140,32 +140,32 @@ describe('appInfoTest', function () {
//isRunningLockTypeSupported(type: RunningLockType): Promise<boolean>
it
(
'
is_runninglock_type_supported_promise_test_1
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
)
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_test_1 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_test_1 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_test_1 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_test_1 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isRunningLockTypeSupported(type: RunningLockType) 多余
it
(
'
is_runninglock_type_supported_promise_test_2
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_promise_test_2 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_promise_test_2 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boolean>)
it
(
'
is_runninglock_type_supported_callback_test_3
'
,
0
,
async
function
(
done
)
{
...
...
@@ -184,17 +184,17 @@ describe('appInfoTest', function () {
})
it
(
'
power_is_screen_on_promise_test
'
,
0
,
async
function
(
done
)
{
//isScreenOn(): Promise<boolean>
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
power_is_screen_on_promise_test screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
power_is_screen_on_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
power_is_screen_on_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
.
then
(
screenOn
=>
{
console
.
info
(
'
power_is_screen_on_promise_test screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
power_is_screen_on_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
power_is_screen_on_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
it
(
'
power_is_screen_on_callback_test
'
,
0
,
async
function
(
done
)
{
//isScreenOn(callback: AsyncCallback<boolean>)
power
.
isScreenOn
((
error
,
screenOn
)
=>
{
...
...
powermgr/powermgrbatterystats/src/main/js/default/test/batterystats_uint.test.js
浏览文件 @
80bb7311
...
...
@@ -15,18 +15,18 @@
import
app
from
'
@system.app
'
import
batteryStats
from
"
@ohos.batteryStatistics
"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
ConsumptionType
=
{
CONSUMPTION_TYPE_INVALID
:
-
17
,
CONSUMPTION_TYPE_APP
:
-
16
,
CONSUMPTION_TYPE_BLUETOOTH
:
-
15
,
CONSUMPTION_TYPE_IDLE
:
-
14
,
CONSUMPTION_TYPE_PHONE
:
-
13
,
CONSUMPTION_TYPE_RADIO
:
-
12
,
CONSUMPTION_TYPE_SCREEN
:
-
11
,
CONSUMPTION_TYPE_USER
:
-
10
,
CONSUMPTION_TYPE_WIFI
:
-
9
,
let
ConsumptionType
=
{
CONSUMPTION_TYPE_INVALID
:
-
17
,
CONSUMPTION_TYPE_APP
:
-
16
,
CONSUMPTION_TYPE_BLUETOOTH
:
-
15
,
CONSUMPTION_TYPE_IDLE
:
-
14
,
CONSUMPTION_TYPE_PHONE
:
-
13
,
CONSUMPTION_TYPE_RADIO
:
-
12
,
CONSUMPTION_TYPE_SCREEN
:
-
11
,
CONSUMPTION_TYPE_USER
:
-
10
,
CONSUMPTION_TYPE_WIFI
:
-
9
,
}
describe
(
'
appInfoTest
'
,
function
()
{
...
...
@@ -38,7 +38,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getBatteryStats Interface Test type = ConsumptionType.CONSUMPTION_TYPE_BLUETOOTH
*/
it
(
'
batteryStats_001
'
,
0
,
async
function
(
done
)
{
var
infoList
;
let
infoList
;
let
promise
=
batteryStats
.
getBatteryStats
().
then
(
function
(
value
)
{
infoList
=
value
;
console
.
info
(
"
Executing
"
);
...
...
@@ -47,7 +47,7 @@ describe('appInfoTest', function () {
});
await
promise
;
console
.
info
(
"
Waiting
"
);
var
found
=
false
;
let
found
=
false
;
for
(
let
i
=
0
;
i
<
infoList
.
length
;
i
++
)
{
if
(
infoList
[
i
].
type
==
ConsumptionType
.
CONSUMPTION_TYPE_BLUETOOTH
)
{
expect
(
infoList
[
i
].
uid
).
assertEqual
(
-
1
);
...
...
@@ -65,7 +65,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getBatteryStats Interface Test type = ConsumptionType.CONSUMPTION_TYPE_IDLE
*/
it
(
'
batteryStats_002
'
,
0
,
async
function
(
done
)
{
var
infoList
;
let
infoList
;
let
promise
=
batteryStats
.
getBatteryStats
().
then
(
function
(
value
)
{
infoList
=
value
;
console
.
info
(
"
Executing
"
);
...
...
@@ -74,7 +74,7 @@ describe('appInfoTest', function () {
});
await
promise
;
console
.
info
(
"
Waiting
"
);
var
found
=
false
;
let
found
=
false
;
for
(
let
i
=
0
;
i
<
infoList
.
length
;
i
++
)
{
if
(
infoList
[
i
].
type
==
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
)
{
expect
(
infoList
[
i
].
uid
).
assertEqual
(
-
1
);
...
...
@@ -92,7 +92,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getBatteryStats Interface Test type = ConsumptionType.CONSUMPTION_TYPE_PHONE
*/
it
(
'
batteryStats_003
'
,
0
,
async
function
(
done
)
{
var
infoList
;
let
infoList
;
let
promise
=
batteryStats
.
getBatteryStats
().
then
(
function
(
value
)
{
infoList
=
value
;
console
.
info
(
"
Executing
"
);
...
...
@@ -101,7 +101,7 @@ describe('appInfoTest', function () {
});
await
promise
;
console
.
info
(
"
Waiting
"
);
var
found
=
false
;
let
found
=
false
;
for
(
let
i
=
0
;
i
<
infoList
.
length
;
i
++
)
{
if
(
infoList
[
i
].
type
==
ConsumptionType
.
CONSUMPTION_TYPE_PHONE
)
{
expect
(
infoList
[
i
].
uid
).
assertEqual
(
-
1
);
...
...
@@ -119,7 +119,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getBatteryStats Interface Test type = ConsumptionType.CONSUMPTION_TYPE_RADIO
*/
it
(
'
batteryStats_004
'
,
0
,
async
function
(
done
)
{
var
infoList
;
let
infoList
;
let
promise
=
batteryStats
.
getBatteryStats
().
then
(
function
(
value
)
{
infoList
=
value
;
console
.
info
(
"
Executing
"
);
...
...
@@ -128,7 +128,7 @@ describe('appInfoTest', function () {
});
await
promise
;
console
.
info
(
"
Waiting
"
);
var
found
=
false
;
let
found
=
false
;
for
(
let
i
=
0
;
i
<
infoList
.
length
;
i
++
)
{
if
(
infoList
[
i
].
type
==
ConsumptionType
.
CONSUMPTION_TYPE_RADIO
)
{
expect
(
infoList
[
i
].
uid
).
assertEqual
(
-
1
);
...
...
@@ -146,7 +146,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getBatteryStats Interface Test type = ConsumptionType.CONSUMPTION_TYPE_SCREEN
*/
it
(
'
batteryStats_005
'
,
0
,
async
function
(
done
)
{
var
infoList
;
let
infoList
;
let
promise
=
batteryStats
.
getBatteryStats
().
then
(
function
(
value
)
{
infoList
=
value
;
console
.
info
(
"
Executing
"
);
...
...
@@ -155,7 +155,7 @@ describe('appInfoTest', function () {
});
await
promise
;
console
.
info
(
"
Waiting
"
);
var
found
=
false
;
let
found
=
false
;
for
(
let
i
=
0
;
i
<
infoList
.
length
;
i
++
)
{
if
(
infoList
[
i
].
type
==
ConsumptionType
.
CONSUMPTION_TYPE_SCREEN
)
{
expect
(
infoList
[
i
].
uid
).
assertEqual
(
-
1
);
...
...
@@ -172,7 +172,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerValue Interface Test uid = 111
*/
it
(
'
batteryStats_006
'
,
0
,
function
()
{
var
power
=
batteryStats
.
getAppPowerValue
(
111
);
let
power
=
batteryStats
.
getAppPowerValue
(
111
);
console
.
info
(
"
App consumption power of uid 111 is:
"
+
power
);
expect
(
power
>=
0
).
assertTrue
();
})
...
...
@@ -182,7 +182,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerValue Interface Test uid = -111
*/
it
(
'
batteryStats_007
'
,
0
,
function
()
{
var
power
=
batteryStats
.
getAppPowerValue
(
-
111
);
let
power
=
batteryStats
.
getAppPowerValue
(
-
111
);
console
.
info
(
"
App consumption power of uid -111 is:
"
+
power
);
expect
(
power
).
assertEqual
(
0
);
})
...
...
@@ -192,7 +192,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerValue Interface Test uid = 0
*/
it
(
'
batteryStats_008
'
,
0
,
function
()
{
var
power
=
batteryStats
.
getAppPowerValue
(
0
);
let
power
=
batteryStats
.
getAppPowerValue
(
0
);
console
.
info
(
"
App consumption power of uid 0 is:
"
+
power
);
expect
(
power
>=
0
).
assertTrue
();
})
...
...
@@ -202,10 +202,10 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerValue Interface Test uid = "111"
*/
it
(
'
batteryStats_009
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getAppPowerValue
(
"
111
"
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument type check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument type check works:
"
+
e
;
console
.
debug
(
"
errorMsg
"
);
expect
(
errorMsg
.
includes
(
"
Wrong argument type
"
)).
assertTrue
();
}
...
...
@@ -216,10 +216,10 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerValue Interface Test uid = 111, 222
*/
it
(
'
batteryStats_010
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getAppPowerValue
(
111
,
222
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument number check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument number check works:
"
+
e
;
console
.
debug
(
errorMsg
);
expect
(
errorMsg
.
includes
(
"
Wrong number of arguments
"
)).
assertTrue
();
}
...
...
@@ -230,7 +230,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerPercent Interface Test uid = 111
*/
it
(
'
batteryStats_011
'
,
0
,
function
()
{
var
powerPercent
=
batteryStats
.
getAppPowerPercent
(
111
);
let
powerPercent
=
batteryStats
.
getAppPowerPercent
(
111
);
console
.
info
(
"
App consumption percent of uid 111 is:
"
+
powerPercent
);
expect
(
powerPercent
>=
0
).
assertTrue
();
})
...
...
@@ -240,7 +240,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerPercent Interface Test uid = -111
*/
it
(
'
batteryStats_012
'
,
0
,
function
()
{
var
powerPercent
=
batteryStats
.
getAppPowerPercent
(
-
111
);
let
powerPercent
=
batteryStats
.
getAppPowerPercent
(
-
111
);
console
.
info
(
"
App consumption percent of uid -111 is:
"
+
powerPercent
);
expect
(
powerPercent
).
assertEqual
(
0
);
})
...
...
@@ -250,7 +250,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerPercent Interface Test uid = 0
*/
it
(
'
batteryStats_013
'
,
0
,
function
()
{
var
powerPercent
=
batteryStats
.
getAppPowerPercent
(
0
);
let
powerPercent
=
batteryStats
.
getAppPowerPercent
(
0
);
console
.
info
(
"
App consumption percent of uid 0 is:
"
+
powerPercent
);
expect
(
powerPercent
>=
0
).
assertTrue
();
})
...
...
@@ -260,10 +260,10 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerPercent Interface Test uid = "111"
*/
it
(
'
batteryStats_014
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getAppPowerPercent
(
"
111
"
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument type check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument type check works:
"
+
e
;
console
.
debug
(
"
errorMsg
"
);
expect
(
errorMsg
.
includes
(
"
Wrong argument type
"
)).
assertTrue
();
}
...
...
@@ -274,10 +274,10 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getAppPowerPercent Interface Test uid = 111, 222
*/
it
(
'
batteryStats_015
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getAppPowerPercent
(
111
,
222
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument number check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument number check works:
"
+
e
;
console
.
debug
(
errorMsg
);
expect
(
errorMsg
.
includes
(
"
Wrong number of arguments
"
)).
assertTrue
();
}
...
...
@@ -288,7 +288,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerValue Interface Test type = ConsumptionType.CONSUMPTION_TYPE_IDLE
*/
it
(
'
batteryStats_016
'
,
0
,
function
()
{
var
power
=
batteryStats
.
getHardwareUnitPowerValue
(
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
);
let
power
=
batteryStats
.
getHardwareUnitPowerValue
(
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
);
console
.
info
(
"
Idle consumption power is:
"
+
power
);
expect
(
power
>=
0
).
assertTrue
();
})
...
...
@@ -298,7 +298,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerValue Interface Test type = 111
*/
it
(
'
batteryStats_017
'
,
0
,
function
()
{
var
power
=
batteryStats
.
getHardwareUnitPowerValue
(
111
);
let
power
=
batteryStats
.
getHardwareUnitPowerValue
(
111
);
console
.
info
(
"
111's consumption power is:
"
+
power
);
expect
(
power
).
assertEqual
(
0
);
})
...
...
@@ -308,7 +308,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerValue Interface Test type = 0
*/
it
(
'
batteryStats_018
'
,
0
,
function
()
{
var
power
=
batteryStats
.
getHardwareUnitPowerValue
(
0
);
let
power
=
batteryStats
.
getHardwareUnitPowerValue
(
0
);
console
.
info
(
"
0's consumption power is:
"
+
power
);
expect
(
power
).
assertEqual
(
0
);
})
...
...
@@ -318,10 +318,10 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerValue Interface Test type = "test"
*/
it
(
'
batteryStats_019
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getHardwareUnitPowerValue
(
"
test
"
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument type check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument type check works:
"
+
e
;
console
.
debug
(
"
errorMsg
"
);
expect
(
errorMsg
.
includes
(
"
Wrong argument type
"
)).
assertTrue
();
}
...
...
@@ -333,11 +333,11 @@ describe('appInfoTest', function () {
* and ConsumptionType.CONSUMPTION_TYPE_WIFI
*/
it
(
'
batteryStats_020
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getHardwareUnitPowerValue
(
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
,
ConsumptionType
.
CONSUMPTION_TYPE_WIFI
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument number check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument number check works:
"
+
e
;
console
.
debug
(
errorMsg
);
expect
(
errorMsg
.
includes
(
"
Wrong number of arguments
"
)).
assertTrue
();
}
...
...
@@ -348,7 +348,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerPercent Interface Test type = ConsumptionType.CONSUMPTION_TYPE_IDLE
*/
it
(
'
batteryStats_021
'
,
0
,
function
()
{
var
powerPercent
=
batteryStats
.
getHardwareUnitPowerPercent
(
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
);
let
powerPercent
=
batteryStats
.
getHardwareUnitPowerPercent
(
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
);
console
.
info
(
"
Idle consumption percent is:
"
+
powerPercent
);
expect
(
powerPercent
>=
0
).
assertTrue
();
})
...
...
@@ -358,7 +358,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerPercent Interface Test type = 111
*/
it
(
'
batteryStats_022
'
,
0
,
function
()
{
var
powerPercent
=
batteryStats
.
getHardwareUnitPowerPercent
(
111
);
let
powerPercent
=
batteryStats
.
getHardwareUnitPowerPercent
(
111
);
console
.
info
(
"
111's consumption percent is:
"
+
powerPercent
);
expect
(
powerPercent
).
assertEqual
(
0
);
})
...
...
@@ -368,7 +368,7 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerPercent Interface Test type = 0
*/
it
(
'
batteryStats_023
'
,
0
,
function
()
{
var
powerPercent
=
batteryStats
.
getHardwareUnitPowerPercent
(
0
);
let
powerPercent
=
batteryStats
.
getHardwareUnitPowerPercent
(
0
);
console
.
info
(
"
0's consumption percent is:
"
+
powerPercent
);
expect
(
powerPercent
).
assertEqual
(
0
);
})
...
...
@@ -378,10 +378,10 @@ describe('appInfoTest', function () {
* @tc.desc batteryStats getHardwareUnitPowerPercent Interface Test type = "test"
*/
it
(
'
batteryStats_024
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getHardwareUnitPowerPercent
(
"
test
"
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument type check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument type check works:
"
+
e
;
console
.
debug
(
"
errorMsg
"
);
expect
(
errorMsg
.
includes
(
"
Wrong argument type
"
)).
assertTrue
();
}
...
...
@@ -393,11 +393,11 @@ describe('appInfoTest', function () {
* and ConsumptionType.CONSUMPTION_TYPE_WIFI
*/
it
(
'
batteryStats_025
'
,
0
,
function
()
{
try
{
try
{
batteryStats
.
getHardwareUnitPowerPercent
(
ConsumptionType
.
CONSUMPTION_TYPE_IDLE
,
ConsumptionType
.
CONSUMPTION_TYPE_WIFI
);
}
catch
(
e
)
{
var
errorMsg
=
"
Argument number check works:
"
+
e
;
}
catch
(
e
)
{
let
errorMsg
=
"
Argument number check works:
"
+
e
;
console
.
debug
(
errorMsg
);
expect
(
errorMsg
.
includes
(
"
Wrong number of arguments
"
)).
assertTrue
();
}
...
...
powermgr/powermgrthermal/src/main/js/default/test/thermal_common_event.test.js
浏览文件 @
80bb7311
...
...
@@ -31,13 +31,13 @@ describe('appInfoTest', function () {
})
function
createSubscriber
()
{
var
commonEventSubscribeInfo
=
{
events
:
[
commonEvent
.
Support
.
COMMON_EVENT_THERMAL_LEVEL_CHANGED
],
};
let
commonEventSubscribeInfo
=
{
events
:
[
commonEvent
.
Support
.
COMMON_EVENT_THERMAL_LEVEL_CHANGED
],
};
commonEvent
.
createSubscriber
(
commonEventSubscribeInfo
)
.
then
(
subscriber
=>
{
console
.
info
(
'
createSubscriber success
'
);
var
mySubscriber
=
subscriber
;
let
mySubscriber
=
subscriber
;
console
.
log
(
subscriber
);
if
(
subscriber
==
""
||
subscriber
==
undefined
||
subscriber
==
null
)
{
...
...
@@ -47,27 +47,27 @@ function createSubscriber() {
.
then
((
data
)
=>
{
console
.
info
(
'
Subscriber getCode success :
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
Subscriber getCode error because:
'
+
JSON
.
stringify
(
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
.
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
.
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
;
let
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
浏览文件 @
80bb7311
...
...
@@ -14,7 +14,7 @@
*/
import
thermal
from
"
@ohos.thermal
"
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************Thermal Performance Test Begin*************
"
);
...
...
@@ -25,7 +25,7 @@ describe('appInfoTest', function () {
})
function
performanceTest1
()
{
var
MAXNUM
=
1000
;
let
MAXNUM
=
1000
;
/**
* @tc.number ThermalPerformance_001
...
...
@@ -35,7 +35,7 @@ function performanceTest1() {
it
(
'
ThermalPerformance_001
'
,
0
,
function
()
{
let
startTime
=
new
Date
().
getTime
();
for
(
let
i
=
0
;
i
<
MAXNUM
;
i
++
)
{
var
level
=
thermal
.
getThermalLevel
();
let
level
=
thermal
.
getThermalLevel
();
}
let
waitTime
=
new
Date
().
getTime
()
-
startTime
;
let
avgTime
=
waitTime
;
//us
...
...
@@ -44,7 +44,7 @@ function performanceTest1() {
}
function
performanceTest2
()
{
var
MAXNUM
=
1000
;
let
MAXNUM
=
1000
;
/**
* @tc.number ThermalPerformance_002
...
...
@@ -65,7 +65,7 @@ function performanceTest2() {
}
function
performanceTest3
()
{
var
MAXNUM
=
1000
;
let
MAXNUM
=
1000
;
/**
* @tc.number ThermalPerformance_002
...
...
powermgr/powermgrthermal/src/main/js/default/test/thermal_uint.test.js
浏览文件 @
80bb7311
...
...
@@ -17,7 +17,7 @@
import
app
from
'
@system.app
'
import
thermal
from
"
@ohos.thermal
"
import
ThermalLevel
from
"
@ohos.thermal
"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************Thermal API Test Begin*************
"
);
...
...
@@ -46,9 +46,9 @@ function test1() {
*/
it
(
'
Thermal_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
enter
"
);
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
cold
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
cold
=
thermal
.
getThermalLevel
();
console
.
info
(
"
cold level is:
"
+
cold
);
expect
(
cold
>=
thermal
.
ThermalLevel
.
COOL
&&
cold
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
...
...
@@ -66,9 +66,9 @@ function test2() {
* @tc.desc Thermal acquisition kit
*/
it
(
'
Thermal_002
'
,
0
,
async
function
(
done
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
warm
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
warm
=
thermal
.
getThermalLevel
();
console
.
info
(
"
warm level is:
"
+
warm
);
expect
(
warm
>=
thermal
.
ThermalLevel
.
COOL
&&
warm
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
...
...
@@ -86,9 +86,9 @@ function test3() {
* @tc.desc Thermal acquisition kit
*/
it
(
'
Thermal_003
'
,
0
,
async
function
(
done
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
hot
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
hot
=
thermal
.
getThermalLevel
();
console
.
info
(
"
hot level is:
"
+
hot
);
expect
(
hot
>=
thermal
.
ThermalLevel
.
COOL
&&
hot
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
...
...
@@ -106,9 +106,9 @@ function test4() {
* @tc.desc Thermal acquisition kit
*/
it
(
'
Thermal_004
'
,
0
,
async
function
(
done
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
overheated
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
overheated
=
thermal
.
getThermalLevel
();
console
.
info
(
"
overheated level is:
"
+
overheated
);
expect
(
overheated
>=
thermal
.
ThermalLevel
.
COOL
&&
overheated
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
...
...
@@ -127,9 +127,9 @@ function test5() {
* @tc.desc Thermal acquisition kit
*/
it
(
'
Thermal_005
'
,
0
,
async
function
(
done
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
warning
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
warning
=
thermal
.
getThermalLevel
();
console
.
info
(
"
warning level is:
"
+
warning
);
expect
(
warning
>=
thermal
.
ThermalLevel
.
COOL
&&
warning
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
...
...
@@ -147,12 +147,12 @@ function test6() {
* @tc.desc Thermal acquisition kit
*/
it
(
'
Thermal_006
'
,
0
,
async
function
(
done
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
emergency
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
emergency
=
thermal
.
getThermalLevel
();
console
.
info
(
"
emergency level is:
"
+
emergency
);
expect
(
emergency
>=
thermal
.
ThermalLevel
.
COOL
&&
emergency
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
emergency
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
resolve
();
done
();
},
MSEC_1000
*
1
);
...
...
@@ -173,8 +173,8 @@ function test7() {
expect
(
cool
>=
thermal
.
ThermalLevel
.
COOL
&&
cool
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
@@ -197,8 +197,8 @@ function test8() {
expect
(
warm
>=
thermal
.
ThermalLevel
.
COOL
&&
warm
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
@@ -221,8 +221,8 @@ function test9() {
expect
(
hot
>=
thermal
.
ThermalLevel
.
COOL
&&
hot
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
@@ -244,11 +244,11 @@ function test10() {
thermal
.
subscribeThermalLevel
((
overheated
)
=>
{
console
.
info
(
"
overheated level is:
"
+
overheated
);
expect
(
overheated
>=
thermal
.
ThermalLevel
.
COOL
&&
overheated
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
overheated
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
@@ -271,8 +271,8 @@ function test11() {
expect
(
warning
>=
thermal
.
ThermalLevel
.
COOL
&&
warning
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
@@ -295,8 +295,8 @@ function test12() {
expect
(
emergency
>=
thermal
.
ThermalLevel
.
COOL
&&
emergency
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
@@ -319,8 +319,8 @@ function test13() {
expect
(
cool
>=
thermal
.
ThermalLevel
.
COOL
&&
cool
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js
浏览文件 @
80bb7311
...
...
@@ -16,7 +16,7 @@
import
app
from
'
@system.app
'
import
thermal
from
"
@ohos.thermal
"
import
ThermalLevel
from
"
@ohos.thermal
"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
MSEC_1000
=
1000
;
describe
(
'
appInfoTest
'
,
function
()
{
...
...
@@ -33,9 +33,9 @@ function test14() {
*/
it
(
'
Thermal_014
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
enter
"
);
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
var
level
=
thermal
.
getThermalLevel
();
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
level
=
thermal
.
getThermalLevel
();
console
.
info
(
"
level is:
"
+
level
);
expect
(
level
==
-
1
).
assertTrue
();
resolve
();
...
...
@@ -57,8 +57,8 @@ function test15() {
expect
(
level
==
-
1
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
...
...
sensors/sensor_standard/src/main/js/default/test/SensorGeneralalgorithm.test.js
浏览文件 @
80bb7311
...
...
@@ -49,7 +49,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
afterEach caled
'
)
})
var
SENSOR_DATA_MATRIX
=
[
let
SENSOR_DATA_MATRIX
=
[
{
"
rotation
"
:
[
-
0.7980074882507324
,
0.5486301183700562
,
0.24937734007835388
,
-
0.17277367413043976
,
-
0.6047078967094421
,
0.7774815559387207
,
0.5773502588272095
,
0.5773502588272095
,
0.5773502588272095
],
...
...
@@ -172,7 +172,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_070 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
1
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
1
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_070
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
GET_DIRECTION
[
0
][
i
])
}
...
...
@@ -195,7 +195,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_071 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
1
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
1
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_071
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
GET_DIRECTION
[
1
][
i
])
}
...
...
@@ -271,7 +271,7 @@ describe("SensorJsTest", function () {
*/
it
(
'
SensorJsTest_075
'
,
0
,
async
function
(
done
)
{
sensor
.
getDirection
(
rotationMatrix
[
0
]).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_075
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
GET_DIRECTION
[
0
][
i
])
}
...
...
@@ -292,7 +292,7 @@ describe("SensorJsTest", function () {
*/
it
(
'
SensorJsTest_076
'
,
0
,
async
function
(
done
)
{
sensor
.
getDirection
(
rotationMatrix
[
1
]).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_076
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
GET_DIRECTION
[
1
][
i
])
}
...
...
@@ -313,7 +313,7 @@ describe("SensorJsTest", function () {
*/
it
(
'
SensorJsTest_077
'
,
0
,
async
function
(
done
)
{
sensor
.
getDirection
([
1
,
2
,
3
,
1
,
2
,
3
,
1
,
2
,
3
,
0
]).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_077 failed
"
)
expect
(
false
).
assertTrue
();
}
...
...
@@ -347,7 +347,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_078 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_078 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
0
][
0
])
&&
expect
(
Number
.
isNaN
(
data
[
1
])).
assertTrue
()
&&
...
...
@@ -377,7 +377,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_079 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_079 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
1
][
0
])
&&
expect
(
Number
.
isNaN
(
data
[
1
])).
assertTrue
()
&&
...
...
@@ -407,7 +407,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_080 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_080 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
2
][
0
])
&&
expect
(
data
[
1
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
2
][
1
])
...
...
@@ -437,7 +437,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_081 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_081 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
3
][
0
])
&&
expect
(
Number
.
isNaN
(
data
[
1
])).
assertTrue
()
&&
expect
(
data
[
2
]).
assertEqual
(
...
...
@@ -466,7 +466,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_082 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_082 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
Number
.
isNaN
(
data
[
0
])
&&
Number
.
isNaN
(
data
[
1
])
&&
Number
.
isNaN
(
data
[
2
])).
assertTrue
();
}
...
...
@@ -487,7 +487,7 @@ describe("SensorJsTest", function () {
console
.
info
(
"
SensorJsAPI--->SensorJsTest_083
"
);
sensor
.
getAngleModify
([
1
,
2
,
3
,
1
,
2
,
3
,
1
,
2
,
3
],
[
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
]).
then
((
data
)
=>
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_083
"
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_083 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
0
][
0
])
&&
expect
(
Number
.
isNaN
(
data
[
1
])).
assertTrue
()
&&
...
...
@@ -515,7 +515,7 @@ describe("SensorJsTest", function () {
[
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
,
3.40282
e
+
38
]).
then
((
data
)
=>
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_084
"
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_084 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
1
][
0
])
&&
expect
(
Number
.
isNaN
(
data
[
1
])).
assertTrue
()
&&
expect
(
data
[
2
]).
assertEqual
(
...
...
@@ -543,7 +543,7 @@ describe("SensorJsTest", function () {
[
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
,
1.17549
e
-
38
]).
then
((
data
)
=>
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_085
"
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_085 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
2
][
0
])
&&
expect
(
data
[
1
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
2
][
1
])
...
...
@@ -572,7 +572,7 @@ describe("SensorJsTest", function () {
+
1
,
3.40282
e
+
38
+
1
,
3.40282
e
+
38
+
1
,
3.40282
e
+
38
+
1
])
.
then
((
data
)
=>
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_086
"
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_086 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
0
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
3
][
0
])
&&
expect
(
Number
.
isNaN
(
data
[
1
])).
assertTrue
()
&&
expect
(
data
[
2
]).
assertEqual
(
ANGLECHANGE_9_RESULT
[
3
][
2
]);
...
...
@@ -599,7 +599,7 @@ describe("SensorJsTest", function () {
[
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
,
0.0
/
0.0
]).
then
((
data
)
=>
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_087
"
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsAPI--->SensorJsTest_087 [
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
Number
.
isNaN
(
data
[
0
])
&&
Number
.
isNaN
(
data
[
1
])
&&
Number
.
isNaN
(
data
[
2
])).
assertTrue
();
}
...
...
@@ -610,7 +610,7 @@ describe("SensorJsTest", function () {
})
})
var
result
=
[
let
result
=
[
[
0.7441122531890869
,
0.5199999809265137
,
-
0.335999995470047
,
-
0.25099998712539673
],
[
0
,
3.402820018375656
e
+
38
,
3.402820018375656
e
+
38
,
3.402820018375656
e
+
38
],
[
1
,
0
,
0
,
0
],
...
...
@@ -632,7 +632,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_088 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
result
[
0
][
i
])
}
...
...
@@ -654,7 +654,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_089 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
result
[
1
][
i
])
}
...
...
@@ -676,7 +676,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_090 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
result
[
2
][
i
])
}
...
...
@@ -699,7 +699,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_091 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
])
expect
(
data
[
i
]).
assertEqual
(
result
[
3
][
i
])
}
...
...
@@ -739,7 +739,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_093 start
'
)
sensor
.
createQuaternion
([
0.52
,
-
0.336
,
-
0.251
]).
then
((
data
)
=>
{
console
.
info
(
'
SensorJsTest_093
'
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
result
[
0
][
i
])
}
...
...
@@ -782,7 +782,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_095 start
'
)
sensor
.
createQuaternion
([
0
,
0
,
0
]).
then
((
data
)
=>
{
console
.
info
(
'
SensorJsTest_095
'
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
result
[
2
][
i
])
}
...
...
@@ -805,7 +805,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_096 start
'
)
sensor
.
createQuaternion
([
-
0.325
,
-
0.562
,
-
0.25
]).
then
((
data
)
=>
{
console
.
info
(
'
SensorJsTest_096
'
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
data[
"
+
i
+
"
]:
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
result
[
3
][
i
])
}
...
...
@@ -856,7 +856,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorJsTest_098 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_098 [
"
+
i
+
"
) =
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
createRotationMatrixResult
[
0
][
i
])
}
...
...
@@ -875,7 +875,7 @@ describe("SensorJsTest", function () {
it
(
'
SensorJsTest_099
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SensorJsTest_099 start
'
)
sensor
.
createRotationMatrix
([
-
0.0245
,
0.402
,
0.0465
]).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_099 [
"
+
i
+
"
] :
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
createRotationMatrixResult
[
0
][
i
])
}
...
...
@@ -897,7 +897,7 @@ describe("SensorJsTest", function () {
it
(
'
SensorJsTest_100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SensorJsTest_100 start
'
)
sensor
.
createRotationMatrix
([
0
,
0
,
0
]).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_100 [
"
+
i
+
"
] :
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
createRotationMatrixResult
[
1
][
i
])
}
...
...
@@ -910,7 +910,7 @@ describe("SensorJsTest", function () {
console
.
info
(
"
SensorJsTest_100 end
"
)
})
var
getGeomagneticDipResult
=
[
0.8760581016540527
,
0.862170
,
-
Infinity
,
44330
]
let
getGeomagneticDipResult
=
[
0.8760581016540527
,
0.862170
,
-
Infinity
,
44330
]
/*
* @tc.name: SensorJsTest_101
...
...
@@ -1099,7 +1099,7 @@ describe("SensorJsTest", function () {
'
axisX
'
:
1
,
'
axisY
'
:
2
}).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_109 data[
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
transformCoordinateSystemResult
[
0
][
i
]);
}
...
...
@@ -1121,7 +1121,7 @@ describe("SensorJsTest", function () {
console
.
info
(
"
---------------------------SensorJsTest_110----------------------------------
"
);
sensor
.
transformCoordinateSystem
([
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
,
3.40282
e
+
39
],
{
'
axisX
'
:
1
,
'
axisY
'
:
3
}).
then
((
data
)
=>
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
info
(
"
SensorJsTest_110 data[
"
+
i
+
"
] =
"
+
data
[
i
]);
expect
(
data
[
i
]).
assertEqual
(
transformCoordinateSystemResult
[
2
][
i
]);
}
...
...
sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js
浏览文件 @
80bb7311
...
...
@@ -144,7 +144,7 @@ describe("SensorJsTest", function () {
reject
(
err
)
},
500
)
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest002 success x:
'
+
data
.
x
+
'
,y:
'
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest002 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -214,7 +214,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest004 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest004 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest004 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -314,7 +314,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest007 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest007 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest007 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -346,7 +346,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest008 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest008 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest008 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -372,7 +372,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest009 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest009 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest009 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -398,7 +398,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest010 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest010 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest010 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -424,7 +424,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest011 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest011 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest011 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -452,7 +452,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest012 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest012 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest012 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -484,7 +484,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest013 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest013 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest013 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -510,7 +510,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest014 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest014 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest014 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -536,7 +536,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest015 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest015 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest015 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -562,7 +562,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest016 once success
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest016 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest016 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -613,7 +613,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest018 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest018 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest018 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -639,7 +639,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest019 failed
'
);
expect
(
false
).
assertfalse
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest019 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest019 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -690,7 +690,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest021 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest021 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest021 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -716,7 +716,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest022 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest022 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest022 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -742,7 +742,7 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest023 failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest023 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest023 success x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
+
'
,geomagneticDip:
'
+
data
.
geomagneticDip
+
'
,deflectionAngle:
'
+
data
.
deflectionAngle
+
'
,levelIntensity:
'
+
data
.
levelIntensity
...
...
@@ -812,7 +812,7 @@ describe("SensorJsTest", function () {
*/
it
(
"
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0260
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0260-------------------------
"
);
for
(
var
i
=
0
;
i
<
timeMillis
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
timeMillis
.
length
;
i
++
)
{
await
sensor
.
getGeomagneticField
({
'
latitude
'
:
80
,
'
longitude
'
:
0
,
'
altitude
'
:
0
},
timeMillis
[
i
]).
then
((
data
)
=>
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest026 x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
...
...
@@ -1130,7 +1130,7 @@ describe("SensorJsTest", function () {
* @tc.desc:verify app info is not null
*/
it
(
'
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0390
'
,
0
,
async
function
(
done
)
{
for
(
var
i
=
0
;
i
<
timeMillis
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
timeMillis
.
length
;
i
++
)
{
console
.
info
(
'
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0390------------------
'
);
await
sensor
.
getGeomagneticField
({
'
latitude
'
:
80
,
'
longitude
'
:
0
,
'
altitude
'
:
0
},
timeMillis
[
i
]).
then
((
data
)
=>
{
...
...
@@ -1259,7 +1259,7 @@ describe("SensorJsTest", function () {
*/
it
(
'
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0450
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0450------------------
'
);
for
(
var
i
=
0
;
i
<
GEOMAGNETIC_COORDINATES
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
GEOMAGNETIC_COORDINATES
.
length
;
i
++
)
{
await
sensor
.
getGeomagneticField
({
'
latitude
'
:
GEOMAGNETIC_COORDINATES
[
i
][
0
],
'
longitude
'
:
GEOMAGNETIC_COORDINATES
[
i
][
1
],
'
altitude
'
:
GEOMAGNETIC_COORDINATES
[
i
][
2
]
...
...
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
浏览文件 @
80bb7311
...
...
@@ -19,8 +19,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import
sensor
from
'
@ohos.sensor
'
function
sleep
(
NumberMillis
)
{
var
now
=
new
Date
()
var
exitTime
=
now
.
getTime
()
+
NumberMillis
let
now
=
new
Date
()
let
exitTime
=
now
.
getTime
()
+
NumberMillis
while
(
true
)
{
now
=
new
Date
()
if
(
now
.
getTime
>
exitTime
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录