ActsDSGetSet.test.js 58.5 KB
Newer Older
1
15829070344 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

16
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
1
15829070344 已提交
17 18 19 20 21 22 23 24 25 26 27 28

import account from '@ohos.account.distributedAccount'
const LOGININFO = {
    name: 'ZhangSan',
    id: '12345',
    event: "Ohos.account.event.LOGIN"
}
const LOGOUTINFO = {
    name: 'ZhangSan',
    id: '12345',
    event: "Ohos.account.event.LOGOUT"
}
29
const LIMIT = 1024
1
15829070344 已提交
30 31 32 33 34 35 36 37
export default function ActsDAGetSetTest() {
    describe('ActsDAGetSetTest', function () {
        beforeEach(function () {
        })
        afterEach(function () {
        })

        /**
38
        * @tc.number     ActsDADeviceId_0100
1
15829070344 已提交
39 40 41
        * @tc.name       Test query the distribruted id by callback.
        * @tc.desc       Test distributedAccount.getOsAccountDistributedInfo API functionality by callback.
        */
1
15829070344 已提交
42 43
        it('ActsDADeviceId_0100', 0, async function(done){
            console.log("====>ActsDADeviceId_0100 test query distribtued id start");
1
15829070344 已提交
44 45 46
            const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; //'12345'sha256的值
            const accountAbility = account.getDistributedAccountAbility();
            accountAbility.setOsAccountDistributedInfo(LOGININFO, (err)=>{
1
15829070344 已提交
47
                console.log("====>ActsDADeviceId_0100 set distributedInfo err:" + JSON.stringify(err));
1
15829070344 已提交
48
                accountAbility.getOsAccountDistributedInfo((err, distributedInfo)=>{
1
15829070344 已提交
49 50
                    console.log("====>ActsDADeviceId_0100 get distributedInfo err:" + JSON.stringify(err));
                    console.log("====>ActsDADeviceId_0100 get distributedInfo:" + JSON.stringify(distributedInfo));
1
15829070344 已提交
51 52 53
                    expect(distributedInfo.name).assertEqual('ZhangSan');
                    expect(distributedInfo.id).assertEqual(distributedId);
                    accountAbility.setOsAccountDistributedInfo(LOGOUTINFO, (err)=>{
1
15829070344 已提交
54
                        console.debug('====>ActsDADeviceId_0100 logout_result:'+ JSON.stringify(err))
1
15829070344 已提交
55 56 57 58 59 60 61 62 63
                        expect(err).assertEqual(null)
                        console.log("====>test query distribtued id end");
                        done();
                    })
                })
            })
        })

        /**
64
        * @tc.number     getDistributedAccountAbility_test
1
15829070344 已提交
65 66 67
        * @tc.name       Test distributedAccount.getDistributedAccountAbility.
        * @tc.desc      Test distributedAccount.getDistributedAccountAbility API functionality.
        */
1
15829070344 已提交
68
        it('getDistributedAccountAbility_test', 0, async function (done) {
1
15829070344 已提交
69 70
            var ret = false;
            const accountAbility = account.getDistributedAccountAbility()
1
15829070344 已提交
71
            console.debug("====>getDistributedAccountAbility_test result:" + JSON.stringify(accountAbility))
1
15829070344 已提交
72 73 74 75 76 77 78 79
            if(accountAbility !== null){
                ret = true;
            }
            expect(ret).assertTrue()
            done();
        })

        /**
80
        * @tc.number     getOsAccountDistributedInfo_test001
1
15829070344 已提交
81 82 83
        * @tc.name       Test distributedAccount.getOsAccountDistributedInfo.
        * @tc.desc       Test distributedAccount.getOsAccountDistributedInfo API functionality.
        */
1
15829070344 已提交
84
        it('getOsAccountDistributedInfo_test001', 0, async function (done) {
1
15829070344 已提交
85
            let accountAbility = account.getDistributedAccountAbility()
86
            accountAbility.getOsAccountDistributedInfo().then( (data) => {
1
15829070344 已提交
87
                console.debug('====>getOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
1
15829070344 已提交
88 89
                expect(data.name).assertEqual('ohosAnonymousName')
                expect(data.id).assertEqual('ohosAnonymousUid')
90
                expect(data.status).assertEqual(0)
1
15829070344 已提交
91 92 93 94 95
                done();
            });
        })

        /**
96
        * @tc.number     getOsAccountDistributedInfo_test002
1
15829070344 已提交
97 98 99
        * @tc.name       Test distributedAccount.getOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.getOsAccountDistributedInfo API functionality by callback.
        */
1
15829070344 已提交
100
        it('getOsAccountDistributedInfo_test002', 0, async function (done) {
1
15829070344 已提交
101
            let accountAbility = account.getDistributedAccountAbility()
102
            accountAbility.getOsAccountDistributedInfo((err, data) => {
1
15829070344 已提交
103 104
                console.debug('====>getOsAccountDistributedInfo_test002 err:' + JSON.stringify(err))
                console.debug('====>getOsAccountDistributedInfo_test002 data:' + JSON.stringify(data))
1
15829070344 已提交
105 106 107
                expect(err).assertEqual(null)
                expect(data.name).assertEqual('ohosAnonymousName')
                expect(data.id).assertEqual('ohosAnonymousUid')
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
                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)
1
15829070344 已提交
143 144 145 146 147
                done();
            });
        })

        /**
148
        * @tc.number     setOsAccountDistributedInfo_test001
1
15829070344 已提交
149 150 151
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality.
        */
1
15829070344 已提交
152
        it('setOsAccountDistributedInfo_test001', 0, async function (done) {
1
15829070344 已提交
153 154 155 156 157 158 159 160
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{}
            };
            accountAbility.setOsAccountDistributedInfo(obj).then(function () {
161 162
                accountAbility.getOsAccountDistributedInfo(function (err, data) {
                    console.debug('====>setOsAccountDistributedInfo_test001 ccerr:' + JSON.stringify(err))
1
15829070344 已提交
163
                    console.debug('====>setOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
1
15829070344 已提交
164
                    expect(data.name).assertEqual('ZhangSan')
165
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
166
                    expect(data.status).assertEqual(1)
1
15829070344 已提交
167 168 169 170 171
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOUT'
                    };
172 173 174 175 176 177 178 179 180 181 182 183
                    accountAbility.setOsAccountDistributedInfo(obj).then(function () {
                        accountAbility.getOsAccountDistributedInfo(function (err, data) {
                            console.debug('====>setOsAccountDistributedInfo_test001 get ccerr:' + JSON.stringify(err))
                            console.debug('====>setOsAccountDistributedInfo_test001 get ccdata:' + JSON.stringify(data))
                            expect(err).assertEqual(null)
                            done();
                        })
                    }).catch((err) => {
                        console.debug('====>setOsAccountDistributedInfo_test001 ccerr:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    })
1
15829070344 已提交
184 185
                });
            });
186
            
1
15829070344 已提交
187 188 189
        })

        /**
190
        * @tc.number     setOsAccountDistributedInfo_test002
1
15829070344 已提交
191 192 193
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        */
1
15829070344 已提交
194
        it('setOsAccountDistributedInfo_test002', 0,  async function (done)  {
1
15829070344 已提交
195 196 197 198 199 200 201
            var accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{}
            };
202 203
            accountAbility.setOsAccountDistributedInfo(obj, function (err) {
                console.debug('====>setOsAccountDistributedInfo_test002 ccerr callback:' + JSON.stringify(err))
1
15829070344 已提交
204
                accountAbility.getOsAccountDistributedInfo(function (err, data) {
205 206
                    console.debug('====>setOsAccountDistributedInfo_test002 get ccerr:' + JSON.stringify(err))
                    console.debug("====>setOsAccountDistributedInfo_test002 get data:" + JSON.stringify(data))
1
15829070344 已提交
207 208
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
209
                    expect(data.status).assertEqual(1)
1
15829070344 已提交
210 211 212 213 214
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOUT'
                    };
215 216 217 218 219
                    accountAbility.setOsAccountDistributedInfo(obj).then(function () {
                        done();
                    }).catch((err) => {
                        console.debug('====>setOsAccountDistributedInfo_test002 set ccerr:' + JSON.stringify(err))
                        expect().assertFail();
1
15829070344 已提交
220 221 222 223 224 225 226
                        done();
                    });
                });
            });
        })

        /**
227
        * @tc.number     setOsAccountDistributedInfo_test003
1
15829070344 已提交
228 229 230
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        */
231
        it('setOsAccountDistributedInfo_test003', 0, async function (done) {
1
15829070344 已提交
232 233 234 235 236 237 238
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.TOKEN_INVALID',
                scalableData:{}
            };
239 240 241 242
            accountAbility.setOsAccountDistributedInfo(obj, async (err)=> {
                console.debug("====>setOsAccountDistributedInfo_test003 set_err:" + JSON.stringify(err))
                expect(err.code).assertEqual(12300001)
                done();
1
15829070344 已提交
243 244 245 246
            });
        })

        /**
247
        * @tc.number     setOsAccountDistributedInfo_test004
1
15829070344 已提交
248 249 250
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        */
251
        it('setOsAccountDistributedInfo_test004', 0, async function (done) {
1
15829070344 已提交
252 253 254 255 256 257 258
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{}
            };
259
            accountAbility.setOsAccountDistributedInfo(obj, async (err)=>{
1
15829070344 已提交
260
                console.debug("====>setOsAccountDistributedInfo_test004 update_err:" + JSON.stringify(err))
261
                accountAbility.getOsAccountDistributedInfo(async (err, data) => {
1
15829070344 已提交
262 263
                    console.debug("====>setOsAccountDistributedInfo_test004 query_err:" + JSON.stringify(err))
                    console.debug("====>setOsAccountDistributedInfo_test004 query_data:" + JSON.stringify(data))
1
15829070344 已提交
264 265
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
266
                    expect(data.status).assertEqual(1)
1
15829070344 已提交
267 268 269 270 271
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
272 273 274
                    try{
                        await accountAbility.setOsAccountDistributedInfo(obj)
                        console.debug('====>setOsAccountDistributedInfo_test004 end')
1
15829070344 已提交
275
                        done();
276 277 278 279 280
                    }catch(err){
                        console.debug('====>setOsAccountDistributedInfo_test004 err:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    }
1
15829070344 已提交
281 282 283 284 285
                });
            });
        })

        /**
286
        * @tc.number     setOsAccountDistributedInfo_test005
1
15829070344 已提交
287 288
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
289
        *                    normal nickname
1
15829070344 已提交
290
        */
291
        it('setOsAccountDistributedInfo_test005', 0, async function (done) {
1
15829070344 已提交
292 293 294 295 296
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
297 298
                scalableData:{},
                nickname:'test'
1
15829070344 已提交
299 300
            };
            accountAbility.setOsAccountDistributedInfo(obj, function (err) {
301 302 303 304 305 306
                console.debug("====>updateOsAccountDistributedInfo_test005 set_err:" + JSON.stringify(err))
                accountAbility.getOsAccountDistributedInfo(async (err, data) => {
                    console.debug("====>updateOsAccountDistributedInfo_test005 get_err:" + JSON.stringify(err))
                    console.debug("====>updateOsAccountDistributedInfo_test005 get_data:" + JSON.stringify(data))
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
307
                    expect(data.status).assertEqual(1)
1
15829070344 已提交
308 309 310 311 312
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
313 314 315 316
                    console.debug("====>start LOGOFF")
                    try{
                        await accountAbility.setOsAccountDistributedInfo(obj)
                        console.debug('====>setOsAccountDistributedInfo_test005 end')
1
15829070344 已提交
317
                        done();
318 319 320 321 322
                    }catch(err){
                        console.debug('====>setOsAccountDistributedInfo_test005 err:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    }
1
15829070344 已提交
323 324 325 326 327
                });
            });
        })

        /**
328 329 330 331
        * @tc.number     setOsAccountDistributedInfo_test006
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by promise.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
        *                   normal nickname
1
15829070344 已提交
332
        */
333
        it('setOsAccountDistributedInfo_test006', 0, async function (done) {
1
15829070344 已提交
334 335 336 337 338
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
339 340
                scalableData: {},
                nickname: 'test'
1
15829070344 已提交
341
            };
342
            accountAbility.setOsAccountDistributedInfo(obj).then(() => {
1
15829070344 已提交
343
                accountAbility.getOsAccountDistributedInfo(function (err, data) {
344 345 346 347
                    console.debug("====>setOsAccountDistributedInfo_test006 get_err:" + JSON.stringify(err))
                    console.debug("====>setOsAccountDistributedInfo_test006 get_data:" + JSON.stringify(data))
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
348
                    expect(data.status).assertEqual(1)
1
15829070344 已提交
349 350 351 352 353
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
354 355 356 357
                    console.debug("====>start LOGOFF")
                    accountAbility.setOsAccountDistributedInfo(obj).then(function (err) {
                        console.debug("====>LOGOFF err:" + JSON.stringify(err))
                        expect(err).assertEqual(null)
1
15829070344 已提交
358 359
                        done();
                    });
360 361 362 363
                }).catch((err) => {
                    console.debug("====>setOsAccountDistributedInfo_test006 update_err:" + JSON.stringify(err))
                    expect().assertFail();
                    done();
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
                })
            })
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test007
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        *                    normal avatar
        */
        it('setOsAccountDistributedInfo_test007', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                avatar:'test'
            };
            accountAbility.setOsAccountDistributedInfo(obj, (err) => {
                console.debug("====>setOsAccountDistributedInfo_test007 set_err:" + JSON.stringify(err))
                accountAbility.getOsAccountDistributedInfo(async (err, data) =>{
                    console.debug("====>setOsAccountDistributedInfo_test007 get_err:" + JSON.stringify(err))
                    console.debug("====>setOsAccountDistributedInfo_test007 get_data:" + JSON.stringify(data))
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
390
                    expect(data.status).assertEqual(1)
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
                    console.debug("====>start LOGOFF")
                    try{
                        await accountAbility.setOsAccountDistributedInfo(obj)
                        console.debug('====>setOsAccountDistributedInfo_test007 end')
                        done();
                    }catch(err){
                        console.debug('====>setOsAccountDistributedInfo_test007 err:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    }
1
15829070344 已提交
406 407 408
                });
            });
        })
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430

        /**
        * @tc.number     setOsAccountDistributedInfo_test008
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by promise.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
        *                   normal avatar
        */
        it('setOsAccountDistributedInfo_test008', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                avatar:'test'
            };
            accountAbility.setOsAccountDistributedInfo(obj).then(() => {
                accountAbility.getOsAccountDistributedInfo((err, data) => {
                    console.debug("====>setOsAccountDistributedInfo_test008 get_err:" + JSON.stringify(err))
                    console.debug("====>setOsAccountDistributedInfo_test008 get_data:" + JSON.stringify(data))
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
431
                    expect(data.status).assertEqual(1)
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
                    console.debug("====>start LOGOFF")
                    accountAbility.setOsAccountDistributedInfo(obj).then(() => {
                        console.debug('====>setOsAccountDistributedInfo_test008 end')
                        done();
                    }).catch((err) => {
                        console.debug('====>setOsAccountDistributedInfo_test008 err:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    })
                });
447
            }).catch((err) => {
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
                console.debug("====>setOsAccountDistributedInfo_test008 throw_err:" + JSON.stringify(err))
                expect().assertFail();
                done();
            })
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test009
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        *                   overlength nickname 21
        */
        it('setOsAccountDistributedInfo_test009', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
            var limitNickName = '';
463
            for (var i = 0; i < 1025; i++) {
464 465 466 467 468 469 470 471 472 473 474 475
                limitNickName += 'n';
            }
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                nickname:limitNickName,
                avatar:'test'
            };
            accountAbility.setOsAccountDistributedInfo(obj, (err)=>{
                console.debug("====>setOsAccountDistributedInfo_test009 set_err:" + JSON.stringify(err))
476
                expect(err.code).assertEqual(12300002);
477 478 479 480 481 482 483 484 485 486 487 488 489
                done();
            })
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test010
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by promise.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
        *               overlength nickname 21
        */
        it('setOsAccountDistributedInfo_test010', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
            var limitNickName = '';
490
            for (var i = 0; i < 1025; i++) {
491 492 493 494 495 496 497 498 499 500
                limitNickName += 'n';
            }
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                nickname:limitNickName,
                avatar:'test'
            };
501
            accountAbility.setOsAccountDistributedInfo(obj).then((err) => {
502 503 504 505 506
                console.debug("====>setOsAccountDistributedInfo_test010 err:" + JSON.stringify(err))
                expect().assertFail()
                done();
            }).catch((err) => {
                console.debug("====>setOsAccountDistributedInfo_test010 throw_err:" + JSON.stringify(err))
507
                expect(err.code).assertEqual(12300002);
508 509 510 511 512 513 514 515 516 517 518 519
                done();
            })
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test011
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        *                   overlength avatar 3*1024*1024+1
        */
        it('setOsAccountDistributedInfo_test011', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
520 521
            var limitAvatar = ''.padEnd(10 * 1024 * 1024 + 1, 'o')          
            console.debug('====>setOsAccountDistributedInfo_test011 avatar_length:' + limitAvatar.length)
522 523 524 525 526 527 528 529 530 531
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                avatar: limitAvatar
            };
            console.debug(JSON.stringify(obj))
            accountAbility.setOsAccountDistributedInfo(obj, (err)=>{
                console.debug("====>setOsAccountDistributedInfo_test011 update_err:" + JSON.stringify(err))
532
                expect(err.code).assertEqual(12300002);
533 534 535 536 537 538 539 540 541 542 543 544
                done();
            })
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test012
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by peomise.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by peomise.
        *                   overlength avatar 3*1024*1024+1
        */
        it('setOsAccountDistributedInfo_test012', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
545
            var limitAvatar = ''.padEnd(10 * 1024 * 1024 + 1, 'o')          
546
            console.debug(limitAvatar.length)
547
            console.debug('====>setOsAccountDistributedInfo_test012 avatar_length:' + limitAvatar.length)
548 549 550 551 552 553 554 555 556
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                avatar: limitAvatar
            };
            try{
                await accountAbility.setOsAccountDistributedInfo(obj)
557
                console.debug("====>setOsAccountDistributedInfo_test012 set_err")
558 559 560 561
                expect().assertFail()
                done();
            }catch(err){
                console.debug("====>setOsAccountDistributedInfo_test012 throw_err:" + JSON.stringify(err))
562
                expect(err.code).assertEqual(12300002);
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
                done();
            }
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test013
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        *                   overlength scalableData
        */
        it('setOsAccountDistributedInfo_test013', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
            var limitInfo = {};
            for (var i = 0; i < 513; i++) {
                limitInfo = Object.assign(limitInfo, {[i]:i})
            }
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:limitInfo,
            };
            console.debug(JSON.stringify(obj))
            accountAbility.setOsAccountDistributedInfo(obj, (err)=>{
                console.debug("====>setOsAccountDistributedInfo_test013 update_err:" + JSON.stringify(err))
588
                expect(err.code).assertEqual(12300002);
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
                done();
            })
        })

        /**
        * @tc.number     setOsAccountDistributedInfo_test014
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by promise.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
        *                 overlength scalableData
        */
        it('setOsAccountDistributedInfo_test014', 0, async function (done) {
            const accountAbility = account.getDistributedAccountAbility()
            var limitInfo = {};
            for (var i = 0; i < 513; i++) {
                limitInfo = Object.assign(limitInfo, {[i]:i})
            }
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:limitInfo,
            };
            try{
                await accountAbility.setOsAccountDistributedInfo(obj)
                expect().assertFail()
                done();
            }catch(err){
                console.debug("====>setOsAccountDistributedInfo_test014 throw_err:" + JSON.stringify(err))
617
                expect(err.code).assertEqual(12300002)
618 619 620
                done();
            }
        })
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707

        /**
         * @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();
            })
        })

708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
        /**
         * @tc.number     DistributedAccountEnum_0100
         * @tc.name       Test distributedAccount.DistributedAccountStatus.NOT_LOGGED_IN.
         * @tc.desc       Test distributedAccount Enum.
         */
        it('DistributedAccountEnum_0100', 0, async function (done) {
            try {
                expect(0).assertEqual(account.DistributedAccountStatus.NOT_LOGGED_IN)
                console.debug("====>DistributedAccountEnum_0100 success:")
                done()
            } catch (err) {
                console.debug("====>DistributedAccountEnum_0100 throw_err:" + JSON.stringify(err))
                expect().assertFail()
                done()
            }
        })

        /**
         * @tc.number     DistributedAccountEnum_0200
         * @tc.name       Test distributedAccount.DistributedAccountStatus.LOGGED_IN.
         * @tc.desc       Test distributedAccount Enum.
         */
        it('DistributedAccountEnum_0200', 0, async function (done) {
            try {
                expect(1).assertEqual(account.DistributedAccountStatus.LOGGED_IN)
                console.debug("====>DistributedAccountEnum_0200 success:")
                done()
            } catch (err) {
                console.debug("====>DistributedAccountEnum_0200 throw_err:" + JSON.stringify(err))
                expect().assertFail()
                done()
            }
        })

742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
        /**
         * @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();
            })
        })
1
15829070344 已提交
1183 1184
    })
}