Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2260d0bc
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看板
提交
2260d0bc
编写于
1月 11, 2022
作者:
G
gaoxi785
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new osaccunt test
Signed-off-by:
N
gaoxi785
<
gaoxi785@huawei.com
>
上级
33df8ab1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
757 addition
and
5 deletion
+757
-5
account/osaccount/actsosaccountsystemtest/Test.json
account/osaccount/actsosaccountsystemtest/Test.json
+1
-1
account/osaccount/actsosaccountsystemtest/entry/src/main/js/default/pages/index/index.js
...systemtest/entry/src/main/js/default/pages/index/index.js
+1
-0
account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/OnOff.test.js
...sosaccountsystemtest/entry/src/main/js/test/OnOff.test.js
+627
-0
account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/Query.test.js
...sosaccountsystemtest/entry/src/main/js/test/Query.test.js
+88
-2
account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js
...thirdpartytest/entry/src/main/js/test/OsAccountIs.test.js
+40
-2
未找到文件。
account/osaccount/actsosaccountsystemtest/Test.json
浏览文件 @
2260d0bc
...
...
@@ -2,7 +2,7 @@
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
2
00000"
,
"test-timeout"
:
"
3
00000"
,
"package"
:
"com.example.actsosaccountsystemtest"
,
"shell-timeout"
:
"60000"
},
...
...
account/osaccount/actsosaccountsystemtest/entry/src/main/js/default/pages/index/index.js
浏览文件 @
2260d0bc
...
...
@@ -35,6 +35,7 @@ export default {
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
this
.
timeout
=
8000
;
configService
.
setConfig
(
this
)
require
(
'
../../../test/List.test
'
)
...
...
account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/OnOff.test.js
浏览文件 @
2260d0bc
...
...
@@ -25,6 +25,179 @@ describe('ActsOsAccountSystemTest', function () {
}
}
/*
* @tc.number : ActsOsAccountOnOff_0100
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that the activating type subscription can receive user switching
*/
it
(
'
ActsOsAccountOnOff_0100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0100 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
osAccountManager
.
off
(
"
activating
"
,
"
osAccountOnOffNameA
"
,
offCallback
);
}
}
function
removeCallback
(
err
){
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0100 end====
"
);
done
();
}
function
offCallback
(){
console
.
debug
(
"
====>off enter
"
)
osAccountManager
.
removeOsAccount
(
localId
,
removeCallback
);
}
osAccountManager
.
on
(
"
activating
"
,
"
osAccountOnOffNameA
"
,
onCallback
);
sleep
(
TIMEOUT
);
osAccountManager
.
createOsAccount
(
"
osAccountNameA
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameA
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0200
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that the activate type subscription can receive user switching
*/
it
(
'
ActsOsAccountOnOff_0200
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0200 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
osAccountManager
.
off
(
"
activate
"
,
"
osAccountOnOffNameB
"
,
offCallback
);
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter
"
)
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0200 end====
"
);
done
();
})
}
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameB
"
,
onCallback
);
sleep
(
TIMEOUT
);
osAccountManager
.
createOsAccount
(
"
osAccountNameB
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameB
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
});
});
})
/*
* @tc.number : ActsOsAccountOnOff_0300
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that the activating type unsubscribes successfully
*/
it
(
'
ActsOsAccountOnOff_0300
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0300 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter
"
)
}
osAccountManager
.
on
(
"
activating
"
,
"
osAccountOnOffNameC
"
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
off
(
"
activating
"
,
"
osAccountOnOffNameC
"
,
offCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameC
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameC
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0300 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0400
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that the activate type unsubscribes successfully
*/
it
(
'
ActsOsAccountOnOff_0400
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0400 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter
"
)
}
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameD
"
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
off
(
"
activate
"
,
"
osAccountOnOffNameD
"
,
offCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameD
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameD
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0400 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0500
* @tc.name : Subscribe and unsubscribing local multi-user
...
...
@@ -69,6 +242,460 @@ describe('ActsOsAccountSystemTest', function () {
},
TIMEOUT
);
});
/*
* @tc.number : ActsOsAccountOnOff_0700
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verification cannot cancel activating type not subscribed
*/
it
(
'
ActsOsAccountOnOff_0700
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0700 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
osAccountManager
.
on
(
"
activating
"
,
""
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameE
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameE
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0700 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0800
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verification cannot cancel activating type not subscribed
*/
it
(
'
ActsOsAccountOnOff_0800
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0800 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
osAccountManager
.
on
(
"
activate
"
,
""
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameF
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameF
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0800 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0900
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verification does not trigger callbacks for activating type subscriptions when switching fails
*/
it
(
'
ActsOsAccountOnOff_0900
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_0900 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter
"
);
console
.
debug
(
"
====>ActsOsAccountOnOff_0900 end====
"
);
done
();
}
osAccountManager
.
on
(
"
activating
"
,
"
osAccountOnOffNameG
"
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
queryAllCreatedOsAccounts
((
err
,
data
)
=>
{
console
.
debug
(
"
====>queryAllCreatedOsAccounts err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
){
if
(
data
[
i
].
isActived
==
true
){
localId
=
data
[
i
].
localId
;
}
}
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
!=
0
).
assertEqual
(
true
);
setTimeout
(()
=>
{
osAccountManager
.
off
(
"
activating
"
,
"
osAccountOnOffNameG
"
,
offCallback
);
},
TIMEOUT
);
});
})
});
/*
* @tc.number : ActsOsAccountOnOff_1000
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verification does not trigger callbacks for activate type subscriptions when switching fails
*/
it
(
'
ActsOsAccountOnOff_1000
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1000 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter
"
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1000 end====
"
);
done
();
}
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameH
"
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
queryAllCreatedOsAccounts
((
err
,
data
)
=>
{
console
.
debug
(
"
====>queryAllCreatedOsAccounts err:
"
+
JSON
.
stringify
(
err
));
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
){
if
(
data
[
i
].
isActived
==
true
){
localId
=
data
[
i
].
localId
;
}
}
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
setTimeout
(()
=>
{
expect
(
err
.
code
!=
0
).
assertEqual
(
true
);
osAccountManager
.
off
(
"
activate
"
,
"
osAccountOnOffNameH
"
,
offCallback
);
},
2000
);
});
})
})
/*
* @tc.number : ActsOsAccountOnOff_1100
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that an instance repeatedly subscribes to local users
*/
it
(
'
ActsOsAccountOnOff_1100
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1100 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
var
countNum
=
0
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
countNum
++
;
}
}
function
onCallbackTwice
(
receiveLocalId
){
console
.
debug
(
"
====>receive twice localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
countNum
++
;
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter====
"
);
expect
(
countNum
).
assertEqual
(
2
);
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1100 end====
"
);
done
();
})
}
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameI
"
,
onCallback
);
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameI
"
,
onCallbackTwice
);
sleep
(
TIMEOUT
);
osAccountManager
.
createOsAccount
(
"
osAccountNameI
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameI
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
off
(
"
activate
"
,
"
osAccountOnOffNameI
"
,
offCallback
);
},
2000
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_1200
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that an instance unsubscribes local users afer resubscribing
*/
it
(
'
ActsOsAccountOnOff_1200
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1200 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
var
countNum
=
0
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
countNum
++
;
}
}
function
onCallbackTwice
(
receiveLocalId
){
console
.
debug
(
"
====>receive twice localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
countNum
++
;
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter====
"
);
}
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
onCallback
);
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
onCallbackTwice
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
off
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
offCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameJ
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameJ
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
expect
(
countNum
).
assertEqual
(
0
);
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1200 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_1300
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that an instance unsubscribes local users afer resubscribing
*/
it
(
'
ActsOsAccountOnOff_1300
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1300 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
osAccountManagerTwice
=
osaccount
.
getAccountManager
();
var
localId
;
var
countFirstNum
=
0
;
var
countSecondNum
=
0
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
countFirstNum
++
;
}
}
function
onCallbackTwice
(
receiveLocalId
){
console
.
debug
(
"
====>receive twice localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
countSecondNum
++
;
}
}
function
offCallback
(){
console
.
debug
(
"
====>off enter====
"
);
}
function
offCallbackTwice
(){
console
.
debug
(
"
====>off twice enter====
"
);
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1300 end====
"
);
done
();
})
}
osAccountManager
.
on
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
onCallback
);
osAccountManagerTwice
.
on
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
onCallbackTwice
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
off
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
offCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameK
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameK
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
expect
(
countFirstNum
).
assertEqual
(
0
);
expect
(
countSecondNum
).
assertEqual
(
1
);
osAccountManagerTwice
.
off
(
"
activate
"
,
"
osAccountOnOffNameJ
"
,
offCallbackTwice
);
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_1400
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Validate subscription with parameter type as empty string
*/
it
(
'
ActsOsAccountOnOff_1400
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1400 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
osAccountManager
.
on
(
""
,
"
osAccountOnOffNameL
"
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameL
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameL
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1400 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_1500
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Validate subscription with parameter type as other string
*/
it
(
'
ActsOsAccountOnOff_1500
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1500 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
osAccountManager
.
on
(
"
Abc
"
,
"
osAccountOnOffNameM
"
,
onCallback
);
sleep
(
TIMEOUTHALF
);
osAccountManager
.
createOsAccount
(
"
osAccountNameM
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameM
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1500 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_1600
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Validate subscription with parameter type as undefined
*/
it
(
'
ActsOsAccountOnOff_1600
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountOnOff_1600 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
var
localId
;
console
.
debug
(
"
====>get AccountManager finish====
"
);
function
onCallback
(
receiveLocalId
){
console
.
debug
(
"
====>receive localId:
"
+
receiveLocalId
);
if
(
receiveLocalId
==
localId
){
console
.
debug
(
"
====>wrongly received localId:
"
+
localId
+
"
after unsubscribing
"
);
expect
().
assertFail
();
done
();
}
}
osAccountManager
.
on
(
undefined
,
"
osAccountOnOffNameM
"
,
onCallback
);
osAccountManager
.
createOsAccount
(
"
osAccountNameM
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
localId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameM
"
);
osAccountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
setTimeout
(()
=>
{
osAccountManager
.
removeOsAccount
(
localId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
localId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountOnOff_1600 end====
"
);
done
();
})
},
TIMEOUT
);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_1700
* @tc.name : Subscribe and unsubscribing local multi-user
...
...
account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/Query.test.js
浏览文件 @
2260d0bc
...
...
@@ -32,6 +32,12 @@ describe('ActsOsAccountSystemTest', function () {
console
.
debug
(
"
====>queryOsAccountById data:
"
+
JSON
.
stringify
(
data
));
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
localId
).
assertEqual
(
100
);
expect
(
data
.
type
.
ADMIN
).
assertEqual
(
0
);
var
serialNumberStr
=
data
.
serialNumber
.
toString
();
var
serialIntercept
=
serialNumberStr
.
substring
(
8
);
console
.
debug
(
"
====>truncate the last eight characters:
"
+
serialIntercept
);
expect
(
serialIntercept
).
assertEqual
(
"
00000001
"
);
expect
(
data
.
isCreateCompleted
).
assertTrue
();
console
.
debug
(
"
====>ActsOsAccountQuery_0100 end====
"
);
done
();
})
...
...
@@ -49,6 +55,12 @@ describe('ActsOsAccountSystemTest', function () {
var
osAccountInfo
=
await
osAccountManager
.
queryOsAccountById
(
100
);
console
.
debug
(
"
====>queryOsAccountById osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
expect
(
osAccountInfo
.
localId
).
assertEqual
(
100
);
expect
(
osAccountInfo
.
type
.
ADMIN
).
assertEqual
(
0
);
var
serialNumberStr
=
osAccountInfo
.
serialNumber
.
toString
();
var
serialIntercept
=
serialNumberStr
.
substring
(
8
);
console
.
debug
(
"
====>truncate the last eight characters:
"
+
serialIntercept
);
expect
(
serialIntercept
).
assertEqual
(
"
00000001
"
);
expect
(
osAccountInfo
.
isCreateCompleted
).
assertTrue
();
console
.
debug
(
"
====>ActsOsAccountQuery_0200 end====
"
);
done
();
});
...
...
@@ -212,7 +224,7 @@ describe('ActsOsAccountSystemTest', function () {
console
.
debug
(
"
====>queryAllCreatedOsAccounts data:
"
+
JSON
.
stringify
(
data
));
expect
(
err
.
code
).
assertEqual
(
0
);
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
dataMap
.
set
(
data
[
i
].
localId
,
data
[
i
].
owner
)
dataMap
.
set
(
data
[
i
].
localId
,
data
[
i
].
localName
)
}
expect
(
dataMap
.
has
(
100
)).
assertTrue
();
console
.
debug
(
"
====>ActsOsAccountQuery_1100 end====
"
);
...
...
@@ -233,13 +245,87 @@ describe('ActsOsAccountSystemTest', function () {
var
osAccountCreated
=
await
osAccountManager
.
queryAllCreatedOsAccounts
();
console
.
debug
(
"
====>queryAllCreatedOsAccounts:
"
+
JSON
.
stringify
(
osAccountCreated
));
for
(
let
i
=
0
,
len
=
osAccountCreated
.
length
;
i
<
len
;
i
++
)
{
dataMap
.
set
(
osAccountCreated
[
i
].
localId
,
osAccountCreated
[
i
].
owner
)
dataMap
.
set
(
osAccountCreated
[
i
].
localId
,
osAccountCreated
[
i
].
localName
)
}
expect
(
dataMap
.
has
(
100
)).
assertTrue
();
console
.
debug
(
"
====>ActsOsAccountQuery_1200 end====
"
);
done
();
});
/*
* @tc.number : ActsOsAccountQuery_1300
* @tc.name : queryAllCreatedOsAccounts callback
* @tc.desc : Verify that all local users contain 100 user and created users
*/
it
(
'
ActsOsAccountQuery_1300
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountQuery_1300 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
debug
(
"
====>get AccountManager finish====
"
);
var
createIocalId
;
let
dataMap
=
new
Map
();
osAccountManager
.
createOsAccount
(
"
osAccountNameQueryA
"
,
1
,
(
err
,
osAccountInfo
)
=>
{
console
.
debug
(
"
====>createOsAccount err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
createIocalId
=
osAccountInfo
.
localId
;
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameQueryA
"
);
osAccountManager
.
queryAllCreatedOsAccounts
((
err
,
data
)
=>
{
console
.
debug
(
"
====>queryAllCreatedOsAccounts err:
"
+
JSON
.
stringify
(
err
));
console
.
debug
(
"
====>queryAllCreatedOsAccounts data:
"
+
JSON
.
stringify
(
data
));
expect
(
err
.
code
).
assertEqual
(
0
);
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
dataMap
.
set
(
data
[
i
].
localId
,
data
[
i
].
localName
)
}
expect
(
dataMap
.
has
(
100
)).
assertTrue
();
expect
(
dataMap
.
has
(
createIocalId
)).
assertTrue
();
if
(
dataMap
.
has
(
createIocalId
))
{
let
createdlocalName
=
dataMap
.
get
(
createIocalId
);
console
.
debug
(
"
====>query all local users containing localId:
"
+
createIocalId
);
console
.
debug
(
"
====>created localName
"
+
createdlocalName
);
expect
(
createdlocalName
).
assertEqual
(
"
osAccountNameQueryA
"
);
osAccountManager
.
removeOsAccount
(
createIocalId
,
(
err
)
=>
{
console
.
debug
(
"
====>remove localId:
"
+
createIocalId
+
"
err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
console
.
debug
(
"
====>ActsOsAccountQuery_1300 end====
"
);
done
();
})
}
})
});
});
/*
* @tc.number : ActsOsAccountQuery_1400
* @tc.name : queryAllCreatedOsAccounts promise
* @tc.desc : Verify that all local users contain 100 user and created users
*/
it
(
'
ActsOsAccountQuery_1400
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
"
====>ActsOsAccountQuery_1400 start====
"
);
var
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
debug
(
"
====>get AccountManager finish====
"
);
var
createIocalId
;
let
dataMap
=
new
Map
();
var
osAccountInfo
=
await
osAccountManager
.
createOsAccount
(
"
osAccountNameQueryB
"
,
1
);
console
.
debug
(
"
====>createOsAccount osAccountInfo:
"
+
JSON
.
stringify
(
osAccountInfo
));
createIocalId
=
osAccountInfo
.
localId
;
expect
(
osAccountInfo
.
localName
).
assertEqual
(
"
osAccountNameQueryB
"
);
var
data
=
await
osAccountManager
.
queryAllCreatedOsAccounts
();
console
.
debug
(
"
====>queryAllCreatedOsAccounts data:
"
+
JSON
.
stringify
(
data
));
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
dataMap
.
set
(
data
[
i
].
localId
,
data
[
i
].
localName
)
}
expect
(
dataMap
.
has
(
100
)).
assertTrue
();
expect
(
dataMap
.
has
(
createIocalId
)).
assertTrue
();
if
(
dataMap
.
has
(
createIocalId
))
{
let
createdlocalName
=
dataMap
.
get
(
createIocalId
);
console
.
debug
(
"
====>query all local users containing localId:
"
+
createIocalId
);
expect
(
createdlocalName
).
assertEqual
(
"
osAccountNameQueryB
"
);
}
await
osAccountManager
.
removeOsAccount
(
createIocalId
);
console
.
debug
(
"
====>ActsOsAccountQuery_1400 end====
"
);
done
();
});
/*
* @tc.number : ActsOsAccountQuery_1500
* @tc.name : queryMaxOsAccountNumber callback
...
...
account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js
浏览文件 @
2260d0bc
...
...
@@ -138,6 +138,45 @@ describe('ActsOsAccountThirdPartyTest', function () {
}
})
/*
* @tc.number : ActsOsAccountIsActived_0500
* @tc.name : isOsAccountActived callback
* @tc.desc : Authentication failed to query the active status of the user that does not exist
*/
it
(
'
ActsOsAccountIsActived_0500
'
,
0
,
async
function
(
done
){
console
.
debug
(
"
====>ActsOsAccountIsActived_0500 start
"
);
var
AccountManager
=
osAccount
.
getAccountManager
();
console
.
debug
(
"
====>get os AccountManager finish====
"
);
var
nonExistLocalId
=
1000
;
AccountManager
.
isOsAccountActived
(
nonExistLocalId
,
(
err
)
=>
{
console
.
debug
(
"
====>isOsAccountActived err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
!=
0
).
assertEqual
(
true
);
console
.
debug
(
"
====>ActsOsAccountIsActived_0500 end
"
);
done
();
})
})
/*
* @tc.number : ActsOsAccountIsActived_0600
* @tc.name : isOsAccountActived promise
* @tc.desc : Authentication failed to query the active status of the user that does not exist
*/
it
(
'
ActsOsAccountIsActived_0600
'
,
0
,
async
function
(
done
){
console
.
debug
(
"
====>ActsOsAccountIsActived_0600 start====
"
);
var
AccountManager
=
osAccount
.
getAccountManager
();
console
.
debug
(
"
====>get os AccountManager finish====
"
);
var
nonExistLocalId
=
1000
;
try
{
await
AccountManager
.
isOsAccountActived
(
nonExistLocalId
);
}
catch
(
err
){
console
.
debug
(
"
====>isOsAccountActived err:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
!=
0
).
assertTrue
();
console
.
debug
(
"
====>ActsOsAccountIsActived_0600 end
"
);
done
();
}
})
/*
* @tc.number : ActsOsAccountIsMulty_0100
* @tc.name : isMultiOsAccountEnable callback
...
...
@@ -363,5 +402,4 @@ describe('ActsOsAccountThirdPartyTest', function () {
console
.
debug
(
"
====>ActsOsAccountIsTest_0200 end====
"
);
done
();
})
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录