Syncenable.test.js 31.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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import account from '@ohos.account.appAccount'
import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'

const TIMEOUT = 2000;
const PERMISSION_USER_SET = 1;
const PERMISSION_USER_NAME = "ohos.permission.DISTRIBUTED_DATASYNC";
var tokenID = undefined;
export default function ActsSetCheckSyncEnable() {
    describe('ActsSetCheckSyncEnable', function () {
        beforeAll(async function (done) {
            console.debug("====>beforeAll start====");
            var appInfo = await bundle.getApplicationInfo('com.example.actssetchecksyncenable', 0, 100);
            tokenID = appInfo.accessTokenId;
            console.debug("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName);
            var atManager = abilityAccessCtrl.createAtManager();
            var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET);
            console.debug("tokenId" + tokenID + " result:" + result);
            sleep(TIMEOUT);
            console.debug("====>beforeAll end====");
            done();
        })

        function sleep(delay) {
            var start = (new Date()).getTime();
            while((new Date()).getTime() - start < delay) {
                continue;
            }
        }

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0100
        * @tc.name      : Check sync flag callback form
        * @tc.desc      : Get the synchronization flag of the account that has not set the synchronization flag
        */
        it('ActsSetCheckSyncEnable_0100', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0100 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("syncenable_callback_notset", (err)=>{
                console.debug("====>add account ActsSetCheckSyncEnable_0100 err:" + JSON.stringify(err));
57
                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
58 59 60
                appAccountManager.checkAppAccountSyncEnable("syncenable_callback_notset", (err, data)=>{
                    console.debug("====>checkAppAccountSyncEnable 0100 err:" + JSON.stringify(err));
                    console.debug("====>checkAppAccountSyncEnable 0100 data:" + JSON.stringify(data));
61
                    expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
62 63 64
                    expect(data).assertEqual(false);
                    appAccountManager.deleteAccount("syncenable_callback_notset", (err)=>{
                        console.debug("====>delete Account ActsSetCheckSyncEnable_0100 err:" + JSON.stringify(err));
65
                        expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
66 67 68 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
                        console.debug("====>ActsSetCheckSyncEnable_0100 end====");
                        done();
                    });
                })
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0200
        * @tc.name      : Check sync flag promise form
        * @tc.desc      : Get the synchronization flag of the account that has not set the synchronization flag
        */
        it('ActsSetCheckSyncEnable_0200', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0200 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsSetCheckSyncEnable_0200 start====");
            try{
                await appAccountManager.addAccount("syncenable_promise_notset");
            }
            catch(err){
                console.error("====>add account ActsSetCheckSyncEnable_0200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0200 start====");
            try{
                var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_notset");
            }
            catch(err){
                console.error("====>checkAppAccountSyncEnable 0200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable 0200 data:" + JSON.stringify(data));
            expect(data).assertEqual(false);
            console.debug("====>delete account ActsSetCheckSyncEnable_0200 start====");
            try{
                await appAccountManager.deleteAccount("syncenable_promise_notset");
            }
            catch(err){
                console.error("====>delete account 0200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsSetCheckSyncEnable_0200 end====");
            done();
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0300
        * @tc.name      : Check the set synchronization flag callback form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag to true for the account
        */
        it('ActsSetCheckSyncEnable_0300', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0300 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("syncenable_callback_settrue", (err)=>{
                console.debug("====>add account ActsSetCheckSyncEnable_0300 err:" + JSON.stringify(err));
126
                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
127 128
                appAccountManager.setAppAccountSyncEnable("syncenable_callback_settrue", true, (err)=>{
                    console.debug("====>setAppAccountSyncEnable 0300 err:" + JSON.stringify(err));
129
                    expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
130 131 132
                    appAccountManager.checkAppAccountSyncEnable("syncenable_callback_settrue", (err, data)=>{
                        console.debug("====>checkAppAccountSyncEnable 0300 err:" + JSON.stringify(err));
                        console.debug("====>checkAppAccountSyncEnable 0300 data:" + JSON.stringify(data));
133
                        expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
134 135 136
                        expect(data).assertEqual(true);
                        appAccountManager.deleteAccount("syncenable_callback_settrue", (err)=>{
                            console.debug("====>delete Account ActsSetCheckSyncEnable_0300 err:" + JSON.stringify(err));
137
                            expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
138 139 140 141 142 143 144 145 146 147 148 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
                            console.debug("====>ActsSetCheckSyncEnable_0300 end====");
                            done();
                        });
                    })
                })
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0400
        * @tc.name      : Check the set synchronization flag promise form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag to true for the account
        */
        it('ActsSetCheckSyncEnable_0400', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0400 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsSetCheckSyncEnable_0400 start====");
            try{
                await appAccountManager.addAccount("syncenable_promise_settrue");
            }
            catch(err){
                console.error("====>add account ActsSetCheckSyncEnable_0400 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_0400 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_settrue", true);
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0400 start====");
            try{
                var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_settrue");
            }
            catch(err){
                console.error("====>checkAppAccountSyncEnable 0400 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable 0400 data:" + JSON.stringify(data));
            expect(data).assertEqual(true);
            console.debug("====>delete account ActsSetCheckSyncEnable_0400 start====");
            try{
                await appAccountManager.deleteAccount("syncenable_promise_settrue");
            }
            catch(err){
                console.error("====>delete account 0400 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsSetCheckSyncEnable_0400 end====");
            done();
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0500
        * @tc.name      : Check the set synchronization flag callback form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag to false for the account
        */
        it('ActsSetCheckSyncEnable_0500', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0500 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("syncenable_callback_setfalse", (err)=>{
                console.debug("====>add account ActsSetCheckSyncEnable_0500 err:" + JSON.stringify(err));
201
                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
202 203
                appAccountManager.setAppAccountSyncEnable("syncenable_callback_setfalse", false, (err)=>{
                    console.debug("====>setAppAccountSyncEnable 0500 err:" + JSON.stringify(err));
204
                    expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
205 206 207
                    appAccountManager.checkAppAccountSyncEnable("syncenable_callback_setfalse", (err, data)=>{
                        console.debug("====>checkAppAccountSyncEnable 0500 err:" + JSON.stringify(err));
                        console.debug("====>checkAppAccountSyncEnable 0500 data:" + JSON.stringify(data));
208
                        expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
209 210 211
                        expect(data).assertEqual(false);
                        appAccountManager.deleteAccount("syncenable_callback_setfalse", (err)=>{
                            console.debug("====>delete Account ActsSetCheckSyncEnable_0500 err:" + JSON.stringify(err));
212
                            expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
213 214 215 216 217 218 219 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
                            console.debug("====>ActsSetCheckSyncEnable_0500 end====");
                            done();
                        });
                    })
                })
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0600
        * @tc.name      : Check the set synchronization flag promise form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag to false for the account
        */
        it('ActsSetCheckSyncEnable_0600', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0600 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsSetCheckSyncEnable_0600 start====");
            try{
                await appAccountManager.addAccount("syncenable_promise_setfalse");
            }
            catch(err){
                console.error("====>add account ActsSetCheckSyncEnable_0600 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_0600 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_setfalse", false);
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0600 start====");
            try{
                var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_setfalse");
            }
            catch(err){
                console.error("====>checkAppAccountSyncEnable 0600 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable 0600 data:" + JSON.stringify(data));
            expect(data).assertEqual(false);
            console.debug("====>delete account ActsSetCheckSyncEnable_0600 start====");
            try{
                await appAccountManager.deleteAccount("syncenable_promise_setfalse");
            }
            catch(err){
                console.error("====>delete account 0600 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsSetCheckSyncEnable_0600 end====");
            done();
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0700
        * @tc.name      : Check the set synchronization flag callback form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag for the account to false
        *                 for the first time and true for the second time
        */
        it('ActsSetCheckSyncEnable_0700', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0700 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("syncenable_callback_falsetrue", (err)=>{
                console.debug("====>add account ActsSetCheckSyncEnable_0700 err:" + JSON.stringify(err));
277
                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
278 279
                appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", false, (err)=>{
                    console.debug("====>setAppAccountSyncEnable first time 0700 err:" + JSON.stringify(err));
280
                    expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
281 282
                    appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", true, (err)=>{
                        console.debug("====>setAppAccountSyncEnable second time 0700 err:" + JSON.stringify(err));
283
                        expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
284 285 286
                        appAccountManager.checkAppAccountSyncEnable("syncenable_callback_falsetrue", (err, data)=>{
                            console.debug("====>checkAppAccountSyncEnable 0700 err:" + JSON.stringify(err));
                            console.debug("====>checkAppAccountSyncEnable 0700 data:" + JSON.stringify(data));
287
                            expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
288 289 290
                            expect(data).assertEqual(true);
                            appAccountManager.deleteAccount("syncenable_callback_falsetrue", (err)=>{
                                console.debug("====>delete Account 0700 err:" + JSON.stringify(err));
291
                                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
292 293 294 295 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
                                console.debug("====>ActsSetCheckSyncEnable_0700 end====");
                                done();
                            });
                        })
                    })
                })
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0800
        * @tc.name      : Check the set synchronization flag promise form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag for the account to false
        *                 for the first time and true for the second time
        */
        it('ActsSetCheckSyncEnable_0800', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0800 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsSetCheckSyncEnable_0800 start====");
            await appAccountManager.addAccount("syncenable_promise_truefalse");
            console.debug("====>setAppAccountSyncEnable first time ActsSetCheckSyncEnable_0800 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", false);
            console.debug("====>setAppAccountSyncEnable second time ActsSetCheckSyncEnable_0800 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", true);
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0800 start====");
            try{
                var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_truefalse");
            }
            catch(err){
                console.error("====>checkAppAccountSyncEnable 0800 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable 0800 data:" + JSON.stringify(data));
            expect(data).assertEqual(true);
            console.debug("====>delete account ActsSetCheckSyncEnable_0800 start====");
            try{
                await appAccountManager.deleteAccount("syncenable_promise_truefalse");
            }
            catch(err){
                console.error("====>delete account 0800 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsSetCheckSyncEnable_0800 end====");
            done();
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_0900
        * @tc.name      : Check the set synchronization flag callback form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag for the account to true
        *                 for the first time and false for the second time
        */
        it('ActsSetCheckSyncEnable_0900', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_0900 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("syncenable_callback_falsetrue", (err)=>{
                console.debug("====>add account ActsSetCheckSyncEnable_0900 err:" + JSON.stringify(err));
353
                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
354 355
                appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", true, (err)=>{
                    console.debug("====>setAppAccountSyncEnable first time 0900 err:" + JSON.stringify(err));
356
                    expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
357 358
                    appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", false, (err)=>{
                        console.debug("====>setAppAccountSyncEnable second time 0900 err:" + JSON.stringify(err));
359
                        expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
360 361 362
                        appAccountManager.checkAppAccountSyncEnable("syncenable_callback_falsetrue", (err, data)=>{
                            console.debug("====>checkAppAccountSyncEnable 0900 err:" + JSON.stringify(err));
                            console.debug("====>checkAppAccountSyncEnable 0900 data:" + JSON.stringify(data));
363
                            expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
364 365 366
                            expect(data).assertEqual(false);
                            appAccountManager.deleteAccount("syncenable_callback_falsetrue", (err)=>{
                                console.debug("====>delete Account 0900 err:" + JSON.stringify(err));
367
                                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
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
                                console.debug("====>ActsSetCheckSyncEnable_0900 end====");
                                done();
                            });
                        })
                    })
                })
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1000
        * @tc.name      : Check the set synchronization flag promise form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag for the account to true
        *                 for the first time and false for the second time
        */
        it('ActsSetCheckSyncEnable_1000', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1000 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsSetCheckSyncEnable_1000 start====");
            await appAccountManager.addAccount("syncenable_promise_truefalse");
            console.debug("====>setAppAccountSyncEnable first time ActsSetCheckSyncEnable_1000 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", true);
            console.debug("====>setAppAccountSyncEnable second time ActsSetCheckSyncEnable_1000 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", false);
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1000 start====");
            try{
                var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_truefalse");
            }
            catch(err){
                console.error("====>checkAppAccountSyncEnable 1000 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable 1000 data:" + JSON.stringify(data));
            expect(data).assertEqual(false);
            console.debug("====>delete account ActsSetCheckSyncEnable_1000 start====");
            try{
                await appAccountManager.deleteAccount("syncenable_promise_truefalse");
            }
            catch(err){
                console.error("====>delete account 1000 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsSetCheckSyncEnable_1000 end====");
            done();
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1100
        * @tc.name      : Check the set synchronization flag callback form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag for the account to true
        *                 for the first time and true for the second time
        */
        it('ActsSetCheckSyncEnable_1100', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1100 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            appAccountManager.addAccount("syncenable_callback_truetrue", (err)=>{
                console.debug("====>add account ActsSetCheckSyncEnable_1100 err:" + JSON.stringify(err));
429
                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
430 431
                appAccountManager.setAppAccountSyncEnable("syncenable_callback_truetrue", true, (err)=>{
                    console.debug("====>setAppAccountSyncEnable first time 1100 err:" + JSON.stringify(err));
432
                    expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
433 434
                    appAccountManager.setAppAccountSyncEnable("syncenable_callback_truetrue", true, (err)=>{
                        console.debug("====>setAppAccountSyncEnable second time 1100 err:" + JSON.stringify(err));
435
                        expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
436 437 438
                        appAccountManager.checkAppAccountSyncEnable("syncenable_callback_truetrue", (err, data)=>{
                            console.debug("====>checkAppAccountSyncEnable 1100 err:" + JSON.stringify(err));
                            console.debug("====>checkAppAccountSyncEnable 1100 data:" + JSON.stringify(data));
439
                            expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
440 441 442
                            expect(data).assertEqual(true);
                            appAccountManager.deleteAccount("syncenable_callback_truetrue", (err)=>{
                                console.debug("====>delete Account 1100 err:" + JSON.stringify(err));
443
                                expect(err).assertEqual(undefined);
J
jiyong_sd 已提交
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
                                console.debug("====>ActsSetCheckSyncEnable_1100 end====");
                                done();
                            });
                        })
                    })
                })
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1200
        * @tc.name      : Check the set synchronization flag promise form
        * @tc.desc      : Check the synchronization flag after setting the synchronization flag for the account to true
        *                 for the true time and true for the second time
        */
        it('ActsSetCheckSyncEnable_1200', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1200 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>add account ActsSetCheckSyncEnable_1200 start====");
            await appAccountManager.addAccount("syncenable_promise_truetrue");
            console.debug("====>setAppAccountSyncEnable first time ActsSetCheckSyncEnable_1200 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truetrue", true);
            console.debug("====>setAppAccountSyncEnable second time ActsSetCheckSyncEnable_1200 start====");
            await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truetrue", true);
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1200 start====");
            try{
                var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_truetrue");
            }
            catch(err){
                console.error("====>checkAppAccountSyncEnable 1200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>checkAppAccountSyncEnable 1200 data:" + JSON.stringify(data));
            expect(data).assertEqual(true);
            console.debug("====>delete account ActsSetCheckSyncEnable_1200 start====");
            try{
                await appAccountManager.deleteAccount("syncenable_promise_truetrue");
            }
            catch(err){
                console.error("====>delete account 1200 fail err:" + JSON.stringify(err));
                expect().assertFail();
                done();
            }
            console.debug("====>ActsSetCheckSyncEnable_1200 end====");
            done();
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1300
        * @tc.name      : setAppAccountSyncEnable callback form
        * @tc.desc      : Set synchronization flag for non-existent account
        */
        it('ActsSetCheckSyncEnable_1300', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1300 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_1300 start====")
            var accountNotExist = "syncenable_callback_notexist";
            appAccountManager.setAppAccountSyncEnable(accountNotExist, true, (err)=>{
                console.debug("====>setAppAccountSyncEnable 1300 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>ActsSetCheckSyncEnable_1300 end====");
                done();
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1400
        * @tc.name      : setAppAccountSyncEnable promise form
        * @tc.desc      : Set synchronization flag for non-existent account
        */
        it('ActsSetCheckSyncEnable_1400', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1400 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_1400 start====")
            var accountNotExist = "syncenable_promise_notexist";
            try{
                await appAccountManager.setAppAccountSyncEnable(accountNotExist, true);
            }
            catch(err){
                console.debug("====>setAppAccountSyncEnable 1400 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>ActsSetCheckSyncEnable_1400 end====");
                done();
            }
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1500
        * @tc.name      : checkAppAccountSyncEnable callback form
        * @tc.desc      : Check synchronization flag for non-existent account
        */
        it('ActsSetCheckSyncEnable_1500', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1500 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1500 start====")
            var accountNotExist = "syncenable_callback_notexist";
            appAccountManager.checkAppAccountSyncEnable(accountNotExist, (err, data)=>{
                console.debug("====>checkAppAccountSyncEnable 1500 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>ActsSetCheckSyncEnable_1500 end====");
                done();
            });
        });

        /*
        * @tc.number    : ActsSetCheckSyncEnable_1600
        * @tc.name      : checkAppAccountSyncEnable promise form
        * @tc.desc      : Check synchronization flag for non-existent account
        */
        it('ActsSetCheckSyncEnable_1600', 0, async function (done) {
            console.debug("====>ActsSetCheckSyncEnable_1600 start====");
            var appAccountManager = account.createAppAccountManager();
            console.debug("====>creat finish====");
            console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1600 start====")
            var accountNotExist = "syncenable_promise_notexist";
            try{
                await appAccountManager.checkAppAccountSyncEnable(accountNotExist);
            }
            catch(err){
                console.debug("====>checkAppAccountSyncEnable 1600 err:" + JSON.stringify(err));
                expect(err.code != 0).assertEqual(true);
                console.debug("====>ActsSetCheckSyncEnable_1600 end====");
                done();
            }
        });
    })
}