Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e97ac3eb
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看板
未验证
提交
e97ac3eb
编写于
2月 22, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 22, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7681 【代码上库】【xts_acts】【powermgr】【master】 power test code optimization
Merge pull request !7681 from kangqiao/master
上级
40fd9b2c
1059d4dd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
181 addition
and
181 deletion
+181
-181
powermgr/thermal_manager/src/main/js/test/thermal_unittest.test.js
...thermal_manager/src/main/js/test/thermal_unittest.test.js
+181
-181
未找到文件。
powermgr/thermal_manager/src/main/js/test/thermal_unittest.test.js
浏览文件 @
e97ac3eb
...
...
@@ -18,203 +18,203 @@ import { describe, it, expect } from '@ohos/hypium'
const
MSEC_1000
=
1000
;
export
default
function
ThermalUnitTest
()
{
describe
(
'
ThermalUnitTest
'
,
function
()
{
console
.
log
(
"
*************Thermal API Test Begin*************
"
);
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0010
* @tc.name Get_Thermal_Level_JSTest0010
* @tc.desc Thermal acquisition kit
*/
it
(
'
Get_Thermal_Level_JSTest0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
enter
"
);
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
level
=
thermal
.
getThermalLevel
();
describe
(
'
ThermalUnitTest
'
,
function
()
{
console
.
log
(
"
*************Thermal API Test Begin*************
"
);
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0010
* @tc.name Get_Thermal_Level_JSTest0010
* @tc.desc Thermal acquisition kit
*/
it
(
'
Get_Thermal_Level_JSTest0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
enter
"
);
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
level
=
thermal
.
getThermalLevel
();
console
.
info
(
"
level is:
"
+
level
);
expect
(
level
>=
0
&&
level
<=
6
).
assertTrue
();
resolve
();
done
();
},
MSEC_1000
*
4
);
})
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0020
* @tc.name SubscribeAndUnsubscribe_Thermal_Level_JSTest0020
* @tc.desc Thermal acquisition kit
*/
it
(
'
SubscribeAndUnsubscribe_Thermal_Level_JSTest0020
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
level
)
=>
{
console
.
info
(
"
level is:
"
+
level
);
expect
(
level
>=
0
&&
level
<=
6
).
assertTrue
();
resolve
();
done
();
},
MSEC_1000
*
4
);
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
},
MSEC_1000
*
4
);
})
})
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0020
* @tc.name SubscribeAndUnsubscribe_Thermal_Level_JSTest0020
* @tc.desc Thermal acquisition kit
*/
it
(
'
SubscribeAndUnsubscribe_Thermal_Level_JSTest0020
'
,
0
,
async
function
(
done
)
{
thermal
.
subscribeThermalLevel
((
level
)
=>
{
console
.
info
(
"
level is:
"
+
level
);
expect
(
level
>=
0
&&
level
<=
6
).
assertTrue
();
done
();
})
await
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
thermal
.
unsubscribeThermalLevel
(()
=>
{
console
.
info
(
"
unsubscribe successfully!
"
);
});
resolve
();
},
MSEC_1000
*
4
);
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0030
* @tc.name Get_Thermal_Level_Cool_JSTest0030
* @tc.desc Get device thermalLevel COOL
*/
it
(
'
Get_Thermal_Level_Cool_JSTest0030
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
COOL
;
console
.
info
(
'
ThermalLevel.COOL =
'
+
thermalLevel
);
expect
(
thermalLevel
===
0
).
assertTrue
();
})
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0030
* @tc.name Get_Thermal_Level_Cool_JSTest0030
* @tc.desc Get device thermalLevel COOL
*/
it
(
'
Get_Thermal_Level_Cool_JSTest0030
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
COOL
;
console
.
info
(
'
ThermalLevel.COOL =
'
+
thermalLevel
);
expect
(
thermalLevel
===
0
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0040
* @tc.name Get_Thermal_Level_Normal_JSTest0040
* @tc.desc Get device thermalLevel NORMAL
*/
it
(
'
Get_Thermal_Level_Normal_JSTest0040
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
NORMAL
;
console
.
info
(
'
ThermalLevel.NORMAL =
'
+
thermalLevel
);
expect
(
thermalLevel
===
1
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0040
* @tc.name Get_Thermal_Level_Normal_JSTest0040
* @tc.desc Get device thermalLevel NORMAL
*/
it
(
'
Get_Thermal_Level_Normal_JSTest0040
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
NORMAL
;
console
.
info
(
'
ThermalLevel.NORMAL =
'
+
thermalLevel
);
expect
(
thermalLevel
===
1
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0050
* @tc.name Get_Thermal_Level_Warm_JSTest0050
* @tc.desc Get device thermalLevel WARM
*/
it
(
'
Get_Thermal_Level_Warm_JSTest0050
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
WARM
;
console
.
info
(
'
ThermalLevel.WARM =
'
+
thermalLevel
);
expect
(
thermalLevel
===
2
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0050
* @tc.name Get_Thermal_Level_Warm_JSTest0050
* @tc.desc Get device thermalLevel WARM
*/
it
(
'
Get_Thermal_Level_Warm_JSTest0050
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
WARM
;
console
.
info
(
'
ThermalLevel.WARM =
'
+
thermalLevel
);
expect
(
thermalLevel
===
2
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0060
* @tc.name Get_Thermal_Level_Hot_JSTest0060
* @tc.desc Get device thermalLevel HOT
*/
it
(
'
Get_Thermal_Level_Hot_JSTest0060
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
HOT
;
console
.
info
(
'
ThermalLevel.HOT =
'
+
thermalLevel
);
expect
(
thermalLevel
===
3
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0060
* @tc.name Get_Thermal_Level_Hot_JSTest0060
* @tc.desc Get device thermalLevel HOT
*/
it
(
'
Get_Thermal_Level_Hot_JSTest0060
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
HOT
;
console
.
info
(
'
ThermalLevel.HOT =
'
+
thermalLevel
);
expect
(
thermalLevel
===
3
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0070
* @tc.name Get_Thermal_Level_OverHeated_JSTest0070
* @tc.desc Get device thermalLevel OVERHEATED
*/
it
(
'
Get_Thermal_Level_OverHeated_JSTest0070
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
OVERHEATED
;
console
.
info
(
'
ThermalLevel.OVERHEATED =
'
+
thermalLevel
);
expect
(
thermalLevel
===
4
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0070
* @tc.name Get_Thermal_Level_OverHeated_JSTest0070
* @tc.desc Get device thermalLevel OVERHEATED
*/
it
(
'
Get_Thermal_Level_OverHeated_JSTest0070
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
OVERHEATED
;
console
.
info
(
'
ThermalLevel.OVERHEATED =
'
+
thermalLevel
);
expect
(
thermalLevel
===
4
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0080
* @tc.name Get_Thermal_Level_Warning_JSTest0080
* @tc.desc Get device thermalLevel WARNING
*/
it
(
'
Get_Thermal_Level_Warning_JSTest0080
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
WARNING
;
console
.
info
(
'
ThermalLevel.WARNING =
'
+
thermalLevel
);
expect
(
thermalLevel
===
5
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0080
* @tc.name Get_Thermal_Level_Warning_JSTest0080
* @tc.desc Get device thermalLevel WARNING
*/
it
(
'
Get_Thermal_Level_Warning_JSTest0080
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
WARNING
;
console
.
info
(
'
ThermalLevel.WARNING =
'
+
thermalLevel
);
expect
(
thermalLevel
===
5
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0090
* @tc.name Get_Thermal_Level_Emergency_JSTest0090
* @tc.desc Get device thermalLevel EMERGENCY
*/
it
(
'
Get_Thermal_Level_Emergency_JSTest0090
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
EMERGENCY
;
console
.
info
(
'
ThermalLevel.EMERGENCY =
'
+
thermalLevel
);
expect
(
thermalLevel
===
6
).
assertTrue
();
})
/**
* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0090
* @tc.name Get_Thermal_Level_Emergency_JSTest0090
* @tc.desc Get device thermalLevel EMERGENCY
*/
it
(
'
Get_Thermal_Level_Emergency_JSTest0090
'
,
0
,
function
()
{
let
thermalLevel
=
thermal
.
ThermalLevel
.
EMERGENCY
;
console
.
info
(
'
ThermalLevel.EMERGENCY =
'
+
thermalLevel
);
expect
(
thermalLevel
===
6
).
assertTrue
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0100
* @tc.name Get_Level_JSTest0100
* @tc.desc Thermal acquisition kit
*/
it
(
'
Get_Level_JSTest0100
'
,
0
,
async
function
(
done
)
{
let
level
=
thermal
.
getLevel
();
console
.
info
(
"
Get_Level_JSTest0100 level is:
"
+
level
);
expect
(
level
>=
thermal
.
ThermalLevel
.
COOL
&&
level
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0100
* @tc.name Get_Level_JSTest0100
* @tc.desc Thermal acquisition kit
*/
it
(
'
Get_Level_JSTest0100
'
,
0
,
async
function
(
done
)
{
let
level
=
thermal
.
getLevel
();
console
.
info
(
"
Get_Level_JSTest0100 level is:
"
+
level
);
expect
(
level
>=
thermal
.
ThermalLevel
.
COOL
&&
level
<=
thermal
.
ThermalLevel
.
EMERGENCY
).
assertTrue
();
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0110
* @tc.name Register_Thermal_Level_Callback_JSTest0110
* @tc.desc Thermal acquisition kit
*/
it
(
'
Register_Thermal_Level_Callback_JSTest0110
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
registerThermalLevelCallback
((
value
)
=>
{
console
.
info
(
"
Register_Thermal_Level_Callback_JSTest0110 level is:
"
+
value
);
let
level
=
thermal
.
getLevel
();
expect
(
level
===
value
).
assertTrue
();
})
}
catch
(
error
)
{
console
.
info
(
'
Register_Thermal_Level_Callback_JSTest0110:
'
+
error
);
expect
().
assertFail
();
}
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0110
* @tc.name Register_Thermal_Level_Callback_JSTest0110
* @tc.desc Thermal acquisition kit
*/
it
(
'
Register_Thermal_Level_Callback_JSTest0110
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
registerThermalLevelCallback
((
value
)
=>
{
console
.
info
(
"
Register_Thermal_Level_Callback_JSTest0110 level is:
"
+
value
);
let
level
=
thermal
.
getLevel
();
expect
(
level
===
value
).
assertTrue
();
})
}
catch
(
error
)
{
console
.
info
(
'
Register_Thermal_Level_Callback_JSTest0110:
'
+
error
);
expect
().
assertFail
();
}
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0120
* @tc.name Register_Thermal_Level_Callback_JSTest0120
* @tc.desc Thermal acquisition kit
*/
it
(
'
Register_Thermal_Level_Callback_JSTest0120
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
registerThermalLevelCallback
(
''
)
}
catch
(
error
)
{
console
.
info
(
'
Register_Thermal_Level_Callback_JSTest0120 error:
'
+
error
);
// 401: Invalid input parameter
expect
(
error
.
code
===
401
).
assertTrue
();
}
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0120
* @tc.name Register_Thermal_Level_Callback_JSTest0120
* @tc.desc Thermal acquisition kit
*/
it
(
'
Register_Thermal_Level_Callback_JSTest0120
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
registerThermalLevelCallback
(
''
)
}
catch
(
error
)
{
console
.
info
(
'
Register_Thermal_Level_Callback_JSTest0120 error:
'
+
error
);
// 401: Invalid input parameter
expect
(
error
.
code
===
401
).
assertTrue
();
}
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0130
* @tc.name UnRegister_Thermal_Level_Callback_JSTest0130
* @tc.desc Thermal acquisition kit
*/
it
(
'
UnRegister_Thermal_Level_Callback_JSTest0130
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
unregisterThermalLevelCallback
(
''
)
}
catch
(
error
)
{
console
.
info
(
'
UnRegister_Thermal_Level_Callback_JSTest0130 error:
'
+
error
);
// 401: Invalid input parameter
expect
(
error
.
code
===
401
).
assertTrue
();
}
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0130
* @tc.name UnRegister_Thermal_Level_Callback_JSTest0130
* @tc.desc Thermal acquisition kit
*/
it
(
'
UnRegister_Thermal_Level_Callback_JSTest0130
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
unregisterThermalLevelCallback
(
''
)
}
catch
(
error
)
{
console
.
info
(
'
UnRegister_Thermal_Level_Callback_JSTest0130 error:
'
+
error
);
// 401: Invalid input parameter
expect
(
error
.
code
===
401
).
assertTrue
();
}
done
();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0140
* @tc.name UnRegister_Thermal_Level_Callback_JSTest0140
* @tc.desc Thermal acquisition kit
*/
it
(
'
UnRegister_Thermal_Level_Callback_JSTest0140
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
unregisterThermalLevelCallback
()
}
catch
(
error
)
{
console
.
info
(
'
Thermal_020:
'
+
error
);
expect
().
assertFail
();
}
try
{
thermal
.
unregisterThermalLevelCallback
(()
=>
{
expect
(
ture
).
assertTrue
();
})
}
catch
(
error
)
{
console
.
info
(
'
Thermal_020:
'
+
error
);
expect
().
assertFail
();
}
done
();
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0140
* @tc.name UnRegister_Thermal_Level_Callback_JSTest0140
* @tc.desc Thermal acquisition kit
*/
it
(
'
UnRegister_Thermal_Level_Callback_JSTest0140
'
,
0
,
async
function
(
done
)
{
try
{
thermal
.
unregisterThermalLevelCallback
()
}
catch
(
error
)
{
console
.
info
(
'
UnRegister_Thermal_Level_Callback_JSTest0140:
'
+
error
);
expect
().
assertFail
();
}
try
{
thermal
.
unregisterThermalLevelCallback
(()
=>
{
expect
(
true
).
assertTrue
();
})
}
catch
(
error
)
{
console
.
info
(
'
UnRegister_Thermal_Level_Callback_JSTest0140:
'
+
error
);
expect
().
assertFail
();
}
done
();
})
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录