ContinuationManagerJsunit.test.js 33.0 KB
Newer Older
Y
yuxiaoya2 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Copyright (c) 2022 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import continuationManager from '@ohos.continuation.continuationManager';

const TEST_DEVICE_ID = "test_deviceId";
const TEST_CONNECT_STATUS = continuationManager.DeviceConnectState.CONNECTED;
let token = -1;

Y
yuxiaoya2 已提交
22 23
export default function continuationManagerTest() {
describe('continuationManagerTest', function() {
Y
yuxiaoya2 已提交
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 57 58 59 60

    beforeAll(async function (done) {
        console.info('beforeAll');
        done();
    })

    afterAll(async function (done) {
        console.info('afterAll');
        done();
    })

    beforeEach(async function (done) {
        console.info('beforeEach');
        await continuationManager.register(function (err, data) {
            token = data;
            console.info('beforeEach register success');
            done();
        });
        console.info('beforeEach end');
    })

    afterEach(async function (done) {
        console.info('afterEach');
        await continuationManager.unregister(token, function (err, data) {
            console.info('afterEach unregister success');
            done();
        });
        console.info('afterEach end');
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0100
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 001
     */
    it('testRegister001', 0, async function(done) {
        try {
Y
yuxiaoya2 已提交
61
            console.info("testRegister001Begin ");
Y
yuxiaoya2 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
            continuationManager.register(function (err, data) {
                expect(err.code == 0).assertTrue();
                expect(data - token == 1).assertTrue();
                done();
            });
        } catch (e) {
            console.info("testRegister001 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0200
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 002
     */
    it('testRegister002', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: [],
83
                targetBundle: "",
Y
yuxiaoya2 已提交
84 85 86 87 88 89
                description: "",
                filter: "",
                continuationMode: null,
                authInfo: {}
            };
            continuationManager.register(continuationExtraParams, function(err, data){
Y
yuxiaoya2 已提交
90
                console.info("testRegister002 " + err.message);
Y
yuxiaoya2 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
                expect(err.message == "Invalidate params.").assertTrue();
                done();
            });
        } catch (e) {
            console.info("testRegister002 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0300
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 003
     */
    it('testRegister003', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
110
                targetBundle: "ohos.example.test",
Y
yuxiaoya2 已提交
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
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: 10,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.register(continuationExtraParams, function(err, data) {
                expect(err.code == 29360216).assertTrue();
                console.info("testRegister003 "+ err);
                done();
            });
        } catch (e) {
            console.info("testRegister003 " + e);
            expect(null).assertFail();
            done();
        }
    })

     /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0400
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 004
     */
    it('testRegister004', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
137
                targetBundle: "ohos.example.test",
Y
yuxiaoya2 已提交
138 139
                description: "description",
                filter: {"name": "authInfo","length": 8},
Y
yuxiaoya2 已提交
140
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
Y
yuxiaoya2 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.register(continuationExtraParams, function(err, data) {
                expect(err.code == 0).assertTrue();
                expect(data - token == 1).assertTrue();
                done();
            });
        } catch (e) {
            console.info("testRegister004 " + e);
            expect(null).assertFail();
            done();
        }
    })


Y
yuxiaoya2 已提交
156 157 158 159 160 161 162 163 164
     /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0500
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 005
     */
      it('testRegister005', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
165
                targetBundle: "ohos.example.test",
Y
yuxiaoya2 已提交
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
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.register(continuationExtraParams, function(err, data) {
                expect(err.code == 0).assertTrue();
                expect(data - token == 1).assertTrue();
                done();
            });
        } catch (e) {
            console.info("testRegister005 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0600
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 006
     */
     it('testRegister006', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
192
                targetBundle: "ohos.example.test",
Y
yuxiaoya2 已提交
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.register(continuationExtraParams).then((data) => {
                expect(data - token == 1).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
        } catch (e) {
            console.info("testRegister006 " + e);
            expect(null).assertFail();
        }
        done();
    })


    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0700
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 007
     */
     it('testRegister007', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.register(continuationExtraParams).then((data) => {
                expect(data - token == 1).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
        } catch (e) {
            console.info("testRegister007 " + e);
            expect(null).assertFail();
        }
        done();
    })


    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0800
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 008
     */
     it('testRegister008', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: [],
                description: "",
                filter: "",
                continuationMode: null,
                authInfo: {}
            };
            continuationManager.register(continuationExtraParams).then((data) => {
                expect(data - token != 1).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
        } catch (e) {
            console.info("testRegister008 " + e);
            expect(null).assertFail();
        }
        done();
    })


    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0900
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 009
     */
     it('testRegister009', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: 10,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.register(continuationExtraParams).then((data) => {
                expect(data - token != 1).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testRegister009 " + e);
            expect(null).assertFail();
            done();
        }
    })

    
    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_1000
     * @tc.name [JS-API8]ContinuationManager.register().
     * @tc.desc Test Js Api ContinuationManager.register() testcase 010
     */
     it('testRegister010', 0, async function(done) {
        try {
            continuationManager.register().then((data) => {
                expect(data - token == 1).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
        } catch (e) {
            console.info("testRegister010 " + e);
            expect(null).assertFail();
        }
        done();
    })

Y
yuxiaoya2 已提交
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 368 369 370
    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0100
     * @tc.name [JS-API8]ContinuationManager.unregister().
     * @tc.desc Test Js Api ContinuationManager.unregister() testcase 001
     */
    it('testUnregister001', 0, async function(done) {
        try {
            continuationManager.unregister(token, function (err, data) {
                expect(err.code == 0).assertTrue();
                expect(data == undefined).assertTrue();
            })
            done();
        } catch (e) {
            console.info("testUnregister001 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0200
     * @tc.name [JS-API8]ContinuationManager.unregister().
     * @tc.desc Test Js Api ContinuationManager.unregister() testcase 002
     */
    it('testUnregister002', 0, async function(done) {
        try {
            continuationManager.unregister(null, function (err, data) {
                console.info("testUnregister002 " + data);
                expect(err.message == "Invalidate params.").assertTrue();
                expect(data == undefined).assertTrue();
            })
            done();
        } catch (e) {
            console.info("testUnregister002 " + e);
            expect(null).assertFail();
            done();
        }
    })


    /**
    * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0300
    * @tc.name [JS-API8]ContinuationManager.unregister().
    * @tc.desc Test Js Api ContinuationManager.unregister() testcase 003
    */
    it('testUnregister003', 0, async function(done) {
        try {
            continuationManager.unregister(300, function (err, data) {
                expect(err.code == 29360208).assertTrue();
                expect(data == undefined).assertTrue();
            })
            done();
        } catch (e) {
            console.info("testUnregister003 " + e);
            expect(null).assertFail();
            done();
        }
    })

Y
yuxiaoya2 已提交
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

    /**
    * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0400
    * @tc.name [JS-API8]ContinuationManager.unregister().
    * @tc.desc Test Js Api ContinuationManager.unregister() testcase 004
    */
     it('testUnregister004', 0, async function(done) {
        try {
            continuationManager.unregister(300, function (data) {
                expect(data.code == 29360208).assertTrue();
            })
            done();
        } catch (e) {
            console.info("testUnregister004 " + e);
            expect(null).assertFail();
            done();
        }
    })

    
    /**
    * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0500
    * @tc.name [JS-API8]ContinuationManager.unregister().
    * @tc.desc Test Js Api ContinuationManager.unregister() testcase 005
    */
     it('testUnregister005', 0, async function(done) {
        try {
            continuationManager.unregister(token, function (data) {
                console.info("testUnregister005 " + JSON.stringify(data));
                expect(data.code == 0).assertTrue();
            })
            done();
        } catch (e) {
            console.info("testUnregister005 " + e);
            expect(null).assertFail();
            done();
        }
    })


Y
yuxiaoya2 已提交
411 412 413 414 415 416 417 418
    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0100
     * @tc.name [JS-API8]ContinuationManager.on().
     * @tc.desc Test Js Api ContinuationManager.on() testcase 001
     */
    it('testOn001', 0, async function(done) {
        try {
            continuationManager.on("deviceConnect", function (data) {
419
                expect(data != null).assertFail();
Y
yuxiaoya2 已提交
420 421 422 423
            });
            done();
        } catch (e) {
            console.info("testOn001 " + e);
424
            expect(e.toString().includes("must be 3")).assertTrue();
Y
yuxiaoya2 已提交
425 426 427 428 429 430 431 432 433 434 435 436
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0200
     * @tc.name [JS-API8]ContinuationManager.on().
     * @tc.desc Test Js Api ContinuationManager.on() testcase 002
     */
    it('testOn002', 0, async function(done) {
        try {
            continuationManager.on("deviceDisconnect", function (data) {
437
                expect(data != null).assertFail();
Y
yuxiaoya2 已提交
438 439 440 441
            });
            done();
        } catch (e) {
            console.info("testOn002 " + e);
442
            expect(e.toString().includes("must be 3")).assertTrue();
Y
yuxiaoya2 已提交
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0300
     * @tc.name [JS-API9]ContinuationManager.on().
     * @tc.desc Test Js Api ContinuationManager.on() testcase 003
     */
    it('testOn003', 0, async function(done) {
        try {
            continuationManager.on("deviceConnect", token, function (data) {
                expect(data == undefined).assertTrue();
            })
            done();
        } catch (e) {
            console.info("testOn003 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0400
     * @tc.name [JS-API9]ContinuationManager.on().
     * @tc.desc Test Js Api ContinuationManager.on() testcase 004
     */
    it('testOn004', 0, async function(done) {
        try {
            continuationManager.on("deviceDisconnect", token, function (data) {
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testOn004 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0100
     * @tc.name [JS-API8]ContinuationManager.off().
     * @tc.desc Test Js Api ContinuationManager.off() testcase 001
     */
    it('testOff001', 0, async function(done) {
        try {
            continuationManager.off("deviceConnect", function (data) {
491
                expect(data != null).assertFail();
Y
yuxiaoya2 已提交
492 493 494 495
            });
            done();
        } catch (e) {
            console.info("testOff001 " + e);
496
            expect(e.toString().includes("must be string")).assertTrue();
Y
yuxiaoya2 已提交
497 498 499 500 501 502 503 504 505 506 507 508
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0200
     * @tc.name [JS-API8]ContinuationManager.off().
     * @tc.desc Test Js Api ContinuationManager.off() testcase 002
     */
    it('testOff002', 0, async function(done) {
        try {
            continuationManager.off("deviceDisconnect", function (data) {
509
                expect(data != null).assertFail();
Y
yuxiaoya2 已提交
510 511 512 513
            });
            done();
        } catch (e) {
            console.info("testOff002 " + e);
514
            expect(e.toString().includes("must be string")).assertTrue();
Y
yuxiaoya2 已提交
515 516 517 518 519 520 521 522 523 524 525 526 527 528
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0300
     * @tc.name [JS-API9]ContinuationManager.off().
     * @tc.desc Test Js Api ContinuationManager.off() testcase 003
     */
    it('testOff003', 0, async function(done) {
        try {
            done();
        } catch (e) {
            console.info("testOff003 " + e);
529
            expect(e.toString().includes("Callback is not registered")).assertTrue();
Y
yuxiaoya2 已提交
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0400
     * @tc.name [JS-API9]ContinuationManager.off().
     * @tc.desc Test Js Api ContinuationManager.off() testcase 004
     */
    it('testOff004', 0, async function(done) {
        try {
            continuationManager.off("deviceDisconnect", token);
            done();
        } catch (e) {
            console.info("testOff004 " + e);
545
            expect(e.toString().includes("Callback is not registered")).assertTrue();
Y
yuxiaoya2 已提交
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0100
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 001
     */
    it('testStartDeviceManager001', 0, async function(done) {
        try {
            continuationManager.startDeviceManager(token, function (err, data) {
                expect(err.code != 0).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager001 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0200
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 002
     */
     it('testStartDeviceManager002', 0, async function(done) {
        try {
            continuationManager.startDeviceManager(null, function (err, data) {
                expect(err.code == -1).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager002 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0300
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 003
     */
    it('testStartDeviceManager003', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
Y
yuxiaoya2 已提交
599
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
Y
yuxiaoya2 已提交
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.startDeviceManager(null, continuationExtraParams, function (err, data) {
                expect(err.code == -1).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager003 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0400
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 004
     */
    it('testStartDeviceManager004', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
Y
yuxiaoya2 已提交
625
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
Y
yuxiaoya2 已提交
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.startDeviceManager(52, continuationExtraParams, function (err, data) {
                console.info("testStartDeviceManager004 " + err.code);
                expect(err.code == 29360208).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager004 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0500
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 005
     */
    it('testStartDeviceManager005', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: 30,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.startDeviceManager(token, continuationExtraParams, function (err, data) {
                console.info("testStartDeviceManager005 " + err.code);
                expect(err.code == 29360216).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager005 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0600
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 006
     */
    it('testStartDeviceManager006', 0, async function(done) {
        try {
            let continuationExtraParams = {
            };
            continuationManager.startDeviceManager(token, continuationExtraParams, function (err, data) {
                console.info("testStartDeviceManager006 " + err.code);
                expect(err.code != 0).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager006 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0700
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 007
     */
    it('testStartDeviceManager007', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_MUTIPLE,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.startDeviceManager(token, continuationExtraParams, function (err, data) {
                expect(err.code != 0).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager007 " + e);
            expect(null).assertFail();
            done();
        }
    })
Y
yuxiaoya2 已提交
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 758 759 760 761 762
    
    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0800
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 008
     */
     it('testStartDeviceManager008', 0, async function(done) {
        try {
            let continuationExtraParams = {
                deviceType: ["00E"],
                description: "description",
                filter: {"name": "authInfo","length": 8},
                continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE,
                authInfo: {"name": "authInfo","length": 8}
            };
            continuationManager.startDeviceManager(token, continuationExtraParams).then((data) => {
                expect(data == undefined).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager008 " + e);
            expect(null).assertFail();
            done();
        }
    })

        
    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0900
     * @tc.name [JS-API8]ContinuationManager.startDeviceManager().
     * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 009
     */
     it('testStartDeviceManager009', 0, async function(done) {
        try {
            continuationManager.startDeviceManager(token).then((data) => {
                expect(data == undefined).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testStartDeviceManager009 " + e);
            expect(null).assertFail();
            done();
        }
    })
Y
yuxiaoya2 已提交
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0100
     * @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
     * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 001
     */
    it('testUpdateConnectStatus001', 0, async function(done) {
        try {
            continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, TEST_CONNECT_STATUS, function (err, data) {
                expect(err.code != 0).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testUpdateConnectStatus001 " + e);
            expect(null).assertFail();  
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0200
     * @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
     * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 002
     */
    it('testUpdateConnectStatus002', 0, async function(done) {
        try {
            continuationManager.updateConnectStatus(null, TEST_DEVICE_ID, TEST_CONNECT_STATUS, function (err, data) {
                console.info("testUpdateConnectStatus002 " + err.code);
                expect(err.code == -1).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testUpdateConnectStatus002 " + e);
            expect(null).assertFail();
            done();
        }
    })

    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0300
     * @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
     * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 003
     */
    it('testUpdateConnectStatus003', 0, async function(done) {
        try {
            continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, -2, function (err, data) {
                console.info("testUpdateConnectStatus003 " + err.code);
                expect(err.code == 29360215).assertTrue();
                expect(data == undefined).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testUpdateConnectStatus003 " + e);
            expect(null).assertFail();
            done();
        }
    })
Y
yuxiaoya2 已提交
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891


    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0400
     * @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
     * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 004
     */
     it('testUpdateConnectStatus004', 0, async function(done) {
        try {
            console.info('testUpdateConnectStatus004 begin');
            continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, 
                continuationManager.DeviceConnectState.IDLE).then((data) => {
                expect(data == undefined).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testUpdateConnectStatus004 " + e);
            expect(null).assertFail();
            done();
        }
    })


    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0500
     * @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
     * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 005
     */
     it('testUpdateConnectStatus005', 0, async function(done) {
        try {
            console.info('testUpdateConnectStatus005 begin');
            continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, 
                continuationManager.DeviceConnectState.CONNECTING).then((data) => {
                expect(data == undefined).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testUpdateConnectStatus005 " + e);
            expect(null).assertFail();
            done();
        }
    })


    /**
     * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0600
     * @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
     * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 006
     */
     it('testUpdateConnectStatus006', 0, async function(done) {
        try {
            continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, 
                continuationManager.DeviceConnectState.DISCONNECTING).then((data) => {
                expect(data == undefined).assertTrue();
            }).catch((err) => {
                expect(err.code == 29360210).assertTrue();
            });
            done();
        } catch (e) {
            console.info("testUpdateConnectStatus006 " + e);
            expect(null).assertFail();
            done();
        }
    })


Y
yuxiaoya2 已提交
892
})}