ActsDSGetSet.test.js 29.1 KB
Newer Older
1
15829070344 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * 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.
 */

// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, done } from '@ohos/hypium'

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"
}
30
const LIMIT = 1024
1
15829070344 已提交
31 32 33 34 35 36 37 38
export default function ActsDAGetSetTest() {
    describe('ActsDAGetSetTest', function () {
        beforeEach(function () {
        })
        afterEach(function () {
        })

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

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

        /**
81
        * @tc.number     getOsAccountDistributedInfo_test001
1
15829070344 已提交
82 83 84
        * @tc.name       Test distributedAccount.getOsAccountDistributedInfo.
        * @tc.desc       Test distributedAccount.getOsAccountDistributedInfo API functionality.
        */
1
15829070344 已提交
85
        it('getOsAccountDistributedInfo_test001', 0, async function (done) {
1
15829070344 已提交
86 87
            let accountAbility = account.getDistributedAccountAbility()
            accountAbility.getOsAccountDistributedInfo().then(function (data) {
1
15829070344 已提交
88
                console.debug('====>getOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
1
15829070344 已提交
89 90 91 92 93 94 95
                expect(data.name).assertEqual('ohosAnonymousName')
                expect(data.id).assertEqual('ohosAnonymousUid')
                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 102
            let accountAbility = account.getDistributedAccountAbility()
            accountAbility.getOsAccountDistributedInfo(function (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 108 109 110 111 112
                expect(err).assertEqual(null)
                expect(data.name).assertEqual('ohosAnonymousName')
                expect(data.id).assertEqual('ohosAnonymousUid')
                done();
            });
        })

        /**
113
        * @tc.number     setOsAccountDistributedInfo_test001
1
15829070344 已提交
114 115 116
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality.
        */
1
15829070344 已提交
117
        it('setOsAccountDistributedInfo_test001', 0, async function (done) {
1
15829070344 已提交
118 119 120 121 122 123 124 125 126
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{}
            };
            accountAbility.setOsAccountDistributedInfo(obj).then(function () {
                accountAbility.getOsAccountDistributedInfo(function (data) {
1
15829070344 已提交
127
                    console.debug('====>setOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
1
15829070344 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('12345')
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOUT'
                    };
                    accountAbility.setOsAccountDistributedInfo(obj).then(function (err) {
                        expect(err).assertEqual(null)
                    });
                });
            });
            accountAbility.getOsAccountDistributedInfo(function (data) {
1
15829070344 已提交
141
                console.debug('====>setOsAccountDistributedInfo_test001 get data:' + JSON.stringify(data))
1
15829070344 已提交
142 143 144 145 146 147
                expect(data).assertEqual(null)
                done();
            })
        })

        /**
148
        * @tc.number     setOsAccountDistributedInfo_test002
1
15829070344 已提交
149 150 151
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        */
1
15829070344 已提交
152
        it('setOsAccountDistributedInfo_test002', 0,  async function (done)  {
1
15829070344 已提交
153 154 155 156 157 158 159 160 161
            var accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{}
            };
            accountAbility.setOsAccountDistributedInfo(obj, function () {
                accountAbility.getOsAccountDistributedInfo(function (err, data) {
1
15829070344 已提交
162
                    console.debug("====>setOsAccountDistributedInfo_test002 data:" + JSON.stringify(data))
1
15829070344 已提交
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOUT'
                    };
                    accountAbility.setOsAccountDistributedInfo(obj).then(function (data) {
                        expect(data).assertEqual(null)
                        done();
                    });
                });
            });
        })

        /**
179
        * @tc.number     setOsAccountDistributedInfo_test003
1
15829070344 已提交
180 181 182
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        */
183
        it('setOsAccountDistributedInfo_test003', 0, async function (done) {
1
15829070344 已提交
184 185 186 187 188 189 190
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.TOKEN_INVALID',
                scalableData:{}
            };
191 192 193 194
            accountAbility.setOsAccountDistributedInfo(obj, async (err)=> {
                console.debug("====>setOsAccountDistributedInfo_test003 set_err:" + JSON.stringify(err))
                expect(err.code).assertEqual(12300001)
                done();
1
15829070344 已提交
195 196 197 198
            });
        })

        /**
199
        * @tc.number     setOsAccountDistributedInfo_test004
1
15829070344 已提交
200 201 202
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
        */
203
        it('setOsAccountDistributedInfo_test004', 0, async function (done) {
1
15829070344 已提交
204 205 206 207 208 209 210
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{}
            };
211
            accountAbility.setOsAccountDistributedInfo(obj, async (err)=>{
1
15829070344 已提交
212
                console.debug("====>setOsAccountDistributedInfo_test004 update_err:" + JSON.stringify(err))
213
                accountAbility.getOsAccountDistributedInfo(async (err, data) => {
1
15829070344 已提交
214 215
                    console.debug("====>setOsAccountDistributedInfo_test004 query_err:" + JSON.stringify(err))
                    console.debug("====>setOsAccountDistributedInfo_test004 query_data:" + JSON.stringify(data))
1
15829070344 已提交
216 217 218 219 220 221 222
                    expect(data.name).assertEqual('ZhangSan')
                    expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
223 224 225
                    try{
                        await accountAbility.setOsAccountDistributedInfo(obj)
                        console.debug('====>setOsAccountDistributedInfo_test004 end')
1
15829070344 已提交
226
                        done();
227 228 229 230 231
                    }catch(err){
                        console.debug('====>setOsAccountDistributedInfo_test004 err:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    }
1
15829070344 已提交
232 233 234 235 236
                });
            });
        })

        /**
237
        * @tc.number     setOsAccountDistributedInfo_test005
1
15829070344 已提交
238 239
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by callback.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
240
        *                    normal nickname
1
15829070344 已提交
241
        */
242
        it('setOsAccountDistributedInfo_test005', 0, async function (done) {
1
15829070344 已提交
243 244 245 246 247
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
248 249
                scalableData:{},
                nickname:'test'
1
15829070344 已提交
250 251
            };
            accountAbility.setOsAccountDistributedInfo(obj, function (err) {
252 253 254 255 256 257
                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')
1
15829070344 已提交
258 259 260 261 262
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
263 264 265 266
                    console.debug("====>start LOGOFF")
                    try{
                        await accountAbility.setOsAccountDistributedInfo(obj)
                        console.debug('====>setOsAccountDistributedInfo_test005 end')
1
15829070344 已提交
267
                        done();
268 269 270 271 272
                    }catch(err){
                        console.debug('====>setOsAccountDistributedInfo_test005 err:' + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    }
1
15829070344 已提交
273 274 275 276 277
                });
            });
        })

        /**
278 279 280 281
        * @tc.number     setOsAccountDistributedInfo_test006
        * @tc.name       Test distributedAccount.setOsAccountDistributedInfo by promise.
        * @tc.desc       Test distributedAccount.setOsAccountDistributedInfo API functionality by promise.
        *                   normal nickname
1
15829070344 已提交
282
        */
283
        it('setOsAccountDistributedInfo_test006', 0, async function (done) {
1
15829070344 已提交
284 285 286 287 288
            const accountAbility = account.getDistributedAccountAbility()
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
289 290
                scalableData: {},
                nickname: 'test'
1
15829070344 已提交
291
            };
292
            accountAbility.setOsAccountDistributedInfo(obj).then(() => {
1
15829070344 已提交
293
                accountAbility.getOsAccountDistributedInfo(function (err, data) {
294 295 296 297
                    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')
1
15829070344 已提交
298 299 300 301 302
                    let obj = {
                        id: '12345',
                        name: 'ZhangSan',
                        event: 'Ohos.account.event.LOGOFF'
                    };
303 304 305 306
                    console.debug("====>start LOGOFF")
                    accountAbility.setOsAccountDistributedInfo(obj).then(function (err) {
                        console.debug("====>LOGOFF err:" + JSON.stringify(err))
                        expect(err).assertEqual(null)
1
15829070344 已提交
307 308
                        done();
                    });
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
                })
                    .catch((err) => {
                        console.debug("====>setOsAccountDistributedInfo_test006 update_err:" + JSON.stringify(err))
                        expect().assertFail();
                        done();
                    })
            })
        })

        /**
        * @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')
                    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 已提交
355 356 357
                });
            });
        })
358 359 360 361 362 363 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 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 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 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 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 588 589 590 591 592 593 594 595 596 597

        /**
        * @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')
                    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();
                    })
                });
            }).catch(() => {
                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 = '';
            for (var i = 0; i < 21; i++) {
                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))
                expect(err.code).assertEqual(12300001);
                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 = '';
            for (var i = 0; i < 21; i++) {
                limitNickName += 'n';
            }
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                nickname:limitNickName,
                avatar:'test'
            };
            accountAbility.setOsAccountDistributedInfo(obj).then(() => {
                console.debug("====>setOsAccountDistributedInfo_test010 err:" + JSON.stringify(err))
                expect().assertFail()
                done();
            }).catch((err) => {
                console.debug("====>setOsAccountDistributedInfo_test010 throw_err:" + JSON.stringify(err))
                expect(err.code).assertEqual(12300001);
                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()
            var limitAvatar = '';
            for (var i = 0; i < LIMIT*3; i++) {
                limitAvatar +=
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '012345678901234567890123';
            }
            limitAvatar += 'n'
            console.debug(limitAvatar.length)
            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))
                expect(err.code).assertEqual(12300001);
                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()
            var limitAvatar = '';
            for (var i = 0; i < LIMIT*3; i++) {
                limitAvatar +=
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' +
                '012345678901234567890123';
            }
            limitAvatar += 'n'
            console.debug(limitAvatar.length)
            let obj = {
                id: '12345',
                name: 'ZhangSan',
                event: 'Ohos.account.event.LOGIN',
                scalableData:{},
                avatar: limitAvatar
            };
            try{
                await accountAbility.setOsAccountDistributedInfo(obj)
                console.debug("====>setOsAccountDistributedInfo_test012 set_err:" + JSON.stringify(err))
                expect().assertFail()
                done();
            }catch(err){
                console.debug("====>setOsAccountDistributedInfo_test012 throw_err:" + JSON.stringify(err))
                expect(err.code).assertEqual(12300001);
                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))
                expect(err.code).assertEqual(12300001);
                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))
                expect(err.code).assertEqual(12300001)
                done();
            }
        })
1
15829070344 已提交
598 599
    })
}