Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
02204690
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看板
未验证
提交
02204690
编写于
10月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6095 test: power用例整改
Merge pull request !6095 from qiuxiangdong/I5WVHE
上级
c42de9cb
ead60a0d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
348 addition
and
442 deletion
+348
-442
powermgr/power_manager/src/main/js/test/power_manager_power.test.js
...ower_manager/src/main/js/test/power_manager_power.test.js
+169
-244
powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js
...nager/src/main/js/test/power_manager_running_lock.test.js
+179
-198
未找到文件。
powermgr/power_manager/src/main/js/test/power_manager_power.test.js
浏览文件 @
02204690
...
@@ -23,340 +23,265 @@ describe('PowerManagerPowerTest', function () {
...
@@ -23,340 +23,265 @@ describe('PowerManagerPowerTest', function () {
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0010
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0010
* @tc.name Power_
Is_Screnn_On_Promis
e_JSTest0010
* @tc.name Power_
Reboot_Devic
e_JSTest0010
* @tc.desc
Checks whether the screen of a device is on or off
* @tc.desc
reboot device (deprecated since 9)
*/
*/
it
(
'
Power_Is_Screnn_On_Promise_JSTest0010
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_Reboot_Device_JSTest0010
'
,
0
,
function
()
{
power
.
wakeupDevice
(
"
Power_Is_Screnn_On_Promise_JSTest0010
"
);
// Reboot tests are not performed by default
power
.
isScreenOn
()
if
(
false
)
{
try
{
power
.
rebootDevice
(
'
Power_Reboot_Device_JSTest0010
'
);
}
catch
(
e
)
{
console
.
info
(
'
Power_Reboot_Device_JSTest0010 error:
'
+
e
);
expect
().
assertFail
();
}
}
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0020
* @tc.name Power_Is_Screnn_On_Promise_JSTest0020
* @tc.desc Checks whether the screen of a device is on or off (deprecated since 9)
*/
it
(
'
Power_Is_Screnn_On_Promise_JSTest0020
'
,
0
,
async
function
(
done
)
{
power
.
wakeupDevice
(
"
Power_Is_Screnn_On_Promise_JSTest0020
"
);
await
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest00
1
0 screenOn is
'
+
screenOn
);
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest00
2
0 screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest0010 success
'
);
console
.
info
(
'
Power_Is_Screnn_On_Promise_JSTest0020 success
'
);
done
();
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
'
Power_Is_Screnn_On_Promise_JSTest00
1
0 error:
'
+
error
);
console
.
log
(
'
Power_Is_Screnn_On_Promise_JSTest00
2
0 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
2
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
3
0
* @tc.name Power_Is_Screnn_On_Callback_JSTest00
2
0
* @tc.name Power_Is_Screnn_On_Callback_JSTest00
3
0
* @tc.desc Checks whether the screen of a device is on or off
* @tc.desc Checks whether the screen of a device is on or off
(deprecated since 9)
*/
*/
it
(
'
Power_Is_Screnn_On_Callback_JSTest00
2
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_Is_Screnn_On_Callback_JSTest00
3
0
'
,
0
,
async
function
(
done
)
{
power
.
wakeupDevice
(
"
Power_Is_Screnn_On_Callback_JSTest00
2
0
"
);
power
.
wakeupDevice
(
"
Power_Is_Screnn_On_Callback_JSTest00
3
0
"
);
power
.
isScreenOn
((
error
,
screenOn
)
=>
{
power
.
isScreenOn
((
error
,
screenOn
)
=>
{
if
(
typeof
error
===
"
undefined
"
)
{
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
Power_Is_Screnn_On_Callback_JSTest00
2
0 screenOn is
'
+
screenOn
);
console
.
info
(
'
Power_Is_Screnn_On_Callback_JSTest00
3
0 screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
Power_Is_Screnn_On_Callback_JSTest0020 success
'
);
console
.
info
(
'
Power_Is_Screnn_On_Callback_JSTest0030 success
'
);
done
();
}
else
{
}
else
{
console
.
log
(
'
Power_Is_Screnn_On_Callback_JSTest00
2
0:
'
+
error
);
console
.
log
(
'
Power_Is_Screnn_On_Callback_JSTest00
3
0:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
}
}
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
3
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
4
0
* @tc.name Power_
WakeupDevices_String_JSTest003
0
* @tc.name Power_
Is_Active_JSTest004
0
* @tc.desc
Try to wakeup the device and let screen on
* @tc.desc
On and Off Screen and get the current screen on and off
*/
*/
it
(
'
Power_WakeupDevices_String_JSTest0030
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_Is_Active_JSTest0040
'
,
0
,
function
()
{
power
.
isScreenOn
()
try
{
.
then
(
screenOn
=>
{
power
.
suspend
();
console
.
info
(
'
Power_WakeupDevices_String_JSTest0030: The current screenOn is
'
+
screenOn
);
power
.
wakeup
(
'
Power_Is_Active_JSTest0040
'
);
if
(
screenOn
)
{
let
on
=
power
.
isActive
();
power
.
suspendDevice
();
console
.
info
(
'
Power_Is_Active_JSTest0040 on:
'
+
on
);
}
expect
(
on
).
assertTrue
();
})
power
.
suspend
();
.
catch
(
error
=>
{
let
off
=
power
.
isActive
();
console
.
log
(
'
Power_WakeupDevices_String_JSTest0030 error:
'
+
error
);
console
.
info
(
'
Power_Is_Active_JSTest0040 off:
'
+
off
);
expect
().
assertFail
();
expect
(
off
).
assertFalse
();
done
();
}
catch
(
e
)
{
})
console
.
info
(
'
Power_Is_Active_JSTest0040:
'
+
e
);
setTimeout
(
function
(){
power
.
wakeupDevice
(
"
Power_WakeupDevices_String_JSTest0030
"
);
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_WakeupDevices_String_JSTest0030: The current screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
Power_WakeupDevices_String_JSTest0030 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_WakeupDevices_String_JSTest0030 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
}
})
},
2000
);
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
4
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
5
0
* @tc.name Power_
SuspendDevices_JSTest004
0
* @tc.name Power_
Get_Power_Mode_JSTest005
0
* @tc.desc
Try to suspend the device and let screen off
* @tc.desc
Gets and sets the power mode
*/
*/
it
(
'
Power_SuspendDevices_JSTest0040
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_Get_Power_Mode_JSTest0050
'
,
0
,
async
function
()
{
power
.
isScreenOn
()
let
currentMode
=
power
.
getPowerMode
();
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_Get_Power_Mode_JSTest0050 currentMode:
'
+
currentMode
);
console
.
info
(
'
Power_SuspendDevices_JSTest0040: The current screenOn is
'
+
screenOn
);
expect
(
currentMode
>=
power
.
DevicePowerMode
.
MODE_NORMAL
&&
if
(
!
screenOn
)
{
currentMode
<=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
).
assertTrue
();
power
.
wakeupDevice
(
"
Power_SuspendDevices_JSTest0040
"
);
}
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_SuspendDevices_JSTest0040 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
setTimeout
(
function
(){
power
.
suspendDevice
();
console
.
info
(
'
Power_SuspendDevices_JSTest0040: SuspendDevice end
'
);
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_SuspendDevices_JSTest0040: The current screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertFalse
();
console
.
info
(
'
Power_SuspendDevices_JSTest0040 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_SuspendDevices_JSTest0040 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
},
2000
);
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
7
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
6
0
* @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest00
7
0
* @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest00
6
0
* @tc.desc Get device power mode MODE_NORMAL
* @tc.desc Get device power mode MODE_NORMAL
*/
*/
it
(
'
Power_Device_Power_Mode_MODENORMAL_JSTest00
7
0
'
,
0
,
function
()
{
it
(
'
Power_Device_Power_Mode_MODENORMAL_JSTest00
6
0
'
,
0
,
function
()
{
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_NORMAL
;
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_NORMAL
;
console
.
info
(
'
MODE_NORMAL =
'
+
devicePowerMode
);
console
.
info
(
'
MODE_NORMAL =
'
+
devicePowerMode
);
expect
(
devicePowerMode
===
600
).
assertTrue
();
expect
(
devicePowerMode
===
600
).
assertTrue
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
8
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
7
0
* @tc.name Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080
* @tc.name Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080
* @tc.desc Get device power mode MODE_POWER_SAVE
* @tc.desc Get device power mode MODE_POWER_SAVE
*/
*/
it
(
'
Power_Device_Power_Mode_MODEPOWERSAVE_JSTest00
8
0
'
,
0
,
function
()
{
it
(
'
Power_Device_Power_Mode_MODEPOWERSAVE_JSTest00
7
0
'
,
0
,
function
()
{
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_POWER_SAVE
;
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_POWER_SAVE
;
console
.
info
(
'
MODE_POWER_SAVE =
'
+
devicePowerMode
);
console
.
info
(
'
MODE_POWER_SAVE =
'
+
devicePowerMode
);
expect
(
devicePowerMode
===
601
).
assertTrue
();
expect
(
devicePowerMode
===
601
).
assertTrue
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
9
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_00
8
0
* @tc.name Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090
* @tc.name Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090
* @tc.desc Get device power mode MODE_PERFORMANCE
* @tc.desc Get device power mode MODE_PERFORMANCE
*/
*/
it
(
'
Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest00
9
0
'
,
0
,
function
()
{
it
(
'
Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest00
8
0
'
,
0
,
function
()
{
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_PERFORMANCE
;
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_PERFORMANCE
;
console
.
info
(
'
MODE_PERFORMANCE =
'
+
devicePowerMode
);
console
.
info
(
'
MODE_PERFORMANCE =
'
+
devicePowerMode
);
expect
(
devicePowerMode
===
602
).
assertTrue
();
expect
(
devicePowerMode
===
602
).
assertTrue
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
10
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
09
0
* @tc.name Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0
10
0
* @tc.name Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0
09
0
* @tc.desc Get device power mode MODE_EXTREME_POWER_SAVE
* @tc.desc Get device power mode MODE_EXTREME_POWER_SAVE
*/
*/
it
(
'
Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0
10
0
'
,
0
,
function
()
{
it
(
'
Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0
09
0
'
,
0
,
function
()
{
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
;
let
devicePowerMode
=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
;
console
.
info
(
'
MODE_EXTREME_POWER_SAVE =
'
+
devicePowerMode
);
console
.
info
(
'
MODE_EXTREME_POWER_SAVE =
'
+
devicePowerMode
);
expect
(
devicePowerMode
===
603
).
assertTrue
();
expect
(
devicePowerMode
===
603
).
assertTrue
();
})
})
// New interface
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
1
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
5
0
* @tc.name Power_
Get_Set_Mode_Promise_JSTest011
0
* @tc.name Power_
WakeupDevices_String_JSTest015
0
* @tc.desc
Gets and sets the power mode
* @tc.desc
Try to wakeup the device and let screen on (SystemApi)
*/
*/
it
(
'
Power_Get_Set_Mode_Promise_JSTest0110
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_WakeupDevices_String_JSTest0150
'
,
0
,
async
function
(
done
)
{
let
currentMode
=
power
.
getPowerMode
();
await
power
.
isScreenOn
()
console
.
info
(
'
Power_Get_Set_Mode_Promise_JSTest0110 currentMode:
'
+
currentMode
);
.
then
(
screenOn
=>
{
expect
(
currentMode
>=
power
.
DevicePowerMode
.
MODE_NORMAL
&&
console
.
info
(
'
Power_WakeupDevices_String_JSTest0150: The current screenOn is
'
+
screenOn
);
currentMode
<=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
).
assertTrue
();
if
(
screenOn
)
{
try
{
power
.
suspendDevice
();
let
isExec
=
false
;
}
power
.
setPowerMode
(
power
.
DevicePowerMode
.
MODE_POWER_SAVE
)
.
then
((
error
)
=>
{
isExec
=
true
;
console
.
info
(
'
Power_Get_Set_Mode_Promise_JSTest0110 error:
'
+
(
typeof
error
));
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
let
mode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Get_Set_Mode_Promise_JSTest0110 mode:
'
+
mode
);
expect
(
mode
===
power
.
DevicePowerMode
.
MODE_POWER_SAVE
).
assertTrue
();
}).
finally
(()
=>
{
expect
(
isExec
).
assertTrue
();
})
})
}
catch
(
e
)
{
.
catch
(
error
=>
{
console
.
info
(
'
Power_Get_Set_Mode_Promise_JSTest0110 error:
'
+
e
);
console
.
log
(
'
Power_WakeupDevices_String_JSTest0150 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
}
})
power
.
setPowerMode
(
currentMode
);
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
();
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
2
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
6
0
* @tc.name Power_
Get_Set_Mode_Promise_Invalid_JSTest012
0
* @tc.name Power_
SuspendDevices_JSTest016
0
* @tc.desc
Set the wrong power mode
* @tc.desc
Try to suspend the device and let screen off (SystemApi)
*/
*/
it
(
'
Power_Get_Set_Mode_Promise_Invalid_JSTest0120
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_SuspendDevices_JSTest0160
'
,
0
,
async
function
(
done
)
{
try
{
await
power
.
isScreenOn
()
// invalid mode
.
then
(
screenOn
=>
{
power
.
setPowerMode
(
''
).
then
(()
=>
{
console
.
info
(
'
Power_SuspendDevices_JSTest0160: The current screenOn is
'
+
screenOn
);
console
.
info
(
'
Power_Get_Set_Mode_Promise_Invalid_JSTest0120 string failed
'
);
if
(
!
screenOn
)
{
power
.
wakeupDevice
(
"
Power_SuspendDevices_JSTest0160
"
);
}
})
.
catch
(
error
=>
{
console
.
log
(
'
Power_SuspendDevices_JSTest0160 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
})
})
}
catch
(
e
)
{
setTimeout
(
function
(){
console
.
info
(
'
Power_Get_Set_Mode_Promise_Invalid_JSTest0120 code:
'
+
e
.
code
+
'
msg:
'
+
e
.
message
);
power
.
suspendDevice
();
// 401: Invalid input parameter
console
.
info
(
'
Power_SuspendDevices_JSTest0160: SuspendDevice end
'
);
expect
(
e
.
code
===
401
).
assertTrue
();
power
.
isScreenOn
()
}
.
then
(
screenOn
=>
{
console
.
info
(
'
Power_SuspendDevices_JSTest0160: The current screenOn is
'
+
screenOn
);
try
{
expect
(
screenOn
).
assertFalse
();
// Number of invalid parameters
console
.
info
(
'
Power_SuspendDevices_JSTest0160 success
'
);
power
.
setPowerMode
(
''
,
''
,
0
).
then
(()
=>
{
})
console
.
info
(
'
Power_Get_Set_Mode_Promise_Invalid_JSTest0120 number failed
'
);
.
catch
(
error
=>
{
console
.
log
(
'
Power_SuspendDevices_JSTest0160 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
})
})
}
catch
(
e
)
{
},
2000
);
console
.
info
(
'
Power_Get_Set_Mode_Promise_Invalid_JSTest0120 code:
'
+
e
.
code
+
'
msg:
'
+
e
.
message
);
// 401: Invalid input parameter
expect
(
e
.
code
===
401
).
assertTrue
();
}
done
();
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
3
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
7
0
* @tc.name Power_
Get_Set_Mode_Callback_JSTest013
0
* @tc.name Power_
Set_Mode_Promise_JSTest011
0
* @tc.desc Gets and sets the power mode
* @tc.desc Gets and sets the power mode
(SystemApi)
*/
*/
it
(
'
Power_Get_Set_Mode_Callback_JSTest0130
'
,
0
,
async
function
(
done
)
{
it
(
'
Power_Set_Mode_Promise_JSTest0110
'
,
0
,
async
function
(
done
)
{
if
(
false
)
{
let
currentMode
=
power
.
getPowerMode
();
let
currentMode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Get_Set_Mode_Callback_JSTest013
0 currentMode:
'
+
currentMode
);
console
.
info
(
'
Power_Set_Mode_Promise_JSTest011
0 currentMode:
'
+
currentMode
);
expect
(
currentMode
>=
power
.
DevicePowerMode
.
MODE_NORMAL
&&
expect
(
currentMode
>=
power
.
DevicePowerMode
.
MODE_NORMAL
&&
currentMode
<=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
).
assertTrue
();
currentMode
<=
power
.
DevicePowerMode
.
MODE_EXTREME_POWER_SAVE
).
assertTrue
();
try
{
try
{
power
.
setPowerMode
(
power
.
DevicePowerMode
.
MODE_PERFORMANCE
,
(
error
)
=>
{
let
isExec
=
false
;
console
.
info
(
'
Power_Get_Set_Mode_Callback_JSTest0130 error:
'
+
(
typeof
error
));
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
();
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
let
mode
=
power
.
getPowerMode
();
let
mode
=
power
.
getPowerMode
();
console
.
info
(
'
Power_Get_Set_Mode_Callback_JSTest0130 mode:
'
+
mode
);
console
.
info
(
'
Power_Set_Mode_Promise_JSTest0110 mode:
'
+
mode
);
expect
(
mode
===
power
.
DevicePowerMode
.
MODE_PERFORMANCE
).
assertTrue
();
expect
(
mode
===
power
.
DevicePowerMode
.
MODE_POWER_SAVE
).
assertTrue
();
}).
finally
(()
=>
{
expect
(
isExec
).
assertTrue
();
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
Power_Get_Set_Mode_Callback_JSTest013
0 error:
'
+
e
);
console
.
info
(
'
Power_Set_Mode_Promise_JSTest011
0 error:
'
+
e
);
expect
().
assertFail
();
expect
().
assertFail
();
}
}
power
.
setPowerMode
(
currentMode
);
power
.
setPowerMode
(
currentMode
);
done
();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0140
* @tc.name Power_Get_Set_Mode_Callback_Invalid_JSTest0140
* @tc.desc Set the wrong power mode
*/
it
(
'
Power_Get_Set_Mode_Callback_Invalid_JSTest0140
'
,
0
,
async
function
(
done
)
{
try
{
// invalid mode
power
.
setPowerMode
(
''
,
(
error
)
=>
{
expect
().
assertFail
();
})
}
catch
(
e
)
{
console
.
info
(
'
Power_Get_Set_Mode_Callback_Invalid_JSTest0140 code:
'
+
e
.
code
+
'
msg:
'
+
e
.
message
);
// 401: Invalid input parameter
expect
(
e
.
code
===
401
).
assertTrue
();
}
try
{
// invalid callback
power
.
setPowerMode
(
power
.
DevicePowerMode
.
MODE_PERFORMANCE
,
''
)
}
catch
(
e
)
{
console
.
info
(
'
Power_Get_Set_Mode_Callback_Invalid_JSTest0140 code:
'
+
e
.
code
+
'
msg:
'
+
e
.
message
);
// 401: Invalid input parameter
expect
(
e
.
code
===
401
).
assertTrue
();
}
}
done
();
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
5
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_01
8
0
* @tc.name Power_
Reboot_JSTest015
0
* @tc.name Power_
Set_Mode_Callback_JSTest018
0
* @tc.desc
reboot
* @tc.desc
Gets and sets the power mode (SystemApi)
*/
*/
it
(
'
Power_Reboot_JSTest0150
'
,
0
,
function
()
{
it
(
'
Power_Set_Mode_Callback_JSTest0180
'
,
0
,
async
function
(
done
)
{
// Reboot tests are not performed by default
if
(
false
)
{
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
{
try
{
power
.
reboot
(
'
Power_Reboot_JSTest0150
'
);
power
.
setPowerMode
(
power
.
DevicePowerMode
.
MODE_PERFORMANCE
,
(
error
)
=>
{
}
catch
(
e
)
{
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 error:
'
+
(
typeof
error
));
console
.
info
(
'
Power_Reboot_JSTest0150 error:
'
+
e
);
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
(
);
expect
().
assertFail
();
let
mode
=
power
.
getPowerMode
();
}
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 mode:
'
+
mode
);
}
expect
(
mode
===
power
.
DevicePowerMode
.
MODE_PERFORMANCE
).
assertTrue
();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0160
* @tc.name Power_Wakeup_Suspend_IsActive_JSTest0160
* @tc.desc On and Off Screen and get the current screen on and off
*/
it
(
'
Power_Wakeup_Suspend_IsActive_JSTest0160
'
,
0
,
function
()
{
try
{
power
.
suspend
();
power
.
wakeup
(
'
wakeup_suspend_isPower_Wakeup_Suspend_IsActive_JSTest0160_active
'
);
let
on
=
power
.
isActive
();
console
.
info
(
'
Power_Wakeup_Suspend_IsActive_JSTest0160 on:
'
+
on
);
expect
(
on
).
assertTrue
();
power
.
suspend
();
let
off
=
power
.
isActive
();
console
.
info
(
'
Power_Wakeup_Suspend_IsActive_JSTest0160 off:
'
+
off
);
expect
(
off
).
assertFalse
();
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
Power_Wakeup_Suspend_IsActive_JSTest0160
:
'
+
e
);
console
.
info
(
'
Power_Set_Mode_Callback_JSTest0180 error
:
'
+
e
);
expect
().
assertFail
();
expect
().
assertFail
();
}
}
})
power
.
setPowerMode
(
currentMode
);
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0170
* @tc.name Power_Wakeup_Invalid_JSTest0170
* @tc.desc wakeup Input invalid parameter
*/
it
(
'
Power_Wakeup_Invalid_JSTest0170
'
,
0
,
function
()
{
try
{
power
.
wakeup
(
0
)
}
catch
(
e
)
{
console
.
info
(
'
Power_Wakeup_Invalid_JSTest0170 code:
'
+
e
.
code
+
"
msg:
"
+
e
.
message
);
// 401: Invalid input parameter
expect
(
e
.
code
===
401
).
assertTrue
();
}
try
{
// The number of parameters does not match
power
.
wakeup
(
''
,
0
)
}
catch
(
e
)
{
console
.
info
(
'
Power_Wakeup_Invalid_JSTest0170 code:
'
+
e
.
code
+
"
msg:
"
+
e
.
message
);
// 401: Invalid input parameter
expect
(
e
.
code
===
401
).
assertTrue
();
}
}
done
();
})
})
})
})
}
}
powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js
浏览文件 @
02204690
...
@@ -22,323 +22,304 @@ describe('PowerManagerRunningLockTest', function () {
...
@@ -22,323 +22,304 @@ describe('PowerManagerRunningLockTest', function () {
console
.
log
(
"
*************RunningLock Unit Test Begin*************
"
);
console
.
log
(
"
*************RunningLock Unit Test Begin*************
"
);
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0110
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0010
* @tc.name Create_Running_Lock_Promise_JSTest0010
* @tc.name Running_Lock_Lock_JSTest0010
* @tc.desc Create running lock
* @tc.desc Prevents the system from hibernating and sets the lock duration (deprecated since 9)
*/
it
(
'
Create_Running_Lock_Promise_JSTest0010
'
,
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_JSTest0010 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
Create_Running_Lock_Promise_JSTest0010 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0120
* @tc.name Create_Running_Lock_CallBack_JSTest0020
* @tc.desc Create running lock
*/
it
(
'
Create_Running_Lock_CallBack_JSTest0020
'
,
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_JSTest0020: runningLock is
'
+
runninglock
);
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
Create_Running_Lock_CallBack_JSTest0020 is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock Create_Running_Lock_CallBack_JSTest0020 is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
Create_Running_Lock_CallBack_JSTest0020 success
'
);
done
();
}
else
{
console
.
log
(
'
Create_Running_Lock_CallBack_JSTest0020:
'
+
error
);
expect
().
assertFail
();
done
();
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0130
* @tc.name Running_Lock_Lock_JSTest0030
* @tc.desc Prevents the system from hibernating and sets the lock duration
*/
*/
it
(
'
Running_Lock_Lock_JSTest003
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Running_Lock_Lock_JSTest001
0
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_3
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
await
runningLock
.
createRunningLock
(
"
Running_Lock_Lock_JSTest0010
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
Running_Lock_Lock_JSTest00
3
0 is used:
'
+
used
);
console
.
info
(
'
Running_Lock_Lock_JSTest00
1
0 is used:
'
+
used
);
expect
(
used
).
assertFalse
();
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock Running_Lock_Lock_JSTest00
3
0 is used:
'
+
used
);
console
.
info
(
'
after lock Running_Lock_Lock_JSTest00
1
0 is used:
'
+
used
);
expect
(
used
).
assertTrue
();
expect
(
used
).
assertTrue
();
console
.
info
(
'
Running_Lock_Lock_JSTest0030 success
'
);
done
();
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
'
Running_Lock_Lock_JSTest00
3
0 error:
'
+
error
);
console
.
log
(
'
Running_Lock_Lock_JSTest00
1
0 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
14
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
02
0
* @tc.name Running_Lock_used_JSTest00
4
0
* @tc.name Running_Lock_used_JSTest00
2
0
* @tc.desc Checks whether a lock is held or in use
* @tc.desc Checks whether a lock is held or in use
(deprecated since 9)
*/
*/
it
(
'
Running_Lock_used_JSTest00
4
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Running_Lock_used_JSTest00
2
0
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_4
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
runningLock
.
createRunningLock
(
"
Running_Lock_used_JSTest0020
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
Running_Lock_used_JSTest00
4
0 used:
'
+
used
);
console
.
info
(
'
Running_Lock_used_JSTest00
2
0 used:
'
+
used
);
expect
(
used
).
assertFalse
();
expect
(
used
).
assertFalse
();
console
.
info
(
'
Running_Lock_used_JSTest0040 success
'
);
console
.
info
(
'
Running_Lock_used_JSTest0020 success
'
);
done
();
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
'
Running_Lock_used_JSTest00
4
0 error:
'
+
error
);
console
.
log
(
'
Running_Lock_used_JSTest00
2
0 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
15
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
03
0
* @tc.name Running_Lock_Unlock_JSTest00
5
0
* @tc.name Running_Lock_Unlock_JSTest00
3
0
* @tc.desc Release running lock
* @tc.desc Release running lock
(deprecated since 9)
*/
*/
it
(
'
Running_Lock_Unlock_JSTest00
5
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Running_Lock_Unlock_JSTest00
3
0
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_5
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
await
runningLock
.
createRunningLock
(
"
Running_Lock_Unlock_JSTest0030
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
expect
(
runninglock
!==
null
).
assertTrue
();
let
used
=
runninglock
.
isUsed
();
let
used
=
runninglock
.
isUsed
();
console
.
info
(
'
Running_Lock_Unlock_JSTest00
5
0 is used:
'
+
used
);
console
.
info
(
'
Running_Lock_Unlock_JSTest00
3
0 is used:
'
+
used
);
expect
(
used
).
assertFalse
();
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock Running_Lock_Unlock_JSTest00
5
0 is used:
'
+
used
);
console
.
info
(
'
after lock Running_Lock_Unlock_JSTest00
3
0 is used:
'
+
used
);
expect
(
used
).
assertTrue
();
expect
(
used
).
assertTrue
();
runninglock
.
unlock
();
runninglock
.
unlock
();
used
=
runninglock
.
isUsed
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after unlock Running_Lock_Unlock_JSTest00
5
0 is used:
'
+
used
);
console
.
info
(
'
after unlock Running_Lock_Unlock_JSTest00
3
0 is used:
'
+
used
);
expect
(
used
).
assertFalse
();
expect
(
used
).
assertFalse
();
console
.
info
(
'
Running_Lock_Unlock_JSTest0050 success
'
);
console
.
info
(
'
Running_Lock_Unlock_JSTest0030 success
'
);
done
();
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
'
Running_Lock_Unlock_JSTest00
5
0 error:
'
+
error
);
console
.
log
(
'
Running_Lock_Unlock_JSTest00
3
0 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
})
done
();
done
();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0040
* @tc.name Running_Lock_Hold_IsHolding_UnHold_JSTest0040
* @tc.desc hold lock, is holding , unhold
*/
it
(
'
Running_Lock_Hold_IsHolding_UnHold_JSTest0040
'
,
0
,
async
function
(
done
)
{
try
{
let
isExec
=
false
;
await
runningLock
.
create
(
"
Running_Lock_Hold_IsHolding_UnHold_JSTest0040
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
((
runninglock
)
=>
{
isExec
=
true
;
expect
(
runninglock
!==
null
).
assertTrue
();
let
holding
=
runninglock
.
isHolding
();
console
.
info
(
'
Running_Lock_Hold_IsHolding_UnHold_JSTest0040 holding false:
'
+
holding
);
expect
(
holding
).
assertFalse
();
runninglock
.
hold
(
1000
);
// hold 1000ms
holding
=
runninglock
.
isHolding
();
console
.
info
(
'
Running_Lock_Hold_IsHolding_UnHold_JSTest0040 holding true:
'
+
holding
);
expect
(
holding
).
assertTrue
();
runninglock
.
unhold
();
expect
(
runninglock
.
isHolding
()).
assertFalse
();
})
.
catch
((
error
)
=>
{
isExec
=
true
;
console
.
info
(
'
Running_Lock_Hold_IsHolding_UnHold_JSTest0040 error:
'
+
(
typeof
error
));
expect
(
typeof
error
!==
"
undefined
"
).
assertTrue
();
console
.
info
(
'
Running_Lock_Hold_IsHolding_UnHold_JSTest0040 error code:
'
+
error
.
code
+
"
msg:
"
+
error
.
message
);
})
.
finally
(()
=>
{
expect
(
isExec
).
assertTrue
();
})
}
catch
(
e
)
{
console
.
info
(
'
Running_Lock_Hold_IsHolding_UnHold_JSTest0040 error:
'
+
e
);
expect
().
assertFail
();
}
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
16
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
05
0
* @tc.name Enum_RunningLock_Type_Background_JSTest00
6
0
* @tc.name Enum_RunningLock_Type_Background_JSTest00
5
0
* @tc.desc The lock type is BACKGROUND
* @tc.desc The lock type is BACKGROUND
*/
*/
it
(
'
Enum_RunningLock_Type_Background_JSTest006
0
'
,
0
,
function
()
{
it
(
'
Enum_RunningLock_Type_Background_JSTest005
0
'
,
0
,
function
()
{
let
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
let
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
1
).
assertTrue
();
expect
(
runningLockType
==
1
).
assertTrue
();
console
.
info
(
'
Enum_RunningLock_Type_Background_JSTest00
6
0 success
'
);
console
.
info
(
'
Enum_RunningLock_Type_Background_JSTest00
5
0 success
'
);
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
17
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
06
0
* @tc.name Enum_RunningLock_Type_Proximityscreencontrol_JSTest00
7
0
* @tc.name Enum_RunningLock_Type_Proximityscreencontrol_JSTest00
6
0
* @tc.desc The lock type is PROXIMITY_SCREEN_CONTROL
* @tc.desc The lock type is PROXIMITY_SCREEN_CONTROL
*/
*/
it
(
'
Enum_RunningLock_Type_Proximityscreencontrol_JSTest00
7
0
'
,
0
,
function
()
{
it
(
'
Enum_RunningLock_Type_Proximityscreencontrol_JSTest00
6
0
'
,
0
,
function
()
{
let
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
let
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
2
).
assertTrue
();
expect
(
runningLockType
==
2
).
assertTrue
();
console
.
info
(
'
Enum_RunningLock_Type_Proximityscreencontrol_JSTest00
7
0 success
'
);
console
.
info
(
'
Enum_RunningLock_Type_Proximityscreencontrol_JSTest00
6
0 success
'
);
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
18
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
07
0
* @tc.name Is_Runninglock_Type_Supported_Promise_
Test1_JSTest008
0
* @tc.name Is_Runninglock_Type_Supported_Promise_
JSTest007
0
* @tc.desc Checks whether the specified RunningLockType is supported
.
* @tc.desc Checks whether the specified RunningLockType is supported
(deprecated since 9)
*/
*/
it
(
'
Is_Runninglock_Type_Supported_Promise_Test1_JSTest008
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Is_Runninglock_Type_Supported_Promise_JSTest007
0
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
)
await
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
)
.
then
(
supported
=>
{
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_test_1
PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
console
.
info
(
'
Is_Runninglock_Type_Supported_Promise_JSTest0070
PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_test_1 success
'
);
console
.
info
(
'
Is_Runninglock_Type_Supported_Promise_JSTest0070 success
'
);
done
();
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_test_1
error:
'
+
error
);
console
.
log
(
'
Is_Runninglock_Type_Supported_Promise_JSTest0070
error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
19
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
08
0
* @tc.name Is_Runninglock_Type_Supported_Promise_
Test2_JSTest009
0
* @tc.name Is_Runninglock_Type_Supported_Promise_
JSTest008
0
* @tc.desc Checks whether the specified RunningLockType is supported
.
* @tc.desc Checks whether the specified RunningLockType is supported
(deprecated since 9)
*/
*/
it
(
'
Is_Runninglock_Type_Supported_Promise_
Test2_JSTest009
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Is_Runninglock_Type_Supported_Promise_
JSTest008
0
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
await
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
supported
=>
{
.
then
(
supported
=>
{
console
.
info
(
'
Is_Runninglock_Type_Supported_Promise_
Test2
BACKGROUND supported is
'
+
supported
);
console
.
info
(
'
Is_Runninglock_Type_Supported_Promise_
JSTest0080
BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
expect
(
supported
).
assertTrue
();
console
.
info
(
'
Is_Runninglock_Type_Supported_Promise_Test2 success
'
);
console
.
info
(
'
Is_Runninglock_Type_Supported_Promise_JSTest0080 success
'
);
done
();
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
'
Is_Runninglock_Type_Supported_Promise_
Test2
error:
'
+
error
);
console
.
log
(
'
Is_Runninglock_Type_Supported_Promise_
JSTest0080
error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
20
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
09
0
* @tc.name Is_Runninglock_Type_Supported_Callback_
test3_JSTest010
0
* @tc.name Is_Runninglock_Type_Supported_Callback_
JSTest009
0
* @tc.desc Checks whether the specified RunningLockType is supported
.
* @tc.desc Checks whether the specified RunningLockType is supported
(deprecated since 9)
*/
*/
it
(
'
Is_Runninglock_Type_Supported_Callback_
test3_JSTest010
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Is_Runninglock_Type_Supported_Callback_
JSTest009
0
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
,
(
error
,
supported
)
=>
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
,
(
error
,
supported
)
=>
{
if
(
typeof
error
===
"
undefined
"
)
{
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
Is_Runninglock_Type_Supported_Callback_
test3_JSTest
supported is
'
+
supported
);
console
.
info
(
'
Is_Runninglock_Type_Supported_Callback_
JSTest0090
supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
expect
(
supported
).
assertTrue
();
console
.
info
(
'
Is_Runninglock_Type_Supported_Callback_test3_JSTest success
'
);
console
.
info
(
'
Is_Runninglock_Type_Supported_Callback_JSTest0090 success
'
);
done
();
}
else
{
}
else
{
console
.
log
(
'
Is_Runninglock_Type_Supported_Callback_
test3_JSTest
:
'
+
error
);
console
.
log
(
'
Is_Runninglock_Type_Supported_Callback_
JSTest0090
:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
done
();
}
}
})
})
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
21
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
10
0
* @tc.name
Create_Running_Lock_Promise_JSTest021
0
* @tc.name
Is_Supported_JSTest010
0
* @tc.desc C
reate lock, hold lock, unlock
* @tc.desc C
hecks whether the specified RunningLockType is supported.
*/
*/
it
(
'
Create_Running_Lock_Promise_JSTest021
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Is_Supported_JSTest010
0
'
,
0
,
async
function
(
done
)
{
try
{
try
{
let
isExec
=
false
;
let
background
=
runningLock
.
isSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
runningLock
.
create
(
"
Create_Running_Lock_Promise_JSTest0210
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
expect
(
background
).
assertTrue
();
.
then
((
error
,
runninglock
)
=>
{
isExec
=
true
;
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
expect
(
runninglock
!==
null
).
assertTrue
();
let
holding
=
runninglock
.
isHolding
();
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0210 holding false:
'
+
holding
);
expect
(
holding
).
assertFalse
();
runninglock
.
hold
(
1000
);
// hold 1000ms
holding
=
runninglock
.
isHolding
();
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0210 holding true:
'
+
holding
);
expect
(
holding
).
assertTrue
();
runninglock
.
unhold
();
expect
(
runninglock
.
isHolding
()).
assertFalse
();
}).
finally
(()
=>
{
expect
(
isExec
).
assertTrue
();
})
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0210 error
:
'
+
e
);
console
.
info
(
'
Is_Supported_JSTest0100 code
:
'
+
e
);
expect
().
assertFail
();
expect
().
assertFail
();
}
}
done
();
done
();
})
})
// New interface
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
22
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
11
0
* @tc.name Create_Running_Lock_Promise_
Invalid_JSTest022
0
* @tc.name Create_Running_Lock_Promise_
JSTest011
0
* @tc.desc Create
lock input invalid value
* @tc.desc Create
running lock promise (deprecated since 9)
*/
*/
it
(
'
Create_Running_Lock_Promise_Invalid_JSTest0220
'
,
0
,
async
function
(
done
)
{
it
(
'
Create_Running_Lock_Promise_JSTest0110
'
,
0
,
async
function
(
done
)
{
try
{
await
runningLock
.
createRunningLock
(
"
running_lock_test_1
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
runningLock
.
create
(
0
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
.
then
((
error
,
runninglock
)
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0110 success
'
);
})
.
catch
(
error
=>
{
console
.
log
(
'
Create_Running_Lock_Promise_JSTest0110 error:
'
+
error
);
expect
().
assertFail
();
expect
().
assertFail
();
})
})
}
catch
(
e
)
{
console
.
info
(
'
Create_Running_Lock_Promise_Invalid_JSTest0220 code:
'
+
e
.
code
+
"
msg:
"
+
e
.
message
);
// 401: Invalid input parameter
expect
(
e
.
code
===
401
).
assertTrue
();
}
done
();
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
23
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
12
0
* @tc.name Create_Running_Lock_Call
back_JSTest023
0
* @tc.name Create_Running_Lock_Call
Back_JSTest012
0
* @tc.desc Create
lock, hold lock, unlock
* @tc.desc Create
running lock callback (deprecated since 9)
*/
*/
it
(
'
Create_Running_Lock_Callback_JSTest0230
'
,
0
,
async
function
(
done
)
{
it
(
'
Create_Running_Lock_CallBack_JSTest0120
'
,
0
,
async
function
(
done
)
{
try
{
runningLock
.
createRunningLock
(
"
Create_Running_Lock_CallBack_JSTest0120
"
,
runningLock
.
RunningLockType
.
BACKGROUND
,
runningLock
.
create
(
"
Create_Running_Lock_Callback_JSTest0230
"
,
runningLock
.
RunningLockType
.
BACKGROUND
,
(
error
,
runninglock
)
=>
{
(
error
,
runninglock
)
=>
{
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
Create_Running_Lock_CallBack_JSTest0120: runningLock is
'
+
runninglock
);
expect
(
runninglock
!==
null
).
assertTrue
();
expect
(
runninglock
!==
null
).
assertTrue
();
runninglock
.
hold
(
1000
);
// hold 1000ms
let
used
=
runninglock
.
isUsed
();
let
holding
=
runninglock
.
isHolding
();
console
.
info
(
'
Create_Running_Lock_CallBack_JSTest0120 is used:
'
+
used
);
console
.
info
(
'
Create_Running_Lock_Callback_JSTest0230 holding true:
'
+
holding
);
expect
(
used
).
assertFalse
();
expect
(
holding
).
assertTrue
();
runninglock
.
lock
(
500
);
runninglock
.
unhold
();
used
=
runninglock
.
isUsed
();
holding
=
runninglock
.
isHolding
();
console
.
info
(
'
after lock Create_Running_Lock_CallBack_JSTest0120 is used:
'
+
used
);
expect
(
holding
).
assertFalse
();
expect
(
used
).
assertTrue
();
console
.
info
(
'
Create_Running_Lock_Callback_JSTest0230 holding false:
'
+
holding
);
console
.
info
(
'
Create_Running_Lock_CallBack_JSTest0120 success
'
);
});
}
else
{
}
catch
(
e
)
{
console
.
log
(
'
Create_Running_Lock_CallBack_JSTest0120:
'
+
error
);
console
.
info
(
'
Create_Running_Lock_Callback_JSTest0230 error:
'
+
e
);
expect
().
assertFail
();
expect
().
assertFail
();
}
}
})
done
();
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
24
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
13
0
* @tc.name Create_Running_Lock_
Callback_Invalid_JSTest024
0
* @tc.name Create_Running_Lock_
Promise_JSTest013
0
* @tc.desc Create lock
input invalid valu
e
* @tc.desc Create lock
promis
e
*/
*/
it
(
'
Create_Running_Lock_
Callback_Invalid_JSTest024
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Create_Running_Lock_
Promise_JSTest013
0
'
,
0
,
async
function
(
done
)
{
try
{
try
{
runningLock
.
create
(
"
Create_Running_Lock_Callback_Invalid_JSTest0240
"
,
"
invalid
"
,
let
isExec
=
false
;
(
error
,
runninglock
)
=>
{
await
runningLock
.
create
(
"
Create_Running_Lock_Promise_JSTest0130
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
expect
().
assertFail
();
.
then
((
runninglock
)
=>
{
});
isExec
=
true
;
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0130 success
'
);
})
.
catch
((
error
)
=>
{
isExec
=
true
;
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0130 error:
'
+
(
typeof
error
));
expect
(
typeof
error
!==
"
undefined
"
).
assertTrue
();
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0130 error code:
'
+
error
.
code
+
"
msg:
"
+
error
.
message
);
})
.
finally
(()
=>
{
expect
(
isExec
).
assertTrue
();
})
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
Create_Running_Lock_Callback_Invalid_JSTest0240 code:
'
+
e
.
code
+
"
msg:
"
+
e
.
message
);
console
.
info
(
'
Create_Running_Lock_Promise_JSTest0130 error:
'
+
e
);
// 401: Invalid input parameter
expect
().
assertFail
();
expect
(
e
.
code
===
401
).
assertTrue
();
}
}
done
();
done
();
})
})
/**
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
25
0
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0
14
0
* @tc.name
Is_Supported_JSTest025
0
* @tc.name
Create_Running_Lock_Callback_JSTest014
0
* @tc.desc C
hecks whether the specified RunningLockType is supported.
* @tc.desc C
reate lock callback
*/
*/
it
(
'
Is_Supported_JSTest025
0
'
,
0
,
async
function
(
done
)
{
it
(
'
Create_Running_Lock_Callback_JSTest014
0
'
,
0
,
async
function
(
done
)
{
try
{
try
{
let
background
=
runningLock
.
isSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
runningLock
.
create
(
"
Create_Running_Lock_Callback_JSTest0140
"
,
runningLock
.
RunningLockType
.
BACKGROUND
,
expect
(
background
).
assertTrue
();
(
error
,
runninglock
)
=>
{
expect
(
typeof
error
===
"
undefined
"
).
assertTrue
();
expect
(
runninglock
!==
null
).
assertTrue
();
console
.
info
(
'
Create_Running_Lock_Callback_JSTest0140 success
'
);
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
Is_Supported_JSTest0250 code
:
'
+
e
);
console
.
info
(
'
Create_Running_Lock_Callback_JSTest0230 error
:
'
+
e
);
expect
().
assertFail
();
expect
().
assertFail
();
}
}
done
();
done
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录