AssociatedData.test.js 61.5 KB
Newer Older
J
jiyong_sd 已提交
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/*
 * 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.
 */
import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'

const TIMEOUT = 5000;
const EACHTIMEOUT = 500;
export default function ActsAccountAssociatedData() {
    describe('ActsAccountAssociatedData', function () {
        function sleep(delay) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve()
                }, delay)
            }).then(() => {
                console.info(`sleep #{time} over ...`)
            })
        }

        beforeAll(async function (done) {
            console.debug("====>beforeAll start====");
            await sleep(TIMEOUT);
            console.debug("====>beforeAll end====");
            done();
        })

        beforeEach(async function (done) {
            console.debug("====>beforeEach enter====");
            await sleep(EACHTIMEOUT);
            done();
        })

        /*
        * @tc.number    : ActsAccountAssociatedData_0100
        * @tc.name      : The correct calls setAssociatedData and getAssociatedData get the value
        * @tc.desc      : The setAssociatedData setting valueis called when the forwarding parameters
        *                 are correct, and then getAssociatedData is called for the value(callback)
        */
        it('ActsAccountAssociatedData_0100', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0100 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_0100",(err)=>{
                console.debug("====>add accountActsAccountAssociatedData_0100 err:" + JSON.stringify(err));
57
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
58 59
                appAccountManager.setAssociatedData("account_name_0100", "key1", "value1", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_0100 err:" + JSON.stringify(err));
60
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
61 62 63
                    appAccountManager.getAssociatedData("account_name_0100", "key1", (err, data)=>{
                        console.debug("====>getAssociatedData 0100 err:" + JSON.stringify(err));
                        console.debug("====>getAssociatedData 0100 data:" + JSON.stringify(data));
64
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
65 66 67
                        expect(data).assertEqual("value1");
                        appAccountManager.deleteAccount("account_name_0100", (err)=>{
                            console.debug("====>delete Account 0100 err:" + JSON.stringify(err));
68
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 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
                            console.debug("====>ActsAccountAssociatedData_0100 end====");
                            done();
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0200
        * @tc.name      : The correct calls setAssociatedData and getAssociatedData get the value
        * @tc.desc      : The setAssociatedData setting value is called when the forwarding parameters
        *                 are correct, and then getAssociatedData is called for the value(promise)
        */
        it('ActsAccountAssociatedData_0200', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0200 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_0200 start====");
            try{
                await appAccountManager.addAccount("account_name_0200");
            }
            catch(err){
                console.error("====>add Account ActsAccountAssociatedData_0200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>setAssociatedData ActsAccountAssociatedData_0200 start====");
            try{
                await appAccountManager.setAssociatedData("account_name_0200", "key2", "value2");
            }
            catch(err){
                console.error("====>setAssociatedData ActsAccountAssociatedData_0200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData ActsAccountAssociatedData_0200 start====");
            try{
                var data = await appAccountManager.getAssociatedData("account_name_0200", "key2");
            }
            catch(err){
                console.error("====>getAssociatedData ActsAccountAssociatedData_0200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData ActsAccountAssociatedData_0200 data:" + JSON.stringify(data));
            expect(data).assertEqual("value2");
            console.debug("====>delete account ActsAccountAssociatedData_0200 start====");
            try{
                await appAccountManager.deleteAccount("account_name_0200");
            }
            catch(err){
                console.error("====>delete account 0200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_0200 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0300
        * @tc.name      : Get it directly without setting value
        * @tc.desc      : Call getAssociatedData directly to get value without calling setAssociatedData(callback)
        */
        it('ActsAccountAssociatedData_0300', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0300 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_0300", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_0300 err:" + JSON.stringify(err));
140
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
141 142 143 144
                appAccountManager.getAssociatedData("account_name_0300", "key3", (err, data)=>{
                    console.debug("====>getAssociatedData 0300 err:" + JSON.stringify(err));
                    console.debug("====>getAssociatedData 0300 data:" + JSON.stringify(data));
                    expect(err.code != 0).assertEqual(true);
145
                    expect(data).assertEqual(null);
J
jiyong_sd 已提交
146 147
                    appAccountManager.deleteAccount("account_name_0300", (err)=>{
                        console.debug("====>delete Account 0300 err:" + JSON.stringify(err));
148
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
                        console.debug("====>ActsAccountAssociatedData_0300 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0400
        * @tc.name      : Get it directly without setting value
        * @tc.desc      : Call getAssociatedData directly to get value without calling setAssociatedData(promise)
        */
        it('ActsAccountAssociatedData_0400', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0400 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_0400 start====");
            try{
                await appAccountManager.addAccount("account_name_0400");
            }
            catch(err){
                console.error("====>add Account ActsAccountAssociatedData_0400 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.getAssociatedData("account_name_0400", "key4");
                console.error("====>getAssociatedData fail ActsAccountAssociatedData_0400====");
                expect().assertFail();
                done();
            }
            catch(err){
                console.debug("====>getAssociatedData ActsAccountAssociatedData_0400 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_0400 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_0400");
                }
                catch(err){
                    console.error("====>delete account 0400 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_0400 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0500
        * @tc.name      : Call getAssociatedData to get value when passing in the error parameter
        * @tc.desc      : After calling setAssociatedData setting value correctly,
        *                 call the getAssociatedData of the pass error to check if you get the value(callback)
        */
        it('ActsAccountAssociatedData_0500', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0500 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_0500",(err)=>{
                console.debug("====>add account ActsAccountAssociatedData_0500 err:" + JSON.stringify(err));
209
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
210 211
                appAccountManager.setAssociatedData("account_name_0500", "key5", "value5", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_0500 err:" + JSON.stringify(err));
212
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
213 214 215 216 217 218
                    appAccountManager.getAssociatedData("account_name_0500", "keyerr", (err, data)=>{
                        console.debug("====>getAssociatedData 0500 err:" + JSON.stringify(err));
                        console.debug("====>getAssociatedData 0500 data:" + JSON.stringify(data));
                        expect(err.code != 0).assertEqual(true);
                        appAccountManager.deleteAccount("account_name_0500", (err)=>{
                            console.debug("====>delete Account 0500 err:" + JSON.stringify(err));
219
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
                            console.debug("====>ActsAccountAssociatedData_0500 end====");
                            done();
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0600
        * @tc.name      : Call getAssociatedData to get value when passing in the error parameter
        * @tc.desc      : After calling setAssociatedData setting value correctly,
        *                 call the getAssociatedData of the pass error to check if you get the value(promise)
        */
        it('ActsAccountAssociatedData_0600', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0600 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_0600 start====");
            try{
                await appAccountManager.addAccount("account_name_0600");
            }
            catch(err){
                console.error("====>add Account ActsAccountAssociatedData_0600 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            await appAccountManager.setAssociatedData("account_name_0600", "key6", "value6");
            try{
                var data = await appAccountManager.getAssociatedData("account_name_0600", "keyerr");
            }
            catch(err){
                console.debug("====>getAssociatedData 0600 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_0600 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_0600");
                }
                catch(err){
                    console.error("====>delete account 0600 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_0600 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0700
        * @tc.name      : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times
        * @tc.desc      : When the first setAssociatedData is called and the second setAssociatedData
        *                 is called,the setting of the value is different if the call getAssociatedData
        *                 can get the second value(callback)
        */
        it('ActsAccountAssociatedData_0700', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0700 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_0700",(err)=>{
                console.debug("====>add account ActsAccountAssociatedData_0700 err:" + JSON.stringify(err));
281
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
282 283
                appAccountManager.setAssociatedData("account_name_0700", "key7", "value7", (err)=>{
                    console.debug("====>setAssociatedDatafir first time 0700 err:" + JSON.stringify(err));
284
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
285 286
                    appAccountManager.setAssociatedData("account_name_0700", "key7", "newvalue7", (err)=>{
                        console.debug("====>setAssociatedDatafir second time 0700 err:" + JSON.stringify(err));
287
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
288 289 290
                        appAccountManager.getAssociatedData("account_name_0700", "key7", (err, data)=>{
                            console.debug("====>getAssociatedData 0700 err:" + JSON.stringify(err));
                            console.debug("====>getAssociatedData 0700 data:" + JSON.stringify(data));
291
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
292 293 294
                            expect(data).assertEqual("newvalue7");
                            appAccountManager.deleteAccount("account_name_0700", (err)=>{
                                console.debug("====>delete Account 0700 err:" + JSON.stringify(err));
295
                                expect(err).assertEqual(null);
J
jiyong_sd 已提交
296 297 298 299 300 301 302 303 304 305 306 307 308 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 355 356 357 358 359 360 361 362 363 364 365 366 367
                                console.debug("====>ActsAccountAssociatedData_0700 end====");
                                done();
                            });
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0800
        * @tc.name      : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times
        * @tc.desc      : When the first setAssociatedData is called and the second setAssociatedData
        *                 is called,the setting of the value is different if the call getAssociatedData
        *                 can get the second value(promise)
        */
        it('ActsAccountAssociatedData_0800', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0800 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            try{
                await appAccountManager.addAccount("account_name_0800");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_0800 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_0800","key8","value8");
                await appAccountManager.setAssociatedData("account_name_0800","key8","newvalue8");
            }catch(err){
                console.error("====>setAssociatedData ActsAccountAssociatedData_0800 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                var data = await appAccountManager.getAssociatedData("account_name_0800", "key8");
            }
            catch(err){
                console.error("====>getAssociatedData ActsAccountAssociatedData_0800 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData ActsAccountAssociatedData_0800 data:" + JSON.stringify(data));
            expect(data).assertEqual("newvalue8");
            console.debug("====>delete account ActsAccountAssociatedData_0800 start====");
            try{
                await appAccountManager.deleteAccount("account_name_0800");
            }
            catch(err){
                console.error("====>delete account 0800 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_0800 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_0900
        * @tc.name      : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times
        * @tc.desc      : When the first setAssociatedData is called and the second setAssociatedData
        *                 is called,the setting of the value is same if the call getAssociatedData
        *                 can get the second value(callback)
        */
        it('ActsAccountAssociatedData_0900', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_0900 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_0900",(err)=>{
                console.debug("====>add account ActsAccountAssociatedData_0900 err:" + JSON.stringify(err));
368
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
369 370
                appAccountManager.setAssociatedData("account_name_0900", "key9", "value9", (err)=>{
                    console.debug("====>setAssociatedData first time 0900 err:" + JSON.stringify(err));
371
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
372 373
                    appAccountManager.setAssociatedData("account_name_0900", "key9", "value9", (err)=>{
                        console.debug("====>setAssociatedData second time 0900 err:" + JSON.stringify(err));
374
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
375 376 377
                        appAccountManager.getAssociatedData("account_name_0900", "key9", (err, data)=>{
                            console.debug("====>getAssociatedData 0900 err:" + JSON.stringify(err));
                            console.debug("====>getAssociatedData 0900 data:" + JSON.stringify(data));
378
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
379 380 381
                            expect(data).assertEqual("value9");
                            appAccountManager.deleteAccount("account_name_0900", (err)=>{
                                console.debug("====>delete Account 0900 err:" + JSON.stringify(err));
382
                                expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                                console.debug("====>ActsAccountAssociatedData_0900 end====");
                                done();
                            });
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1000
        * @tc.name      : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times
        * @tc.desc      : When the first setAssociatedData is called and the second setAssociatedData
        *                 is called,the setting of the value is same if the call getAssociatedData
        *                 can get the second value(promise)
        */
        it('ActsAccountAssociatedData_1000', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1000 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>addAccount ActsAccountAssociatedData_1000 start====");
            try{
                await appAccountManager.addAccount("account_name_1000");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_1000 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_1000", "key10", "value10");
                await appAccountManager.setAssociatedData("account_name_1000", "key10", "value10");
            }
            catch(err){
                console.error("====>setAssociatedData ActsAccountAssociatedData_1000 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                var data = await appAccountManager.getAssociatedData("account_name_1000", "key10");
            }
            catch(err){
                console.error("====>getAssociatedData ActsAccountAssociatedData_1000 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData 1000 data:" + JSON.stringify(data));
            expect(data).assertEqual("value10");
            console.debug("====>delete account ActsAccountAssociatedData_1000 start====");
            try{
                await appAccountManager.deleteAccount("account_name_1000");
            }
            catch(err){
                console.error("====>delete account 1000 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_1000 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1100
        * @tc.name      : Call multiple setAssociatedData calls multiple times getAssociatedData gets the value separately
        * @tc.desc      : Call setAssociatedData setting value again after calling setAssociatedData setting
        *                 different value, and then call getAssociatedData twice to get the set value(callback)
        */
        it('ActsAccountAssociatedData_1100', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1100 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_1100",(err)=>{
                console.debug("====>add account ActsAccountAssociatedData_1100 err:" + JSON.stringify(err));
456
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
457 458
                appAccountManager.setAssociatedData("account_name_1100", "key11_first", "value11_first", (err)=>{
                    console.debug("====>setAssociatedData first time 1100 err:" + JSON.stringify(err));
459
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
460 461
                    appAccountManager.setAssociatedData("account_name_1100", "key11_second", "value11_second", (err)=>{
                        console.debug("====>setAssociatedData second time 1100 err:" + JSON.stringify(err));
462
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
463 464 465
                        appAccountManager.getAssociatedData("account_name_1100", "key11_first", (err,data)=>{
                            console.debug("====>getAssociatedData key11_first 1100 err:" + JSON.stringify(err));
                            console.debug("====>getAssociatedData key11_first 1100 data:" + JSON.stringify(data));
466
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
467 468 469 470
                            expect(data).assertEqual("value11_first");
                            appAccountManager.getAssociatedData("account_name_1100", "key11_second", (err,data)=>{
                                console.debug("====>getAssociatedData key11_second 1100 err:" + JSON.stringify(err));
                                console.debug("====>getAssociatedData key11_second 1100 data:" + JSON.stringify(data));
471
                                expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                                expect(data).assertEqual("value11_second");
                                appAccountManager.deleteAccount("account_name_1100", (err)=>{
                                    console.debug("====>delete Account 1100 err:" + JSON.stringify(err));
                                });
                                console.debug("====>ActsAccountAssociatedData_1100 end====");
                                done();
                            });
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1200
        * @tc.name      : Call multiple setAssociatedData calls multiple times getAssociatedData gets the value separately
        * @tc.desc      : Call setAssociatedData setting value again after calling setAssociatedData setting
        *                 different value, and then call getAssociatedData twice to get the set value(promise)
        */
        it('ActsAccountAssociatedData_1200', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1200 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>addAccount ActsAccountAssociatedData_1200 start====");
            try{
                await appAccountManager.addAccount("account_name_1200");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_1200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_1200", "key12_first", "value12_first");
                await appAccountManager.setAssociatedData("account_name_1200", "key12_second", "value12_second");
            }
            catch(err){
                console.error("====>setAssociatedData ActsAccountAssociatedData_1200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                var dataFir = await appAccountManager.getAssociatedData("account_name_1200", "key12_first");
                var dataSec = await appAccountManager.getAssociatedData("account_name_1200", "key12_second");
            }
            catch(err){
                console.error("====>getAssociatedData ActsAccountAssociatedData_1200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_1200 getAssociatedData dataFir:" + JSON.stringify(dataFir));
            expect(dataFir).assertEqual("value12_first");
            console.debug("====>ActsAccountAssociatedData_1200 getAssociatedData dataSec:" + JSON.stringify(dataSec));
            expect(dataSec).assertEqual("value12_second");
            console.debug("====>delete account ActsAccountAssociatedData_1200 start====");
            try{
                await appAccountManager.deleteAccount("account_name_1200");
            }
            catch(err){
                console.error("====>delete account 1200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_1200 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1300
        * @tc.name      : setAssociatedData setting value is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting value when the incoming parameter KEY is wrong(callback)
        */
        it('ActsAccountAssociatedData_1300', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1300 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_1300", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_1300 err:" + JSON.stringify(err));
550
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
551 552 553 554 555
                appAccountManager.setAssociatedData("account_name_1300", "", "value13", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_1300 err:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    appAccountManager.deleteAccount("account_name_1300", (err)=>{
                        console.debug("====>delete account ActsAccountAssociatedData_1300 err:" + JSON.stringify(err));
556
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
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 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
                        console.debug("====>ActsAccountAssociatedData_1300 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1400
        * @tc.name      : setAssociatedData setting value is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting value when the incoming parameter KEY is wrong(promise)
        */
        it('ActsAccountAssociatedData_1400', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1400 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_1400 start====");
            try{
                await appAccountManager.addAccount("account_name_1400");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_1400 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_1400", "", "value14");
            }
            catch(err){
                console.debug("====>setAssociatedData ActsAccountAssociatedData_1400 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_1400 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_1400");
                }
                catch(err){
                    console.error("====>delete account 1400 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_1400 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1500
        * @tc.name      : setAssociatedData setting key is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting key when the incoming parameter KEY is wrong(callback)
        */
        it('ActsAccountAssociatedData_1500', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1500 start====");
            var keyOverSize = "K"
            for(var i = 0;i < 256;i++)
            keyOverSize = keyOverSize + "K!@#";
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_1500", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_1500 err:" + JSON.stringify(err));
616
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
617 618 619 620 621 622 623
                console.debug("====>1500 keyOverSize.length:" + JSON.stringify(keyOverSize.length));
                expect(keyOverSize.length).assertEqual(1025);
                appAccountManager.setAssociatedData("account_name_1500", keyOverSize, "value15", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_1500 err:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    appAccountManager.deleteAccount("account_name_1500", (err)=>{
                        console.debug("====>delete account ActsAccountAssociatedData_1500 err:" + JSON.stringify(err));
624
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                        console.debug("====>ActsAccountAssociatedData_1500 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1600
        * @tc.name      : setAssociatedData setting key is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting key when the incoming parameter KEY is wrong(promise)
        */
        it('ActsAccountAssociatedData_1600', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1600 start====");
            var keyOverSize = "K"
            for(var i=0;i<256;i++)
            keyOverSize = keyOverSize + "K!@#";
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            expect(keyOverSize.length).assertEqual(1025);
            console.debug("====>add account ActsAccountAssociatedData_1600 start====");
            try{
                await appAccountManager.addAccount("account_name_1600");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_1600 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_1600", keyOverSize, "value16");
            }
            catch(err){
                console.debug("====>setAssociatedData ActsAccountAssociatedData_1600 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_1600 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_1600");
                }
                catch(err){
                    console.error("====>delete account 1600 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_1600 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1700
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming key is a space(callback)
        */
        it('ActsAccountAssociatedData_1700', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1700 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_1700", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_1700 err:" + JSON.stringify(err));
685
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
686 687
                appAccountManager.setAssociatedData("account_name_1700", " ", "value17", (err)=>{
                    console.debug("====>ActsAccountAssociatedData_1700 setAssociatedData:" + JSON.stringify(err));
688
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
689 690 691
                    appAccountManager.getAssociatedData("account_name_1700", " ", (err, data)=>{
                        console.debug("====>getAssociatedData 1700 err:" + JSON.stringify(err));
                        console.debug("====>getAssociatedData 1700 data:" + JSON.stringify(data));
692
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
693 694 695
                        expect(data).assertEqual("value17");
                        appAccountManager.deleteAccount("account_name_1700", (err)=>{
                            console.debug("====>delete Account 1700 err:" + JSON.stringify(err));
696
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
697 698 699 700 701 702 703 704 705 706 707 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 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757
                            console.debug("====>ActsAccountAssociatedData_1700 end====");
                            done();
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1800
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming key is a space(promise)
        */
        it('ActsAccountAssociatedData_1800', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1800 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_1800 start====");
            try{
                await appAccountManager.addAccount("account_name_1800");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_1800 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            await appAccountManager.setAssociatedData("account_name_1800", " ", "value18");
            try{
                var data = await appAccountManager.getAssociatedData("account_name_1800", " ");
            }
            catch(err){
                console.error("====>setAssociatedData ActsAccountAssociatedData_1800 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData ActsAccountAssociatedData_1800 data:" + JSON.stringify(data));
            expect(data).assertEqual("value18");
            console.debug("====>delete account ActsAccountAssociatedData_1800 start====");
            try{
                await appAccountManager.deleteAccount("account_name_1800");
            }
            catch(err){
                console.error("====>delete account 1800 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_1800 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_1900
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming value is null(callback)
        */
        it('ActsAccountAssociatedData_1900', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_1900 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_1900", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_1900 err:" + JSON.stringify(err));
758
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
759 760
                appAccountManager.setAssociatedData("account_name_1900", "key19", "", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_1900 err:" + JSON.stringify(err));
761
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
762 763 764
                    appAccountManager.getAssociatedData("account_name_1900", "key19", (err, data)=>{
                        console.debug("====>getAssociatedData 1900 err:" + JSON.stringify(err));
                        console.debug("====>getAssociatedData 1900 data:" + JSON.stringify(data));
765
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
766 767 768
                        expect(data).assertEqual("");
                        appAccountManager.deleteAccount("account_name_1900", (err)=>{
                            console.debug("====>delete Account 1900 err:" + JSON.stringify(err));
769
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                            console.debug("====>ActsAccountAssociatedData_1900 end====");
                            done();
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2000
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming value is null(promise)
        */
        it('ActsAccountAssociatedData_2000', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2000 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_2000 start====");
            try{
                await appAccountManager.addAccount("account_name_2000");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_2000 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_2000", "key20", "");
            }
            catch(err){
                console.error("====>setAssociatedData ActsAccountAssociatedData_2000 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                var data = await appAccountManager.getAssociatedData("account_name_2000", "key20");
            }
            catch(err){
                console.error("====>getAssociatedData 2000 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData ActsAccountAssociatedData_2000 data:" + JSON.stringify(data));
            expect(data).assertEqual("");
            console.debug("====>delete account ActsAccountAssociatedData_2000 start====");
            try{
                await appAccountManager.deleteAccount("account_name_2000");
            }
            catch(err){
                console.error("====>delete account 2000 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_2000 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2100
        * @tc.name      : setAssociatedData setting value is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting value when the incoming parameter value is wrong(callback)
        */
        it('ActsAccountAssociatedData_2100', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2100 start====");
            var valueOverSize = "K"
            for(var i = 0;i < 256;i++)
            valueOverSize = valueOverSize + "K!@#";
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_2100",(err)=>{
                console.debug("====>add account ActsAccountAssociatedData_2100 err:" + JSON.stringify(err));
841
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
842 843 844 845 846 847
                expect(valueOverSize.length).assertEqual(1025);
                appAccountManager.setAssociatedData("account_name_2100", "key21", valueOverSize, (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_2100 err:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    appAccountManager.deleteAccount("account_name_2100", (err)=>{
                        console.debug("====>delete Account ActsAccountAssociatedData_2100 err:" + JSON.stringify(err));
848
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                        console.debug("====>ActsAccountAssociatedData_2100 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2200
        * @tc.name      : setAssociatedData setting value is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting value when the incoming parameter value is wrong(promise)
        */
        it('ActsAccountAssociatedData_2200', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2200 start====");
            var valueOverSize = "K"
            for(var i = 0;i < 256;i++)
            valueOverSize = valueOverSize + "K!@#";
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            expect(valueOverSize.length).assertEqual(1025);
            try{
                await appAccountManager.addAccount("account_name_2200");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_2200 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("account_name_2200", "key22", valueOverSize);
            }
            catch(err){
                console.debug("====>setAssociatedData ActsAccountAssociatedData_2200 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_2200 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_2200");
                }
                catch(err){
                    console.error("====>delete account 2200 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_2200 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2300
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming value is a space(callback)
        */
        it('ActsAccountAssociatedData_2300', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2300 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_2300", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_2300 err:" + JSON.stringify(err));
908
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
909 910
                appAccountManager.setAssociatedData("account_name_2300", "key23", " ", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_2300 err:" + JSON.stringify(err));
911
                    expect(err).assertEqual(null);
J
jiyong_sd 已提交
912 913 914
                    appAccountManager.getAssociatedData("account_name_2300", "key23", (err, data)=>{
                        console.debug("====>getAssociatedData 2300 err:" + JSON.stringify(err));
                        console.debug("====>getAssociatedData 2300 data:" + JSON.stringify(data));
915
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
916 917 918
                        expect(data).assertEqual(" ");
                        appAccountManager.deleteAccount("account_name_2300", (err)=>{
                            console.debug("====>delete Account 2300 err:" + JSON.stringify(err));
919
                            expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                            console.debug("====>ActsAccountAssociatedData_2300 end====");
                            done();
                        });
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2400
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming value is a space(promise)
        */
        it('ActsAccountAssociatedData_2400', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2400 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsAccountAssociatedData_2400 start====");
            try{
                await appAccountManager.addAccount("account_name_2400");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_2400 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            await appAccountManager.setAssociatedData("account_name_2400", "key24", " ");
            try{
                var data = await appAccountManager.getAssociatedData("account_name_2400", "key24");
            }
            catch(err){
                console.error("====>getAssociatedData 2400 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>getAssociatedData 2400 err:" + JSON.stringify(data));
            expect(data).assertEqual(" ");
            console.debug("====>delete account ActsAccountAssociatedData_2400 start====");
            try{
                await appAccountManager.deleteAccount("account_name_2400");
            }
            catch(err){
                console.error("====>delete account 2400 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsAccountAssociatedData_2400 end====");
            done();
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2500
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming name is null(callback)
        */
        it('ActsAccountAssociatedData_2500', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2500 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_2500", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_2500 err:" + JSON.stringify(err));
981
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
982 983 984 985 986
                appAccountManager.setAssociatedData("", "key25", "value25", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_2500 err:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    appAccountManager.deleteAccount("account_name_2500", (err)=>{
                        console.debug("====>delete Account ActsAccountAssociatedData_2500 err:" + JSON.stringify(err));
987
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                        console.debug("====>ActsAccountAssociatedData_2500 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2600
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming name is null(promise)
        */
        it('ActsAccountAssociatedData_2600', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2600 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>ActsAccountAssociatedData_2600 addAccount start====");
            try{
                await appAccountManager.addAccount("account_name_2600");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_2600 err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData("", "key26", "value26");
            }
            catch(err){
                console.debug("====>setAssociatedData ActsAccountAssociatedData_2600 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_2600 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_2600");
                }
                catch(err){
                    console.error("====>delete account 2600 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_2600 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2700
        * @tc.name      : setAssociatedData setting name is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting name when the incoming parameter name is wrong(callback)
        */
        it('ActsAccountAssociatedData_2700', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2700 start====");
            var nameOverSize = "n"
            for(var i = 0;i < 256;i++)
            nameOverSize = nameOverSize+"name";
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("account_name_2700",(err)=>{
                console.debug("====>add account ActsAccountAssociatedData_2700 err:" + JSON.stringify(err));
1047
                expect(err).assertEqual(null);
J
jiyong_sd 已提交
1048 1049 1050 1051 1052 1053
                expect(nameOverSize.length).assertEqual(1025);
                appAccountManager.setAssociatedData(nameOverSize, "key27", "value27", (err)=>{
                    console.debug("====>ActsAccountAssociatedData_2700 setAssociatedData:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    appAccountManager.deleteAccount("account_name_2700", (err)=>{
                        console.debug("====>delete Account ActsAccountAssociatedData_2700 err:" + JSON.stringify(err));
1054
                        expect(err).assertEqual(null);
J
jiyong_sd 已提交
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
                        console.debug("====>ActsAccountAssociatedData_2700 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2800
        * @tc.name      : setAssociatedData setting name is called when the argument is wrong
        * @tc.desc      : Call setAssociatedData setting name when the incoming parameter name is wrong(promise)
        */
        it('ActsAccountAssociatedData_2800', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2800 start====");
            var nameOverSize = "n"
            for(var i = 0;i < 256;i++)
            nameOverSize = nameOverSize + "name";
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            expect(nameOverSize.length).assertEqual(1025);
            console.debug("====>add account ActsAccountAssociatedData_2800 start====");
            try{
                await appAccountManager.addAccount("account_name_2800");
            }
            catch(err){
                console.error("====>add account ActsAccountAssociatedData_2800 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            try{
                await appAccountManager.setAssociatedData(nameOverSize, "key28", "value28");
            }
            catch(err){
                console.debug("====>setAssociatedData ActsAccountAssociatedData_2800 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>delete account ActsAccountAssociatedData_2800 start====");
                try{
                    await appAccountManager.deleteAccount("account_name_2800");
                }
                catch(err){
                    console.error("====>delete account 2800 fail err:" + JSON.stringify(err));
                    expect().assertFail();
                    done();
                }
                console.debug("====>ActsAccountAssociatedData_2800 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_2900
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming name is a space(callback)
        */
        it('ActsAccountAssociatedData_2900', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_2900 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount(" ", (err)=>{
                console.debug("====>add account ActsAccountAssociatedData_2900 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                appAccountManager.setAssociatedData(" ", "key29", "value29", (err)=>{
                    console.debug("====>setAssociatedData ActsAccountAssociatedData_2900 err:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    appAccountManager.getAssociatedData(" ", "key29", (err, data)=>{
                        console.debug("====>getAssociatedData 2900 err:" + JSON.stringify(err));
                        console.debug("====>getAssociatedData 2900 data:" + JSON.stringify(data));
                        expect(err.code != 0).assertEqual(true);
1123
                        expect(data).assertEqual(null);
J
jiyong_sd 已提交
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
                        console.debug("====>ActsAccountAssociatedData_2900 end====");
                        done();
                    });
                });
            });
        });

        /*
        * @tc.number    : ActsAccountAssociatedData_3000
        * @tc.name      : setAssociatedData and getAssociatedData are called when the argument is spaced
        * @tc.desc      : Call setAssociatedData and then getAssociatedData when the incoming name is a space(promise)
        */
        it('ActsAccountAssociatedData_3000', 0, async function (done) {
            console.debug("====>ActsAccountAssociatedData_3000 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            try{
                await appAccountManager.addAccount(" ");
            }
            catch(err){
                console.debug("====>add account ActsAccountAssociatedData_3000 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                try{
                    await appAccountManager.setAssociatedData(" ", "key30", "value30");
                }
                catch(err){
                    console.error("====>setAssociatedData ActsAccountAssociatedData_3000 err:" + JSON.stringify(err));
                    expect(err.code != 0).assertEqual(true);
                    try{
                        await appAccountManager.getAssociatedData(" ", "key30");
                    }
                    catch(err){
                        console.error("====>getAssociatedData ActsAccountAssociatedData_3000 err:" + JSON.stringify(err));
                        expect(err.code != 0).assertEqual(true);
                        console.debug("====>ActsAccountAssociatedData_3000 end====");
                        done();
                    }
                }
            }
        })
    })
}