Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fbaaeaa2
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,发现更多精彩内容 >>
未验证
提交
fbaaeaa2
编写于
4月 12, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2955 test: Supports the @system.battery.d.ts interface test
Merge pull request !2955 from ShiJie/master
上级
1a89cc13
819ced23
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
254 addition
and
2 deletion
+254
-2
powermgr/powermgrbattery/src/main/js/default/test/List.test.js
...mgr/powermgrbattery/src/main/js/default/test/List.test.js
+2
-1
powermgr/powermgrbattery/src/main/js/default/test/system_battery.test.js
...grbattery/src/main/js/default/test/system_battery.test.js
+125
-0
powermgr/powermgrbattery_rk3568/src/main/js/default/test/List.test.js
...ermgrbattery_rk3568/src/main/js/default/test/List.test.js
+2
-1
powermgr/powermgrbattery_rk3568/src/main/js/default/test/system_battery.test.js
...ry_rk3568/src/main/js/default/test/system_battery.test.js
+125
-0
未找到文件。
powermgr/powermgrbattery/src/main/js/default/test/List.test.js
浏览文件 @
fbaaeaa2
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -15,3 +15,4 @@
require
(
'
./battery_unit.test.js
'
)
require
(
'
./battery_common_event.test.js
'
)
require
(
'
./power_manager_running_lock.test.js
'
)
require
(
'
./system_battery.test.js
'
)
\ No newline at end of file
powermgr/powermgrbattery/src/main/js/default/test/system_battery.test.js
0 → 100644
浏览文件 @
fbaaeaa2
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
battery
from
'
@system.battery
'
;
import
batteryInfo
from
'
@ohos.batteryInfo
'
;
import
{
describe
}
from
'
deccjsunit/index
'
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************System Battery Unit Test Begin*************
"
);
/**
* @tc.number system_battery_js_0100
* @tc.name get_status_test_success
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_success
'
,
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
()
}
},
fail
:
(
data
,
code
)
=>
{
console
.
log
(
"
get_status_test_success, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
true
).
assertFalse
()
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
}
});
expect
(
execSucc
).
assertTrue
()
expect
(
execcomplete
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0200
* @tc.name get_status_test_fail
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_fail
'
,
0
,
function
()
{
let
exec
=
false
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
()
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
}
});
expect
(
exec
).
assertTrue
()
expect
(
execcomplete
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0300
* @tc.name get_status_test_complete
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_complete
'
,
0
,
function
()
{
let
execcomplete
=
false
battery
.
getStatus
({
success
:
null
,
fail
:
null
,
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
}
});
expect
(
execcomplete
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0400
* @tc.name get_status_test_parameter_is_null
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_parameter_is_null
'
,
0
,
function
()
{
battery
.
getStatus
({
success
:
null
,
fail
:
null
,
complete
:
null
});
expect
(
true
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0500
* @tc.name get_status_test_parameter_is_empty
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_parameter_is_empty
'
,
0
,
function
()
{
battery
.
getStatus
();
expect
(
true
).
assertTrue
()
})
})
\ No newline at end of file
powermgr/powermgrbattery_rk3568/src/main/js/default/test/List.test.js
浏览文件 @
fbaaeaa2
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -15,3 +15,4 @@
require
(
'
./battery_unit.test.js
'
)
require
(
'
./battery_common_event.test.js
'
)
require
(
'
./power_manager_running_lock.test.js
'
)
require
(
'
./system_battery.test.js
'
)
powermgr/powermgrbattery_rk3568/src/main/js/default/test/system_battery.test.js
0 → 100644
浏览文件 @
fbaaeaa2
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
battery
from
'
@system.battery
'
;
import
batteryInfo
from
'
@ohos.batteryInfo
'
;
import
{
describe
}
from
'
deccjsunit/index
'
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************System Battery Unit Test Begin*************
"
);
/**
* @tc.number system_battery_js_0100
* @tc.name get_status_test_success
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_success
'
,
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
()
}
},
fail
:
(
data
,
code
)
=>
{
console
.
log
(
"
get_status_test_success, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
true
).
assertFalse
()
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
}
});
expect
(
execSucc
).
assertTrue
()
expect
(
execcomplete
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0200
* @tc.name get_status_test_fail
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_fail
'
,
0
,
function
()
{
let
exec
=
false
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
()
},
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
}
});
expect
(
exec
).
assertTrue
()
expect
(
execcomplete
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0300
* @tc.name get_status_test_complete
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_complete
'
,
0
,
function
()
{
let
execcomplete
=
false
battery
.
getStatus
({
success
:
null
,
fail
:
null
,
complete
:
()
=>
{
execcomplete
=
true
expect
(
true
).
assertTrue
()
console
.
log
(
"
The device information is obtained successfully. Procedure
"
);
}
});
expect
(
execcomplete
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0400
* @tc.name get_status_test_parameter_is_null
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_parameter_is_null
'
,
0
,
function
()
{
battery
.
getStatus
({
success
:
null
,
fail
:
null
,
complete
:
null
});
expect
(
true
).
assertTrue
()
})
/**
* @tc.number system_battery_js_0500
* @tc.name get_status_test_parameter_is_empty
* @tc.desc Battery acquisition kit
*/
it
(
'
get_status_test_parameter_is_empty
'
,
0
,
function
()
{
battery
.
getStatus
();
expect
(
true
).
assertTrue
()
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录