Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
dab7e20c
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看板
提交
dab7e20c
编写于
1月 04, 2023
作者:
G
greada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
power test code optimization!
Signed-off-by:
N
greada
<
kangqiao1@huawei.com
>
上级
2db2bb3a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
188 deletion
+19
-188
powermgr/battery_manager/src/main/js/test/battery_unit.test.js
...mgr/battery_manager/src/main/js/test/battery_unit.test.js
+1
-34
powermgr/power_manager/src/main/config.json
powermgr/power_manager/src/main/config.json
+8
-2
powermgr/power_manager/src/main/js/test/power_manager_power.test.js
...ower_manager/src/main/js/test/power_manager_power.test.js
+10
-152
未找到文件。
powermgr/battery_manager/src/main/js/test/battery_unit.test.js
浏览文件 @
dab7e20c
...
...
@@ -279,39 +279,6 @@ describe('BatteryUnitTest', function () {
}
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1740
* @tc.name nowCurrent_JSTest
* @tc.desc Battry Present Interface Test
*/
it
(
'
nowCurrent_JSTest
'
,
0
,
function
()
{
let
nowCurrent
=
batteryInfo
.
nowCurrent
;
console
.
info
(
'
nowCurrent =
'
+
nowCurrent
);
expect
((
nowCurrent
>=
-
20000
&&
nowCurrent
<=
20000
)).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1750
* @tc.name remainingEnergy_JSTest
* @tc.desc Battry Present Interface Test
*/
it
(
'
remainingEnergy_JSTest
'
,
0
,
function
()
{
let
remainingEnergy
=
batteryInfo
.
remainingEnergy
;
console
.
info
(
'
remEnergy =
'
+
remainingEnergy
);
expect
(
remainingEnergy
>=
0
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1760
* @tc.name totalEnergy_JSTest
* @tc.desc Battry Present Interface Test
*/
it
(
'
totalEnergy_JSTest
'
,
0
,
function
()
{
let
totalEnergy
=
batteryInfo
.
totalEnergy
;
console
.
info
(
'
totalenergy =
'
+
totalEnergy
);
expect
(
totalEnergy
>=
0
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1780
* @tc.name batterylevel_JSTest
...
...
@@ -398,7 +365,7 @@ describe('BatteryUnitTest', function () {
it
(
'
remainingChargeTime_JSTest
'
,
0
,
function
()
{
let
remainingChargeTime
=
batteryInfo
.
estimatedRemainingChargeTime
;
console
.
info
(
'
remainingChargeTime =
'
+
remainingChargeTime
);
expect
(
remainingChargeTime
>=
0
).
assertTrue
();
expect
(
remainingChargeTime
>=
-
1
).
assertTrue
();
})
/**
...
...
powermgr/power_manager/src/main/config.json
浏览文件 @
dab7e20c
...
...
@@ -16,8 +16,8 @@
"package"
:
"com.example.mypowerapp"
,
"name"
:
".entry"
,
"deviceType"
:
[
"tablet"
,
"default"
,
"tablet"
,
"default"
,
"phone"
],
"distro"
:
{
...
...
@@ -85,6 +85,12 @@
}
}
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.RUNNING_LOCK"
,
"reason"
:
"use ohos.permission.RUNNING_LOCK"
}
],
"testRunner"
:
{
"name"
:
"OpenHarmonyTestRunner"
,
"srcPath"
:
"TestRunner"
...
...
powermgr/power_manager/src/main/js/test/power_manager_power.test.js
浏览文件 @
dab7e20c
...
...
@@ -26,7 +26,7 @@ describe('PowerManagerPowerTest', function () {
* @tc.name Power_Reboot_Device_JSTest0010
* @tc.desc reboot device (deprecated since 9)
*/
it
(
'
Power_Reboot_Device_JSTest0010
'
,
0
,
function
()
{
it
(
'
Power_Reboot_Device_JSTest0010
'
,
0
,
function
()
{
// Reboot tests are not performed by default
if
(
false
)
{
try
{
...
...
@@ -45,16 +45,9 @@ describe('PowerManagerPowerTest', function () {
*/
it
(
'
Power_Is_Screnn_On_Promise_JSTest0020
'
,
0
,
async
function
(
done
)
{
power
.
wakeupDevice
(
"
Power_Is_Screnn_On_Promise_JSTest0020
"
);
await
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest0020 screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest0020 success
'
);
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_Is_Screnn_On_Promise_JSTest0020 error:
'
+
error
);
expect
().
assertFail
();
})
let
isScreenOn
=
await
power
.
isScreenOn
();
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest0020 isScreenOn is
'
+
isScreenOn
);
expect
(
isScreenOn
).
assertTrue
();
done
();
})
...
...
@@ -85,19 +78,12 @@ describe('PowerManagerPowerTest', function () {
*/
it
(
'
Power_Is_Active_JSTest0040
'
,
0
,
function
()
{
try
{
power
.
suspend
();
power
.
wakeup
(
'
Power_Is_Active_JSTest0040
'
);
let
on
=
power
.
isActive
();
console
.
info
(
'
Power_Is_Active_JSTest0040 on:
'
+
on
);
expect
(
on
).
assertTrue
();
power
.
suspend
();
let
off
=
power
.
isActive
();
console
.
info
(
'
Power_Is_Active_JSTest0040 off:
'
+
off
);
expect
(
off
).
assertFalse
();
}
catch
(
e
)
{
console
.
info
(
'
Power_Is_Active_JSTest0040:
'
+
e
);
expect
().
assertFail
();
}
var
isActive
=
power
.
isActive
();
console
.
info
(
'
power is active:
'
+
isActive
);
expect
(
isActive
).
assertNotNull
();
}
catch
(
err
)
{
console
.
error
(
'
check active status failed, err:
'
+
err
);
}
})
/**
...
...
@@ -155,133 +141,5 @@ describe('PowerManagerPowerTest', function () {
console
.
info
(
'
MODE_EXTREME_POWER_SAVE =
'
+
devicePowerMode
);
expect
(
devicePowerMode
===
603
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0150
* @tc.name Power_WakeupDevices_String_JSTest0150
* @tc.desc Try to wakeup the device and let screen on (SystemApi)
*/
it
(
'
Power_WakeupDevices_String_JSTest0150
'
,
0
,
async
function
(
done
)
{
await
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_WakeupDevices_String_JSTest0150: The current screenOn is
'
+
screenOn
);
if
(
screenOn
)
{
power
.
suspendDevice
();
}
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_WakeupDevices_String_JSTest0150 error:
'
+
error
);
expect
().
assertFail
();
})
setTimeout
(
function
(){
power
.
wakeupDevice
(
"
Power_WakeupDevices_String_JSTest0150
"
);
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_WakeupDevices_String_JSTest0150: The current screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
Power_WakeupDevices_String_JSTest0150 success
'
);
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_WakeupDevices_String_JSTest0150 error:
'
+
error
);
expect
().
assertFail
();
})
},
2000
);
done
();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0160
* @tc.name Power_SuspendDevices_JSTest0160
* @tc.desc Try to suspend the device and let screen off (SystemApi)
*/
it
(
'
Power_SuspendDevices_JSTest0160
'
,
0
,
async
function
(
done
)
{
await
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_SuspendDevices_JSTest0160: The current screenOn is
'
+
screenOn
);
if
(
!
screenOn
)
{
power
.
wakeupDevice
(
"
Power_SuspendDevices_JSTest0160
"
);
}
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_SuspendDevices_JSTest0160 error:
'
+
error
);
expect
().
assertFail
();
})
setTimeout
(
function
(){
power
.
suspendDevice
();
console
.
info
(
'
Power_SuspendDevices_JSTest0160: SuspendDevice end
'
);
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_SuspendDevices_JSTest0160: The current screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertFalse
();
console
.
info
(
'
Power_SuspendDevices_JSTest0160 success
'
);
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_SuspendDevices_JSTest0160 error:
'
+
error
);
expect
().
assertFail
();
})
},
2000
);
done
();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0170
* @tc.name Power_Set_Mode_Promise_JSTest0110
* @tc.desc Gets and sets the power mode (SystemApi)
*/
it
(
'
Power_Set_Mode_Promise_JSTest0110
'
,
0
,
async
function
(
done
)
{
if
(
false
)
{
let
currentMode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Set_Mode_Promise_JSTest0110 currentMode:
'
+
currentMode
);
expect
(
currentMode
>=
power
.
DevicePowerMode
.
MODE_NORMAL
&&
currentMode
<=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
).
assertTrue
();
try
{
let
isExec
=
false
;
await
power
.
setPowerMode
(
power
.
DevicePowerMode
.
MODE_POWER_SAVE
)
.
then
((
error
)
=>
{
isExec
=
true
;
console
.
info
(
'
Power_Set_Mode_Promise_JSTest0110 error:
'
+
(
typeof
error
));
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
let
mode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Set_Mode_Promise_JSTest0110 mode:
'
+
mode
);
expect
(
mode
===
power
.
DevicePowerMode
.
MODE_POWER_SAVE
).
assertTrue
();
}).
finally
(()
=>
{
expect
(
isExec
).
assertTrue
();
})
}
catch
(
e
)
{
console
.
info
(
'
Power_Set_Mode_Promise_JSTest0110 error:
'
+
e
);
expect
().
assertFail
();
}
power
.
setPowerMode
(
currentMode
);
}
done
();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0180
* @tc.name Power_Set_Mode_Callback_JSTest0180
* @tc.desc Gets and sets the power mode (SystemApi)
*/
it
(
'
Power_Set_Mode_Callback_JSTest0180
'
,
0
,
async
function
(
done
)
{
if
(
false
)
{
let
currentMode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 currentMode:
'
+
currentMode
);
expect
(
currentMode
>=
power
.
DevicePowerMode
.
MODE_NORMAL
&&
currentMode
<=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
).
assertTrue
();
try
{
power
.
setPowerMode
(
power
.
DevicePowerMode
.
MODE_PERFORMANCE
,
(
error
)
=>
{
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 error:
'
+
(
typeof
error
));
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
let
mode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 mode:
'
+
mode
);
expect
(
mode
===
power
.
DevicePowerMode
.
MODE_PERFORMANCE
).
assertTrue
();
})
}
catch
(
e
)
{
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 error:
'
+
e
);
expect
().
assertFail
();
}
power
.
setPowerMode
(
currentMode
);
}
done
();
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录