Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
34dfb4c2
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
34dfb4c2
编写于
5月 25, 2023
作者:
Z
zhaimengchao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【Account】【Master】Added NewInterface and OptionalParameters xts for the DistributedAccount
Signed-off-by:
N
zhaimengchao
<
zhaimengchao@huawei.com
>
上级
8f7676c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
978 addition
and
107 deletion
+978
-107
account/OsAccountTest_js/src/main/js/test/ActsDSGetSet.test.js
...nt/OsAccountTest_js/src/main/js/test/ActsDSGetSet.test.js
+581
-11
account/OsAccountTest_js/src/main/js/test/OsAccount.test.js
account/OsAccountTest_js/src/main/js/test/OsAccount.test.js
+397
-96
未找到文件。
account/OsAccountTest_js/src/main/js/test/ActsDSGetSet.test.js
浏览文件 @
34dfb4c2
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
,
done
}
from
'
@ohos/hypium
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
account
from
'
@ohos.account.distributedAccount
'
const
LOGININFO
=
{
...
...
@@ -83,10 +83,11 @@ export default function ActsDAGetSetTest() {
*/
it
(
'
getOsAccountDistributedInfo_test001
'
,
0
,
async
function
(
done
)
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
getOsAccountDistributedInfo
().
then
(
function
(
data
)
{
accountAbility
.
getOsAccountDistributedInfo
().
then
(
(
data
)
=>
{
console
.
debug
(
'
====>getOsAccountDistributedInfo_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
expect
(
data
.
status
).
assertEqual
(
0
)
done
();
});
})
...
...
@@ -98,12 +99,47 @@ export default function ActsDAGetSetTest() {
*/
it
(
'
getOsAccountDistributedInfo_test002
'
,
0
,
async
function
(
done
)
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
getOsAccountDistributedInfo
(
function
(
err
,
data
)
{
accountAbility
.
getOsAccountDistributedInfo
(
(
err
,
data
)
=>
{
console
.
debug
(
'
====>getOsAccountDistributedInfo_test002 err:
'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'
====>getOsAccountDistributedInfo_test002 data:
'
+
JSON
.
stringify
(
data
))
expect
(
err
).
assertEqual
(
null
)
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
expect
(
data
.
status
).
assertEqual
(
0
)
done
();
});
})
/**
* @tc.number getOsAccountDistributedInfoByLocalId_test001
* @tc.name Test distributedAccount.getOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality.
*/
it
(
'
getOsAccountDistributedInfoByLocalId_test001
'
,
0
,
async
function
(
done
)
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
).
then
(
function
(
data
)
{
console
.
debug
(
'
====>getOsAccountDistributedInfoByLocalId_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
expect
(
data
.
status
).
assertEqual
(
0
)
done
();
});
})
/**
* @tc.number getOsAccountDistributedInfoByLocalId_test002
* @tc.name Test distributedAccount.getOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
getOsAccountDistributedInfoByLocalId_test002
'
,
0
,
async
function
(
done
)
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
function
(
err
,
data
)
{
console
.
debug
(
'
====>getOsAccountDistributedInfoByLocalId_test002 err:
'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'
====>getOsAccountDistributedInfoByLocalId_test002 data:
'
+
JSON
.
stringify
(
data
))
expect
(
err
).
assertEqual
(
null
)
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
expect
(
data
.
status
).
assertEqual
(
0
)
done
();
});
})
...
...
@@ -127,6 +163,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
'
====>setOsAccountDistributedInfo_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -169,6 +206,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
"
====>setOsAccountDistributedInfo_test002 get data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -225,6 +263,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
"
====>setOsAccountDistributedInfo_test004 query_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -265,6 +304,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
"
====>updateOsAccountDistributedInfo_test005 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -305,6 +345,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
"
====>setOsAccountDistributedInfo_test006 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -316,12 +357,11 @@ export default function ActsDAGetSetTest() {
expect
(
err
).
assertEqual
(
null
)
done
();
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfo_test006 update_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfo_test006 update_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
})
...
...
@@ -347,6 +387,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
"
====>setOsAccountDistributedInfo_test007 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -387,6 +428,7 @@ export default function ActsDAGetSetTest() {
console
.
debug
(
"
====>setOsAccountDistributedInfo_test008 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
...
...
@@ -402,7 +444,7 @@ export default function ActsDAGetSetTest() {
done
();
})
});
}).
catch
(()
=>
{
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfo_test008 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
...
...
@@ -456,7 +498,7 @@ export default function ActsDAGetSetTest() {
nickname
:
limitNickName
,
avatar
:
'
test
'
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
((
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfo_test010 err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
();
...
...
@@ -512,7 +554,7 @@ export default function ActsDAGetSetTest() {
};
try
{
await
accountAbility
.
setOsAccountDistributedInfo
(
obj
)
console
.
debug
(
"
====>setOsAccountDistributedInfo_test012 set_err
:
"
+
JSON
.
stringify
(
err
)
)
console
.
debug
(
"
====>setOsAccountDistributedInfo_test012 set_err
"
)
expect
().
assertFail
()
done
();
}
catch
(
err
){
...
...
@@ -576,5 +618,533 @@ export default function ActsDAGetSetTest() {
done
();
}
})
/**
* @tc.number setOsAccountDistributedInfoByLocalId_test0100
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
* setOsAccountDistributedInfoByLocalId callback
*/
it
(
'
setOsAccountDistributedInfoByLocalId_test0100
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
status
:
0
};
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
,
(
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfoByLocalId_test0100 set_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
async
(
err
,
data
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfoByLocalId_test0100 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>setOsAccountDistributedInfoByLocalId_test0100 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
,
status
:
0
};
console
.
debug
(
"
====>start LOGOFF
"
)
try
{
await
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
)
console
.
debug
(
'
====>setOsAccountDistributedInfoByLocalId_test0100 end
'
)
done
();
}
catch
(
err
){
console
.
debug
(
'
====>setOsAccountDistributedInfoByLocalId_test0100 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
}
});
});
})
/**
* @tc.number setOsAccountDistributedInfoByLocalId_test0200
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by promise.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
* setOsAccountDistributedInfoByLocalId promise
*/
it
(
'
setOsAccountDistributedInfoByLocalId_test0200
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
status
:
0
};
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
).
then
(()
=>
{
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
(
err
,
data
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfoByLocalId_test0200 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>setOsAccountDistributedInfoByLocalId_test0200 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
,
status
:
0
};
console
.
debug
(
"
====>start LOGOFF
"
)
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
).
then
(()
=>
{
console
.
debug
(
'
====>setOsAccountDistributedInfoByLocalId_test0200 end
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
'
====>setOsAccountDistributedInfoByLocalId_test0200 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfoByLocalId_test0200 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number DistributedAccountOptionalParameter_0100
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
* OptionalParameter
*/
it
(
'
DistributedAccountOptionalParameter_0100
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
,
(
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0100 set_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
getOsAccountDistributedInfo
(
async
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0100 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0100 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
try
{
await
accountAbility
.
setOsAccountDistributedInfo
(
obj
)
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0100 end
'
)
done
();
}
catch
(
err
){
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0100 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
}
});
});
})
/**
* @tc.number DistributedAccountOptionalParameter_0200
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by promise.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
* OptionalParameter
*/
it
(
'
DistributedAccountOptionalParameter_0200
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
accountAbility
.
getOsAccountDistributedInfo
((
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0200 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0200 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
,
};
console
.
debug
(
"
====>start LOGOFF
"
)
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0200 end
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0200 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0200 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number DistributedAccountOptionalParameter_0300
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
* OptionalParameter
*/
it
(
'
DistributedAccountOptionalParameter_0300
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
null
,
nickname
:
null
,
avatar
:
null
,
status
:
null
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
,
(
err
)
=>
{
console
.
debug
(
"
====>setOsAccountDistributedInfo_test017 set_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
getOsAccountDistributedInfo
(
async
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0300 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0300 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
try
{
await
accountAbility
.
setOsAccountDistributedInfo
(
obj
)
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0300 end
'
)
done
();
}
catch
(
err
){
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0300 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
}
});
});
})
/**
* @tc.number DistributedAccountOptionalParameter_0400
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by promise.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
* OptionalParameter
*/
it
(
'
DistributedAccountOptionalParameter_0400
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
null
,
nickname
:
null
,
avatar
:
null
,
status
:
null
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
accountAbility
.
getOsAccountDistributedInfo
((
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0400 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0400 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
,
};
console
.
debug
(
"
====>start LOGOFF
"
)
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0400 end
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0400 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0400 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number DistributedAccountOptionalParameter_0500
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
* OptionalParameter
*/
it
(
'
DistributedAccountOptionalParameter_0500
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
,
(
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0500 set_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
getOsAccountDistributedInfo
(
async
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0500 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0500 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
try
{
await
accountAbility
.
setOsAccountDistributedInfo
(
obj
)
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0500 end
'
)
done
();
}
catch
(
err
){
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0500 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
}
});
});
})
/**
* @tc.number DistributedAccountOptionalParameter_0600
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by promise.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
* OptionalParameter
*/
it
(
'
DistributedAccountOptionalParameter_0600
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
};
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
accountAbility
.
getOsAccountDistributedInfo
((
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0600 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0600 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
,
};
console
.
debug
(
"
====>start LOGOFF
"
)
accountAbility
.
setOsAccountDistributedInfo
(
obj
).
then
(()
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0600 end
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0600 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0600 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number DistributedAccountOptionalParameter_0700
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
* setOsAccountDistributedInfoByLocalId callback null OptionParameter
*/
it
(
'
DistributedAccountOptionalParameter_0700
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
null
,
nickname
:
null
,
avatar
:
null
,
status
:
null
};
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
,
(
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0700 set_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
async
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0700 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0700 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
try
{
await
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
)
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0700 end
'
)
done
();
}
catch
(
err
){
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0700 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
}
});
});
})
/**
* @tc.number DistributedAccountOptionalParameter_0800
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by promise.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
* setOsAccountDistributedInfoByLocalId promise null OptionParameter
*/
it
(
'
DistributedAccountOptionalParameter_0800
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
null
,
nickname
:
null
,
avatar
:
null
,
status
:
null
};
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
).
then
(()
=>
{
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0800 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0800 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
).
then
(()
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0800 end
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0800 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0800 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number DistributedAccountOptionalParameter_0900
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
* setOsAccountDistributedInfoByLocalId callback undefined OptionParameter
*/
it
(
'
DistributedAccountOptionalParameter_0900
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
,
(
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0900 set_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
async
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0900 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_0900 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
try
{
await
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
)
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0900 end
'
)
done
();
}
catch
(
err
){
console
.
debug
(
'
====>DistributedAccountOptionalParameter_0900 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
}
});
});
})
/**
* @tc.number DistributedAccountOptionalParameter_1000
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by promise.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
* setOsAccountDistributedInfoByLocalId promise undefined OptionParameter
*/
it
(
'
DistributedAccountOptionalParameter_1000
'
,
0
,
async
function
(
done
)
{
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
).
then
(()
=>
{
accountAbility
.
getOsAccountDistributedInfoByLocalId
(
100
,
(
err
,
data
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_1000 get_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>DistributedAccountOptionalParameter_1000 get_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
expect
(
data
.
status
).
assertEqual
(
1
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
console
.
debug
(
"
====>start LOGOFF
"
)
accountAbility
.
setOsAccountDistributedInfoByLocalId
(
100
,
obj
).
then
(()
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_1000 end
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
'
====>DistributedAccountOptionalParameter_1000 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
});
}).
catch
((
err
)
=>
{
console
.
debug
(
"
====>DistributedAccountOptionalParameter_1000 throw_err:
"
+
JSON
.
stringify
(
err
))
expect
().
assertFail
();
done
();
})
})
})
}
account/OsAccountTest_js/src/main/js/test/OsAccount.test.js
浏览文件 @
34dfb4c2
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
,
done
}
from
'
@ohos/hypium
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
account
from
'
@ohos.account.distributedAccount
'
const
LOGININFO
=
{
...
...
@@ -39,26 +39,33 @@ export default function AccountTest() {
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
ActsDistributedAccountDeviceId_0100
'
,
0
,
async
function
(
done
){
console
.
log
(
"
====>test query distribtued id start
"
);
const
distributedId
=
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
;
//'12345'sha256的值
const
accountAbility
=
account
.
getDistributedAccountAbility
();
accountAbility
.
updateOsAccountDistributedInfo
(
LOGININFO
,
(
err
)
=>
{
console
.
log
(
"
====>update distributedInfo err:
"
+
JSON
.
stringify
(
err
));
accountAbility
.
queryOsAccountDistributedInfo
((
err
,
distributedInfo
)
=>
{
console
.
log
(
"
====>query distributedInfo err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
====>query distributedInfo:
"
+
JSON
.
stringify
(
distributedInfo
));
expect
(
distributedInfo
.
name
).
assertEqual
(
'
ZhangSan
'
);
expect
(
distributedInfo
.
id
).
assertEqual
(
distributedId
);
console
.
debug
(
'
success
'
)
accountAbility
.
updateOsAccountDistributedInfo
(
LOGOUTINFO
,
(
err
)
=>
{
console
.
debug
(
'
====>ActsDistributedAccountDeviceId_0100 logout_result:
'
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertEqual
(
undefined
)
console
.
log
(
"
====>test query distribtued id end
"
);
done
();
console
.
debug
(
'
====>ActsDistributedAccountDeviceId_0100 start====
'
)
try
{
console
.
log
(
"
====>test query distribtued id start
"
);
const
distributedId
=
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
;
//'12345'sha256的值
const
accountAbility
=
account
.
getDistributedAccountAbility
();
accountAbility
.
updateOsAccountDistributedInfo
(
LOGININFO
,
(
err
)
=>
{
console
.
log
(
"
====>update distributedInfo err:
"
+
JSON
.
stringify
(
err
));
accountAbility
.
queryOsAccountDistributedInfo
((
err
,
distributedInfo
)
=>
{
console
.
log
(
"
====>query distributedInfo err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
====>query distributedInfo:
"
+
JSON
.
stringify
(
distributedInfo
));
expect
(
distributedInfo
.
name
).
assertEqual
(
'
ZhangSan
'
);
expect
(
distributedInfo
.
id
).
assertEqual
(
distributedId
);
console
.
debug
(
'
success
'
)
accountAbility
.
updateOsAccountDistributedInfo
(
LOGOUTINFO
,
(
err
)
=>
{
console
.
debug
(
'
====>ActsDistributedAccountDeviceId_0100 logout_result:
'
+
JSON
.
stringify
(
err
))
expect
(
err
).
assertEqual
(
undefined
)
console
.
log
(
"
====>test query distribtued id end
"
);
done
();
})
})
})
})
}
catch
(
err
){
console
.
debug
(
'
====>ActsDistributedAccountDeviceId_0100 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
...
...
@@ -67,14 +74,21 @@ export default function AccountTest() {
* @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality.
*/
it
(
'
account_getDistributedAccountAbility_test
'
,
0
,
async
function
(
done
)
{
var
ret
=
false
;
const
accountAbility
=
account
.
getDistributedAccountAbility
()
console
.
debug
(
"
====>account_getDistributedAccountAbility_test result:
"
+
JSON
.
stringify
(
accountAbility
))
if
(
accountAbility
!==
null
){
ret
=
true
;
console
.
debug
(
'
====>account_getDistributedAccountAbility_test start====
'
)
try
{
var
ret
=
false
;
const
accountAbility
=
account
.
getDistributedAccountAbility
()
console
.
debug
(
"
====>account_getDistributedAccountAbility_test result:
"
+
JSON
.
stringify
(
accountAbility
))
if
(
accountAbility
!==
null
){
ret
=
true
;
}
expect
(
ret
).
assertTrue
()
done
();
}
catch
(
err
){
console
.
debug
(
'
====>ActsDistributedAccountDeviceId_0100 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
expect
(
ret
).
assertTrue
()
done
();
})
/**
...
...
@@ -83,13 +97,20 @@ export default function AccountTest() {
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality.
*/
it
(
'
account_queryOsAccountDistributedInfo_test001
'
,
0
,
async
function
(
done
)
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
queryOsAccountDistributedInfo
().
then
(
function
(
data
)
{
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
done
();
});
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test001 start====
'
)
try
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
queryOsAccountDistributedInfo
().
then
(
function
(
data
)
{
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
done
();
});
}
catch
(
err
){
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test001 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
...
...
@@ -98,15 +119,22 @@ export default function AccountTest() {
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_queryOsAccountDistributedInfo_test002
'
,
0
,
async
function
(
done
)
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test002 start
'
)
try
{
let
accountAbility
=
account
.
getDistributedAccountAbility
()
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test002 err:
'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test002 data:
'
+
JSON
.
stringify
(
data
))
expect
(
err
).
assertEqual
(
undefined
)
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
done
();
});
}
catch
(
err
){
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test002 err:
'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'
====>account_queryOsAccountDistributedInfo_test002 data:
'
+
JSON
.
stringify
(
data
))
expect
(
err
).
assertEqual
(
undefined
)
expect
(
data
.
name
).
assertEqual
(
'
ohosAnonymousName
'
)
expect
(
data
.
id
).
assertEqual
(
'
ohosAnonymousUid
'
)
done
();
});
expect
().
assertFail
()
done
()
}
})
/**
...
...
@@ -115,6 +143,7 @@ export default function AccountTest() {
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it
(
'
account_updateOsAccountDistributedInfo_test001
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test001 start====
'
)
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
data
=
null
let
obj
=
{
...
...
@@ -123,30 +152,40 @@ export default function AccountTest() {
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
data
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
);
done
();
try
{
await
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test001 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
)
});
});
});
});
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
data
)
{
expect
(
data
).
assertEqual
(
undefined
)
done
();
})
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test001 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0
2
00
* @tc.number SUB_Account_distributedAccount_JS_API_0
5
00
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_updateOsAccountDistributedInfo_test002
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test002 start====
'
)
var
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
...
...
@@ -154,30 +193,37 @@ export default function AccountTest() {
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:{}
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test002 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
expect
(
data
).
assertEqual
(
undefined
)
done
();
try
{
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test002 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
expect
(
data
).
assertEqual
(
undefined
)
done
();
});
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test002 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0
3
00
* @tc.number SUB_Account_distributedAccount_JS_API_0
6
00
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_updateOsAccountDistributedInfo_test003
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test003 start====
'
)
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
data
=
null
let
obj
=
{
...
...
@@ -186,22 +232,29 @@ export default function AccountTest() {
event
:
'
Ohos.account.event.TOKEN_INVALID
'
,
scalableData
:
data
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
(
result
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test003 update_err:
"
+
JSON
.
stringify
(
result
))
accountAbility
.
queryOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test003 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
"
ohosAnonymousName
"
)
done
();
})
});
try
{
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
(
result
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test003 update_err:
"
+
JSON
.
stringify
(
result
))
accountAbility
.
queryOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test003 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
"
ohosAnonymousName
"
)
done
();
})
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test003 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0
5
00
* @tc.number SUB_Account_distributedAccount_JS_API_0
7
00
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_updateOsAccountDistributedInfo_test004
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test004 start====
'
)
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
...
...
@@ -209,24 +262,272 @@ export default function AccountTest() {
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:{}
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
(
err
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test004 update_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test004 query_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test004 query_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
)
done
();
try
{
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
(
err
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test004 update_err:
"
+
JSON
.
stringify
(
err
))
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test004 query_err:
"
+
JSON
.
stringify
(
err
))
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test004 query_data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOFF
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
)
done
();
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test004 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0800
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it
(
'
account_updateOsAccountDistributedInfo_test005
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test005 start====
'
)
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
try
{
await
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test005 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
)
done
()
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test005 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0900
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_updateOsAccountDistributedInfo_test006
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test006 start====
'
)
var
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
undefined
,
nickname
:
undefined
,
avatar
:
undefined
,
status
:
undefined
};
try
{
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test006 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
expect
(
data
).
assertEqual
(
undefined
)
done
();
});
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test006 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_1000
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it
(
'
account_updateOsAccountDistributedInfo_test007
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test007 start====
'
)
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
null
,
nickname
:
null
,
avatar
:
null
,
status
:
null
};
try
{
await
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test007 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
)
done
()
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test007 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_1100
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_updateOsAccountDistributedInfo_test008
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test008 start====
'
)
var
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
,
scalableData
:
null
,
nickname
:
null
,
avatar
:
null
,
status
:
null
};
try
{
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test008 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
expect
(
data
).
assertEqual
(
undefined
)
done
();
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test008 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_1200
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it
(
'
account_updateOsAccountDistributedInfo_test009
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test009 start====
'
)
const
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
};
try
{
await
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test009 data:
'
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
err
)
{
expect
(
err
).
assertEqual
(
undefined
)
done
()
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test009 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_1300
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it
(
'
account_updateOsAccountDistributedInfo_test010
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test010 start====
'
)
var
accountAbility
=
account
.
getDistributedAccountAbility
()
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGIN
'
};
try
{
accountAbility
.
updateOsAccountDistributedInfo
(
obj
,
function
()
{
accountAbility
.
queryOsAccountDistributedInfo
(
function
(
err
,
data
)
{
console
.
debug
(
"
====>account_updateOsAccountDistributedInfo_test010 data:
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
name
).
assertEqual
(
'
ZhangSan
'
)
expect
(
data
.
id
).
assertEqual
(
'
5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5
'
)
let
obj
=
{
id
:
'
12345
'
,
name
:
'
ZhangSan
'
,
event
:
'
Ohos.account.event.LOGOUT
'
};
accountAbility
.
updateOsAccountDistributedInfo
(
obj
).
then
(
function
(
data
)
{
expect
(
data
).
assertEqual
(
undefined
)
done
();
});
});
});
}
catch
(
err
){
console
.
debug
(
'
====>account_updateOsAccountDistributedInfo_test010 err:
'
+
JSON
.
stringify
(
err
))
expect
().
assertFail
()
done
()
}
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录