Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1af9fed5
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看板
提交
1af9fed5
编写于
8月 18, 2022
作者:
G
gaoxi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update case
Signed-off-by:
N
gaoxi
<
gaoxi785@huawei.com
>
上级
37adfc46
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
774 deletion
+33
-774
miscservices/screenlock_js/src/main/js/test/screenlock_service_test.js
...screenlock_js/src/main/js/test/screenlock_service_test.js
+31
-757
miscservices/screenlock_js/src/main/js/test/screenlock_service_test_promise.js
...ck_js/src/main/js/test/screenlock_service_test_promise.js
+2
-17
未找到文件。
miscservices/screenlock_js/src/main/js/test/screenlock_service_test.js
浏览文件 @
1af9fed5
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
screenLock
from
'
@ohos.
app.screenlockability
'
;
import
screenLock
from
'
@ohos.
screenLock
'
;
import
{
describe
,
expect
,
it
}
from
'
deccjsunit/index
'
const
SCREEN_STATE_BEGIN_OFF
=
0
;
...
...
@@ -87,12 +87,6 @@ describe('ScreenLockServiceTest', function () {
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
ScreenLock_Test_0200 isScreenLocked's status is
"
+
data
);
expect
(
data
==
false
).
assertTrue
();
});
var
resetIsScreenLocked
=
true
;
screenLock
.
test_setScreenLocked
(
resetIsScreenLocked
,
(
err
,
data
)
=>
{
console
.
log
(
"
ScreenLock_Test_0200 test_setScreenLocked data is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
...
...
@@ -144,18 +138,10 @@ describe('ScreenLockServiceTest', function () {
console
.
log
(
"
Screenlock_Test_0400: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
var
unlockScreenResult
=
0
;
var
eventType
=
'
unlockScreenResult
'
;
screenLock
.
sendScreenLockEvent
(
eventType
,
unlockScreenResult
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_0400: sendScreenLockEvent result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_0400: isScreenLocked result is
"
+
data
);
expect
(
data
==
fals
e
).
assertTrue
();
expect
(
data
==
tru
e
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
...
...
@@ -190,14 +176,6 @@ describe('ScreenLockServiceTest', function () {
console
.
log
(
"
Screenlock_Test_0500: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
var
unlockScreenResult
=
1
;
var
eventType
=
'
unlockScreenResult
'
;
screenLock
.
sendScreenLockEvent
(
eventType
,
unlockScreenResult
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_0500: sendScreenLockEvent result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_0500: isScreenLocked result is
"
+
data
);
...
...
@@ -213,811 +191,107 @@ describe('ScreenLockServiceTest', function () {
});
/*
* @tc.number Screenlock_Test_
21
00
* @tc.number Screenlock_Test_
06
00
* @tc.name After the systemUI is started, it is in the locked state, the lock management sends
the unlock request successfully, and the lock screen application notifies the unlock
success message
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_
21
00
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
------------------start Screenlock_Test_
21
00-------------------
"
);
it
(
"
Screenlock_Test_
06
00
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
------------------start Screenlock_Test_
06
00-------------------
"
);
try
{
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_
21
00: isScreenLocked result is
"
+
data
);
console
.
log
(
"
Screenlock_Test_
06
00: isScreenLocked result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
screenLock
.
unlockScreen
(()
=>
{
console
.
log
(
"
Screenlock_Test_2100: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
var
unlockScreenResult
=
0
;
var
eventType
=
'
unlockScreenResult
'
;
screenLock
.
sendScreenLockEvent
(
eventType
,
unlockScreenResult
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2100: sendScreenLockEvent result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
console
.
log
(
"
Screenlock_Test_0600: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_
21
00: isScreenLocked result is
"
+
data
);
expect
(
data
==
fals
e
).
assertTrue
();
console
.
log
(
"
Screenlock_Test_
06
00: isScreenLocked result is
"
+
data
);
expect
(
data
==
tru
e
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
var
isScreenLockedValue
=
true
;
screenLock
.
test_setScreenLocked
(
isScreenLockedValue
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_
21
00: test_setScreenLocked setting
"
+
data
+
"
result is successfull
"
);
console
.
log
(
"
Screenlock_Test_
06
00: test_setScreenLocked setting
"
+
data
+
"
result is successfull
"
);
done
();
});
}
catch
(
error
)
{
console
.
info
(
"
Screenlock_Test_
21
00: error =
"
+
error
);
console
.
info
(
"
Screenlock_Test_
06
00: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
info
(
"
------------------end Screenlock_Test_
21
00-------------------
"
);
console
.
info
(
"
------------------end Screenlock_Test_
06
00-------------------
"
);
});
/*
* @tc.number Screenlock_Test_
22
00
* @tc.number Screenlock_Test_
07
00
* @tc.name After systemUI is started, it is currently unlocked
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_
22
00
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_
22
00-------------------
"
);
it
(
"
Screenlock_Test_
07
00
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_
07
00-------------------
"
);
try
{
var
isScreenlockedValue
=
false
;
screenLock
.
test_setScreenLocked
(
isScreenlockedValue
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_
22
00: test_setScreenLocked is successful,result is
"
+
data
);
console
.
log
(
"
Screenlock_Test_
07
00: test_setScreenLocked is successful,result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_
22
00: isScreenLocked is successful, result is
"
+
data
);
console
.
log
(
"
Screenlock_Test_
07
00: isScreenLocked is successful, result is
"
+
data
);
expect
(
data
==
false
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
isScreenlockedValue
=
true
;
screenLock
.
test_setScreenLocked
(
isScreenlockedValue
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2200: test_setScreenLocked is successful, result is
"
+
data
);
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_
22
00: error =
"
+
error
);
console
.
log
(
"
logMessage Screenlock_Test_
07
00: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screen
Lock_Test_22
00-------------------
"
);
console
.
log
(
"
------------------end Screen
lock_Test_07
00-------------------
"
);
});
/*
* @tc.number Screenlock_Test_
23
00
* @tc.number Screenlock_Test_
08
00
* @tc.name After the systemUI is started, it is in the locked state, the lock management sends
the unlock request successfully, and the lock screen application notifies the unlock
failed message
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_
23
00
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
------------------start Screenlock_Test_
23
00-------------------
"
);
it
(
"
Screenlock_Test_
08
00
"
,
0
,
async
function
(
done
)
{
console
.
info
(
"
------------------start Screenlock_Test_
08
00-------------------
"
);
try
{
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_
23
00: isScreenLocked result is
"
+
data
);
expect
(
data
==
tru
e
).
assertTrue
();
console
.
log
(
"
Screenlock_Test_
08
00: isScreenLocked result is
"
+
data
);
expect
(
data
==
fals
e
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
screenLock
.
unlockScreen
(()
=>
{
console
.
log
(
"
Screenlock_Test_2300: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
var
unlockScreenResult
=
1
;
var
eventType
=
'
unlockScreenResult
'
;
screenLock
.
sendScreenLockEvent
(
eventType
,
unlockScreenResult
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2300: sendScreenLockEvent result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
console
.
log
(
"
Screenlock_Test_0800: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
((
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2300: isScreenLocked result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
info
(
"
Screenlock_Test_2300: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
info
(
"
------------------end Screenlock_Test_2300-------------------
"
);
});
/*
* @tc.number Screenlock_Test_2400
* @tc.name Device management causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_2400
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_2400-------------------
"
);
try
{
var
eventType
=
'
beginSleep
'
;
var
reasonForSleep
=
1
;
screenLock
.
test_runtimeNotify
(
eventType
,
reasonForSleep
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2400: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2400: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_BEGIN_SLEEP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
end Screenlock_Test_2400: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_2400-------------------
"
);
});
/*
* @tc.number Screenlock_Test_2500
* @tc.name Device management causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_2500
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_2500-------------------
"
);
try
{
var
eventType
=
'
endSleep
'
;
var
reasonForSleep
=
1
;
screenLock
.
test_runtimeNotify
(
eventType
,
reasonForSleep
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2500: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2500: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_END_SLEEP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_2500: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_2500-------------------
"
);
});
/*
* @tc.number Screenlock_Test_2600
* @tc.name Device management causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_2600
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_2600-------------------
"
);
try
{
var
eventType
=
'
beginScreenOff
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2600: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2600: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_BEGIN_OFF
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_2600: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_2600-------------------
"
);
});
/*
* @tc.number Screenlock_Test_2700
* @tc.name Device management causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_2700
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_2700-------------------
"
);
try
{
var
eventType
=
'
endScreenOff
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2700: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2700: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_END_OFF
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_2700: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_2700-------------------
"
);
});
/*
* @tc.number Screenlock_Test_2800
* @tc.name User causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_2800
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_2800-------------------
"
);
try
{
var
eventType
=
'
beginSleep
'
;
var
reasonForSleep
=
2
;
screenLock
.
test_runtimeNotify
(
eventType
,
reasonForSleep
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2800: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2800: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_BEGIN_SLEEP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_2800: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_2800-------------------
"
);
});
/*
* @tc.number Screenlock_Test_2900
* @tc.name User causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_2900
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_2900-------------------
"
);
try
{
var
eventType
=
'
endSleep
'
;
var
reasonForSleep
=
2
;
screenLock
.
test_runtimeNotify
(
eventType
,
reasonForSleep
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2900: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_2900: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_END_SLEEP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_2900: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_2900-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3000
* @tc.name User causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3000
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3000-------------------
"
);
try
{
var
eventType
=
'
beginScreenOff
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3000: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3000: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_BEGIN_OFF
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3000: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3000-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3100
* @tc.name User causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3100
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3100-------------------
"
);
try
{
var
eventType
=
'
endScreenOff
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3100: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3100: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_END_OFF
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3100: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3100-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3200
* @tc.name No operation for a long time causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3200
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3200-------------------
"
);
try
{
var
eventType
=
'
beginSleep
'
;
var
reasonForSleep
=
3
;
screenLock
.
test_runtimeNotify
(
eventType
,
reasonForSleep
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3200: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3200: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_BEGIN_SLEEP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3200: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3200-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3300
* @tc.name No operation for a long time causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3300
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3300-------------------
"
);
try
{
var
eventType
=
'
endSleep
'
;
var
reasonForSleep
=
3
;
screenLock
.
test_runtimeNotify
(
eventType
,
reasonForSleep
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3300: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3300: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_END_SLEEP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3300: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3300-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3400
* @tc.name No operation for a long time causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3400
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3400-------------------
"
);
try
{
var
eventType
=
'
beginScreenOff
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3400: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3400: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_BEGIN_OFF
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3400: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3400-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3500
* @tc.name No operation for a long time causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3500
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3500-------------------
"
);
try
{
var
eventType
=
'
endScreenOff
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3500: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3500: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_END_OFF
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3500: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3500-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3600
* @tc.name Responding to bright screen events, and run "beginWakeUp" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3600
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3600-------------------
"
);
try
{
var
eventType
=
'
beginWakeUp
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3600: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3600: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_BEGIN_WAKEUP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3600: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3600-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3700
* @tc.name Responding to bright screen events, and run "endWakeUp" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3700
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------logMessage Screenlock_Test_3700-------------------
"
);
try
{
var
eventType
=
'
endWakeUp
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3700: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3700: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
INTERACTIVE_STATE_END_WAKEUP
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3700: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3700-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3800
* @tc.name Responding to bright screen events, and run "beginScreenOn" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3800
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3800-------------------
"
);
try
{
var
eventType
=
'
beginScreenOn
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3800: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3800: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_BEGIN_ON
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3800: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3800-------------------
"
);
});
/*
* @tc.number Screenlock_Test_3900
* @tc.name Responding to bright screen events, and run "endScreenOn" operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_3900
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_3900-------------------
"
);
try
{
var
eventType
=
'
endScreenOn
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3900: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_3900: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
SCREEN_STATE_END_ON
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_3900: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_3900-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4000
* @tc.name Modify the user ID to 2, and the modification is successful
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4000
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4000-------------------
"
);
try
{
var
eventType
=
'
changeUser
'
;
var
userId
=
2
;
screenLock
.
test_runtimeNotify
(
eventType
,
userId
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4000: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4000: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
userId
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4000: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4000-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4100
* @tc.name Modify the user ID to 0, and the modification is successful
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4100
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------logMessage Screenlock_Test_4100-------------------
"
);
try
{
var
eventType
=
'
changeUser
'
;
var
userId
=
0
;
screenLock
.
test_runtimeNotify
(
eventType
,
userId
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4100: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4100: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
userId
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4100: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4100-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4200
* @tc.name Modify the user ID to -3, and the modification is failed
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4200
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4200-------------------
"
);
try
{
var
eventType
=
'
changeUser
'
;
var
userId
=
-
3
;
screenLock
.
test_runtimeNotify
(
eventType
,
userId
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4200: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
var
oldUserId
=
0
;
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4200: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
oldUserId
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4200: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4200-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4300
* @tc.name Modify the user ID to 99999999999999, and the modification is failed
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4300
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4300-------------------
"
);
try
{
var
eventType
=
'
changeUser
'
;
var
userId
=
99999999999999
;
screenLock
.
test_runtimeNotify
(
eventType
,
userId
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4300: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
var
oldUserId
=
0
;
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4300: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
oldUserId
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4300: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4300-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4400
* @tc.name Modify the user ID to 'abc', and the modification is failed
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4400
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4400-------------------
"
);
try
{
var
eventType
=
'
changeUser
'
;
var
userId
=
'
abc
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
userId
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4400: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
var
oldUserId
=
0
;
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4400: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
oldUserId
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4400: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4400-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4500
* @tc.name Settings can lock the screen
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4500
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4500-------------------
"
);
try
{
var
eventType
=
'
screenlockEnabled
'
;
var
isScreenlockEnabled
=
0
;
screenLock
.
test_runtimeNotify
(
eventType
,
isScreenlockEnabled
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4500: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4500: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
isScreenlockEnabled
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4500: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4500-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4600
* @tc.name Setting can not lock screen
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4600
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4600-------------------
"
);
try
{
var
eventType
=
'
screenlockEnabled
'
;
var
isScreenlockEnabled
=
1
;
screenLock
.
test_runtimeNotify
(
eventType
,
isScreenlockEnabled
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4600: test_runtimeNotify is successful, result is
"
+
data
);
});
sleep
(
SLEEP_TIME
);
screenLock
.
test_getRuntimeState
(
eventType
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4600: test_getRuntimeState is successful, result is
"
+
data
);
expect
(
data
==
isScreenlockEnabled
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_4600: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_4600-------------------
"
);
});
/*
* @tc.number Screenlock_Test_4700
* @tc.name Run 'beginExitAnimation' operate
* @tc.desc Function test
* @tc.level 0
*/
it
(
"
Screenlock_Test_4700
"
,
0
,
async
function
(
done
)
{
console
.
log
(
"
------------------start Screenlock_Test_4700-------------------
"
);
try
{
var
eventType
=
'
beginExitAnimation
'
;
screenLock
.
test_runtimeNotify
(
eventType
,
-
100
,
(
err
,
data
)
=>
{
console
.
log
(
"
Screenlock_Test_4700: test_runtimeNotify is successful, result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
console
.
log
(
"
Screenlock_Test_0800: isScreenLocked result is
"
+
data
);
expect
(
data
==
false
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
log
(
"
logMessage Screenlock_Test_47
00: error =
"
+
error
);
console
.
info
(
"
Screenlock_Test_08
00: error =
"
+
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
log
(
"
------------------end Screenlock_Test_47
00-------------------
"
);
});
console
.
info
(
"
------------------end Screenlock_Test_08
00-------------------
"
);
});
})
\ No newline at end of file
miscservices/screenlock_js/src/main/js/test/screenlock_service_test_promise.js
浏览文件 @
1af9fed5
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
screenLock
from
'
@ohos.
app.screenlockability
'
;
import
screenLock
from
'
@ohos.
screenLock
'
;
import
{
describe
,
expect
,
it
}
from
'
deccjsunit/index
'
const
SLEEP_TIME
=
1000
;
...
...
@@ -126,18 +126,11 @@ describe('ScreenLockServicePromiseTest', function () {
console
.
log
(
"
ScreenLock_Test_Promise_0400: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
var
unlockScreenResult
=
0
;
var
eventType
=
'
unlockScreenResult
'
;
screenLock
.
sendScreenLockEvent
(
eventType
,
unlockScreenResult
).
then
((
data
)
=>
{
console
.
log
(
"
ScreenLock_Test_Promise_0400: sendScreenLockEvent result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
().
then
((
data
)
=>
{
console
.
log
(
"
ScreenLock_Test_Promise_0400: isScreenLocked result is
"
+
data
);
expect
(
data
==
fals
e
).
assertTrue
();
expect
(
data
==
tru
e
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
...
...
@@ -172,14 +165,6 @@ describe('ScreenLockServicePromiseTest', function () {
console
.
log
(
"
ScreenLock_Test_Promise_0500: send unlockScreen issue success
"
);
});
sleep
(
SLEEP_TIME
);
var
unlockScreenResult
=
1
;
var
eventType
=
'
unlockScreenResult
'
;
screenLock
.
sendScreenLockEvent
(
eventType
,
unlockScreenResult
).
then
((
data
)
=>
{
console
.
log
(
"
ScreenLock_Test_Promise_0500: sendScreenLockEvent result is
"
+
data
);
expect
(
data
==
true
).
assertTrue
();
});
sleep
(
SLEEP_TIME
);
screenLock
.
isScreenLocked
().
then
((
data
)
=>
{
console
.
log
(
"
ScreenLock_Test_Promise_0500: isScreenLocked result is
"
+
data
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录