Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
96f88506
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看板
提交
96f88506
编写于
9月 26, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
!763 增加电源子系统running lock测试用例
Merge pull request !763 from 梁启航/master
上级
84353750
fb43b640
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
222 addition
and
1 deletion
+222
-1
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/power_manager_running_lock.test.js
...c/main/js/default/test/power_manager_running_lock.test.js
+220
-0
未找到文件。
powermgr/powermgrbattery/src/main/js/default/test/List.test.js
浏览文件 @
96f88506
...
@@ -12,4 +12,5 @@
...
@@ -12,4 +12,5 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
require
(
'
./battery_unit.test.js
'
)
require
(
'
./battery_unit.test.js
'
)
\ No newline at end of file
require
(
'
./power_manager_running_lock.test.js
'
)
\ No newline at end of file
powermgr/powermgrbattery/src/main/js/default/test/power_manager_running_lock.test.js
0 → 100644
浏览文件 @
96f88506
/*
* Copyright (C) 2021 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
app
from
'
@system.app
'
import
Context
from
'
@ohos.napi_context
'
import
runningLock
from
'
@ohos.runningLock
'
;
import
power
from
'
@ohos.power
'
;
import
'
@ohos.permission.RUNNING_LOCK
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
appInfoTest
'
,
function
()
{
console
.
log
(
"
*************Power Unit Test Begin*************
"
);
//createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
it
(
'
create_running_lock_promise_test
'
,
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_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
create_running_lock_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>)
it
(
'
create_running_lock_callback_test
'
,
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_test: runningLock is
'
+
runninglock
);
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
create_running_lock_callback_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock create_running_lock_callback_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
create_running_lock_callback_test success
'
);
done
();
}
else
{
console
.
log
(
'
create_running_lock_callback_test:
'
+
error
);
expect
().
assertFail
();
done
();
}
})
})
//lock(timeout: number)
it
(
'
running_lock_lock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_3
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_lock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
console
.
info
(
'
running_lock_lock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_lock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isUsed()
it
(
'
running_lock_isused_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_4
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_isused_test used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_isused_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_isused_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//unlock()
it
(
'
running_lock_unlock_test
'
,
0
,
async
function
(
done
)
{
runningLock
.
createRunningLock
(
"
running_lock_test_5
"
,
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
runninglock
=>
{
expect
(
runninglock
!==
null
).
assertTrue
();
var
used
=
runninglock
.
isUsed
();
console
.
info
(
'
running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
runninglock
.
lock
(
500
);
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after lock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertTrue
();
runninglock
.
unlock
();
used
=
runninglock
.
isUsed
();
console
.
info
(
'
after unlock running_lock_unlock_test is used:
'
+
used
);
expect
(
used
).
assertFalse
();
console
.
info
(
'
running_lock_unlock_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
running_lock_unlock_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//Runninglock锁的类型为BACKGROUND
it
(
'
enum_runningLock_type_background_test
'
,
0
,
function
()
{
var
runningLockType
=
runningLock
.
RunningLockType
.
BACKGROUND
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
1
).
assertTrue
();
console
.
info
(
'
enum_runningLock_type_background_test success
'
);
})
//Runninglock锁的类型为PROXIMITY_SCREEN_CONTROL
it
(
'
enum_runningLock_type_proximityscreencontrol_test
'
,
0
,
function
()
{
var
runningLockType
=
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
;
console
.
info
(
'
runningLockType =
'
+
runningLockType
);
expect
(
runningLockType
==
2
).
assertTrue
();
console
.
info
(
'
enum_runningLock_type_proximityscreencontrol_test success
'
);
})
//isRunningLockTypeSupported(type: RunningLockType): Promise<boolean>
it
(
'
is_runninglock_type_supported_promise_test_1
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
PROXIMITY_SCREEN_CONTROL
)
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is
'
+
supported
);
expect
(
supported
).
assertFalse
();
console
.
info
(
'
is_runninglock_type_supported_test_1 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_test_1 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isRunningLockTypeSupported(type: RunningLockType) 多余
it
(
'
is_runninglock_type_supported_promise_test_2
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
)
.
then
(
supported
=>
{
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_promise_test_2 success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
is_runninglock_type_supported_promise_test_2 error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
//isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boolean>)
it
(
'
is_runninglock_type_supported_callback_test_3
'
,
0
,
async
function
(
done
)
{
runningLock
.
isRunningLockTypeSupported
(
runningLock
.
RunningLockType
.
BACKGROUND
,
(
error
,
supported
)
=>
{
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
is_runninglock_type_supported_callback_test_3 BACKGROUND supported is
'
+
supported
);
expect
(
supported
).
assertTrue
();
console
.
info
(
'
is_runninglock_type_supported_callback_test_3 success
'
);
done
();
}
else
{
console
.
log
(
'
is_runninglock_type_supported_callback_test_3:
'
+
error
);
expect
().
assertFail
();
done
();
}
})
})
it
(
'
power_is_screen_on_promise_test
'
,
0
,
async
function
(
done
)
{
//isScreenOn(): Promise<boolean>
power
.
isScreenOn
()
.
then
(
screenOn
=>
{
console
.
info
(
'
power_is_screen_on_promise_test screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
power_is_screen_on_promise_test success
'
);
done
();
})
.
catch
(
error
=>
{
console
.
log
(
'
power_is_screen_on_promise_test error:
'
+
error
);
expect
().
assertFail
();
done
();
})
})
it
(
'
power_is_screen_on_callback_test
'
,
0
,
async
function
(
done
)
{
//isScreenOn(callback: AsyncCallback<boolean>)
power
.
isScreenOn
((
error
,
screenOn
)
=>
{
if
(
typeof
error
===
"
undefined
"
)
{
console
.
info
(
'
power_is_screen_on_callback_test screenOn is
'
+
screenOn
);
expect
(
screenOn
).
assertTrue
();
console
.
info
(
'
power_is_screen_on_callback_test success
'
);
done
();
}
else
{
console
.
log
(
'
power_is_screen_on_callback_test:
'
+
error
);
expect
().
assertFail
();
done
();
}
})
})
it
(
'
power_reboot_device_test
'
,
0
,
function
()
{
//rebootDevice(reason: string): void
power
.
rebootDevice
(
"
power_js_test_reboot
"
);
console
.
info
(
'
power_reboot_device_test success
'
);
})
it
(
'
power_shutdown_device_test
'
,
0
,
function
()
{
//shutdownDevice(reason: string): void
power
.
shutdownDevice
(
"
power_js_test_shutdown
"
);
console
.
info
(
'
power_shutdown_device_test success
'
);
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录