Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
b1842bf5
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,发现更多精彩内容 >>
未验证
提交
b1842bf5
编写于
4月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3041 test: 优化@system.battery.d.tsXTS用例
Merge pull request !3041 from ShiJie/master
上级
ce7be3d8
1df11381
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
159 addition
and
59 deletion
+159
-59
powermgr/powermgrbattery/src/main/js/default/test/system_battery.test.js
...grbattery/src/main/js/default/test/system_battery.test.js
+159
-59
未找到文件。
powermgr/powermgrbattery/src/main/js/default/test/system_battery.test.js
浏览文件 @
b1842bf5
...
...
@@ -14,112 +14,212 @@
*/
import
battery
from
'
@system.battery
'
;
import
batteryInfo
from
'
@ohos.batteryInfo
'
;
import
{
describe
}
from
'
deccjsunit/index
'
import
batteryInfo
from
'
@ohos.battery
'
;
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
function
successFunc
(
data
,
tag
)
{
console
.
log
(
tag
+
"
: level:
"
+
data
.
level
+
"
, charging:
"
+
data
.
charging
);
let
soc
=
(
batteryInfo
.
batterySOC
*
0.01
);
expect
(
fabs
(
soc
-
data
.
level
)
<=
1
e
-
9
).
assertTrue
();
if
(
batteryInfo
.
chargingStatus
===
batteryInfo
.
BatteryChargeState
.
ENABLE
||
batteryInfo
.
chargingStatus
===
batteryInfo
.
BatteryChargeState
.
FULL
)
{
expect
(
data
.
charging
).
assertTrue
();
}
else
{
expect
(
data
.
charging
).
assertFalse
();
}
}
function
failFunc
(
data
,
code
,
tag
)
{
console
.
log
(
tag
+
"
: data:
"
+
data
+
"
, code:
"
+
code
);
expect
().
assertFail
();
}
function
completeFunc
(
tag
)
{
console
.
log
(
tag
+
"
: The device information is obtained successfully.
"
);
}
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************System Battery Unit Test Begin*************
"
);
/**
* @tc.number system_battery_js_0100
* @tc.name get_status_
test_success
* @tc.name get_status_
success_test
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_success
'
,
0
,
function
()
{
let
execSucc
=
false
let
execcomplete
=
false
const
successTest
=
"
get_status_success_test
"
;
it
(
successTest
,
0
,
function
()
{
let
execSucc
=
false
;
let
execcomplete
=
false
;
battery
.
getStatus
({
success
:
(
data
)
=>
{
execSucc
=
true
let
batterySoc
=
(
batteryInfo
.
batterySOC
*
0.01
);
console
.
log
(
"
batterySoc:
"
+
batterySoc
+
"
, data.level:
"
+
data
.
levet
)
expect
(
fabs
(
data
.
levet
-
batterySoc
)
<=
1
e
-
9
).
assertTrue
()
if
(
batteryInfo
.
chargingStatus
==
batteryInfo
.
BatteryChargeState
.
ENABLE
)
{
expect
(
data
.
charging
).
assertTrue
()
}
else
{
expect
(
data
.
charging
).
assertFalse
()
}
execSucc
=
true
;
successFunc
(
data
,
successTest
);
},
fail
:
(
data
,
code
)
=>
{
console
.
log
(
"
get_status_test_success, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
true
).
assertFalse
()
failFunc
(
data
,
code
,
successTest
);
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
execcomplete
=
true
;
completeFunc
(
successTest
);
}
});
expect
(
execSucc
).
assertTrue
()
expect
(
execcomplete
).
assertTrue
()
})
expect
(
execSucc
).
assertTrue
()
;
expect
(
execcomplete
).
assertTrue
()
;
})
;
/**
* @tc.number system_battery_js_0200
* @tc.name get_status_
test_fail
* @tc.name get_status_
success_null_test
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_fail
'
,
0
,
function
()
{
let
exec
=
false
let
execcomplete
=
false
const
successNullTest
=
"
get_status_success_null_test
"
;
it
(
successNullTest
,
0
,
function
()
{
let
execcomplete
=
false
;
battery
.
getStatus
({
success
:
null
,
fail
:
(
data
,
code
)
=>
{
console
.
log
(
"
get_status_test_fail, data:
"
+
data
+
"
, code:
"
+
code
);
exec
=
true
;
// The success argument is not a function, code: -4
expect
(
code
==
-
4
).
assertTrue
()
failFunc
(
data
,
code
,
successNullTest
);
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
execcomplete
=
true
;
completeFunc
(
successNullTest
);
}
});
expect
(
exec
).
assertTrue
()
expect
(
execcomplete
).
assertTrue
()
})
expect
(
execcomplete
).
assertTrue
();
});
/**
* @tc.number system_battery_js_0300
* @tc.name get_status_
test_complete
* @tc.name get_status_
success_empty_test
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_complete
'
,
0
,
function
()
{
let
execcomplete
=
false
const
successEmptyTest
=
"
get_status_success_null_test
"
;
it
(
successEmptyTest
,
0
,
function
()
{
let
execcomplete
=
false
;
battery
.
getStatus
({
success
:
null
,
fail
:
null
,
fail
:
(
data
,
code
)
=>
{
failFunc
(
data
,
code
,
successEmptyTest
);
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
execcomplete
=
true
;
completeFunc
(
successEmptyTest
);
}
});
expect
(
execcomplete
).
assertTrue
()
})
expect
(
execcomplete
).
assertTrue
()
;
})
;
/**
* @tc.number system_battery_js_0400
* @tc.name get_status_
test_parameter_is_null
* @tc.name get_status_
fail_null_test
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_parameter_is_null
'
,
0
,
function
()
{
let
failNullTest
=
"
get_status_fail_null_test
"
;
it
(
failNullTest
,
0
,
function
()
{
let
execSucc
=
false
;
let
execcomplete
=
false
;
battery
.
getStatus
({
success
:
null
,
success
:
(
data
)
=>
{
execSucc
=
true
;
successFunc
(
data
,
failNullTest
);
},
fail
:
null
,
complete
:
null
complete
:
()
=>
{
execcomplete
=
true
;
completeFunc
(
failNullTest
);
}
});
expect
(
execSucc
).
assertTrue
();
expect
(
execcomplete
).
assertTrue
();
});
expect
(
true
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0500
* @tc.name get_status_test_parameter_is_empty
* @tc.name get_status_fail_empty_test
* @tc.desc Battery acquisition kit
*/
let
failEmptyTest
=
"
get_status_fail_empty_test
"
;
it
(
failEmptyTest
,
0
,
function
()
{
let
execSucc
=
false
;
let
execcomplete
=
false
;
battery
.
getStatus
({
success
:
()
=>
{
execSucc
=
true
;
successFunc
(
data
,
failEmptyTest
);
},
complete
:
()
=>
{
execcomplete
=
true
;
completeFunc
(
failEmptyTest
);
}
});
expect
(
execSucc
).
assertTrue
();
expect
(
execcomplete
).
assertTrue
();
});
/**
* @tc.number system_battery_js_0600
* @tc.name get_status_complete_null_test
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_parameter_is_empty
'
,
0
,
function
()
{
let
completeNullTest
=
"
get_status_complete_null_test
"
;
it
(
completeNullTest
,
0
,
function
()
{
let
execSucc
=
false
;
battery
.
getStatus
({
success
:
(
data
)
=>
{
execSucc
=
true
;
successFunc
(
data
,
completeNullTest
);
},
fail
:
(
data
,
code
)
=>
{
failFunc
(
data
,
code
,
completeNullTest
);
},
complete
:
null
});
expect
(
execSucc
).
assertTrue
();
});
/**
* @tc.number system_battery_js_0700
* @tc.name get_status_complete_empty_test
* @tc.desc Battery acquisition kit
*/
let
completeEmptyTest
=
"
get_status_complete_empty_test
"
;
it
(
completeEmptyTest
,
0
,
function
()
{
let
execSucc
=
false
;
battery
.
getStatus
({
success
:
(
data
)
=>
{
execSucc
=
true
;
successFunc
(
data
,
completeEmptyTest
);
},
fail
:
(
data
,
code
)
=>
{
failFunc
(
data
,
code
,
completeEmptyTest
);
}
});
expect
(
execSucc
).
assertTrue
();
});
/**
* @tc.number system_battery_js_0800
* @tc.name get_status_all_null
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_all_null
'
,
0
,
function
()
{
let
allNull
=
false
;
battery
.
getStatus
({
success
:
null
,
fail
:
null
,
complete
:
null
,
});
expect
(
!
allNull
).
assertTrue
();
});
/**
* @tc.number system_battery_js_0800
* @tc.name get_status_all_empty
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_all_empty
'
,
0
,
function
()
{
let
allNull
=
false
;
battery
.
getStatus
();
expect
(
true
).
assertTrue
()
})
})
\ No newline at end of file
expect
(
!
allNull
).
assertTrue
();
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录