RpcClientJsunit.test.js 243.7 KB
Newer Older
J
jiyong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * 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 rpc from '@ohos.rpc'
import fileio from '@ohos.fileio';
Z
zhangpa2021 已提交
18
import FA from '@ohos.ability.featureAbility'
Z
zhangpa2021 已提交
19 20
import {describe, beforeAll, beforeEach, afterEach, afterAll, expect, it} from '@ohos/hypium'
export default function actsRpcClientJsTest() {
J
jiyong 已提交
21 22 23

var gIRemoteObject = undefined;

Z
zhangpa2021 已提交
24
describe('actsRpcClientJsTest', function(){
Z
zhangpa2021 已提交
25
    console.info("-----------------------SUB_Softbus_IPC_MessageParce_Test is starting-----------------------");
J
jiyong 已提交
26

Z
zhangpa2021 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39
    beforeEach(async function (){
        console.info('beforeEach called');
    });

    afterEach(async function (){
        console.info('afterEach called');
    });

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


J
jiyong 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    const CODE_WRITE_BYTEARRAY = 1;
    const CODE_WRITE_INTARRAY = 2;
    const CODE_WRITE_FLOATARRAY = 3;
    const CODE_WRITE_SHORT = 4;
    const CODE_WRITE_LONG = 5;
    const CODE_WRITE_DOUBLE = 6;
    const CODE_WRITE_BOOLEAN = 7;
    const CODE_WRITE_CHAR = 8;
    const CODE_WRITE_STRING = 9;
    const CODE_WRITE_BYTE = 10;
    const CODE_WRITE_INT = 11;
    const CODE_WRITE_FLOAT = 12;
    const CODE_WRITE_RAWDATA = 13;
    const CODE_WRITE_REMOTEOBJECT = 14;
    const CODE_WRITE_SEQUENCEABLE = 15;
    const CODE_WRITE_NOEXCEPTION = 16;
    const CODE_WRITE_SEQUENCEABLEARRAY = 17;
    const CODE_WRITE_REMOTEOBJECTARRAY = 18;
    const CODE_ALL_TYPE = 20;
    const CODE_ALL_ARRAY_TYPE = 21;
    const CODE_WRITEINT8_ASHMEM = 22;
    const CODE_WRITESEQUENCEABLE = 23
J
jiyong 已提交
62 63 64 65 66 67
    const CODE_WRITE_SHORT_MULTI = 24;
    const CODE_WRITE_BYTE_MULTI = 25;
    const CODE_WRITE_INT_MULTI = 26;
    const CODE_TRANSACTION = 27;
    const CODE_IPCSKELETON = 28;
    const CODE_FILESDIR = 29;
Z
zhangpa2021 已提交
68 69
    const CODE_WRITE_REMOTEOBJECTARRAY_1 = 30;
    const CODE_WRITE_REMOTEOBJECTARRAY_2 = 31;
J
jiyong 已提交
70 71 72 73 74 75 76 77

    function connectAbility() {
        let want = {
            "bundleName":"ohos.rpc.test.server",
            "abilityName": "ohos.rpc.test.server.ServiceAbility",
        };
        let connect = {
            onConnect:function (elementName, remoteProxy) {
Z
zhangpa2021 已提交
78
                console.info('RpcClient: onConnect called, instance of proxy: '
J
jiyong 已提交
79
                             + (remoteProxy instanceof rpc.RemoteProxy))
J
jiyong 已提交
80 81 82 83
                gIRemoteObject = remoteProxy

            },
            onDisconnect:function (elementName) {
Z
zhangpa2021 已提交
84
                console.info("RpcClient: onDisconnect")
J
jiyong 已提交
85 86
            },
            onFailed:function () {
Z
zhangpa2021 已提交
87
                console.info("RpcClient: onFailed")
J
jiyong 已提交
88 89 90 91 92
                gIRemoteObject = null
            }
        };
        FA.connectAbility(want, connect)
        return new Promise((resolve, reject) =>{
Z
zhangpa2021 已提交
93
            console.info("start connect local ability, wait 5 seconds")
J
jiyong 已提交
94
            setTimeout(()=>{
Z
zhangpa2021 已提交
95
                console.info("resolve proxy: " + gIRemoteObject)
J
jiyong 已提交
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 140 141 142 143
                resolve(gIRemoteObject)
            }, 5000)
        })
    }

    function sleep(numberMillis)
    {
        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
            return;
        }
    }

    class TestRemoteObject extends rpc.RemoteObject {
        constructor(descriptor) {
            super(descriptor);
        }
    }

    class MyDeathRecipient {
        constructor(gIRemoteObject, done) {
            this.gIRemoteObject = gIRemoteObject
            this.done = done
        }

        onRemoteDied() {
            console.info("server died")
            expect(this.proxy.removeDeathRecipient(this, 0)).assertTrue()
            let _done = this.done
            setTimeout(function() {
                _done()
            }, 1000)
        }
    }

    class TestAbility extends rpc.RemoteObject {
        asObject() {
            return this;
        }
    }

    class TestAbilityStub extends rpc.RemoteObject {
        constructor(descriptor) {
            super(descriptor)
        }
Z
zhangpa2021 已提交
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

        onRemoteRequest(code, data, reply, option) {
            console.info("TestAbilityStub: onRemoteRequest called, code: " + code)
            let descriptor = data.readInterfaceToken()
            if (descriptor !== "TestAbilityStub") {
                console.error("received unknown descriptor: " + descriptor)
                return false
            }
            switch (code) {
                case 1:
                {
                    let tmp1 = data.readByte()
                    let tmp2 = data.readByte()
                    let tmp3 = data.readShort()
                    let tmp4 = data.readShort()
                    let tmp5 = data.readInt()
                    let tmp6 = data.readInt()
                    let tmp7 = data.readLong()
                    let tmp8 = data.readLong()
                    let tmp9 = data.readFloat()
                    let tmp10 = data.readFloat()
                    let tmp11 = data.readDouble()
                    let tmp12 = data.readDouble()
                    let tmp13 = data.readBoolean()
                    let tmp14 = data.readBoolean()
                    let tmp15 = data.readChar()
                    let tmp16 = data.readString()
                    let s = new MySequenceable(null, null)
                    data.readSequenceable(s)
                    reply.writeNoException()
                    reply.writeByte(tmp1)
                    reply.writeByte(tmp2)
                    reply.writeShort(tmp3)
                    reply.writeShort(tmp4)
                    reply.writeInt(tmp5)
                    reply.writeInt(tmp6)
                    reply.writeLong(tmp7)
                    reply.writeLong(tmp8)
                    reply.writeFloat(tmp9)
                    reply.writeFloat(tmp10)
                    reply.writeDouble(tmp11)
                    reply.writeDouble(tmp12)
                    reply.writeBoolean(tmp13)
                    reply.writeBoolean(tmp14)
                    reply.writeChar(tmp15)
                    reply.writeString(tmp16)
                    reply.writeSequenceable(s)
                    return true
                }
                default:
                {
                    console.error("default case, code: " + code)
                    return false
                }
            }
        }
J
jiyong 已提交
200 201
    }

Z
zhangpa2021 已提交
202

J
jiyong 已提交
203 204 205 206 207 208 209 210
    class TestListener extends rpc.RemoteObject {
        constructor(descriptor, checkResult) {
            super(descriptor);
            this.checkResult = checkResult
        }
        onRemoteRequest(code, data, reply, option) {
            let result = false
            if (code  == 1) {
Z
zhangpa2021 已提交
211
                console.info("onRemoteRequest called, descriptor: " + this.getInterfaceDescriptor())
J
jiyong 已提交
212 213
                result = true
            } else {
Z
zhangpa2021 已提交
214
                console.info("unknown code: " + code)
J
jiyong 已提交
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
            }
            let _checkResult = this.checkResult
            let _num = data.readInt()
            let _str = data.readString()
            setTimeout(function(){
                _checkResult(_num, _str)
            }, 2*1000);
            return result
        }
    }

    class MySequenceable {
        constructor(num, string) {
            this.num = num;
            this.str = string;
        }
        marshalling(messageParcel) {
            messageParcel.writeInt(this.num);
            messageParcel.writeString(this.str);
            return true;
        }
        unmarshalling(messageParcel) {
            this.num = messageParcel.readInt();
            this.str = messageParcel.readString();
            return true;
        }
    }

    class Stub extends rpc.RemoteObject {
        onRemoteRequest(code, data, reply, option) {
            let callerPid = rpc.IPCSkeleton.getCallingPid();
Z
zhangpa2021 已提交
246
            console.info("RpcServer: getCallingPid result: " + callerPid);
J
jiyong 已提交
247
            let callerUid = rpc.IPCSkeleton.getCallingUid();
Z
zhangpa2021 已提交
248
            console.info("RpcServer: getCallingUid result: " + callerUid);
J
jiyong 已提交
249
            let callerDeviceID  = rpc.IPCSkeleton.getCallingDeviceID();
Z
zhangpa2021 已提交
250
            console.info("RpcServer: getCallingUid result: " + callerDeviceID );
J
jiyong 已提交
251
            let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
Z
zhangpa2021 已提交
252
            console.info("RpcServer: localDeviceID is: " + localDeviceID);
J
jiyong 已提交
253 254 255 256
            return true;
        }
    }

J
jiyong 已提交
257 258 259 260 261 262 263
    function assertArrayElementEqual(actual, expected) {
        expect(actual.length).assertEqual(expected.length)
        for (let i = 0; i < actual.length; i++) {
            expect(actual[i]).assertEqual(expected[i])
        }
    }

J
jiyong 已提交
264 265 266
    beforeAll(async function (done) {
        console.info('beforeAll called')
        await connectAbility().then((remote) => {
Z
zhangpa2021 已提交
267
            console.info("got remote proxy: " + remote)
J
jiyong 已提交
268
        }).catch((err) => {
Z
zhangpa2021 已提交
269
            console.info("got exception: " + err)
J
jiyong 已提交
270 271
        })
        done()
Z
zhangpa2021 已提交
272
        console.info("beforeAll done")
J
jiyong 已提交
273 274
    })

Z
zhangpa2021 已提交
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 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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 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 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 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 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0100
     * @tc.name    Call the writeinterfacetoken interface, write the interface descriptor, and read interfacetoken
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0100", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0100---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0100: create object successfully.");

        var token = "hello ruan zong xian";
        var result = data.writeInterfaceToken(token);
        console.info("SUB_Softbus_IPC_MessageParcel_0100:run writeInterfaceToken success, result is " + result);
        expect(result == true).assertTrue();

        var resultToken = data.readInterfaceToken();
        console.info("SUB_Softbus_IPC_MessageParcel_0100:run readInterfaceToken success, result is " + resultToken);
        expect(resultToken == token);

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0100:error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0100---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0200
     * @tc.name    Call the writeinterfacetoken interface to write a non string interface descriptor
               and read interfacetoken
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0200", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0200---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0200: create object successfully.");

        var token = 123;
        var result = data.writeInterfaceToken(token);

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0200: error = " + error);
        expect(error != null).assertTrue();
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0200---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0300
     * @tc.name    The data size of the messageparcel obtained by calling the getSize interface
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0300", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0300---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0300: create object successfully.");

        var size = data.getSize();
        console.info("SUB_Softbus_IPC_MessageParcel_0300:run getSize is success, result is " + size);
        expect(size == 0).assertTrue();

        var addData = 1;
        var result = data.writeInt(addData);
        console.info("SUB_Softbus_IPC_MessageParcel_0300:run writeInt is success, result is " + result);
        expect(result == true).assertTrue();

        size = data.getSize();
        console.info("SUB_Softbus_IPC_MessageParcel_0300:run getSize is success, result is " + size);
        expect(size == 4).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0300: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0300---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0400
     * @tc.name    The capacity of the messageparcel obtained by calling the getcapacity interface
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0400", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0400---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0400: create object successfully.");

        var size = data.getCapacity();
        console.info("SUB_Softbus_IPC_MessageParcel_0400:run getCapacity is success, result is " + size);
        expect(size == 0).assertTrue();

        var addData = 1;
        var result = data.writeInt(addData);
        console.info("SUB_Softbus_IPC_MessageParcel_0400:run writeInt is success, result is " + result);
        expect(result == true).assertTrue();

        size = data.getCapacity();
        console.info("SUB_Softbus_IPC_MessageParcel_0400:run getCapacity is success, result is " + size);
        expect(size == 64).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0400: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0400---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0500
     * @tc.name    Call the SetSize interface to set the data size of messageparcel
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0500", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0500---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0500: create object successfully.");

        var addData = 1;
        var result = data.writeInt(addData);
        console.info("SUB_Softbus_IPC_MessageParcel_0500:run writeInt is success, result is " + result);
        expect(result == true).assertTrue();

        var size = 6;
        var setResult = data.setSize(size);
        console.info("SUB_Softbus_IPC_MessageParcel_0500:run setSize success, result is " + setResult);
        expect(setResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0500: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0500---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0600
     * @tc.name    Call the SetSize interface to set the data size of messageparcel. The write data size
     *             does not match the set value
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0600", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0600---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0600: create object successfully.");

        var capacity = 64;
        var setResult = data.setCapacity(capacity);
        console.info("SUB_Softbus_IPC_MessageParcel_0600:run setCapacity success, result is " + setResult);
        expect(setResult == true).assertTrue();

        var size = 4;
        setResult = data.setSize(size);
        console.info("SUB_Softbus_IPC_MessageParcel_0600:run setSize success, result is " + setResult);
        expect(setResult == true).assertTrue();

        var addData = 2;
        var result = data.writeLong(addData);
        console.info("SUB_Softbus_IPC_MessageParcel_0600:run writeInt is success, result is " + result);
        expect(result == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0600: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0600---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0700
     * @tc.name    Call the setcapacity interface to set the capacity of messageparcel
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0700", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0700---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0700: create object successfully.");

        var size = 64;
        var setResult = data.setCapacity(size);
        console.info("SUB_Softbus_IPC_MessageParcel_0700:run setSize success, result is " + setResult);
        expect(setResult == true).assertTrue();

        var addData = 1;
        var result = data.writeInt(addData);
        console.info("SUB_Softbus_IPC_MessageParcel_0700:run writeInt is success, result is " + result);
        expect(result == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0700: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0700---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0800
     * @tc.name    Call the setcapacity interface to set the capacity of messageparcel. 
     *             The write data capacity is inconsistent with the set value
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0800", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0800---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0800: create object successfully.");

        var size = 4;
        var setResult = data.setCapacity(size);
        console.info("SUB_Softbus_IPC_MessageParcel_0800:run setSize success, result is " + setResult);
        expect(setResult == true).assertTrue();

        var addData = [1, 2, 3, 4, 5, 6, 7, 8];
        var result = data.writeIntArray(addData);
        console.info("SUB_Softbus_IPC_MessageParcel_0800:run writeInt is success, result is " + result);
        expect(result == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0800: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0800---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_0900
     * @tc.name    Empty object to obtain the readable byte space, read location, 
     *             writable byte space and write location information of messageparcel
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_0900", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_0900---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_0900: create object successfully.");

        var result1 = data.getWritableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_0900: run getWritableBytes is success, result is " + result1);
        expect(result1 == 0).assertTrue();

        var result2 = data.getReadableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_0900: run getReadableBytes is success, result is " + result2);
        expect(result2 == 0).assertTrue();

        var result3 = data.getReadPosition();
        console.info("SUB_Softbus_IPC_MessageParcel_0900: run getReadPosition is success, result is " + result2);
        expect(result3 == 0).assertTrue();

        var result4 = data.getWritePosition();
        console.info("SUB_Softbus_IPC_MessageParcel_0900: run getWritePosition is success, result is " + result2);
        expect(result4 == 0).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_0900: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_0900---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1000
     * @tc.name    Create an object and write data to obtain the readable byte space, read location, 
     *             writable byte space and write location information of messageparcel
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1000", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1000---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1000: create object successfully.");

        var dataInt = 1;
        var resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1000: run writeInt success, result is " + resultInt);

        var dataLong = 2;
        var resultLong = data.writeLong(dataLong);
        console.info("SUB_Softbus_IPC_MessageParcel_1000: run writeLong success, result is " + resultLong);

        var result1 = data.getWritableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_1000: run getWritableBytes is success, result is " + result1);
        expect(result1 == 52).assertTrue();

        var result2 = data.getReadableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_1000: run getReadableBytes is success, result is " + result2);
        expect(result2 == 12).assertTrue();

        var result3 = data.getReadPosition();
        console.info("SUB_Softbus_IPC_MessageParcel_1000: run getReadPosition is success, result is " + result3);
        expect(result3 == 0).assertTrue();

        var result4 = data.getWritePosition();
        console.info("SUB_Softbus_IPC_MessageParcel_1000: run getWritePosition is success, result is " + result4);
        expect(result4 == 12).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1000: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1000---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1100
     * @tc.name    Call rewindread interface to offset the read position to the specified position
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1100", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1100---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        expect(data.getWritableBytes() == 0).assertTrue();
        expect(data.getReadableBytes() == 0).assertTrue();
        expect(data.getReadPosition() == 0).assertTrue();
        expect(data.getWritePosition() == 0).assertTrue();

        var dataInt = 1;
        var resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run writeInt success, result is " + resultInt);
        var dataLong = 2;
        var resultLong = data.writeLong(dataLong);
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run writeLong success, result is " + resultLong);

        expect(data.getWritableBytes() == 52).assertTrue();
        expect(data.getReadableBytes() == 12).assertTrue();
        expect(data.getReadPosition() == 0).assertTrue();
        expect(data.getWritePosition() == 12).assertTrue();

        var readIntData = data.readInt();
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run readInt is success, result is " + readIntData);
        expect(readIntData == dataInt).assertTrue();

        var writePosition = 0;
        var writeResult = data.rewindWrite(writePosition);
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run rewindWrite is success, result is " + writeResult);
        expect(writeResult == true).assertTrue();

        expect(data.getWritePosition() == 0).assertTrue();
        dataInt = 3;
        resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run writeInt success, result is " + resultInt);

        var readPosition = 0;
        var readResult = data.rewindRead(readPosition);
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run rewindWrite is success, result is " + readResult);
        expect(readResult == true).assertTrue();

        readIntData = data.readInt();
        console.info("SUB_Softbus_IPC_MessageParcel_1100: run readInt is success, result is " + readIntData);
        expect(readIntData == dataInt).assertTrue();
        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1100: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1100---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1200
     * @tc.name    The rewindread interface is called to re offset the read position to the specified position.
     *             The specified position is out of range
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1200", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1200---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: create object successfully.");

        var result1 = data.getWritableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getWritableBytes success, result is " + result1);
        expect(result1 == 0).assertTrue();
        var result2 = data.getReadableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getReadableBytes success, result is " + result2);
        expect(result2 == 0).assertTrue();
        var result3 = data.getReadPosition();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getReadPosition success, result is " + result3);
        expect(result3 == 0).assertTrue();
        var result4 = data.getWritePosition();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getWritePosition success, result is " + result4);
        expect(result4 == 0).assertTrue();

        var dataInt = 1;
        var resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run writeInt success, result is " + resultInt);
        expect(resultInt == true).assertTrue();
        var dataLong = 2;
        var resultLong = data.writeLong(dataLong);
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run writeLong success, result is " + resultLong);
        expect(resultLong == true).assertTrue();

        result1 = data.getWritableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getWritableBytes is success, result is " + result1);
        expect(result1 == 52).assertTrue();
        result2 = data.getReadableBytes();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getReadableBytes is success, result is " + result2);
        expect(result2 == 12).assertTrue();
        result3 = data.getReadPosition();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getReadPosition is success, result is " + result3);
        expect(result3 == 0).assertTrue();
        result4 = data.getWritePosition();
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run getWritePosition is success, result is " + result4);
        expect(result4 == 12).assertTrue();

        var readPosition = 100;
        var readResult = data.rewindRead(readPosition);
        console.info("SUB_Softbus_IPC_MessageParcel_1200: run rewindRead is success, result is " + readResult);
        expect(readResult == false).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1200: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1200---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1300
     * @tc.name    Call rewindwrite and the interface offsets the write position to the specified position
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1300", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1300---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1300: create object successfully.");

        var dataInt = 1;
        var resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1300: run writeInt success, result is " + resultInt);
        expect(resultInt == true).assertTrue();

        var readIntData = data.readInt();
        console.info("SUB_Softbus_IPC_MessageParcel_1300: run readInt success, result is " + readIntData);
        expect(readIntData == dataInt).assertTrue();

        var writePosition = 0;
        var rewindWriteResult = data.rewindWrite(writePosition);
        console.info("SUB_Softbus_IPC_MessageParcel_1300: run rewindWrite success, result is " + rewindWriteResult);
        expect(rewindWriteResult == true).assertTrue();

        dataInt = 3;
        resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1300: run writeInt success, result is " + resultInt);
        expect(resultInt == true).assertTrue();

        var readPosition = 0;
        var rewindReadResult = data.rewindRead(readPosition);
        console.info("SUB_Softbus_IPC_MessageParcel_1300: run rewindRead success, result is " + rewindReadResult);
        expect(rewindReadResult == true);

        readIntData = data.readInt();
        console.info("SUB_Softbus_IPC_MessageParcel_1300: run readInt success, result is " + readIntData);
        expect(readIntData == dataInt).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1300: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1300---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1400
     * @tc.name    Call rewindwrite and the interface offsets the write position to the specified position.
     *             The specified position is out of range
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1400", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1400---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1400: create object successfully.");

        var dataInt = 1;
        var resultInt = data.writeInt(dataInt);
        console.info("SUB_Softbus_IPC_MessageParcel_1400: run writeInt success, result is " + resultInt);
        expect(resultInt == true).assertTrue();

        var readIntData = data.readInt();
        console.info("SUB_Softbus_IPC_MessageParcel_1400: run readInt success, result is " + readIntData);
        expect(readIntData == dataInt).assertTrue();

        var writePosition = 99;
        var rewindWriteResult = data.rewindWrite(writePosition);
        console.info("SUB_Softbus_IPC_MessageParcel_1400: run rewindWrite failed, result is " + rewindWriteResult);
        expect(rewindWriteResult == false).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1400: error = " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1400---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1500
     * @tc.name    Call the writeshortarray interface, write the array to the messageparcel instance, 
     *             and call readshortarray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1500", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1500---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1500: create object successfully.");

        var wShortArryData = [3, 5, 9];
        var writeShortArrayResult = data.writeShortArray(wShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1500: run writeShortArray success, result is "
                     + writeShortArrayResult);
        expect(writeShortArrayResult == true).assertTrue();

        var rShortArryData = data.readShortArray();
        console.info("SUB_Softbus_IPC_MessageParcel_1500: run readShortArray is success, result is "
                     + rShortArryData);
        expect(wShortArryData[0] == rShortArryData[0]).assertTrue();
        expect(wShortArryData[1] == rShortArryData[1]).assertTrue();
        expect(wShortArryData[2] == rShortArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1500: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1500---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1600
     * @tc.name    Call the writeshortarray interface, write the short integer array to the messageparcel instance, 
     *             and call readshortarray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1600", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1600---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1600: create object successfully.");

        var wShortArryData = [3, 5, 9];
        var writeShortArrayResult = data.writeShortArray(wShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1600: run writeShortArray success, result is "
                     + writeShortArrayResult);
        expect(writeShortArrayResult == true).assertTrue();

        var rShortArryData = [];
        data.readShortArray(rShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1600: run readShortArray is success, result is "
                     + rShortArryData);
        expect(wShortArryData[0] == rShortArryData[0]).assertTrue();
        expect(wShortArryData[1] == rShortArryData[1]).assertTrue();
        expect(wShortArryData[2] == rShortArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1600: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1600---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1700
     * @tc.name    Writeshortarray interface, boundary value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1700", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1700---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1700: create object successfully.");

        var wShortArryData = [-32768, 0, 1, 2, 32767];
        var writeShortArrayResult = data.writeShortArray(wShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1700: run writeShortArray success, result is "
                     + writeShortArrayResult);
        expect(writeShortArrayResult == true).assertTrue();

        var rShortArryData = [];
        data.readShortArray(rShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1700: run readShortArray is success, result is "
                     + rShortArryData);
        expect(wShortArryData[0] == rShortArryData[0]).assertTrue();
        expect(wShortArryData[1] == rShortArryData[1]).assertTrue();
        expect(wShortArryData[2] == rShortArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1700: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1700---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1800
     * @tc.name    Writeshortarray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1800", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1800---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1800: create object successfully.");

        var wShortArryData = [-32768, 0, 1, 2, 32767];
        var writeShortArrayResult = data.writeShortArray(wShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1800: run writeShortArray success, result is "
                     + writeShortArrayResult);
        expect(writeShortArrayResult == true).assertTrue();

        var errorShortArryData = [-32769, 32768];
        var errorWriteShortArrayResult = data.writeShortArray(errorShortArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1800: run writeShortArray success, result is "
                     + errorWriteShortArrayResult);
        expect(errorWriteShortArrayResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1800: error = " + error);
    }

    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1800---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_1900
     * @tc.name    Call the writelongarray interface, write the long integer array to the messageparcel instance, 
     *             and call readlongarray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_1900", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_1900---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_1900: create object successfully.");

        var wLongArryData = [3276826, 1234567, 99999999];
        var writeLongArrayResult = data.writeLongArray(wLongArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_1900: run writeShortArray success, result is "
                     + writeLongArrayResult);
        expect(writeLongArrayResult == true).assertTrue();

        var rLongArryData = data.readLongArray();
        console.info("SUB_Softbus_IPC_MessageParcel_1900: run readShortArray is success, result is "
                     + rLongArryData);
        expect(rLongArryData[0] == wLongArryData[0]).assertTrue();
        expect(rLongArryData[1] == wLongArryData[1]).assertTrue();
        expect(rLongArryData[2] == wLongArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_1900: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_1900---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2000
     * @tc.name    Call the writelongarray interface, write the long integer array to the messageparcel instance, 
     *             and call readlongarray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2000", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2000---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2000: create object successfully.");

        var wLongArryData = [3276826, 1234567, 99999999];
        var writeLongArrayResult = data.writeLongArray(wLongArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2000: run writeShortArray success, result is "
                     + writeLongArrayResult);
        expect(writeLongArrayResult == true).assertTrue();

        var rLongArryData = [];
        data.readLongArray(rLongArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2000: run readShortArray is success, result is "
                     + rLongArryData);
        expect(rLongArryData[0] == wLongArryData[0]).assertTrue();
        expect(rLongArryData[1] == wLongArryData[1]).assertTrue();
        expect(rLongArryData[2] == wLongArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2000: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2000---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2100
     * @tc.name    Writelongarray interface, boundary value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2100", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2100---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2100: create object successfully.");

        var wLongArryData = [-2147483647, 0, 1, 2, 2147483647];
        var writeLongArrayResult = data.writeLongArray(wLongArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2100: run writeShortArray success, result is "
                     + writeLongArrayResult);
        expect(writeLongArrayResult == true).assertTrue();

        var rLongArryData = data.readLongArray();
        console.info("SUB_Softbus_IPC_MessageParcel_2100: run readShortArray is success, result is "
                     + rLongArryData);
        expect(rLongArryData[0] == wLongArryData[0]).assertTrue();
        expect(rLongArryData[1] == wLongArryData[1]).assertTrue();
        expect(rLongArryData[2] == wLongArryData[2]).assertTrue();
        expect(rLongArryData[3] == wLongArryData[3]).assertTrue();
        expect(rLongArryData[4] == wLongArryData[4]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2100: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2100---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2200
     * @tc.name    Writelongarray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2200", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2200---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2200: create object successfully.");

        var errorLongArryData = [-2147483649, 0, 1, 2, 2147483649];
        var errorWriteLongArrayResult = data.writeLongArray(errorLongArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2200: run writeShortArray success, result is "
                     + errorWriteLongArrayResult);
        expect(errorWriteLongArrayResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2200: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2200---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2300
     * @tc.name    Call the writedoublearray interface, write the array to the messageparcel instance, 
     *             and call readdoublearra to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2300", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2300---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2300: create object successfully.");

        var wDoubleArryData = [1.2, 235.67, 99.76];
        var writeDoubleArrayResult = data.writeDoubleArray(wDoubleArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2300: run writeShortArray success, result is "
                     + writeDoubleArrayResult);
        expect(writeDoubleArrayResult == true).assertTrue();

        var rDoubleArryData = data.readDoubleArray();
        console.info("SUB_Softbus_IPC_MessageParcel_2300: run readShortArray is success, result is "
                     + rDoubleArryData);
        expect(rDoubleArryData[0] == wDoubleArryData[0]).assertTrue();
        expect(rDoubleArryData[1] == wDoubleArryData[1]).assertTrue();
        expect(rDoubleArryData[2] == wDoubleArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2300: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2300---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2400
     * @tc.name    Call the writedoublearray interface, write the array to the messageparcel instance, 
     *             and call readdoublearra (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2400", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2400---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2400: create object successfully.");

        var wDoubleArryData = [1.2, 235.67, 99.76];
        var writeDoubleArrayResult = data.writeDoubleArray(wDoubleArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2400: run writeShortArray success, result is "
                     + writeDoubleArrayResult);
        expect(writeDoubleArrayResult == true).assertTrue();

        var rDoubleArryData = [];
        data.readDoubleArray(rDoubleArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2400: run readShortArray is success, result is "
                     + rDoubleArryData);
        expect(rDoubleArryData[0] == wDoubleArryData[0]).assertTrue();
        expect(rDoubleArryData[1] == wDoubleArryData[1]).assertTrue();
        expect(rDoubleArryData[2] == wDoubleArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2400: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2400---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2500
     * @tc.name    Writedoublearray interface, boundary value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2500", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2500---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2500: create object successfully.");

        var wDoubleArryData = [-1235453.2, 235.67, 9987659.76];
        var writeDoubleArrayResult = data.writeDoubleArray(wDoubleArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2500: run writeShortArray success, result is "
                     + writeDoubleArrayResult);
        expect(writeDoubleArrayResult == true).assertTrue();

        var rDoubleArryData = data.readDoubleArray();
        console.info("SUB_Softbus_IPC_MessageParcel_2500: run readShortArray is success, result is "
                     + rDoubleArryData);
        expect(rDoubleArryData[0] == wDoubleArryData[0]).assertTrue();
        expect(rDoubleArryData[1] == wDoubleArryData[1]).assertTrue();
        expect(rDoubleArryData[2] == wDoubleArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2500: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2500---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2600
     * @tc.name    Writedoublearray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2600", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2600---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2600: create object successfully.");

        var errorDoubleArryData = [-12354883737337373873853.2, 235.67, 99999999999999993737373773987659.76];
        var errorWriteDoubleArrayResult = data.writeDoubleArray(errorDoubleArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2600: run writeDoubleArray success, result is "
                     + errorWriteDoubleArrayResult);
        expect(errorWriteDoubleArrayResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2600: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2600---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2700
     * @tc.name    Call the writeboolean array interface, write the array to the messageparcel instance, 
     *             and call readboolean array to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2700", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2700---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2700: create object successfully.");

        var wBooleanArryData = [true, false, false];
        var writeBooleanArrayResult = data.writeBooleanArray(wBooleanArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2700: run writeShortArray success, result is "
                     + writeBooleanArrayResult);
        expect(writeBooleanArrayResult == true).assertTrue();

        var rBooleanArryData = data.readBooleanArray();
        console.info("SUB_Softbus_IPC_MessageParcel_2700: run readShortArray is success, result is "
                     + rBooleanArryData);
        expect(rBooleanArryData[0] == wBooleanArryData[0]).assertTrue();
        expect(rBooleanArryData[1] == wBooleanArryData[1]).assertTrue();
        expect(rBooleanArryData[2] == wBooleanArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2700: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2700---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2800
     * @tc.name    Call the writeboolean array interface, write the array to the messageparcel instance, 
     *             and call readboolean array (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2800", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2800---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2800: create object successfully.");

        var wBooleanArryData = [true, false, false];
        var writeBooleanArrayResult = data.writeBooleanArray(wBooleanArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2800: run writeShortArray success, result is "
                     + writeBooleanArrayResult);
        expect(writeBooleanArrayResult == true).assertTrue();

        var rBooleanArryData = [];
        data.readBooleanArray(rBooleanArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2800: run readShortArray is success, result is "
                     + rBooleanArryData);
        expect(rBooleanArryData[0] == wBooleanArryData[0]).assertTrue();
        expect(rBooleanArryData[1] == wBooleanArryData[1]).assertTrue();
        expect(rBooleanArryData[2] == wBooleanArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2800: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2800---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_2900
     * @tc.name    Writeboolean array interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_2900", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_2900---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_2900: create object successfully.");

        var errorBooleanArryData = [true, 'abc', false];
        var errorWriteBooleanArrayResult = data.writeBooleanArray(errorBooleanArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_2900: run writeShortArray success, result is "
                     + errorWriteBooleanArrayResult);
        expect(errorWriteBooleanArrayResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_2900: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_2900---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3000
     * @tc.name    Call the writechararray interface, write the array to the messageparcel instance, 
     *             and call readchararray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3000", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3000---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_3000: create object successfully.");

        var wCharArryData = [10, 20, 30];
        var writeCharArrayResult = data.writeCharArray(wCharArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3000: run writeShortArray success, result is "
                     + writeCharArrayResult);
        expect(writeCharArrayResult == true).assertTrue();

        var rCharArryData = data.readCharArray();
        console.info("SUB_Softbus_IPC_MessageParcel_3000: run readShortArray is success, result is "
                     + rCharArryData);
        expect(rCharArryData[0] == wCharArryData[0]).assertTrue();
        expect(rCharArryData[1] == wCharArryData[1]).assertTrue();
        expect(rCharArryData[2] == wCharArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_3000: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3000---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3100
     * @tc.name    Call the writechararray interface, write the array to the messageparcel instance, 
     *             and call readchararray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3100", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3100---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_3100: create object successfully.");

        var wCharArryData = [10, 20, 30];
        var writeCharArrayResult = data.writeCharArray(wCharArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3100: run writeShortArray success, result is "
                     + writeCharArrayResult);
        expect(writeCharArrayResult == true).assertTrue();


        var rCharArryData = [];
        data.readCharArray(rCharArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3100: run readShortArray is success, result is "
                     + rCharArryData);
        expect(rCharArryData[0] == wCharArryData[0]).assertTrue();
        expect(rCharArryData[1] == wCharArryData[1]).assertTrue();
        expect(rCharArryData[2] == wCharArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_3100: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3100---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3200
     * @tc.name    Writechararray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3200", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3200---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_3200: create object successfully.");

        var errorCharArryData = ['e', 'asfgdgdtu', 'a'];
        var errorWriteCharArrayResult = data.writeCharArray(errorCharArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3200: run writeShortArray success, result is "
                     + errorWriteCharArrayResult);
        expect(errorWriteCharArrayResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_3200: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3200---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3300
     * @tc.name    Call the writestringarray interface, write the array to the messageparcel instance, 
     *             and call readstringarray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3300", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3300---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_3300: create object successfully.");

        var wStringArryData = ['abc', 'hello', 'beauty'];
        var writeStringArrayResult = data.writeStringArray(wStringArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3300: run writeShortArray success, result is "
                     + writeStringArrayResult);
        expect(writeStringArrayResult == true).assertTrue();

        var rStringArryData = data.readStringArray();
        console.info("SUB_Softbus_IPC_MessageParcel_3300: run readShortArray is success, result is "
                     + rStringArryData);
        expect(rStringArryData[0] == wStringArryData[0]).assertTrue();
        expect(rStringArryData[1] == wStringArryData[1]).assertTrue();
        expect(rStringArryData[2] == wStringArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_3300: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3300---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3400
     * @tc.name    Call the writestringarray interface, write the array to the messageparcel instance, 
     *             and call readstringarray() to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3400", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3400---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_3400: create object successfully.");

        var wStringArryData = ['abc', 'hello', 'beauty'];
        var writeStringArrayResult = data.writeStringArray(wStringArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3400: run writeShortArray success, result is "
                     + writeStringArrayResult);
        expect(writeStringArrayResult == true).assertTrue();


        var rStringArryData = [];
        reply.readStringArray(rStringArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3400: run readShortArray is success, result is "
                     + rStringArryData);
        expect(rStringArryData[0] == wStringArryData[0]).assertTrue();
        expect(rStringArryData[1] == wStringArryData[1]).assertTrue();
        expect(rStringArryData[2] == wStringArryData[2]).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_3400: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3400---------------------------");
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3500
     * @tc.name    Writestringarray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3500", 0, function(){
    console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3500---------------------------");
    try{
        var data = rpc.MessageParcel.create();
        console.info("SUB_Softbus_IPC_MessageParcel_3500: create object successfully.");

        var errorStringArryData = ['abc' , '123' , 'beauty'];
        var errorWriteStringArrayResult = data.writeStringArray(errorStringArryData);
        console.info("SUB_Softbus_IPC_MessageParcel_3500: run writeStringArray success, result is "
                     + errorWriteStringArrayResult);
        expect(errorWriteStringArrayResult == true).assertTrue();

        data.reclaim();
    } catch (error) {
        console.info("SUB_Softbus_IPC_MessageParcel_3500: error " + error);
    }
    console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3500---------------------------");
    });


J
jiyong 已提交
1452 1453 1454 1455 1456 1457 1458 1459
    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3600
     * @tc.name    Call the writebytearray interface, write the array to the messageparcel instance,
     *             and call readbytearray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3600", 0, async function(done){
Z
zhangpa2021 已提交
1460
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3600---------------------------");
J
jiyong 已提交
1461 1462
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1463
            console.info("SUB_Softbus_IPC_MessageParcel_3600: create object successfully.");
J
jiyong 已提交
1464 1465
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
Z
zhangpa2021 已提交
1466
            let ByteArrayVar = [1, 2, 3, 4, 5];
J
jiyong 已提交
1467
            var writeShortArrayResult = data.writeByteArray(ByteArrayVar);
Z
zhangpa2021 已提交
1468
            console.info("SUB_Softbus_IPC_MessageParcel_3600: run writeShortArray success, result is "
J
jiyong 已提交
1469 1470 1471 1472 1473
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1474
                console.info("SUB_Softbus_IPC_MessageParcel_3600: gIRemoteObject undefined");
J
jiyong 已提交
1475
            }
Z
zhangpa2021 已提交
1476 1477
            gIRemoteObject.sendRequest(CODE_WRITE_BYTEARRAY, data, reply, option).then((result) => {
                console.info("SUB_Softbus_IPC_MessageParcel_3600: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1478
                expect(result.errCode == 0).assertTrue();
J
jiyong 已提交
1479 1480

                var shortArryDataReply = result.reply.readByteArray();
Z
zhangpa2021 已提交
1481
                console.info("SUB_Softbus_IPC_MessageParcel_3600: run readByteArray is success, result is "
J
jiyong 已提交
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
                             + shortArryDataReply);
                expect(shortArryDataReply[0] == ByteArrayVar[0]).assertTrue();
                expect(shortArryDataReply[1] == ByteArrayVar[1]).assertTrue();
                expect(shortArryDataReply[2] == ByteArrayVar[2]).assertTrue();
                expect(shortArryDataReply[3] == ByteArrayVar[3]).assertTrue();
                expect(shortArryDataReply[4] == ByteArrayVar[4]).assertTrue();
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1493
            console.info("SUB_Softbus_IPC_MessageParcel_3600: error " +error);
J
jiyong 已提交
1494
        }
Z
zhangpa2021 已提交
1495
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3600---------------------------");
J
jiyong 已提交
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3700
     * @tc.name    Call the writebytearray interface, write the array to the messageparcel instance,
     *             and call readbytearray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3700", 0, async function(done){
Z
zhangpa2021 已提交
1506
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3700---------------------------");
J
jiyong 已提交
1507 1508
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1509
            console.info("SUB_Softbus_IPC_MessageParcel_3700: create object successfully.");
J
jiyong 已提交
1510 1511 1512
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

Z
zhangpa2021 已提交
1513
            let ByteArrayVar = [1, 2, 3, 4, 5];
J
jiyong 已提交
1514
            var writeShortArrayResult = data.writeByteArray(ByteArrayVar);
Z
zhangpa2021 已提交
1515
            console.info("SUB_Softbus_IPC_MessageParcel_3700: run writeShortArray success, result is "
J
jiyong 已提交
1516 1517 1518 1519 1520
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1521
                console.info("SUB_Softbus_IPC_MessageParcel_3700: gIRemoteObject undefined");
J
jiyong 已提交
1522
            }
Z
zhangpa2021 已提交
1523 1524
            gIRemoteObject.sendRequest(CODE_WRITE_BYTEARRAY, data, reply, option).then((result) => {
                console.info("SUB_Softbus_IPC_MessageParcel_3700: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1525

Z
zhangpa2021 已提交
1526
                var newArr = new Array(5)
J
jiyong 已提交
1527
                result.reply.readByteArray(newArr);
Z
zhangpa2021 已提交
1528
                console.info("SUB_Softbus_IPC_MessageParcel_3700: run readByteArray is success, result is "
J
jiyong 已提交
1529
                + newArr);
J
jiyong 已提交
1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
                expect(newArr[0] == ByteArrayVar[0]).assertTrue()
                expect(newArr[1] == ByteArrayVar[1]).assertTrue()
                expect(newArr[2] == ByteArrayVar[2]).assertTrue()
                expect(newArr[3] == ByteArrayVar[3]).assertTrue()
                expect(newArr[4] == ByteArrayVar[4]).assertTrue()
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1541
            console.info("SUB_Softbus_IPC_MessageParcel_3700: error " +error);
J
jiyong 已提交
1542
        }
Z
zhangpa2021 已提交
1543
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3700---------------------------");
J
jiyong 已提交
1544 1545 1546 1547 1548 1549 1550 1551 1552
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3800
     * @tc.name    Writebytearray interface, boundary value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_3800", 0, async function(done){
Z
zhangpa2021 已提交
1553
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3800---------------------------");
J
jiyong 已提交
1554 1555
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1556
            console.info("SUB_Softbus_IPC_MessageParcel_3800: create object successfully.");
J
jiyong 已提交
1557 1558 1559
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

Z
zhangpa2021 已提交
1560
            let ByteArrayVar = [-128, 0, 1, 2, 127];
J
jiyong 已提交
1561
            var writeShortArrayResult = data.writeByteArray(ByteArrayVar);
Z
zhangpa2021 已提交
1562
            console.info("SUB_Softbus_IPC_MessageParcel_3800: run writeShortArray success, result is "
J
jiyong 已提交
1563
            + writeShortArrayResult);
J
jiyong 已提交
1564 1565
            expect(writeShortArrayResult == true).assertTrue();

J
jiyong 已提交
1566 1567
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1568
                console.info("SUB_Softbus_IPC_MessageParcel_3800: gIRemoteObject undefined");
J
jiyong 已提交
1569
            }
Z
zhangpa2021 已提交
1570 1571
            gIRemoteObject.sendRequest(CODE_WRITE_BYTEARRAY, data, reply, option).then((result) => {
                console.info("SUB_Softbus_IPC_MessageParcel_3800: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1572

Z
zhangpa2021 已提交
1573
                var newArr = new Array(5)
J
jiyong 已提交
1574
                result.reply.readByteArray(newArr);
Z
zhangpa2021 已提交
1575
                console.info("SUB_Softbus_IPC_MessageParcel_3800: run readByteArray is success, result is "
J
jiyong 已提交
1576 1577 1578 1579 1580 1581 1582
                + newArr);
                expect(newArr[0] == ByteArrayVar[0]).assertTrue()
                expect(newArr[1] == ByteArrayVar[1]).assertTrue()
                expect(newArr[2] == ByteArrayVar[2]).assertTrue()
                expect(newArr[3] == ByteArrayVar[3]).assertTrue()
                expect(newArr[4] == ByteArrayVar[4]).assertTrue()
            });
J
jiyong 已提交
1583 1584 1585 1586 1587

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1588
            console.info("SUB_Softbus_IPC_MessageParcel_3800: error " +error);
J
jiyong 已提交
1589
        }
Z
zhangpa2021 已提交
1590
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3800---------------------------");
J
jiyong 已提交
1591 1592 1593 1594 1595 1596 1597 1598
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_3900
     * @tc.name    Writebytearray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
1599
    it("SUB_Softbus_IPC_MessageParcel_3900", 0, async function(done){
Z
zhangpa2021 已提交
1600
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_3900---------------------------");
J
jiyong 已提交
1601 1602
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1603
            console.info("SUB_Softbus_IPC_MessageParcel_3900: create object successfully.");
J
jiyong 已提交
1604 1605
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
Z
zhangpa2021 已提交
1606
            let ByteArrayVar = [-129, 0, 1, 2, 127];
J
jiyong 已提交
1607
            var writeShortArrayResult = data.writeByteArray(ByteArrayVar);
Z
zhangpa2021 已提交
1608
            console.info("SUB_Softbus_IPC_MessageParcel_3900: run writeShortArray success, result is "
J
jiyong 已提交
1609 1610 1611 1612 1613
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1614
                console.info("SUB_Softbus_IPC_MessageParcel_3900: gIRemoteObject undefined");
J
jiyong 已提交
1615
            }
Z
zhangpa2021 已提交
1616 1617
            gIRemoteObject.sendRequest(CODE_WRITE_BYTEARRAY, data, reply, option).then((result) => {
                console.info("SUB_Softbus_IPC_MessageParcel_3900: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1618 1619 1620
                expect(result.errCode == 0).assertTrue();

                var shortArryDataReply = result.reply.readByteArray();
Z
zhangpa2021 已提交
1621
                console.info("SUB_Softbus_IPC_MessageParcel_3900: run readByteArray is success, result is "
J
jiyong 已提交
1622 1623 1624 1625 1626 1627 1628
                + shortArryDataReply);
                expect(shortArryDataReply[0] == 127).assertTrue();
                expect(shortArryDataReply[1] == ByteArrayVar[1]).assertTrue();
                expect(shortArryDataReply[2] == ByteArrayVar[2]).assertTrue();
                expect(shortArryDataReply[3] == ByteArrayVar[3]).assertTrue();
                expect(shortArryDataReply[4] == ByteArrayVar[4]).assertTrue();
            });
J
jiyong 已提交
1629
            data.reclaim();
J
jiyong 已提交
1630 1631
            reply.reclaim();
            done();
J
jiyong 已提交
1632
        } catch (error) {
Z
zhangpa2021 已提交
1633
            console.info("SUB_Softbus_IPC_MessageParcel_3900: error " +error);
J
jiyong 已提交
1634
        }
Z
zhangpa2021 已提交
1635
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_3900---------------------------");
J
jiyong 已提交
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4000
     * @tc.name    Call the writeintarray interface, write the array to the messageparcel instance,
     *             and call readintarray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4000", 0, async function(done){
Z
zhangpa2021 已提交
1646
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4000---------------------------");
J
jiyong 已提交
1647 1648
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1649
            console.info("SUB_Softbus_IPC_MessageParcel_4000: create object successfully.");
J
jiyong 已提交
1650 1651 1652 1653 1654
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            var intArryData = [100, 111, 112];
            var writeShortArrayResult = data.writeIntArray(intArryData);
Z
zhangpa2021 已提交
1655
            console.info("SUB_Softbus_IPC_MessageParcel_4000: run writeShortArray success, result is "
J
jiyong 已提交
1656 1657 1658 1659 1660
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1661
                console.info("SUB_Softbus_IPC_MessageParcel_4000: gIRemoteObject undefined");
J
jiyong 已提交
1662 1663
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_INTARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1664
                console.info("SUB_Softbus_IPC_MessageParcel_4000: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1665 1666
                expect(result.errCode == 0).assertTrue();

J
jiyong 已提交
1667
                var shortArryDataReply = result.reply.readIntArray();
Z
zhangpa2021 已提交
1668
                console.info("SUB_Softbus_IPC_MessageParcel_4000: run readByteArray is success, result is "
J
jiyong 已提交
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678
                + shortArryDataReply);
                expect(shortArryDataReply[0] == intArryData[0]).assertTrue();
                expect(shortArryDataReply[1] == intArryData[1]).assertTrue();
                expect(shortArryDataReply[2] == intArryData[2]).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1679
            console.info("SUB_Softbus_IPC_MessageParcel_4000: error " + error);
J
jiyong 已提交
1680
        }
Z
zhangpa2021 已提交
1681
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4000---------------------------");
J
jiyong 已提交
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4100
     * @tc.name    Call the writeintarray interface, write the array to the messageparcel instance,
     *             and call readintarray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4100", 0, async function(done){
Z
zhangpa2021 已提交
1692
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4100---------------------------");
J
jiyong 已提交
1693 1694
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1695
            console.info("SUB_Softbus_IPC_MessageParcel_4100: create object successfully.");
J
jiyong 已提交
1696 1697 1698 1699 1700
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            var intArryData = [100, 111, 112];
            var writeShortArrayResult = data.writeIntArray(intArryData);
Z
zhangpa2021 已提交
1701
            console.info("SUB_Softbus_IPC_MessageParcel_4100: run writeShortArray success, result is "
J
jiyong 已提交
1702 1703 1704 1705 1706
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1707
                console.info("SUB_Softbus_IPC_MessageParcel_4100: gIRemoteObject undefined");
J
jiyong 已提交
1708 1709
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_INTARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1710
                console.info("SUB_Softbus_IPC_MessageParcel_4100: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1711
                expect(result.errCode == 0).assertTrue();
J
jiyong 已提交
1712 1713 1714

                var newArr = []
                result.reply.readIntArray(newArr);
Z
zhangpa2021 已提交
1715
                console.info("SUB_Softbus_IPC_MessageParcel_4100: run readIntArray is success, intArryDataReply is "
J
jiyong 已提交
1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
                + newArr);
                expect(newArr[0] == intArryData[0]).assertTrue();
                expect(newArr[1] == intArryData[1]).assertTrue();
                expect(newArr[2] == intArryData[2]).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1726
            console.info("SUB_Softbus_IPC_MessageParcel_4100: error " + error);
J
jiyong 已提交
1727
        }
Z
zhangpa2021 已提交
1728
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4100---------------------------");
J
jiyong 已提交
1729 1730 1731 1732 1733 1734 1735 1736 1737
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4200
     * @tc.name    Writeintarray interface, boundary value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4200", 0, async function(){
Z
zhangpa2021 已提交
1738
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4200---------------------------");
J
jiyong 已提交
1739 1740
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1741
            console.info("SUB_Softbus_IPC_MessageParcel_4200: create object successfully.");
J
jiyong 已提交
1742 1743
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
1744 1745

            var intArryData = [-2147483648, 0, 1, 2, 2147483647];
J
jiyong 已提交
1746
            var writeIntArrayResult = data.writeIntArray(intArryData);
Z
zhangpa2021 已提交
1747
            console.info("SUB_Softbus_IPC_MessageParcel_4200: run writeShortArray success, result is "
J
jiyong 已提交
1748 1749
            + writeIntArrayResult);
            expect(writeIntArrayResult == true).assertTrue();
J
jiyong 已提交
1750

J
jiyong 已提交
1751 1752
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1753
                console.info("SUB_Softbus_IPC_MessageParcel_4200: gIRemoteObject undefined");
J
jiyong 已提交
1754 1755
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_INTARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1756
                console.info("SUB_Softbus_IPC_MessageParcel_4200: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1757 1758 1759
                expect(result.errCode == 0).assertTrue();

                var shortArryDataReply = result.reply.readIntArray();
Z
zhangpa2021 已提交
1760
                console.info("SUB_Softbus_IPC_MessageParcel_4200: run readByteArray is success, result is "
J
jiyong 已提交
1761 1762 1763 1764 1765 1766 1767
                + shortArryDataReply);
                expect(shortArryDataReply[0] == intArryData[0]).assertTrue();
                expect(shortArryDataReply[1] == intArryData[1]).assertTrue();
                expect(shortArryDataReply[2] == intArryData[2]).assertTrue();
                expect(shortArryDataReply[3] == intArryData[3]).assertTrue();
                expect(shortArryDataReply[4] == intArryData[4]).assertTrue();
            });
J
jiyong 已提交
1768 1769 1770

            data.reclaim();
        } catch (error) {
Z
zhangpa2021 已提交
1771
            console.info("SUB_Softbus_IPC_MessageParcel_4200: error " + error);
J
jiyong 已提交
1772
        }
Z
zhangpa2021 已提交
1773
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4200---------------------------");
J
jiyong 已提交
1774 1775 1776 1777 1778 1779 1780 1781 1782
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4300
     * @tc.name    Writeintarray interface, illegal value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4300", 0, async function(){
Z
zhangpa2021 已提交
1783
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4300---------------------------");
J
jiyong 已提交
1784 1785
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1786
            console.info("SUB_Softbus_IPC_MessageParcel_4300: create object successfully.");
J
jiyong 已提交
1787 1788
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
1789 1790

            var intArryData = [-2147483649, 0, 1, 2, 2147483647];
J
jiyong 已提交
1791
            var writeIntArrayResult = data.writeIntArray(intArryData);
Z
zhangpa2021 已提交
1792
            console.info("SUB_Softbus_IPC_MessageParcel_4300: run writeShortArray success, result is "
J
jiyong 已提交
1793 1794
            + writeIntArrayResult);
            expect(writeIntArrayResult == true).assertTrue();
J
jiyong 已提交
1795

J
jiyong 已提交
1796 1797
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1798
                console.info("SUB_Softbus_IPC_MessageParcel_4300: gIRemoteObject undefined");
J
jiyong 已提交
1799 1800
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_INTARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1801
                console.info("SUB_Softbus_IPC_MessageParcel_4300: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1802 1803 1804
                expect(result.errCode == 0).assertTrue();

                var shortArryDataReply = result.reply.readIntArray();
Z
zhangpa2021 已提交
1805
                console.info("SUB_Softbus_IPC_MessageParcel_4300: run readByteArray is success, result is "
J
jiyong 已提交
1806 1807 1808 1809 1810 1811 1812
                + shortArryDataReply);
                expect(shortArryDataReply[0] == 2147483647).assertTrue();
                expect(shortArryDataReply[1] == intArryData[1]).assertTrue();
                expect(shortArryDataReply[2] == intArryData[2]).assertTrue();
                expect(shortArryDataReply[3] == intArryData[3]).assertTrue();
                expect(shortArryDataReply[4] == intArryData[4]).assertTrue();
            });
J
jiyong 已提交
1813 1814 1815

            data.reclaim();
        } catch (error) {
Z
zhangpa2021 已提交
1816
            console.info("SUB_Softbus_IPC_MessageParcel_4300: error " + error);
J
jiyong 已提交
1817
        }
Z
zhangpa2021 已提交
1818
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4300---------------------------");
J
jiyong 已提交
1819 1820 1821 1822 1823 1824 1825 1826 1827 1828
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4400
     * @tc.name    Call the writefloatarray interface, write the array to the messageparcel instance,
     *             and call readfloatarray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4400", 0, async function(done){
Z
zhangpa2021 已提交
1829
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4400---------------------------");
J
jiyong 已提交
1830 1831
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1832
            console.info("SUB_Softbus_IPC_MessageParcel_4400: create object successfully.");
J
jiyong 已提交
1833 1834 1835 1836 1837
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            var floatArryData = [1.2, 1.3, 1.4];
            var writeShortArrayResult = data.writeFloatArray(floatArryData);
Z
zhangpa2021 已提交
1838
            console.info("SUB_Softbus_IPC_MessageParcel_4400: run writeFloatArray success, result is "
J
jiyong 已提交
1839 1840 1841 1842 1843 1844
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();


            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1845
                console.info("SUB_Softbus_IPC_MessageParcel_4400: gIRemoteObject undefined");
J
jiyong 已提交
1846 1847
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_FLOATARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1848
                console.info("SUB_Softbus_IPC_MessageParcel_4400: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1849 1850 1851
                expect(result.errCode == 0).assertTrue();

                var floatArryDataReply = result.reply.readFloatArray();
Z
zhangpa2021 已提交
1852
                console.info("SUB_Softbus_IPC_MessageParcel_4400: run readFloatArray is success, floatArryDataReply is "
J
jiyong 已提交
1853 1854 1855 1856 1857 1858 1859 1860 1861 1862
                + floatArryDataReply);
                expect(floatArryDataReply[0] == floatArryData[0]).assertTrue();
                expect(floatArryDataReply[1] == floatArryData[1]).assertTrue();
                expect(floatArryDataReply[2] == floatArryData[2]).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1863
            console.info("SUB_Softbus_IPC_MessageParcel_4400: error " + error);
J
jiyong 已提交
1864
        }
Z
zhangpa2021 已提交
1865
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4400---------------------------");
J
jiyong 已提交
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4500
     * @tc.name    Call the writefloatarray interface, write the array to the messageparcel instance,
     *             and call readfloatarray (datain: number []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4500", 0, async function(done){
Z
zhangpa2021 已提交
1876
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4500---------------------------");
J
jiyong 已提交
1877 1878
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1879
            console.info("SUB_Softbus_IPC_MessageParcel_4500: create object successfully.");
J
jiyong 已提交
1880 1881 1882 1883 1884
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            var floatArryData = [1.2, 1.3, 1.4]
            var writeShortArrayResult = data.writeFloatArray(floatArryData);
Z
zhangpa2021 已提交
1885
            console.info("SUB_Softbus_IPC_MessageParcel_4500: run writeFloatArray success, result is "
J
jiyong 已提交
1886 1887 1888 1889 1890
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1891
                console.info("SUB_Softbus_IPC_MessageParcel_4500: gIRemoteObject undefined");
J
jiyong 已提交
1892 1893
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_FLOATARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1894
                console.info("SUB_Softbus_IPC_MessageParcel_4500: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1895 1896 1897 1898
                expect(result.errCode == 0).assertTrue();

                var newArr = []
                result.reply.readFloatArray(newArr);
Z
zhangpa2021 已提交
1899
                console.info("SUB_Softbus_IPC_MessageParcel_4500: readFloatArray is success, floatArryDataReply is "
J
jiyong 已提交
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
                + newArr);
                expect(newArr[0] == floatArryData[0]).assertTrue();
                expect(newArr[1] == floatArryData[1]).assertTrue();
                expect(newArr[2] == floatArryData[2]).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1910
            console.info("SUB_Softbus_IPC_MessageParcel_4500: error " +error);
J
jiyong 已提交
1911
        }
Z
zhangpa2021 已提交
1912
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4500---------------------------");
J
jiyong 已提交
1913 1914 1915 1916 1917 1918 1919 1920 1921
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4600
     * @tc.name    Writefloatarray interface, boundary value verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4600", 0, async function(done){
Z
zhangpa2021 已提交
1922
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4600---------------------------");
J
jiyong 已提交
1923 1924
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1925
            console.info("SUB_Softbus_IPC_MessageParcel_4600: create object successfully.");
J
jiyong 已提交
1926 1927 1928 1929 1930
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            var floatArryData = [-3.40E+38, 1.3, 3.40E+38];
            var writeShortArrayResult = data.writeFloatArray(floatArryData);
Z
zhangpa2021 已提交
1931
            console.info("SUB_Softbus_IPC_MessageParcel_4600: run writeFloatArray success, result is "
J
jiyong 已提交
1932 1933 1934
            + writeShortArrayResult);
            expect(writeShortArrayResult == true).assertTrue();

J
jiyong 已提交
1935 1936
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1937
                console.info("SUB_Softbus_IPC_MessageParcel_4600: gIRemoteObject undefined");
J
jiyong 已提交
1938 1939
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_FLOATARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1940
                console.info("SUB_Softbus_IPC_MessageParcel_4600: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1941
                expect(result.errCode == 0).assertTrue();
J
jiyong 已提交
1942

J
jiyong 已提交
1943
                var newArr = result.reply.readFloatArray();
Z
zhangpa2021 已提交
1944
                console.info("SUB_Softbus_IPC_MessageParcel_4600: run readFloatArray is success, floatArryDataReply is "
J
jiyong 已提交
1945 1946 1947 1948 1949
                + newArr);
                expect(newArr[0] == floatArryData[0]).assertTrue();
                expect(newArr[1] == floatArryData[1]).assertTrue();
                expect(newArr[2] == floatArryData[2]).assertTrue();
            });
J
jiyong 已提交
1950 1951 1952 1953
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
1954
            console.info("SUB_Softbus_IPC_MessageParcel_4600: error " +error);
J
jiyong 已提交
1955
        }
Z
zhangpa2021 已提交
1956
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4600---------------------------");
J
jiyong 已提交
1957 1958 1959 1960 1961 1962 1963 1964
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4700
     * @tc.name    Writefloatarray interface, illegal value validation
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
1965
    it("SUB_Softbus_IPC_MessageParcel_4700", 0, async function(done){
Z
zhangpa2021 已提交
1966
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4600---------------------------");
J
jiyong 已提交
1967 1968
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
1969
            console.info("SUB_Softbus_IPC_MessageParcel_4700: create object successfully.");
J
jiyong 已提交
1970 1971
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
1972 1973 1974

            var floatArryData = [-4.40E+38, 1.3, 3.40E+38];
            var writeShortArrayResult = data.writeFloatArray(floatArryData);
Z
zhangpa2021 已提交
1975
            console.info("SUB_Softbus_IPC_MessageParcel_4700: run writeFloatArray success, result is "
J
jiyong 已提交
1976
            + writeShortArrayResult);
J
jiyong 已提交
1977 1978 1979 1980
            expect(writeShortArrayResult == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
1981
                console.info("SUB_Softbus_IPC_MessageParcel_4700: gIRemoteObject undefined");
J
jiyong 已提交
1982 1983
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_FLOATARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
1984
                console.info("SUB_Softbus_IPC_MessageParcel_4700: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
1985
                expect(result.errCode == 0).assertTrue();
J
jiyong 已提交
1986

J
jiyong 已提交
1987
                var newArr = result.reply.readFloatArray();
Z
zhangpa2021 已提交
1988
                console.info("SUB_Softbus_IPC_MessageParcel_4700: run readFloatArray is success, floatArryDataReply is "
J
jiyong 已提交
1989 1990 1991 1992 1993
                + newArr);
                expect(newArr[0] == floatArryData[0]).assertTrue();
                expect(newArr[1] == floatArryData[1]).assertTrue();
                expect(newArr[2] == floatArryData[2]).assertTrue();
            });
J
jiyong 已提交
1994
            data.reclaim();
J
jiyong 已提交
1995 1996
            reply.reclaim();
            done();
J
jiyong 已提交
1997
        } catch (error) {
Z
zhangpa2021 已提交
1998
            console.info("SUB_Softbus_IPC_MessageParcel_4600: error " +error);
J
jiyong 已提交
1999
        }
Z
zhangpa2021 已提交
2000
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4600---------------------------");
J
jiyong 已提交
2001 2002
    });

J
jiyong 已提交
2003

J
jiyong 已提交
2004 2005 2006 2007 2008 2009 2010 2011
    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4800
     * @tc.name    Call the writeShort interface to write the short integer data to the messageparcel instance,
     *             and call readshort to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4800", 0, async function(done){
Z
zhangpa2021 已提交
2012
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4800---------------------------");
J
jiyong 已提交
2013 2014
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2015
            console.info("SUB_Softbus_IPC_MessageParcel_4800: create object successfully.");
J
jiyong 已提交
2016 2017 2018 2019 2020
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            var short = 8;
            var writeShor = data.writeShort(short);
Z
zhangpa2021 已提交
2021
            console.info("SUB_Softbus_IPC_MessageParcel_4800: run writeShort success, writeShor is " + writeShor);
J
jiyong 已提交
2022 2023 2024 2025 2026
            expect(writeShor == true).assertTrue();


            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2027
                console.info("SUB_Softbus_IPC_MessageParcel_4800: gIRemoteObject undefined");
J
jiyong 已提交
2028 2029
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SHORT, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2030
                console.info("SUB_Softbus_IPC_MessageParcel_4800: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2031 2032 2033
                expect(result.errCode == 0).assertTrue();

                var readShort = result.reply.readShort();
Z
zhangpa2021 已提交
2034
                console.info("SUB_Softbus_IPC_MessageParcel_4800: run readFloatArray is success, readShort is "
J
jiyong 已提交
2035 2036 2037 2038 2039 2040 2041 2042
                + readShort);
                expect(readShort == short).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2043
            console.info("SUB_Softbus_IPC_MessageParcel_4800: error " + error);
J
jiyong 已提交
2044
        }
Z
zhangpa2021 已提交
2045
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4800---------------------------");
J
jiyong 已提交
2046 2047 2048 2049
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_4900
J
jiyong 已提交
2050
     * @tc.name    WriteShort interface, boundary value verification
J
jiyong 已提交
2051 2052 2053 2054
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_4900", 0, async function(done){
Z
zhangpa2021 已提交
2055
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_4900---------------------------");
J
jiyong 已提交
2056 2057
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2058
            console.info("SUB_Softbus_IPC_MessageParcel_4900: create object successfully.");
J
jiyong 已提交
2059 2060
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2061

J
jiyong 已提交
2062 2063 2064 2065 2066 2067
            const CODE_WRITE_SHORT_MULTI = 24;
            expect(data.writeShort(-32768) == true).assertTrue();
            expect(data.writeShort(0) == true).assertTrue();
            expect(data.writeShort(1) == true).assertTrue();
            expect(data.writeShort(2) == true).assertTrue();
            expect(data.writeShort(32767) == true).assertTrue();
J
jiyong 已提交
2068

J
jiyong 已提交
2069 2070
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2071
                console.info("SUB_Softbus_IPC_MessageParcel_4900: gIRemoteObject undefined");
J
jiyong 已提交
2072 2073
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SHORT_MULTI, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2074
                console.info("SUB_Softbus_IPC_MessageParcel_4900: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2075 2076 2077 2078 2079 2080 2081 2082
                expect(result.errCode == 0).assertTrue();

                expect(result.reply.readShort() == -32768).assertTrue();
                expect(result.reply.readShort() == 0).assertTrue();
                expect(result.reply.readShort() == 1).assertTrue();
                expect(result.reply.readShort() == 2).assertTrue();
                expect(result.reply.readShort() == 32767).assertTrue();
            });
J
jiyong 已提交
2083 2084

            data.reclaim();
J
jiyong 已提交
2085
            reply.reclaim();
J
jiyong 已提交
2086 2087
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2088
            console.info("SUB_Softbus_IPC_MessageParcel_4800: error " + error);
J
jiyong 已提交
2089
        }
Z
zhangpa2021 已提交
2090
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_4800---------------------------");
J
jiyong 已提交
2091 2092 2093 2094
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5000
J
jiyong 已提交
2095
     * @tc.name    WriteShort interface, illegal value verification
J
jiyong 已提交
2096 2097 2098
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2099
    it("SUB_Softbus_IPC_MessageParcel_5000", 0, async function(done){
Z
zhangpa2021 已提交
2100
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5000---------------------------");
J
jiyong 已提交
2101 2102
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2103
            console.info("SUB_Softbus_IPC_MessageParcel_5000: create object successfully.");
J
jiyong 已提交
2104 2105
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2106

J
jiyong 已提交
2107 2108 2109 2110 2111
            expect(data.writeShort(-32769) == true).assertTrue();
            expect(data.writeShort(0) == true).assertTrue();
            expect(data.writeShort(1) == true).assertTrue();
            expect(data.writeShort(2) == true).assertTrue();
            expect(data.writeShort(32768) == true).assertTrue();
J
jiyong 已提交
2112

J
jiyong 已提交
2113 2114
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2115
                console.info("SUB_Softbus_IPC_MessageParcel_5000: gIRemoteObject undefined");
J
jiyong 已提交
2116 2117
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SHORT_MULTI, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2118
                console.info("SUB_Softbus_IPC_MessageParcel_5000: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2119
                expect(result.errCode == 0).assertTrue();
J
jiyong 已提交
2120

J
jiyong 已提交
2121 2122 2123 2124 2125 2126
                expect(result.reply.readShort() == 32767).assertTrue();
                expect(result.reply.readShort() == 0).assertTrue();
                expect(result.reply.readShort() == 1).assertTrue();
                expect(result.reply.readShort() == 2).assertTrue();
                expect(result.reply.readShort() == -32768).assertTrue();
            });
J
jiyong 已提交
2127 2128

            data.reclaim();
J
jiyong 已提交
2129 2130
            reply.reclaim();
            done();
J
jiyong 已提交
2131
        } catch (error) {
Z
zhangpa2021 已提交
2132
            console.info("SUB_Softbus_IPC_MessageParcel_5000: error " + error);
J
jiyong 已提交
2133
        }
Z
zhangpa2021 已提交
2134
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5000---------------------------");
J
jiyong 已提交
2135 2136 2137 2138
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5100
J
jiyong 已提交
2139 2140
     * @tc.name    Call writelong interface to write long integer data to messageparcel instance
     *             and call readlong to read data
J
jiyong 已提交
2141 2142 2143
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2144
    it("SUB_Softbus_IPC_MessageParcel_5100", 0, async function(done){
Z
zhangpa2021 已提交
2145
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5100---------------------------");
J
jiyong 已提交
2146 2147
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2148
            console.info("SUB_Softbus_IPC_MessageParcel_5100: create object successfully.");
J
jiyong 已提交
2149 2150
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2151

J
jiyong 已提交
2152 2153
            var short = 10000;
            var writelong = data.writeLong(short);
Z
zhangpa2021 已提交
2154
            console.info("SUB_Softbus_IPC_MessageParcel_5100: run writeLong success, writelong is " + writelong);
J
jiyong 已提交
2155
            expect(writelong == true).assertTrue();
J
jiyong 已提交
2156

J
jiyong 已提交
2157 2158
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2159
                console.info("SUB_Softbus_IPC_MessageParcel_5100: gIRemoteObject undefined");
J
jiyong 已提交
2160 2161
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_LONG, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2162
                console.info("SUB_Softbus_IPC_MessageParcel_5100: run sendRequest success, result is "
J
jiyong 已提交
2163 2164 2165 2166
                             + result.errCode);
                expect(result.errCode == 0).assertTrue();

                var readlong = result.reply.readLong();
Z
zhangpa2021 已提交
2167
                console.info("SUB_Softbus_IPC_MessageParcel_5100: run readLong is success, readlong is " + readlong);
J
jiyong 已提交
2168 2169
                expect(readlong == short).assertTrue();
            });
J
jiyong 已提交
2170 2171

            data.reclaim();
J
jiyong 已提交
2172 2173
            reply.reclaim();
            done();
J
jiyong 已提交
2174
        } catch (error) {
Z
zhangpa2021 已提交
2175
            console.info("SUB_Softbus_IPC_MessageParcel_5100: error " + error);
J
jiyong 已提交
2176
        }
Z
zhangpa2021 已提交
2177
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5100---------------------------");
J
jiyong 已提交
2178 2179 2180 2181
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5200
J
jiyong 已提交
2182
     * @tc.name    Writelong interface, boundary value verification
J
jiyong 已提交
2183 2184 2185 2186
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_5200", 0, async function(done){
Z
zhangpa2021 已提交
2187
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5200---------------------------");
J
jiyong 已提交
2188 2189
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2190
            console.info("SUB_Softbus_IPC_MessageParcel_5200: create object successfully.");
J
jiyong 已提交
2191 2192
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2193

J
jiyong 已提交
2194
            var short = 2147483647;
J
jiyong 已提交
2195
            var writelong = data.writeLong(short);
Z
zhangpa2021 已提交
2196
            console.info("SUB_Softbus_IPC_MessageParcel_5200: run writeLong success, writelong is " + writelong);
J
jiyong 已提交
2197 2198
            expect(writelong == true).assertTrue();

J
jiyong 已提交
2199 2200
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2201
                console.info("SUB_Softbus_IPC_MessageParcel_5200: gIRemoteObject undefined");
J
jiyong 已提交
2202 2203
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_LONG, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2204
                console.info("SUB_Softbus_IPC_MessageParcel_5200: run sendRequest success, result is "
J
jiyong 已提交
2205 2206 2207 2208
                + result.errCode);
                expect(result.errCode == 0).assertTrue();

                var readlong = result.reply.readLong();
Z
zhangpa2021 已提交
2209
                console.info("SUB_Softbus_IPC_MessageParcel_5200: run readLong is success, readlong is " + readlong);
J
jiyong 已提交
2210 2211
                expect(readlong == short).assertTrue();
            });
J
jiyong 已提交
2212 2213 2214 2215

            data.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2216
            console.info("SUB_Softbus_IPC_MessageParcel_5200: error " + error);
J
jiyong 已提交
2217
        }
Z
zhangpa2021 已提交
2218
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5200---------------------------");
J
jiyong 已提交
2219 2220 2221 2222
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5300
J
jiyong 已提交
2223
     * @tc.name    Writelong interface, illegal value verification
J
jiyong 已提交
2224 2225 2226
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2227
    it("SUB_Softbus_IPC_MessageParcel_5300", 0, async function(done){
Z
zhangpa2021 已提交
2228
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5300---------------------------");
J
jiyong 已提交
2229 2230
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2231
            console.info("SUB_Softbus_IPC_MessageParcel_5300: create object successfully.");
J
jiyong 已提交
2232 2233
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2234

J
jiyong 已提交
2235
            var short = 214748364887;
J
jiyong 已提交
2236
            var writelong = data.writeLong(short);
Z
zhangpa2021 已提交
2237
            console.info("SUB_Softbus_IPC_MessageParcel_5300: run writeLong success, writelong is " + writelong);
J
jiyong 已提交
2238 2239
            expect(writelong == true).assertTrue();

J
jiyong 已提交
2240 2241
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2242
                console.info("SUB_Softbus_IPC_MessageParcel_5300: gIRemoteObject undefined");
J
jiyong 已提交
2243 2244
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_LONG, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2245
                console.info("SUB_Softbus_IPC_MessageParcel_5300: run sendRequest success, result is "
J
jiyong 已提交
2246 2247 2248 2249
                + result.errCode);
                expect(result.errCode == 0).assertTrue();

                var readlong = result.reply.readLong();
Z
zhangpa2021 已提交
2250
                console.info("SUB_Softbus_IPC_MessageParcel_5300: run readLong is success, readlong is " + readlong);
J
jiyong 已提交
2251 2252
                expect(readlong == short).assertTrue();
            });
J
jiyong 已提交
2253 2254

            data.reclaim();
J
jiyong 已提交
2255
            done();
J
jiyong 已提交
2256
        } catch (error) {
Z
zhangpa2021 已提交
2257
            console.info("SUB_Softbus_IPC_MessageParcel_5300: error " + error);
J
jiyong 已提交
2258
        }
Z
zhangpa2021 已提交
2259
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5300---------------------------");
J
jiyong 已提交
2260 2261
    });

J
jiyong 已提交
2262

J
jiyong 已提交
2263 2264
    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5400
J
jiyong 已提交
2265
     * @tc.name    Call the parallel interface to read and write data to the double instance
J
jiyong 已提交
2266 2267 2268
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2269
    it("SUB_Softbus_IPC_MessageParcel_5400", 0,async function(done){
Z
zhangpa2021 已提交
2270
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5400---------------------------");
J
jiyong 已提交
2271 2272
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2273
            console.info("SUB_Softbus_IPC_MessageParcel_5400: create object successfully.");
J
jiyong 已提交
2274 2275
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2276

J
jiyong 已提交
2277 2278
            var token = 10.2;
            var result = data.writeDouble(token);
Z
zhangpa2021 已提交
2279
            console.info("SUB_Softbus_IPC_MessageParcel_5400:run writeDouble success, result is " + result);
J
jiyong 已提交
2280 2281
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2282
                console.info("SUB_Softbus_IPC_MessageParcel_5400: gIRemoteObject is undefined");
J
jiyong 已提交
2283 2284
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_DOUBLE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2285
                    console.info("SUB_Softbus_IPC_MessageParcel_5400: run sendRequest success, result is "
J
jiyong 已提交
2286 2287
                                 + result.errCode);
                    var replyReadResult = reply.readDouble();
Z
zhangpa2021 已提交
2288
                    console.info("SUB_Softbus_IPC_MessageParcel_5400: run replyReadResult is success," +
J
jiyong 已提交
2289 2290 2291
                    "replyReadResult is " + replyReadResult);
                    expect(replyReadResult == token).assertTrue();
                });
J
jiyong 已提交
2292
            data.reclaim();
J
jiyong 已提交
2293
            reply.reclaim();
J
jiyong 已提交
2294 2295
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2296
            console.info("SUB_Softbus_IPC_MessageParcel_5400:error = " + error);
J
jiyong 已提交
2297
        }
J
jiyong 已提交
2298

Z
zhangpa2021 已提交
2299
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5400---------------------------");
J
jiyong 已提交
2300 2301 2302 2303
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5500
J
jiyong 已提交
2304
     * @tc.name    Writedouble interface, boundary value verification
J
jiyong 已提交
2305 2306 2307
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2308
    it("SUB_Softbus_IPC_MessageParcel_5500", 0,async function(){
Z
zhangpa2021 已提交
2309
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5500---------------------------");
J
jiyong 已提交
2310 2311
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2312
            console.info("SUB_Softbus_IPC_MessageParcel_5500: create object successfully.");
J
jiyong 已提交
2313 2314
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2315 2316
            var token = 1.79E+308;
            var result = data.writeDouble(token);
Z
zhangpa2021 已提交
2317
            console.info("SUB_Softbus_IPC_MessageParcel_5500:run writeDouble success, result is " + result);
J
jiyong 已提交
2318
            expect(result == true).assertTrue();
J
jiyong 已提交
2319 2320 2321

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2322
                console.info("SUB_Softbus_IPC_MessageParcel_5400: gIRemoteObject is undefined");
J
jiyong 已提交
2323 2324
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_DOUBLE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2325
                console.info("SUB_Softbus_IPC_MessageParcel_5400: run sendRequest success, result is "
J
jiyong 已提交
2326 2327
                + result.errCode);
                var replyReadResult = reply.readDouble();
Z
zhangpa2021 已提交
2328
                console.info("SUB_Softbus_IPC_MessageParcel_5400: run replyReadResult is success," +
J
jiyong 已提交
2329 2330 2331
                "replyReadResult is " + replyReadResult);
                expect(replyReadResult == token).assertTrue();
            });
J
jiyong 已提交
2332 2333

            data.reclaim();
J
jiyong 已提交
2334
            reply.reclaim();
J
jiyong 已提交
2335
        } catch (error) {
Z
zhangpa2021 已提交
2336
            console.info("SUB_Softbus_IPC_MessageParcel_5500:error = " + error);
J
jiyong 已提交
2337
        }
Z
zhangpa2021 已提交
2338
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5500---------------------------");
J
jiyong 已提交
2339 2340 2341 2342
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5600
J
jiyong 已提交
2343
     * @tc.name    Writedouble interface, illegal value validation
J
jiyong 已提交
2344 2345 2346
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2347
    it("SUB_Softbus_IPC_MessageParcel_5600", 0,async function(){
Z
zhangpa2021 已提交
2348
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5600---------------------------");
J
jiyong 已提交
2349 2350
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2351
            console.info("SUB_Softbus_IPC_MessageParcel_5600: create object successfully.");
J
jiyong 已提交
2352 2353 2354

            var flag = false;
            var token = "1.79E+465312156";
J
jiyong 已提交
2355
            var result = data.writeDouble(token);
Z
zhangpa2021 已提交
2356
            console.info("SUB_Softbus_IPC_MessageParcel_5600:run writeDouble success, result is " + result);
J
jiyong 已提交
2357 2358

            flag = true;
J
jiyong 已提交
2359 2360
            data.reclaim();
        } catch (error) {
Z
zhangpa2021 已提交
2361
            console.info("SUB_Softbus_IPC_MessageParcel_5600:error = " + error);
J
jiyong 已提交
2362
            expect(flag == false).assertTrue();
J
jiyong 已提交
2363
        }
Z
zhangpa2021 已提交
2364
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5600---------------------------");
J
jiyong 已提交
2365 2366 2367 2368
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5700
J
jiyong 已提交
2369 2370
     * @tc.name    Call the writeboolean interface to write the data to the messageparcel instance,
     *             and call readboolean to read the data
J
jiyong 已提交
2371 2372 2373 2374
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_5700", 0,async function(done){
Z
zhangpa2021 已提交
2375
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5700---------------------------");
J
jiyong 已提交
2376 2377
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2378
            console.info("SUB_Softbus_IPC_MessageParcel_5700: create object successfully.");
J
jiyong 已提交
2379 2380
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2381 2382
            var token = true;
            var result = data.writeBoolean(token);
Z
zhangpa2021 已提交
2383
            console.info("SUB_Softbus_IPC_MessageParcel_5700:run writeBoolean success, result is " + result);
J
jiyong 已提交
2384
            expect(result == true).assertTrue();
J
jiyong 已提交
2385 2386
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2387
                console.info("SUB_Softbus_IPC_MessageParcel_5700: gIRemoteObject is undefined");
J
jiyong 已提交
2388
            }
J
jiyong 已提交
2389
            await gIRemoteObject.sendRequest(CODE_WRITE_BOOLEAN, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2390
                console.info("SUB_Softbus_IPC_MessageParcel_5700: run sendRequest success, result is "
J
jiyong 已提交
2391
                             + result.errCode);
J
jiyong 已提交
2392
                var replyReadResult = result.reply.readBoolean();
Z
zhangpa2021 已提交
2393
                console.info("SUB_Softbus_IPC_MessageParcel_5700: run readBoolean is success," +
J
jiyong 已提交
2394 2395
                "result is " + replyReadResult);
                expect(replyReadResult == token).assertTrue();
J
jiyong 已提交
2396 2397 2398 2399 2400
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2401
            console.info("SUB_Softbus_IPC_MessageParcel_5700:error = " + error);
J
jiyong 已提交
2402
        }
Z
zhangpa2021 已提交
2403
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5700---------------------------");
J
jiyong 已提交
2404 2405 2406 2407
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5800
J
jiyong 已提交
2408
     * @tc.name    Writeboolean interface, illegal value verification
J
jiyong 已提交
2409 2410 2411 2412
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_5800", 0,async function(){
Z
zhangpa2021 已提交
2413
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5800---------------------------");
J
jiyong 已提交
2414 2415
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2416
            console.info("SUB_Softbus_IPC_MessageParcel_5800: create object successfully.");
J
jiyong 已提交
2417 2418 2419 2420
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var token = 9;
            var result = data.writeBoolean(token);
Z
zhangpa2021 已提交
2421
            console.info("SUB_Softbus_IPC_MessageParcel_5800:run writeBoolean success, result is " + result);
J
jiyong 已提交
2422
            expect(result == false).assertTrue();
J
jiyong 已提交
2423
        } catch (error) {
Z
zhangpa2021 已提交
2424
            console.info("SUB_Softbus_IPC_MessageParcel_5800:error = " + error);
J
jiyong 已提交
2425
        }
J
jiyong 已提交
2426
        data.reclaim();
Z
zhangpa2021 已提交
2427
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5800---------------------------");
J
jiyong 已提交
2428 2429 2430 2431
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_5900
J
jiyong 已提交
2432 2433
     * @tc.name    Call the writechar interface to write the data to the messageparcel instance,
     *             and call readchar to read the data
J
jiyong 已提交
2434 2435 2436
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2437
    it("SUB_Softbus_IPC_MessageParcel_5900", 0,async function(done){
Z
zhangpa2021 已提交
2438
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_5900---------------------------");
J
jiyong 已提交
2439 2440
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2441
            console.info("SUB_Softbus_IPC_MessageParcel_5900: create object successfully.");
J
jiyong 已提交
2442 2443
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
Z
zhangpa2021 已提交
2444
            var token = 10;
J
jiyong 已提交
2445
            var result = data.writeChar(token);
Z
zhangpa2021 已提交
2446
            console.info("SUB_Softbus_IPC_MessageParcel_5900:run writeChar success, result is " + result);
J
jiyong 已提交
2447 2448 2449
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2450
                console.info("SUB_Softbus_IPC_MessageParcel_5900: gIRemoteObject is undefined");
J
jiyong 已提交
2451 2452
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_CHAR, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2453
                console.info("SUB_Softbus_IPC_MessageParcel_5900: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2454
                var replyReadResult = result.reply.readChar();
Z
zhangpa2021 已提交
2455
                console.info("SUB_Softbus_IPC_MessageParcel_5900: run readChar is success," +
J
jiyong 已提交
2456 2457 2458
                "result is " + replyReadResult);
                expect(replyReadResult == token).assertTrue();
            });
J
jiyong 已提交
2459 2460

            data.reclaim();
J
jiyong 已提交
2461 2462
            reply.reclaim();
            done();
J
jiyong 已提交
2463
        } catch (error) {
Z
zhangpa2021 已提交
2464
            console.info("SUB_Softbus_IPC_MessageParcel_5900:error = " + error);
J
jiyong 已提交
2465
        }
Z
zhangpa2021 已提交
2466
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_5900---------------------------");
J
jiyong 已提交
2467 2468 2469 2470
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6000
J
jiyong 已提交
2471
     * @tc.name    Writechar interface, illegal value verification
J
jiyong 已提交
2472 2473 2474
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2475
    it("SUB_Softbus_IPC_MessageParcel_6000", 0,async function(){
Z
zhangpa2021 已提交
2476
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6000---------------------------");
J
jiyong 已提交
2477 2478
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2479
            console.info("SUB_Softbus_IPC_MessageParcel_6000: create object successfully.");
J
jiyong 已提交
2480 2481
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2482 2483
            var token = 'ades';
            var result = data.writeChar(token);
Z
zhangpa2021 已提交
2484
            console.info("SUB_Softbus_IPC_MessageParcel_6000:run writeChar success, result is " + result);
Z
zhangpa2021 已提交
2485 2486
            expect(result == true).assertTrue()
            var readresult = data.readChar();
Z
zhangpa2021 已提交
2487
            expect(readresult == 'a').assertTrue()
Z
zhangpa2021 已提交
2488

J
jiyong 已提交
2489
        } catch (error) {
Z
zhangpa2021 已提交
2490
            console.info("SUB_Softbus_IPC_MessageParcel_6000:error = " + error);
J
jiyong 已提交
2491
        }
J
jiyong 已提交
2492
        data.reclaim();
Z
zhangpa2021 已提交
2493
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6000---------------------------");
J
jiyong 已提交
2494 2495 2496 2497
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6100
J
jiyong 已提交
2498 2499
     * @tc.name    Call the writestring interface to write the data to the messageparcel instance,
     *             and call readstring() to read the data
J
jiyong 已提交
2500 2501 2502 2503
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6100", 0,async function(done){
Z
zhangpa2021 已提交
2504
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6100---------------------------");
J
jiyong 已提交
2505 2506
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2507
            console.info("SUB_Softbus_IPC_MessageParcel_6100: create object successfully.");
J
jiyong 已提交
2508 2509
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2510 2511
            var token = 'weqea';
            var result = data.writeString(token);
Z
zhangpa2021 已提交
2512
            console.info("SUB_Softbus_IPC_MessageParcel_6100:run writeString success, result is " + result);
J
jiyong 已提交
2513 2514 2515
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2516
                console.info("SUB_Softbus_IPC_MessageParcel_6100: gIRemoteObject is undefined");
J
jiyong 已提交
2517
            }
J
jiyong 已提交
2518
            await gIRemoteObject.sendRequest(CODE_WRITE_STRING, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2519
                console.info("SUB_Softbus_IPC_MessageParcel_6100: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2520
                var replyReadResult = result.reply.readString();
Z
zhangpa2021 已提交
2521
                console.info("SUB_Softbus_IPC_MessageParcel_6100: run readString is success," +
J
jiyong 已提交
2522 2523
                "result is " + replyReadResult);
                expect(replyReadResult == token).assertTrue();
J
jiyong 已提交
2524 2525 2526 2527 2528 2529
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2530
            console.info("SUB_Softbus_IPC_MessageParcel_6100:error = " + error);
J
jiyong 已提交
2531
        }
Z
zhangpa2021 已提交
2532
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6100---------------------------");
J
jiyong 已提交
2533 2534 2535 2536
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6200
J
jiyong 已提交
2537
     * @tc.name    Writestring interface, illegal value verification
J
jiyong 已提交
2538 2539 2540 2541
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6200", 0,async function(){
Z
zhangpa2021 已提交
2542
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6200---------------------------");
J
jiyong 已提交
2543 2544
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2545
            console.info("SUB_Softbus_IPC_MessageParcel_6200: create object successfully.");
J
jiyong 已提交
2546 2547
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2548 2549
            var token = 123;
            var result = data.writeString(token);
Z
zhangpa2021 已提交
2550
            console.info("SUB_Softbus_IPC_MessageParcel_6200:run writeString success, result is " + result);
J
jiyong 已提交
2551 2552
            expect(result == false).assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
2553
            console.info("SUB_Softbus_IPC_MessageParcel_6200:error = " + error);
J
jiyong 已提交
2554
        }
J
jiyong 已提交
2555
        sleep(2000)
J
jiyong 已提交
2556
        data.reclaim();
J
jiyong 已提交
2557
        reply.reclaim();
Z
zhangpa2021 已提交
2558
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6200---------------------------");
J
jiyong 已提交
2559 2560 2561 2562
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6300
J
jiyong 已提交
2563 2564
     * @tc.name    Call the writebyte interface to write data to the messageparcel instance,
     *             and call readbyte to read data
J
jiyong 已提交
2565 2566 2567 2568
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6300", 0,async function(done){
Z
zhangpa2021 已提交
2569
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6300---------------------------");
J
jiyong 已提交
2570 2571
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2572
            console.info("SUB_Softbus_IPC_MessageParcel_6300: create object successfully.");
J
jiyong 已提交
2573 2574
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2575 2576
            var token = 2;
            var result = data.writeByte(token);
Z
zhangpa2021 已提交
2577
            console.info("SUB_Softbus_IPC_MessageParcel_6300:run writeByte success, result is " + result);
J
jiyong 已提交
2578 2579 2580
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2581
                console.info("SUB_Softbus_IPC_MessageParcel_6300: gIRemoteObject is undefined");
J
jiyong 已提交
2582
            }
J
jiyong 已提交
2583
            await gIRemoteObject.sendRequest(CODE_WRITE_BYTE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2584
                console.info("SUB_Softbus_IPC_MessageParcel_6300: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2585
                var replyReadResult = result.reply.readByte();
Z
zhangpa2021 已提交
2586
                console.info("SUB_Softbus_IPC_MessageParcel_6300: run readByte is success," +
J
jiyong 已提交
2587 2588 2589 2590 2591 2592 2593 2594
                "result is " + replyReadResult);
                expect(replyReadResult == token).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2595
            console.info("SUB_Softbus_IPC_MessageParcel_6300:error = " + error);
J
jiyong 已提交
2596
        }
Z
zhangpa2021 已提交
2597
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6300---------------------------");
J
jiyong 已提交
2598 2599 2600 2601
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6400
J
jiyong 已提交
2602
     * @tc.name    Writebyte interface, boundary value verification
J
jiyong 已提交
2603 2604 2605 2606
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6400", 0,async function(done){
Z
zhangpa2021 已提交
2607
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6400---------------------------");
J
jiyong 已提交
2608 2609
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2610
            console.info("SUB_Softbus_IPC_MessageParcel_6400: create object successfully.");
J
jiyong 已提交
2611 2612
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2613 2614 2615 2616 2617 2618

            expect(data.writeByte(-128) == true).assertTrue();
            expect(data.writeByte(0) == true).assertTrue();
            expect(data.writeByte(1) == true).assertTrue();
            expect(data.writeByte(2) == true).assertTrue();
            expect(data.writeByte(127) == true).assertTrue();
J
jiyong 已提交
2619 2620
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2621
                console.info("SUB_Softbus_IPC_MessageParcel_6400: gIRemoteObject is undefined");
J
jiyong 已提交
2622
            }
J
jiyong 已提交
2623
            await gIRemoteObject.sendRequest(CODE_WRITE_BYTE_MULTI, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2624
                console.info("SUB_Softbus_IPC_MessageParcel_6400: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2625 2626 2627 2628 2629 2630

                expect(reply.readByte() == -128).assertTrue();
                expect(reply.readByte() == 0).assertTrue();
                expect(reply.readByte() == 1).assertTrue();
                expect(reply.readByte() == 2).assertTrue();
                expect(reply.readByte() == 127).assertTrue();
J
jiyong 已提交
2631 2632 2633 2634 2635 2636
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2637
            console.info("SUB_Softbus_IPC_MessageParcel_6400:error = " + error);
J
jiyong 已提交
2638
        }
Z
zhangpa2021 已提交
2639
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6400---------------------------");
J
jiyong 已提交
2640 2641 2642 2643
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6500
J
jiyong 已提交
2644
     * @tc.name    Writebyte interface, illegal value verification
J
jiyong 已提交
2645 2646 2647
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2648
    it("SUB_Softbus_IPC_MessageParcel_6500", 0,async function(done){
Z
zhangpa2021 已提交
2649
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6500---------------------------");
J
jiyong 已提交
2650 2651
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2652
            console.info("SUB_Softbus_IPC_MessageParcel_6500: create object successfully.");
J
jiyong 已提交
2653 2654
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2655

J
jiyong 已提交
2656 2657 2658 2659 2660 2661 2662
            expect(data.writeByte(-129) == true).assertTrue();
            expect(data.writeByte(0) == true).assertTrue();
            expect(data.writeByte(1) == true).assertTrue();
            expect(data.writeByte(2) == true).assertTrue();
            expect(data.writeByte(128) == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2663
                console.info("SUB_Softbus_IPC_MessageParcel_6500: gIRemoteObject is undefined");
J
jiyong 已提交
2664 2665
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_BYTE_MULTI, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2666
                console.info("SUB_Softbus_IPC_MessageParcel_6500: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2667 2668 2669 2670 2671 2672 2673 2674

                expect(reply.readByte() == 127).assertTrue();
                expect(reply.readByte() == 0).assertTrue();
                expect(reply.readByte() == 1).assertTrue();
                expect(reply.readByte() == 2).assertTrue();
                expect(reply.readByte() == -128).assertTrue();
            });

J
jiyong 已提交
2675
            data.reclaim();
J
jiyong 已提交
2676 2677
            reply.reclaim();
            done();
J
jiyong 已提交
2678
        } catch (error) {
Z
zhangpa2021 已提交
2679
            console.info("SUB_Softbus_IPC_MessageParcel_6400:error = " + error);
J
jiyong 已提交
2680
        }
Z
zhangpa2021 已提交
2681
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6400---------------------------");
J
jiyong 已提交
2682 2683 2684 2685
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6600
J
jiyong 已提交
2686 2687
     * @tc.name    Call the writeint interface to write the data to the messageparcel instance,
     *             and call readint to read the data
J
jiyong 已提交
2688 2689 2690 2691
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6600", 0,async function(done){
Z
zhangpa2021 已提交
2692
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6600---------------------------");
J
jiyong 已提交
2693 2694
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2695
            console.info("SUB_Softbus_IPC_MessageParcel_6600: create object successfully.");
J
jiyong 已提交
2696 2697
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2698 2699
            var token = 2;
            var result = data.writeInt(token);
Z
zhangpa2021 已提交
2700
            console.info("SUB_Softbus_IPC_MessageParcel_6600:run writeInt success, result is " + result);
J
jiyong 已提交
2701 2702 2703
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2704
                console.info("SUB_Softbus_IPC_MessageParcel_6600: gIRemoteObject is undefined");
J
jiyong 已提交
2705
            }
J
jiyong 已提交
2706
            await gIRemoteObject.sendRequest(CODE_WRITE_INT, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2707
                console.info("SUB_Softbus_IPC_MessageParcel_6600: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2708
                var replyReadResult = result.reply.readInt();
Z
zhangpa2021 已提交
2709
                console.info("SUB_Softbus_IPC_MessageParcel_6600: run readInt is success," +
J
jiyong 已提交
2710
                "result is " + replyReadResult);
J
jiyong 已提交
2711 2712 2713 2714 2715 2716 2717
                expect(replyReadResult == token).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2718
            console.info("SUB_Softbus_IPC_MessageParcel_6600:error = " + error);
J
jiyong 已提交
2719
        }
J
jiyong 已提交
2720

Z
zhangpa2021 已提交
2721
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6600---------------------------");
J
jiyong 已提交
2722 2723 2724 2725
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6700
J
jiyong 已提交
2726
     * @tc.name    Writeint interface, boundary value verification
J
jiyong 已提交
2727 2728 2729 2730
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6700", 0,async function(done){
Z
zhangpa2021 已提交
2731
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6700---------------------------");
J
jiyong 已提交
2732 2733
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2734
            console.info("SUB_Softbus_IPC_MessageParcel_6700: create object successfully.");
J
jiyong 已提交
2735 2736
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2737 2738 2739 2740 2741 2742 2743

            expect(data.writeInt(-2147483648) == true).assertTrue();
            expect(data.writeInt(0) == true).assertTrue();
            expect(data.writeInt(1) == true).assertTrue();
            expect(data.writeInt(2) == true).assertTrue();
            expect(data.writeInt(2147483647) == true).assertTrue();

J
jiyong 已提交
2744 2745
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2746
                console.info("SUB_Softbus_IPC_MessageParcel_6700: gIRemoteObject is undefined");
J
jiyong 已提交
2747
            }
J
jiyong 已提交
2748
            await gIRemoteObject.sendRequest(CODE_WRITE_INT_MULTI, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2749
                console.info("SUB_Softbus_IPC_MessageParcel_6700: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2750 2751 2752 2753 2754
                expect(result.reply.readInt() == -2147483648).assertTrue();
                expect(result.reply.readInt() == 0).assertTrue();
                expect(result.reply.readInt() == 1).assertTrue();
                expect(result.reply.readInt() == 2).assertTrue();
                expect(result.reply.readInt() == 2147483647).assertTrue();
J
jiyong 已提交
2755 2756 2757 2758 2759 2760
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2761
            console.info("SUB_Softbus_IPC_MessageParcel_6700:error = " + error);
J
jiyong 已提交
2762
        }
J
jiyong 已提交
2763

Z
zhangpa2021 已提交
2764
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6700---------------------------");
J
jiyong 已提交
2765 2766 2767 2768
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6800
J
jiyong 已提交
2769
     * @tc.name    Writeint interface, illegal value verification
J
jiyong 已提交
2770 2771 2772
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2773
    it("SUB_Softbus_IPC_MessageParcel_6800", 0,async function(done){
Z
zhangpa2021 已提交
2774
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6700---------------------------");
J
jiyong 已提交
2775 2776
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2777
            console.info("SUB_Softbus_IPC_MessageParcel_6800: create object successfully.");
J
jiyong 已提交
2778 2779
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2780

J
jiyong 已提交
2781 2782 2783 2784 2785
            expect(data.writeInt(-2147483649) == true).assertTrue();
            expect(data.writeInt(0) == true).assertTrue();
            expect(data.writeInt(1) == true).assertTrue();
            expect(data.writeInt(2) == true).assertTrue();
            expect(data.writeInt(2147483648) == true).assertTrue();
J
jiyong 已提交
2786

J
jiyong 已提交
2787 2788
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2789
                console.info("SUB_Softbus_IPC_MessageParcel_6800: gIRemoteObject is undefined");
J
jiyong 已提交
2790 2791
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_INT_MULTI, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2792
                console.info("SUB_Softbus_IPC_MessageParcel_6800: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2793 2794 2795 2796 2797 2798
                expect(result.reply.readInt() == 2147483647).assertTrue();
                expect(result.reply.readInt() == 0).assertTrue();
                expect(result.reply.readInt() == 1).assertTrue();
                expect(result.reply.readInt() == 2).assertTrue();
                expect(result.reply.readInt() == -2147483648).assertTrue();
            });
J
jiyong 已提交
2799 2800

            data.reclaim();
J
jiyong 已提交
2801 2802
            reply.reclaim();
            done();
J
jiyong 已提交
2803
        } catch (error) {
Z
zhangpa2021 已提交
2804
            console.info("SUB_Softbus_IPC_MessageParcel_6800:error = " + error);
J
jiyong 已提交
2805
        }
J
jiyong 已提交
2806

Z
zhangpa2021 已提交
2807
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6800---------------------------");
J
jiyong 已提交
2808 2809 2810 2811
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_6900
J
jiyong 已提交
2812 2813
     * @tc.name    Call the writefloat interface to write data to the messageparcel instance,
     *             and call readfloat to read data
J
jiyong 已提交
2814 2815 2816 2817
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_6900", 0,async function(done){
Z
zhangpa2021 已提交
2818
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_6900---------------------------");
J
jiyong 已提交
2819 2820
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2821
            console.info("SUB_Softbus_IPC_MessageParcel_6900: create object successfully.");
J
jiyong 已提交
2822 2823
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2824 2825
            var token = 2.2;
            var result = data.writeFloat(token);
Z
zhangpa2021 已提交
2826
            console.info("SUB_Softbus_IPC_MessageParcel_6900:run writeDouble success, result is " + result);
J
jiyong 已提交
2827 2828 2829
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2830
                console.info("SUB_Softbus_IPC_MessageParcel_6900: gIRemoteObject is undefined");
J
jiyong 已提交
2831
            }
J
jiyong 已提交
2832
            await gIRemoteObject.sendRequest(CODE_WRITE_FLOAT, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2833
                console.info("SUB_Softbus_IPC_MessageParcel_6900: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2834
                var replyReadResult = result.reply.readFloat();
Z
zhangpa2021 已提交
2835
                console.info("SUB_Softbus_IPC_MessageParcel_6900: run readFloat is success," +
J
jiyong 已提交
2836 2837 2838 2839 2840 2841 2842 2843
                "result is " + replyReadResult);
                expect(replyReadResult == token).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2844
            console.info("SUB_Softbus_IPC_MessageParcel_6900:error = " + error);
J
jiyong 已提交
2845
        }
Z
zhangpa2021 已提交
2846
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_6900---------------------------");
J
jiyong 已提交
2847 2848 2849 2850
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7000
J
jiyong 已提交
2851
     * @tc.name    Writefloat interface, boundary value verification
J
jiyong 已提交
2852 2853 2854 2855
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7000", 0,async function(done){
Z
zhangpa2021 已提交
2856
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7000---------------------------");
J
jiyong 已提交
2857 2858
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2859
            console.info("SUB_Softbus_IPC_MessageParcel_7000: create object successfully.");
J
jiyong 已提交
2860 2861
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2862 2863
            var token = 3.4E+38;
            var result = data.writeFloat(token);
Z
zhangpa2021 已提交
2864
            console.info("SUB_Softbus_IPC_MessageParcel_7000:run writeFloat success, result is " + result);
J
jiyong 已提交
2865 2866 2867
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
2868
                console.info("SUB_Softbus_IPC_MessageParcel_7000: gIRemoteObject is undefined");
J
jiyong 已提交
2869
            }
J
jiyong 已提交
2870
            await gIRemoteObject.sendRequest(CODE_WRITE_FLOAT, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
2871
                console.info("SUB_Softbus_IPC_MessageParcel_7000: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
2872
                var newReadResult = result.reply.readFloat();
Z
zhangpa2021 已提交
2873
                console.info("SUB_Softbus_IPC_MessageParcel_7000: readFloat result is " + newReadResult);
J
jiyong 已提交
2874
                expect(newReadResult == token).assertTrue();
J
jiyong 已提交
2875 2876 2877 2878 2879 2880
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2881
            console.info("SUB_Softbus_IPC_MessageParcel_7000:error = " + error);
J
jiyong 已提交
2882
        }
J
jiyong 已提交
2883

Z
zhangpa2021 已提交
2884
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7000---------------------------");
J
jiyong 已提交
2885 2886 2887 2888
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7100
J
jiyong 已提交
2889
     * @tc.name    Writefloat interface, illegal value validation
J
jiyong 已提交
2890 2891 2892
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2893
    it("SUB_Softbus_IPC_MessageParcel_7100", 0,async function(){
Z
zhangpa2021 已提交
2894
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7100---------------------------");
J
jiyong 已提交
2895 2896
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2897
            console.info("SUB_Softbus_IPC_MessageParcel_7100: create object successfully.");
J
jiyong 已提交
2898

J
jiyong 已提交
2899 2900
            var token = 'a';
            var result = data.writeFloat(token);
Z
zhangpa2021 已提交
2901
            console.info("SUB_Softbus_IPC_MessageParcel_7100:run writeFloat success, result is " + result);
J
jiyong 已提交
2902
            expect(result == false).assertTrue();
J
jiyong 已提交
2903 2904
            data.reclaim();
        } catch (error) {
Z
zhangpa2021 已提交
2905
            console.info("SUB_Softbus_IPC_MessageParcel_7100:error = " + error);
J
jiyong 已提交
2906
        }
Z
zhangpa2021 已提交
2907
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7100---------------------------");
J
jiyong 已提交
2908 2909 2910 2911
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7200
J
jiyong 已提交
2912
     * @tc.name    Test messageparcel to deliver rawdata data
J
jiyong 已提交
2913 2914 2915 2916
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7200", 0,async function(){
Z
zhangpa2021 已提交
2917
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7200---------------------------");
J
jiyong 已提交
2918 2919
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2920
            console.info("SUB_Softbus_IPC_MessageParcel_7200: create object successfully.");
J
jiyong 已提交
2921

J
jiyong 已提交
2922
            var Capacity = data.getRawDataCapacity()
Z
zhangpa2021 已提交
2923
            console.info("SUB_Softbus_IPC_MessageParcel_7200:run Capacity success, Capacity is " + Capacity);
J
jiyong 已提交
2924

Z
zhangpa2021 已提交
2925
            var rawdata = [1, 2, 3]
J
jiyong 已提交
2926
            var result = data.writeRawData(rawdata, rawdata.length);
Z
zhangpa2021 已提交
2927
            console.info("SUB_Softbus_IPC_MessageParcel_7200:run writeRawData success, result is " + result);
J
jiyong 已提交
2928 2929
            expect(result == true).assertTrue();
            var newReadResult = data.readRawData(rawdata.length)
Z
zhangpa2021 已提交
2930
            console.info("SUB_Softbus_IPC_MessageParcel_7200:run readRawData success, result is " + newReadResult);
J
jiyong 已提交
2931 2932 2933
            expect(newReadResult[0] == rawdata[0]).assertTrue();
            expect(newReadResult[1] == rawdata[1]).assertTrue();
            expect(newReadResult[2] == rawdata[2]).assertTrue();
J
jiyong 已提交
2934
        } catch (error) {
Z
zhangpa2021 已提交
2935
            console.info("SUB_Softbus_IPC_MessageParcel_7200:error = " + error);
J
jiyong 已提交
2936
        }
J
jiyong 已提交
2937
        data.reclaim();
Z
zhangpa2021 已提交
2938
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7200---------------------------");
J
jiyong 已提交
2939 2940 2941 2942
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7300
J
jiyong 已提交
2943
     * @tc.name    Illegal value passed in from writerawdata interface
J
jiyong 已提交
2944 2945 2946 2947
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7300", 0,async function(done){
Z
zhangpa2021 已提交
2948
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7300---------------------------");
J
jiyong 已提交
2949 2950
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2951
            console.info("SUB_Softbus_IPC_MessageParcel_7300: create object successfully.");
J
jiyong 已提交
2952 2953
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
J
jiyong 已提交
2954
            var Capacity = data.getRawDataCapacity()
Z
zhangpa2021 已提交
2955 2956
            console.info("SUB_Softbus_IPC_MessageParcel_7300:run Capacity success, result is " + Capacity);
            var token = [2,1,4,3,129] ;
Z
zhangpa2021 已提交
2957
            var result = data.writeRawData(token, 149000000);
Z
zhangpa2021 已提交
2958
            console.info("SUB_Softbus_IPC_MessageParcel_7300:run writeRawData success, result is " + result);
J
jiyong 已提交
2959
            expect(result == false).assertTrue();
J
jiyong 已提交
2960 2961 2962 2963
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
2964
            console.info("SUB_Softbus_IPC_MessageParcel_7300:error = " + error);
J
jiyong 已提交
2965 2966
        }

Z
zhangpa2021 已提交
2967
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7300---------------------------");
J
jiyong 已提交
2968 2969 2970 2971
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7400
J
jiyong 已提交
2972
     * @tc.name    Call the writeremoteobject interface to serialize the remote object
J
jiyong 已提交
2973 2974 2975
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
2976
    it("SUB_Softbus_IPC_MessageParcel_7400", 0,async function(){
Z
zhangpa2021 已提交
2977
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7400---------------------------");
J
jiyong 已提交
2978 2979
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
2980
            console.info("SUB_Softbus_IPC_MessageParcel_7400: create object successfully.");
J
jiyong 已提交
2981

J
jiyong 已提交
2982 2983
            let testRemoteObject = new TestRemoteObject("testObject");
            var result = data.writeRemoteObject(testRemoteObject);
Z
zhangpa2021 已提交
2984
            console.info("SUB_Softbus_IPC_MessageParcel_7400: result is " + result);
J
jiyong 已提交
2985
            expect(result == true).assertTrue();
Z
zhangpa2021 已提交
2986
            data.readRemoteObject()           
J
jiyong 已提交
2987
        } catch (error) {
Z
zhangpa2021 已提交
2988
            console.info("SUB_Softbus_IPC_MessageParcel_7400:error = " + error);
J
jiyong 已提交
2989
        }
J
jiyong 已提交
2990
        data.reclaim();
Z
zhangpa2021 已提交
2991
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7400---------------------------");
J
jiyong 已提交
2992 2993 2994 2995
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7500
J
jiyong 已提交
2996
     * @tc.name    Call the writeremoteobject interface to serialize the remote object and pass in the empty object
J
jiyong 已提交
2997 2998 2999
     * @tc.desc    Function test
     * @tc.level   0
     */
J
jiyong 已提交
3000
    it("SUB_Softbus_IPC_MessageParcel_7500", 0,async function(){
Z
zhangpa2021 已提交
3001
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7500---------------------------");
J
jiyong 已提交
3002 3003
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3004
            console.info("SUB_Softbus_IPC_MessageParcel_7500: create object successfully.");
J
jiyong 已提交
3005

J
jiyong 已提交
3006 3007
            var token = {}
            var result = data.writeRemoteObject(token);
Z
zhangpa2021 已提交
3008
            console.info("SUB_Softbus_IPC_MessageParcel_7500: result is " + result);
J
jiyong 已提交
3009 3010
            expect(result == false).assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
3011
            console.info("SUB_Softbus_IPC_MessageParcel_7500:error = " + error);
J
jiyong 已提交
3012 3013
        }
        data.reclaim();
Z
zhangpa2021 已提交
3014
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7500---------------------------");
J
jiyong 已提交
3015 3016 3017 3018 3019 3020 3021 3022 3023 3024
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7600
     * @tc.name    Call the writesequenceable interface to write the custom serialized
     *             object to the messageparcel instance
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7600", 0,async function(){
Z
zhangpa2021 已提交
3025
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7600---------------------------");
J
jiyong 已提交
3026 3027
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3028
            console.info("SUB_Softbus_IPC_MessageParcel_7600: create object successfully.");
J
jiyong 已提交
3029 3030 3031 3032 3033
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            let sequenceable = new MySequenceable(1, "aaa");
            let result = data.writeSequenceable(sequenceable);
Z
zhangpa2021 已提交
3034
            console.info("SUB_Softbus_IPC_MessageParcel_7600: writeSequenceable is " + result);
J
jiyong 已提交
3035 3036 3037
            let ret = new MySequenceable(0, "");

            let result2 = data.readSequenceable(ret);
Z
zhangpa2021 已提交
3038
            console.info("SUB_Softbus_IPC_MessageParcel_7600: readSequenceable is " + result2);
J
jiyong 已提交
3039 3040
            expect(result2 == true).assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
3041
            console.info("SUB_Softbus_IPC_MessageParcel_7600:error = " + error);
J
jiyong 已提交
3042 3043
        }
        data.reclaim();
Z
zhangpa2021 已提交
3044
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7600---------------------------");
J
jiyong 已提交
3045 3046 3047 3048 3049 3050 3051 3052 3053 3054
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7700
     * @tc.name    After the server finishes processing, write noexception first before writing the result,
     *             and the client calls readexception to judge whether the server is abnormal
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7700", 0,async function(done){
Z
zhangpa2021 已提交
3055
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7700---------------------------");
J
jiyong 已提交
3056 3057
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3058
            console.info("SUB_Softbus_IPC_MessageParcel_7700: create object successfully.");
J
jiyong 已提交
3059 3060 3061 3062
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            data.writeNoException();
Z
zhangpa2021 已提交
3063
            console.info("SUB_Softbus_IPC_MessageParcel_7700: run writeNoException success");
J
jiyong 已提交
3064 3065 3066 3067
            expect(data.writeInt(6) == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3068
                console.info("SUB_Softbus_IPC_MessageParcel_7700: gIRemoteObject is undefined");
J
jiyong 已提交
3069 3070
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_NOEXCEPTION, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3071
                console.info("SUB_Softbus_IPC_MessageParcel_7700: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3072 3073
                result.reply.readException()
                var replyData = result.reply.readInt();
Z
zhangpa2021 已提交
3074
                console.info("SUB_Softbus_IPC_MessageParcel_7700: readResult is " + replyData);
J
jiyong 已提交
3075 3076 3077 3078 3079 3080 3081
                expect(replyData == 6).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3082
            console.info("SUB_Softbus_IPC_MessageParcel_7700:error = " + error);
J
jiyong 已提交
3083
        }
Z
zhangpa2021 已提交
3084
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7700---------------------------");
J
jiyong 已提交
3085 3086 3087 3088 3089 3090 3091 3092 3093 3094
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7800
     * @tc.name    If the data on the server is abnormal, the client calls readexception
     *             to judge whether the server is abnormal
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7800", 0,async function(done){
Z
zhangpa2021 已提交
3095
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7800---------------------------");
J
jiyong 已提交
3096 3097
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3098
            console.info("SUB_Softbus_IPC_MessageParcel_7800: create object successfully.");
J
jiyong 已提交
3099 3100 3101 3102
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            data.writeNoException();
Z
zhangpa2021 已提交
3103
            console.info("SUB_Softbus_IPC_MessageParcel_7800: run writeNoException success");
J
jiyong 已提交
3104 3105 3106 3107
            expect(data.writeInt(1232222223444) == true).assertTrue();

            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3108
                console.info("SUB_Softbus_IPC_MessageParcel_7800: gIRemoteObject is undefined");
J
jiyong 已提交
3109 3110
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_NOEXCEPTION, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3111
                console.info("SUB_Softbus_IPC_MessageParcel_7800: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3112 3113
                result.reply.readException()
                var replyData = result.reply.readInt();
Z
zhangpa2021 已提交
3114
                console.info("SUB_Softbus_IPC_MessageParcel_7800: readResult is " + replyData);
J
jiyong 已提交
3115 3116 3117 3118 3119 3120
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3121
            console.info("SUB_Softbus_IPC_MessageParcel_7800:error = " + error);
J
jiyong 已提交
3122
        }
Z
zhangpa2021 已提交
3123
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7800---------------------------");
J
jiyong 已提交
3124 3125 3126 3127 3128 3129 3130 3131 3132
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_7900
     * @tc.name    Serializable object marshaling and unmarshalling test
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_7900", 0, async function(done){
Z
zhangpa2021 已提交
3133
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_7900---------------------------");
J
jiyong 已提交
3134 3135
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3136
            console.info("SUB_Softbus_IPC_MessageParcel_7900: create object successfully.");
J
jiyong 已提交
3137 3138 3139 3140
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var sequenceable = new MySequenceable(1, "aaa");
            var result = data.writeSequenceable(sequenceable);
Z
zhangpa2021 已提交
3141
            console.info("SUB_Softbus_IPC_MessageParcel_7900: writeSequenceable is " + result);
J
jiyong 已提交
3142 3143 3144
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3145
                console.info("SUB_Softbus_IPC_MessageParcel_7900: gIRemoteObject is undefined");
J
jiyong 已提交
3146 3147
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SEQUENCEABLE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3148
                console.info("SUB_Softbus_IPC_MessageParcel_7900: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3149 3150
                var s = new MySequenceable(null,null)
                var resultReply = result.reply.readSequenceable(s);
Z
zhangpa2021 已提交
3151
                console.info("SUB_Softbus_IPC_MessageParcel_7900: run readSequenceable is success,result is "
J
jiyong 已提交
3152 3153 3154 3155 3156 3157 3158 3159 3160
                             + resultReply);
                expect(s.str == sequenceable.str).assertTrue();
                expect(s.num == sequenceable.num).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3161
            console.info("SUB_Softbus_IPC_MessageParcel_7900:error = " + error);
J
jiyong 已提交
3162 3163
        }

Z
zhangpa2021 已提交
3164
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_7900---------------------------");
J
jiyong 已提交
3165 3166 3167 3168 3169 3170 3171 3172 3173
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8000
     * @tc.name    Non serializable object marshaling test
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8000", 0, async function(done){
Z
zhangpa2021 已提交
3174
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8000---------------------------");
J
jiyong 已提交
3175 3176
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3177
            console.info("SUB_Softbus_IPC_MessageParcel_8000: create object successfully.");
J
jiyong 已提交
3178 3179 3180 3181
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var sequenceable = new MySequenceable(1, "aaa");
            var result = data.writeSequenceable(sequenceable);
Z
zhangpa2021 已提交
3182
            console.info("SUB_Softbus_IPC_MessageParcel_8000: writeSequenceable is " + result);
J
jiyong 已提交
3183 3184 3185
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3186
                console.info("SUB_Softbus_IPC_MessageParcel_8000: gIRemoteObject is undefined");
J
jiyong 已提交
3187 3188
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SEQUENCEABLE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3189
                console.info("SUB_Softbus_IPC_MessageParcel_8000: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3190 3191
                var s = new MySequenceable(null,null)
                var replyReadResult = reply.readSequenceable(s);
Z
zhangpa2021 已提交
3192
                console.info("SUB_Softbus_IPC_MessageParcel_8000: run readSequenceable is success," +
J
jiyong 已提交
3193 3194 3195 3196 3197 3198 3199 3200
                "result is " + replyReadResult);
                expect(replyReadResult == true).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3201
            console.info("SUB_Softbus_IPC_MessageParcel_8000:error = " + error);
J
jiyong 已提交
3202
        }
Z
zhangpa2021 已提交
3203
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8000---------------------------");
J
jiyong 已提交
3204 3205 3206 3207 3208 3209 3210 3211 3212
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8100
     * @tc.name    The server did not send a serializable object, and the client was ungrouped
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8100", 0,async function(done){
Z
zhangpa2021 已提交
3213
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8100---------------------------");
J
jiyong 已提交
3214 3215
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3216
            console.info("SUB_Softbus_IPC_MessageParcel_8100: create object successfully.");
J
jiyong 已提交
3217 3218 3219 3220
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var sequenceable = 10;
            var result = data.writeInt(sequenceable);
Z
zhangpa2021 已提交
3221
            console.info("RpcClient: writeInt is " + result);
J
jiyong 已提交
3222 3223 3224
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3225
                console.info("SUB_Softbus_IPC_MessageParcel_8100: gIRemoteObject is undefined");
J
jiyong 已提交
3226 3227
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_INT, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3228
                console.info("SUB_Softbus_IPC_MessageParcel_8100: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3229 3230
                var s = new MySequenceable(0,null)
                var replyReadResult = result.reply.readSequenceable(s);
Z
zhangpa2021 已提交
3231
                console.info("SUB_Softbus_IPC_MessageParcel_8100: run readSequenceable is success," +
J
jiyong 已提交
3232 3233 3234 3235 3236 3237 3238
                "result is " + replyReadResult);
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3239
            console.info("SUB_Softbus_IPC_MessageParcel_8100:error = " + error);
J
jiyong 已提交
3240 3241
        }

Z
zhangpa2021 已提交
3242
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8100---------------------------");
J
jiyong 已提交
3243 3244 3245 3246 3247 3248 3249 3250 3251 3252
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8200
     * @tc.name    Call the writesequenceable interface to write the custom serialized object to the
     *             messageparcel instance, and call readsequenceable to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8200", 0,async function(done){
Z
zhangpa2021 已提交
3253
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8200---------------------------");
J
jiyong 已提交
3254 3255
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3256
            console.info("SUB_Softbus_IPC_MessageParcel_8200: create object successfully.");
J
jiyong 已提交
3257 3258 3259 3260
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var sequenceable = new MySequenceable(2, "abc");
            var result = data.writeSequenceable(sequenceable);
Z
zhangpa2021 已提交
3261
            console.info("RpcClient: writeSequenceable is " + result);
J
jiyong 已提交
3262 3263 3264
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3265
                console.info("SUB_Softbus_IPC_MessageParcel_8200: gIRemoteObject is undefined");
J
jiyong 已提交
3266 3267
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SEQUENCEABLE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3268
                console.info("SUB_Softbus_IPC_MessageParcel_8200: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3269 3270
                var s = new MySequenceable(null,null)
                var replyReadResult = result.reply.readSequenceable(s);
Z
zhangpa2021 已提交
3271
                console.info("SUB_Softbus_IPC_MessageParcel_8200: run readSequenceable is success," +
J
jiyong 已提交
3272 3273 3274 3275 3276 3277 3278 3279 3280
                "result is " + replyReadResult);
                expect(s.str == sequenceable.str).assertTrue();
                expect(s.num == sequenceable.num).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3281
            console.info("SUB_Softbus_IPC_MessageParcel_8200:error = " + error);
J
jiyong 已提交
3282 3283
        }

Z
zhangpa2021 已提交
3284
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8200---------------------------");
J
jiyong 已提交
3285 3286 3287 3288 3289 3290 3291 3292 3293 3294
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8300
     * @tc.name    Call the writesequenceablearray interface to write the custom serialized object to the
     *             messageparcel instance, and call readsequenceablearray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8300", 0,async function(done){
Z
zhangpa2021 已提交
3295
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8300---------------------------");
J
jiyong 已提交
3296 3297
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3298
            console.info("SUB_Softbus_IPC_MessageParcel_8300: create object successfully.");
J
jiyong 已提交
3299 3300 3301 3302 3303
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var sequenceable = [new MySequenceable(1, "aaa"),
                                new MySequenceable(2, "bbb"), new MySequenceable(3, "ccc")];
            var result = data.writeSequenceableArray(sequenceable);
Z
zhangpa2021 已提交
3304
            console.info("SUB_Softbus_IPC_MessageParcel_8300: writeSequenceableArray is " + result);
J
jiyong 已提交
3305 3306 3307
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3308
                console.info("SUB_Softbus_IPC_MessageParcel_8300: gIRemoteObject is undefined");
J
jiyong 已提交
3309 3310
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SEQUENCEABLEARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3311
                console.info("SUB_Softbus_IPC_MessageParcel_8300: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3312 3313 3314
                var s = [new MySequenceable(null, null), new MySequenceable(null, null),
                         new MySequenceable(null, null)];
                result.reply.readSequenceableArray(s);
Z
zhangpa2021 已提交
3315
                console.info("SUB_Softbus_IPC_MessageParcel_8300: run readSequenceableArray is success.");
J
jiyong 已提交
3316 3317 3318 3319 3320 3321 3322 3323 3324 3325
                for (let i = 0; i < s.length; i++) {
                    expect(s[i].str).assertEqual(sequenceable[i].str)
                    expect(s[i].num).assertEqual(sequenceable[i].num)
                }
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3326
            console.info("SUB_Softbus_IPC_MessageParcel_8300:error = " + error);
J
jiyong 已提交
3327 3328
        }

Z
zhangpa2021 已提交
3329
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8300---------------------------");
J
jiyong 已提交
3330 3331 3332 3333 3334 3335 3336 3337 3338 3339
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8400
     * @tc.name    Call the writesequenceablearray interface to write the custom serialized object to the
     *             messageparcel instance, and call readsequenceablearray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8400", 0,async function(done){
Z
zhangpa2021 已提交
3340
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8400---------------------------");
J
jiyong 已提交
3341 3342
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3343
            console.info("SUB_Softbus_IPC_MessageParcel_8400: create object successfully.");
J
jiyong 已提交
3344 3345 3346 3347 3348
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            var sequenceable = [new MySequenceable(4, "abc"),
            new MySequenceable(5, "bcd"), new MySequenceable(6, "cef")];
            var result = data.writeSequenceableArray(sequenceable);
Z
zhangpa2021 已提交
3349
            console.info("SUB_Softbus_IPC_MessageParcel_8400: writeSequenceable is " + result);
J
jiyong 已提交
3350 3351 3352
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3353
                console.info("SUB_Softbus_IPC_MessageParcel_8400: gIRemoteObject is undefined");
J
jiyong 已提交
3354 3355
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_SEQUENCEABLEARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3356
                console.info("SUB_Softbus_IPC_MessageParcel_8400: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3357 3358 3359
                var s = [new MySequenceable(null, null),
                         new MySequenceable(null, null), new MySequenceable(null, null)]
                result.reply.readSequenceableArray(s);
Z
zhangpa2021 已提交
3360
                console.info("SUB_Softbus_IPC_MessageParcel_8400: run readSequenceableArray is success.");
J
jiyong 已提交
3361 3362 3363 3364 3365 3366 3367 3368 3369 3370
                for (let i = 0; i < s.length; i++) {
                    expect(s[i].str).assertEqual(sequenceable[i].str)
                    expect(s[i].num).assertEqual(sequenceable[i].num)
                }
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3371
            console.info("SUB_Softbus_IPC_MessageParcel_8400:error = " + error);
J
jiyong 已提交
3372 3373
        }

Z
zhangpa2021 已提交
3374
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8400---------------------------");
J
jiyong 已提交
3375 3376 3377 3378 3379 3380 3381 3382 3383 3384
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8500
     * @tc.name    Call the writesequenceablearray interface to write the custom
     *             serialized object to the messageparcel instance
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8500", 0,async function(){
Z
zhangpa2021 已提交
3385
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8500---------------------------");
J
jiyong 已提交
3386 3387
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3388
            console.info("SUB_Softbus_IPC_MessageParcel_8500: create object successfully.");
J
jiyong 已提交
3389 3390
            var sequenceable = 1;
            var result = data.writeSequenceableArray(sequenceable);
Z
zhangpa2021 已提交
3391
            console.info("SUB_Softbus_IPC_MessageParcel_8500: writeSequenceable is " + result);
J
jiyong 已提交
3392 3393
            expect(result == false).assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
3394
            console.info("SUB_Softbus_IPC_MessageParcel_8500:error = " + error);
J
jiyong 已提交
3395 3396
        }
        data.reclaim();
Z
zhangpa2021 已提交
3397
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8500---------------------------");
J
jiyong 已提交
3398 3399 3400 3401 3402 3403 3404 3405 3406 3407
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8600
     * @tc.name    Call the writeremoteobjectarray interface to write the object array to the messageparcel
     *             instance, and call readremoteobjectarray to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8600", 0,async function(done){
Z
zhangpa2021 已提交
3408
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8600---------------------------");
J
jiyong 已提交
3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420
        try{
            let count = 0
            function checkResult(num, str) {
                expect(num).assertEqual(123)
                expect(str).assertEqual("rpcListenerTest")
                count++;
                console.info("check result done, count: " + count)
                if (count == 3) {
                    done()
                }
            }
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3421
            console.info("SUB_Softbus_IPC_MessageParcel_8600: create object successfully.");
J
jiyong 已提交
3422 3423 3424 3425 3426 3427 3428 3429
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            expect(data.writeInterfaceToken("rpcTestAbility")).assertTrue()
            var listeners = [new TestListener("rpcListener", checkResult),
                                    new TestListener("rpcListener2", checkResult),
                                    new TestListener("rpcListener3", checkResult)];
            var result = data.writeRemoteObjectArray(listeners);
Z
zhangpa2021 已提交
3430
            console.info("SUB_Softbus_IPC_MessageParcel_8600: writeRemoteObjectArray is " + result);
J
jiyong 已提交
3431 3432 3433
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3434
                console.info("SUB_Softbus_IPC_MessageParcel_8600: gIRemoteObject is undefined");
J
jiyong 已提交
3435 3436
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3437
                console.info("SUB_Softbus_IPC_MessageParcel_8600: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3438
                expect(result.errCode).assertEqual(0);
Z
zhangpa2021 已提交
3439 3440 3441
                expect(result.code).assertEqual(CODE_WRITE_REMOTEOBJECTARRAY);
                expect(result.data).assertEqual(data);
                expect(result.reply).assertEqual(reply);
J
jiyong 已提交
3442 3443 3444 3445 3446 3447
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3448
            console.info("SUB_Softbus_IPC_MessageParcel_8600:error = " + error);
J
jiyong 已提交
3449 3450
        }

Z
zhangpa2021 已提交
3451
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8600---------------------------");
J
jiyong 已提交
3452 3453 3454 3455 3456 3457 3458 3459 3460 3461
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8700
     * @tc.name    Call the writeremoteobjectarray interface to write the object array to the messageparcel instance,
     *             and call readremoteobjectarray (objects: iremoteobject []) to read the data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8700", 0,async function(done){
Z
zhangpa2021 已提交
3462
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8700---------------------------");
J
jiyong 已提交
3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474
        try{
            let count = 0
            function checkResult(num, str) {
                expect(num).assertEqual(123)
                expect(str).assertEqual("rpcListenerTest")
                count++;
                console.info("check result done, count: " + count)
                if (count == 3) {
                    done()
                }
            }
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3475
            console.info("SUB_Softbus_IPC_MessageParcel_8700: create object successfully.");
J
jiyong 已提交
3476 3477 3478 3479 3480 3481 3482
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            expect(data.writeInterfaceToken("rpcTestAbility")).assertTrue()
            var listeners = [new TestListener("rpcListener", checkResult),
                             new TestListener("rpcListener2", checkResult),
                             new TestListener("rpcListener3", checkResult)];
            var result = data.writeRemoteObjectArray(listeners);
Z
zhangpa2021 已提交
3483
            console.info("RpcClient: writeRemoteObjectArray is " + result);
J
jiyong 已提交
3484 3485 3486
            expect(result == true).assertTrue();
            if (gIRemoteObject == undefined)
            {
Z
zhangpa2021 已提交
3487
                console.info("SUB_Softbus_IPC_MessageParcel_8700: gIRemoteObject is undefined");
J
jiyong 已提交
3488 3489
            }
            await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
3490
                console.info("SUB_Softbus_IPC_MessageParcel_8700: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
3491 3492 3493 3494 3495 3496 3497
                expect(result.errCode == 0).assertTrue();
            });

            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3498
            console.info("SUB_Softbus_IPC_MessageParcel_8700:error = " + error);
J
jiyong 已提交
3499
        }
Z
zhangpa2021 已提交
3500
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8700---------------------------");
J
jiyong 已提交
3501 3502 3503 3504 3505 3506 3507 3508 3509
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8800
     * @tc.name    Test messageparcel delivery file descriptor object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8800", 0,async function(done){
Z
zhangpa2021 已提交
3510
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8800---------------------------");
J
jiyong 已提交
3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542
        let context = FA.getContext()
        await context.getFilesDir()
            .then(async function(path) {
                expect(path != null).assertTrue()
                let basePath = path;
                let filePath = basePath + "/test1.txt";
                let fd = fileio.openSync(filePath, 0o2| 0o100 | 0o2000, 0o666);
                expect(fd >= 0).assertTrue()
                let str = "HELLO RPC"
                let bytesWr = fileio.writeSync(fd, str);
                let option = new rpc.MessageOption()
                let data = rpc.MessageParcel.create()
                let reply = rpc.MessageParcel.create()
                let result = data.containFileDescriptors()
                let writeInt = data.writeInt(bytesWr)
                expect(writeInt == true).assertTrue()
                let writeFileDescriptor = data.writeFileDescriptor(fd)
                expect(writeFileDescriptor == true).assertTrue()
                let result1 = data.containFileDescriptors()
                expect(data.containFileDescriptors()).assertTrue()
                await gIRemoteObject.sendRequest(CODE_FILESDIR, data, reply, option)
                    .then(function(result) {
                        expect(result.errCode).assertEqual(0)
                        let buf = new ArrayBuffer(str.length * 2);
                        let bytesRd = fileio.readSync(fd, buf, {position:0,});
                        let fdResult = reply.readFileDescriptor()
                        let content = String.fromCharCode.apply(null, new Uint8Array(buf));
                        expect(content).assertEqual(str + str)
                        let dupFd = rpc.MessageParcel.dupFileDescriptor(fd);
                        let buf2 = new ArrayBuffer(str.length * 2);
                        let byteRd2 = fileio.readSync(dupFd, buf2, {position:0,});
                        let content2 = String.fromCharCode.apply(null, new Uint8Array(buf2));
Z
zhangpa2021 已提交
3543
                        console.info("dupFd bytes read: " + byteRd2 + ", content2: " + content2);
J
jiyong 已提交
3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556
                        expect(content2).assertEqual(str + str)
                        rpc.MessageParcel.closeFileDescriptor(fd);
                        rpc.MessageParcel.closeFileDescriptor(dupFd);
                    })
                try {
                    console.info("after close fd, write again")
                    fileio.writeSync(fd, str)
                    expect(0).assertEqual(1)
                } catch(e) {
                    console.error("got exception: " + e)
                }
            })
        done()
Z
zhangpa2021 已提交
3557
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8800---------------------------");
J
jiyong 已提交
3558 3559 3560 3561 3562 3563 3564 3565 3566
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_8900
     * @tc.name    Test messageparcel to deliver the reply message received in promise across processes
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_8900", 0,async function(done){
Z
zhangpa2021 已提交
3567
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_8900---------------------------");
J
jiyong 已提交
3568 3569
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3570
            console.info("SUB_Softbus_IPC_MessageParcel_8900: create object successfully.");
J
jiyong 已提交
3571 3572 3573 3574 3575 3576 3577 3578 3579
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            expect(data.writeByte(2)).assertTrue()
            expect(data.writeShort(3)).assertTrue()
            expect(data.writeInt(4)).assertTrue()
            expect(data.writeLong(5)).assertTrue()
            expect(data.writeFloat(1.2)).assertTrue()
            expect(data.writeDouble(10.2)).assertTrue()
            expect(data.writeBoolean(true)).assertTrue()
Z
zhangpa2021 已提交
3580
            expect(data.writeChar(5)).assertTrue()
J
jiyong 已提交
3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593
            expect(data.writeString("HelloWorld")).assertTrue()
            expect(data.writeSequenceable(new MySequenceable(1, "aaa"))).assertTrue()

            await gIRemoteObject.sendRequest(CODE_ALL_TYPE, data, reply, option).then((result) => {
                console.info("sendRequest done, error code: " + result.errCode)
                expect(result.errCode).assertEqual(0)
                expect(result.reply.readByte()).assertEqual(2)
                expect(result.reply.readShort()).assertEqual(3)
                expect(result.reply.readInt()).assertEqual(4)
                expect(result.reply.readLong()).assertEqual(5)
                expect(result.reply.readFloat()).assertEqual(1.2)
                expect(result.reply.readDouble()).assertEqual(10.2)
                expect(result.reply.readBoolean()).assertTrue()
Z
zhangpa2021 已提交
3594
                expect(result.reply.readChar()).assertEqual(5)
J
jiyong 已提交
3595 3596 3597 3598 3599 3600 3601 3602 3603 3604
                expect(result.reply.readString()).assertEqual("HelloWorld")
                let s = new MySequenceable(null, null)
                expect(result.reply.readSequenceable(s)).assertTrue()
                expect(s.num).assertEqual(1)
                expect(s.str).assertEqual("aaa")
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3605
            console.info("SUB_Softbus_IPC_MessageParcel_8900:error = " + error);
J
jiyong 已提交
3606
        }
Z
zhangpa2021 已提交
3607
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_8900---------------------------");
J
jiyong 已提交
3608 3609 3610 3611 3612 3613 3614 3615 3616 3617
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_9000
     * @tc.name    Test the cross process delivery of messageparcel and receive the reply message
     *             in the callback function
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_9000", 0,async function(done){
Z
zhangpa2021 已提交
3618
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_9000---------------------------");
J
jiyong 已提交
3619 3620
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3621
            console.info("SUB_Softbus_IPC_MessageParcel_8900: create object successfully.");
J
jiyong 已提交
3622 3623 3624 3625 3626 3627 3628 3629 3630
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            expect(data.writeByte(2)).assertTrue()
            expect(data.writeShort(3)).assertTrue()
            expect(data.writeInt(4)).assertTrue()
            expect(data.writeLong(5)).assertTrue()
            expect(data.writeFloat(1.2)).assertTrue()
            expect(data.writeDouble(10.2)).assertTrue()
            expect(data.writeBoolean(true)).assertTrue()
Z
zhangpa2021 已提交
3631
            expect(data.writeChar(5)).assertTrue()
J
jiyong 已提交
3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644
            expect(data.writeString("HelloWorld")).assertTrue()
            expect(data.writeSequenceable(new MySequenceable(1, "aaa"))).assertTrue()

            gIRemoteObject.sendRequest(CODE_ALL_TYPE, data, reply, option,(err, result) => {
                console.info("sendRequest done, error code: " + result.errCode)
                expect(result.errCode).assertEqual(0)
                expect(result.reply.readByte()).assertEqual(2)
                expect(result.reply.readShort()).assertEqual(3)
                expect(result.reply.readInt()).assertEqual(4)
                expect(result.reply.readLong()).assertEqual(5)
                expect(result.reply.readFloat()).assertEqual(1.2)
                expect(result.reply.readDouble()).assertEqual(10.2)
                expect(result.reply.readBoolean()).assertTrue()
Z
zhangpa2021 已提交
3645
                expect(result.reply.readChar()).assertEqual(5)
J
jiyong 已提交
3646 3647 3648 3649 3650 3651 3652 3653 3654 3655
                expect(result.reply.readString()).assertEqual("HelloWorld")
                let s = new MySequenceable(null, null)
                expect(result.reply.readSequenceable(s)).assertTrue()
                expect(s.num).assertEqual(1)
                expect(s.str).assertEqual("aaa")
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3656
            console.info("SUB_Softbus_IPC_MessageParcel_9000:error = " + error);
J
jiyong 已提交
3657 3658 3659 3660
        }
        sleep(2000)
        data.reclaim();
        reply.reclaim();
Z
zhangpa2021 已提交
3661
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_9000---------------------------");
J
jiyong 已提交
3662 3663 3664 3665 3666 3667 3668 3669 3670 3671
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_9100
     * @tc.name    Test the cross process transmission of messageparcel.
     *             After receiving the reply message in promise, read various types of arrays in order
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_9100", 0,async function(done){
Z
zhangpa2021 已提交
3672
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_9100---------------------------");
J
jiyong 已提交
3673 3674
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3675
            console.info("SUB_Softbus_IPC_MessageParcel_9100: create object successfully.");
J
jiyong 已提交
3676 3677
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
Z
zhangpa2021 已提交
3678
            expect(data.writeByteArray([1, 2, 3])).assertTrue();
J
jiyong 已提交
3679 3680 3681 3682 3683 3684
            expect(data.writeShortArray([4, 5, 6])).assertTrue()
            expect(data.writeIntArray([7, 8, 9])).assertTrue()
            expect(data.writeLongArray([10, 11, 12])).assertTrue()
            expect(data.writeFloatArray([1.1, 1.2, 1.3])).assertTrue()
            expect(data.writeDoubleArray([2.1, 2.2, 2.3])).assertTrue()
            expect(data.writeBooleanArray([true, true, false])).assertTrue()
Z
zhangpa2021 已提交
3685
            expect(data.writeCharArray([10, 20, 30])).assertTrue()
J
jiyong 已提交
3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697
            expect(data.writeStringArray(['abc', 'seggg'])).assertTrue()
            let a = [new MySequenceable(1, "aaa"), new MySequenceable(2, "bbb"), new MySequenceable(3, "ccc")]
            expect(data.writeSequenceableArray(a)).assertTrue()
            gIRemoteObject.sendRequest(CODE_ALL_ARRAY_TYPE, data, reply, option,(err, result) => {
                expect(result.errCode).assertEqual(0)
                assertArrayElementEqual(result.reply.readByteArray(), [1, 2, 3])
                assertArrayElementEqual(result.reply.readShortArray(), [4, 5, 6])
                assertArrayElementEqual(result.reply.readIntArray(), [7, 8, 9])
                assertArrayElementEqual(result.reply.readLongArray(), [10, 11, 12])
                assertArrayElementEqual(result.reply.readFloatArray(), [1.1, 1.2, 1.3])
                assertArrayElementEqual(result.reply.readDoubleArray(), [2.1, 2.2, 2.3])
                assertArrayElementEqual(result.reply.readBooleanArray(), [true, true, false])
Z
zhangpa2021 已提交
3698
                assertArrayElementEqual(result.reply.readCharArray(), [10, 20, 30])
J
jiyong 已提交
3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711
                assertArrayElementEqual(result.reply.readStringArray(), ['abc', 'seggg'])
                let b = [new MySequenceable(null, null), new MySequenceable(null, null),
                    new MySequenceable(null, null)]
                result.reply.readSequenceableArray(b)
                for (let i = 0; i < b.length; i++) {
                    expect(b[i].str).assertEqual(a[i].str)
                    expect(b[i].num).assertEqual(a[i].num)
                }
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3712
            console.info("SUB_Softbus_IPC_MessageParcel_9100:error = " + error);
J
jiyong 已提交
3713 3714 3715 3716
        }
        sleep(2000)
        data.reclaim();
        reply.reclaim();
Z
zhangpa2021 已提交
3717
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_9100---------------------------");
J
jiyong 已提交
3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_9200
     * @tc.name    Test messageparcel cross process delivery. After receiving the reply message in promise,
     *             the client constructs an empty array in sequence and reads the data from the reply message
     *             into the corresponding array
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageParcel_9200", 0,async function(done){
Z
zhangpa2021 已提交
3729
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_9200---------------------------");
J
jiyong 已提交
3730 3731
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
3732
            console.info("SUB_Softbus_IPC_MessageParcel_9200: create object successfully.");
J
jiyong 已提交
3733 3734
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
Z
zhangpa2021 已提交
3735
            expect(data.writeByteArray([1, 2, 3])).assertTrue();
J
jiyong 已提交
3736 3737 3738 3739 3740 3741
            expect(data.writeShortArray([4, 5, 6])).assertTrue()
            expect(data.writeIntArray([7, 8, 9])).assertTrue()
            expect(data.writeLongArray([10, 11, 12])).assertTrue()
            expect(data.writeFloatArray([1.1, 1.2, 1.3])).assertTrue()
            expect(data.writeDoubleArray([2.1, 2.2, 2.3])).assertTrue()
            expect(data.writeBooleanArray([true, true, false])).assertTrue()
Z
zhangpa2021 已提交
3742
            expect(data.writeCharArray([10, 20, 30])).assertTrue()
J
jiyong 已提交
3743 3744 3745
            expect(data.writeStringArray(['abc', 'seggg'])).assertTrue()
            let a = [new MySequenceable(1, "aaa"), new MySequenceable(2, "bbb"), new MySequenceable(3, "ccc")]
            expect(data.writeSequenceableArray(a)).assertTrue()
Z
zhangpa2021 已提交
3746
            gIRemoteObject.sendRequest(CODE_ALL_ARRAY_TYPE, data, reply, option).then((result) => {
J
jiyong 已提交
3747 3748 3749 3750 3751 3752 3753 3754
                expect(result.errCode).assertEqual(0)
                assertArrayElementEqual(result.reply.readByteArray(), [1, 2, 3])
                assertArrayElementEqual(result.reply.readShortArray(), [4, 5, 6])
                assertArrayElementEqual(result.reply.readIntArray(), [7, 8, 9])
                assertArrayElementEqual(result.reply.readLongArray(), [10, 11, 12])
                assertArrayElementEqual(result.reply.readFloatArray(), [1.1, 1.2, 1.3])
                assertArrayElementEqual(result.reply.readDoubleArray(), [2.1, 2.2, 2.3])
                assertArrayElementEqual(result.reply.readBooleanArray(), [true, true, false])
Z
zhangpa2021 已提交
3755
                assertArrayElementEqual(result.reply.readCharArray(), [10, 20, 30])
J
jiyong 已提交
3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768
                assertArrayElementEqual(result.reply.readStringArray(), ['abc', 'seggg'])
                let b = [new MySequenceable(null, null), new MySequenceable(null, null),
                new MySequenceable(null, null)]
                result.reply.readSequenceableArray(b)
                for (let i = 0; i < b.length; i++) {
                    expect(b[i].str).assertEqual(a[i].str)
                    expect(b[i].num).assertEqual(a[i].num)
                }
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
3769
            console.info("SUB_Softbus_IPC_MessageParcel_9200:error = " + error);
J
jiyong 已提交
3770 3771 3772 3773
        }
        sleep(2000)
        data.reclaim();
        reply.reclaim();
Z
zhangpa2021 已提交
3774
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_9200---------------------------");
J
jiyong 已提交
3775 3776 3777 3778 3779 3780 3781 3782 3783
    });

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_9300
     * @tc.name    Test messageparcel to pass an object of type iremoteobject across processes
     * @tc.desc    Function test
     * @tc.level   0
     */
    it('SUB_Softbus_IPC_MessageParcel_9300', 0, async function(done) {
Z
zhangpa2021 已提交
3784
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_9300---------------------------");
J
jiyong 已提交
3785 3786 3787 3788 3789
        function checkResult(num, str) {
            expect(num).assertEqual(123)
            expect(str).assertEqual("rpcListenerTest")
            done()
        }
Z
zhangpa2021 已提交
3790
    try{
J
jiyong 已提交
3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801
        let option = new rpc.MessageOption()
        let data = rpc.MessageParcel.create()
        let reply = rpc.MessageParcel.create()

        let listener = new TestListener("rpcListener", checkResult)
        let result = data.writeRemoteObject(listener)
        expect(result == true).assertTrue()
        console.info("SUB_Softbus_IPC_MessageParcel_9300 result is:" + result)
        expect(data.writeInt(123)).assertTrue()
        expect(data.writeString("rpcListenerTest")).assertTrue()
        await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECT, data, reply, option)
Z
zhangpa2021 已提交
3802
            .then((result)=> {
J
jiyong 已提交
3803 3804 3805 3806
                console.info("sendRequest done, error code: " + result.errCode)
                expect(result.errCode).assertEqual(0)
                result.reply.readException()
            })
Z
zhangpa2021 已提交
3807

J
jiyong 已提交
3808 3809
                data.reclaim()
                reply.reclaim()
Z
zhangpa2021 已提交
3810
                console.info("test done")
Z
zhangpa2021 已提交
3811
    } catch(error) {
Z
zhangpa2021 已提交
3812
            console.info("SUB_Softbus_IPC_MessageParcel_9300: error = " + error);
Z
zhangpa2021 已提交
3813
        }
Z
zhangpa2021 已提交
3814
            console.info("---------------------end SUB_Softbus_IPC_MessageParcel_9300---------------------------");
Z
zhangpa2021 已提交
3815
    })
Z
zhangpa2021 已提交
3816
    
J
jiyong 已提交
3817 3818 3819 3820 3821 3822 3823 3824

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_9400
     * @tc.name    Test messageparcel to pass an array of iremoteobject objects across processes
     * @tc.desc    Function test
     * @tc.level   0
     */
    it('SUB_Softbus_IPC_MessageParcel_9400', 0, async function(done) {
Z
zhangpa2021 已提交
3825
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_9400---------------------------");
Z
zhangpa2021 已提交
3826 3827 3828 3829 3830 3831 3832 3833
        
        let count = 0;
        function checkResult(num, str) {
            expect(num).assertEqual(123)
            expect(str).assertEqual("rpcListenerTest")
            count++
            console.info("check result done, count: " + count)
            if (count == 3) {
J
jiyong 已提交
3834 3835
                done()
            }
Z
zhangpa2021 已提交
3836 3837 3838
        }

        try{
J
jiyong 已提交
3839 3840 3841
            let option = new rpc.MessageOption()
            let data = rpc.MessageParcel.create()
            let reply = rpc.MessageParcel.create()
Z
zhangpa2021 已提交
3842 3843 3844
            let listeners = [new TestListener("rpcListener", checkResult),
            new TestListener("rpcListener2", checkResult),
            new TestListener("rpcListener3", checkResult)]
J
jiyong 已提交
3845 3846 3847 3848 3849
            let result = data.writeRemoteObjectArray(listeners)
            expect(result == true).assertTrue()
            console.info("SUB_Softbus_IPC_MessageParcel_9400 result is:" + result)
            expect(data.writeInt(123)).assertTrue()
            expect(data.writeString("rpcListenerTest")).assertTrue()
Z
zhangpa2021 已提交
3850
            await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY_1, data, reply, option)
Z
zhangpa2021 已提交
3851 3852
            .then((result)=> {
                console.info("sendRequest done, error code: " + result.errCode)
Z
zhangpa2021 已提交
3853
                expect(result.errCode).assertEqual(0)
Z
zhangpa2021 已提交
3854
                result.reply.readException()
Z
zhangpa2021 已提交
3855
            })
Z
zhangpa2021 已提交
3856

Z
zhangpa2021 已提交
3857 3858
                data.reclaim()
                reply.reclaim()
Z
zhangpa2021 已提交
3859
                console.info("test done")
Z
zhangpa2021 已提交
3860
        } catch(error) {
Z
zhangpa2021 已提交
3861
            console.info("SUB_Softbus_IPC_MessageParcel_9400: error = " + error);
Z
zhangpa2021 已提交
3862
            }
Z
zhangpa2021 已提交
3863
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_9400---------------------------");
J
jiyong 已提交
3864 3865 3866 3867 3868 3869 3870 3871 3872 3873
    })

    /*
     * @tc.number  SUB_Softbus_IPC_MessageParcel_9500
     * @tc.name    Test messageparcel to pass the array of iremoteobject objects across processes. The server
     *             constructs an empty array in onremoterequest and reads it from messageparcel
     * @tc.desc    Function test
     * @tc.level   0
     */
    it('SUB_Softbus_IPC_MessageParcel_9500', 0, async function(done) {
Z
zhangpa2021 已提交
3874
        console.info("---------------------start SUB_Softbus_IPC_MessageParcel_9500---------------------------");
Z
zhangpa2021 已提交
3875 3876 3877 3878 3879 3880 3881
        let count = 0;
        function checkResult(num, str) {
            expect(num).assertEqual(123)
            expect(str).assertEqual("rpcListenerTest")
            count++
            console.info("check result done, count: " + count)
            if (count == 3) {
J
jiyong 已提交
3882 3883
                done()
            }
Z
zhangpa2021 已提交
3884 3885 3886
        }

        try{
J
jiyong 已提交
3887 3888 3889
            let option = new rpc.MessageOption()
            let data = rpc.MessageParcel.create()
            let reply = rpc.MessageParcel.create()
Z
zhangpa2021 已提交
3890 3891 3892
            let listeners = [new TestListener("rpcListener", checkResult),
            new TestListener("rpcListener2", checkResult),
            new TestListener("rpcListener3", checkResult)]
J
jiyong 已提交
3893 3894
            let result = data.writeRemoteObjectArray(listeners)
            expect(result == true).assertTrue()
Z
zhangpa2021 已提交
3895
            data.readRemoteObjectArray()
J
jiyong 已提交
3896 3897 3898
            console.info("SUB_Softbus_IPC_MessageParcel_9500 result is:" + result)
            expect(data.writeInt(123)).assertTrue()
            expect(data.writeString("rpcListenerTest")).assertTrue()
Z
zhangpa2021 已提交
3899
            await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY_2, data, reply, option)
Z
zhangpa2021 已提交
3900 3901 3902 3903 3904 3905 3906 3907
            .then((result)=> {
                console.info("sendRequest done, error code: " + result.errCode)
                expect(result.errCode).assertEqual(0)
                result.reply.readException()
            })

                data.reclaim()
                reply.reclaim()
Z
zhangpa2021 已提交
3908
                console.info("test done")
Z
zhangpa2021 已提交
3909
        } catch(error) {
Z
zhangpa2021 已提交
3910
            console.info("SUB_Softbus_IPC_MessageParcel_9500: error = " + error);
Z
zhangpa2021 已提交
3911
            }
Z
zhangpa2021 已提交
3912
        console.info("---------------------end SUB_Softbus_IPC_MessageParcel_9500---------------------------");
J
jiyong 已提交
3913 3914 3915 3916 3917 3918 3919 3920 3921
    })

    /*
     * @tc.number  SUB_Softbus_IPC_MessageOption_0100
     * @tc.name    Basic method of testing messageoption
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageOption_0100",0,function(){
Z
zhangpa2021 已提交
3922
        console.info("---------------------start SUB_Softbus_IPC_MessageOption_0100---------------------------");
J
jiyong 已提交
3923 3924
        try{
            let option = new rpc.MessageOption();
Z
zhangpa2021 已提交
3925
            console.info("SUB_Softbus_IPC_MessageOption_0100: create object successfully.");
J
jiyong 已提交
3926 3927

            let time = option.getWaitTime();
Z
zhangpa2021 已提交
3928
            console.info("SUB_Softbus_IPC_MessageOption_0100: run getWaitTime success, time is " + time);
J
jiyong 已提交
3929 3930 3931
            expect(time == rpc.MessageOption.TF_WAIT_TIME).assertTrue();

            let flog = option.getFlags();
Z
zhangpa2021 已提交
3932
            console.info("SUB_Softbus_IPC_MessageOption_0100: run getFlags success, flog is " + flog);
J
jiyong 已提交
3933 3934
            expect(flog == rpc.MessageOption.TF_SYNC).assertTrue();

Z
zhangpa2021 已提交
3935
            option.setFlags(rpc.MessageOption.TF_AYNC)
Z
zhangpa2021 已提交
3936
            console.info("SUB_Softbus_IPC_MessageOption_0100: run setFlags success");
J
jiyong 已提交
3937 3938

            let flog2 = option.getFlags();
Z
zhangpa2021 已提交
3939
            console.info("SUB_Softbus_IPC_MessageOption_0100: run getFlags success, flog2 is " + flog2);
J
jiyong 已提交
3940 3941 3942 3943

            option.setWaitTime(16);

            let time2 = option.getWaitTime();
Z
zhangpa2021 已提交
3944
            console.info("SUB_Softbus_IPC_MessageOption_0100: run getWaitTime success, time is " + time2);
J
jiyong 已提交
3945 3946
            expect(time2 == 16).assertTrue();
        }catch(error){
Z
zhangpa2021 已提交
3947
            console.info("SUB_Softbus_IPC_MessageOption_0100: error " + error);
J
jiyong 已提交
3948
        }
Z
zhangpa2021 已提交
3949
        console.info("---------------------end SUB_Softbus_IPC_MessageOption_0100---------------------------");
J
jiyong 已提交
3950 3951 3952 3953 3954 3955 3956 3957 3958
    })

    /*
     * @tc.number  SUB_Softbus_IPC_MessageOption_0200
     * @tc.name    Setflags interface outlier detection
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageOption_0200",0,function(){
Z
zhangpa2021 已提交
3959
        console.info("---------------------start SUB_Softbus_IPC_MessageOption_0200---------------------------");
J
jiyong 已提交
3960 3961
        try{
            let option = new rpc.MessageOption();
Z
zhangpa2021 已提交
3962
            console.info("SUB_Softbus_IPC_MessageOption_0200: create object successfully.");
J
jiyong 已提交
3963 3964

            let time = option.getWaitTime();
Z
zhangpa2021 已提交
3965
            console.info("SUB_Softbus_IPC_MessageOption_0200: run getWaitTime success, time is " + time);
J
jiyong 已提交
3966 3967 3968
            expect(time == rpc.MessageOption.TF_WAIT_TIME).assertTrue();

            let flog = option.getFlags();
Z
zhangpa2021 已提交
3969
            console.info("SUB_Softbus_IPC_MessageOption_0200: run getFlags success, flog is " + flog);
J
jiyong 已提交
3970 3971 3972 3973
            expect(flog == rpc.MessageOption.TF_SYNC);

            option.setFlags(3);
        }catch(error){
Z
zhangpa2021 已提交
3974
            console.info("SUB_Softbus_IPC_MessageOption_0200: error " + error);
J
jiyong 已提交
3975
        }
Z
zhangpa2021 已提交
3976
        console.info("---------------------end SUB_Softbus_IPC_MessageOption_0200---------------------------");
J
jiyong 已提交
3977 3978
    })

Z
zhangpa2021 已提交
3979 3980 3981 3982 3983 3984 3985
    /*
     * @tc.number  SUB_Softbus_IPC_MessageOption_0300
     * @tc.name    Setflags interface outlier detection
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_MessageOption_0300",0,function(){
Z
zhangpa2021 已提交
3986
        console.info("---------------------start SUB_Softbus_IPC_MessageOption_0300---------------------------");
Z
zhangpa2021 已提交
3987 3988 3989
        try{
           expect(rpc.MessageOption.TF_SYNC).assertEqual(0);

Z
zhangpa2021 已提交
3990
           expect(rpc.MessageOption.TF_ASYNC).assertEqual(1);
Z
zhangpa2021 已提交
3991 3992 3993 3994 3995 3996

           expect(rpc.MessageOption.TF_WAIT_TIME).assertEqual(4);

           expect(rpc.MessageOption.TF_ACCEPT_FDS).assertEqual(0x10);

        }catch(error){
Z
zhangpa2021 已提交
3997
            console.info("SUB_Softbus_IPC_MessageOption_0300: error " + error);
Z
zhangpa2021 已提交
3998
        }
Z
zhangpa2021 已提交
3999
        console.info("---------------------end SUB_Softbus_IPC_MessageOption_0300---------------------------");
Z
zhangpa2021 已提交
4000 4001
    })

J
jiyong 已提交
4002 4003 4004 4005 4006 4007 4008
    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0100
     * @tc.name    Exception parameter validation of the created anonymous shared memory object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0100",0,function(){
Z
zhangpa2021 已提交
4009
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0100---------------------------");
J
jiyong 已提交
4010 4011
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", -1)
Z
zhangpa2021 已提交
4012
            console.info("SUB_Softbus_IPC_Ashmem_0100: ashmem " + ashmem);
J
jiyong 已提交
4013 4014

            let ashmem2 = rpc.Ashmem.createAshmem(null, 1024)
Z
zhangpa2021 已提交
4015
            console.info("SUB_Softbus_IPC_Ashmem_0100: ashmem2 " + ashmem2);
J
jiyong 已提交
4016
        }catch(error){
Z
zhangpa2021 已提交
4017
            console.info("SUB_Softbus_IPC_Ashmem_0100: error " + error);
J
jiyong 已提交
4018
        }
Z
zhangpa2021 已提交
4019
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0100---------------------------");
J
jiyong 已提交
4020 4021 4022 4023 4024 4025 4026 4027 4028
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0200
     * @tc.name    Call the getashmemsize interface to get the size of the shared memory object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0200",0,function(){
Z
zhangpa2021 已提交
4029
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0200---------------------------");
J
jiyong 已提交
4030 4031 4032
        try{
            let mapSize = 4096;
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", mapSize)
Z
zhangpa2021 已提交
4033
            console.info("SUB_Softbus_IPC_Ashmem_0200: run  createAshmem success");
J
jiyong 已提交
4034

Z
zhangpa2021 已提交
4035
            ashmem.closeAshmem();
J
jiyong 已提交
4036
            let size = ashmem.getAshmemSize()
Z
zhangpa2021 已提交
4037 4038
            console.info("SUB_Softbus_IPC_Ashmem_0200: run getAshmemSize success, size is " + size);
            expect(size == mapSize).assertFale();
J
jiyong 已提交
4039

Z
zhangpa2021 已提交
4040
            
J
jiyong 已提交
4041
        }catch(error){
Z
zhangpa2021 已提交
4042
            console.info("SUB_Softbus_IPC_Ashmem_0200: error " + error);
J
jiyong 已提交
4043
        }
Z
zhangpa2021 已提交
4044
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0200---------------------------");
J
jiyong 已提交
4045 4046 4047 4048 4049 4050 4051 4052 4053
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0300
     * @tc.name    Call the getashmemsize interface to get the size of the shared memory object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0300",0,function(){
Z
zhangpa2021 已提交
4054
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0300---------------------------");
J
jiyong 已提交
4055 4056 4057
        try{
            let mapSize = 4096;
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", mapSize)
Z
zhangpa2021 已提交
4058
            console.info("SUB_Softbus_IPC_Ashmem_0300: run  createAshmem success");
J
jiyong 已提交
4059 4060

            let size = ashmem.getAshmemSize()
Z
zhangpa2021 已提交
4061
            console.info("SUB_Softbus_IPC_Ashmem_0300: run getAshmemSize success, size is " + size);
J
jiyong 已提交
4062 4063 4064 4065
            expect(size == mapSize).assertTrue();

            ashmem.closeAshmem();
        }catch(error){
Z
zhangpa2021 已提交
4066
            console.info("SUB_Softbus_IPC_Ashmem_0300: error " + error);
J
jiyong 已提交
4067
        }
Z
zhangpa2021 已提交
4068
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0300---------------------------");
J
jiyong 已提交
4069 4070 4071 4072 4073 4074 4075 4076 4077
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0400
     * @tc.name    Writeashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0400",0,function(){
Z
zhangpa2021 已提交
4078
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0400---------------------------");
J
jiyong 已提交
4079 4080
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4081
            console.info("SUB_Softbus_IPC_Ashmem_0400: ashmem " + ashmem);
J
jiyong 已提交
4082 4083 4084 4085 4086

            ashmem.closeAshmem()

            var data = rpc.MessageParcel.create();
            let writeAshmem = data.writeAshmem(ashmem);
Z
zhangpa2021 已提交
4087
            console.info("SUB_Softbus_IPC_Ashmem_0400: run writeAshmem success, writeAshmem is " + writeAshmem);
J
jiyong 已提交
4088 4089 4090 4091
            expect(writeAshmem == false).assertTrue();

            data.reclaim();
        }catch(error){
Z
zhangpa2021 已提交
4092
            console.info("SUB_Softbus_IPC_Ashmem_0400: error " + error);
J
jiyong 已提交
4093
        }
Z
zhangpa2021 已提交
4094
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0400---------------------------");
J
jiyong 已提交
4095 4096 4097 4098 4099 4100 4101 4102 4103
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0500
     * @tc.name    Readfromashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0500",0,function(){
Z
zhangpa2021 已提交
4104
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0500---------------------------");
J
jiyong 已提交
4105 4106
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4107
            console.info("SUB_Softbus_IPC_Ashmem_0500: ashmem " + ashmem);
J
jiyong 已提交
4108 4109

            ashmem.unmapAshmem()
Z
zhangpa2021 已提交
4110
            console.info("SUB_Softbus_IPC_Ashmem_0500: run unmapAshmem success");
J
jiyong 已提交
4111 4112 4113 4114

            let bytes = new Int8Array([1, 2, 3, 4, 5])

            let ret = ashmem.readFromAshmem(bytes.length, 0);
Z
zhangpa2021 已提交
4115
            console.info("SUB_Softbus_IPC_Ashmem_0500: run readFromAshmem result is " + ret);
J
jiyong 已提交
4116 4117 4118 4119
            expect(ret==null).assertTrue();

            ashmem.closeAshmem();
        }catch(error){
Z
zhangpa2021 已提交
4120
            console.info("SUB_Softbus_IPC_Ashmem_0500: error " + error);
J
jiyong 已提交
4121
        }
Z
zhangpa2021 已提交
4122
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0500---------------------------");
J
jiyong 已提交
4123 4124 4125 4126 4127 4128 4129 4130 4131
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0600
     * @tc.name    Mapashmem interface creates shared file mappings
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0600",0,function(){
Z
zhangpa2021 已提交
4132
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0600---------------------------");
J
jiyong 已提交
4133 4134
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4135
            console.info("SUB_Softbus_IPC_Ashmem_0600: ashmem " + ashmem);
J
jiyong 已提交
4136 4137

            let result = ashmem.mapAshmem(rpc.Ashmem.PROT_READ);
Z
zhangpa2021 已提交
4138
            console.info("SUB_Softbus_IPC_Ashmem_0600: run mapAshmem success, result is " + result);
J
jiyong 已提交
4139 4140 4141 4142
            expect(result == true).assertTrue();

            ashmem.closeAshmem()
        }catch(error){
Z
zhangpa2021 已提交
4143
            console.info("SUB_Softbus_IPC_Ashmem_0600: error " + error);
J
jiyong 已提交
4144
        }
Z
zhangpa2021 已提交
4145
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0600---------------------------");
J
jiyong 已提交
4146 4147 4148 4149 4150 4151 4152 4153 4154
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0700
     * @tc.name    Mapashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0700",0,function(){
Z
zhangpa2021 已提交
4155
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0700---------------------------");
J
jiyong 已提交
4156 4157 4158
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4159
            console.info("SUB_Softbus_IPC_Ashmem_0700: ashmem " + ashmem);
J
jiyong 已提交
4160 4161

            let result = ashmem.mapAshmem(999);
Z
zhangpa2021 已提交
4162
            console.info("SUB_Softbus_IPC_Ashmem_0700: run mapAshmem success, result is " + result);
J
jiyong 已提交
4163 4164 4165 4166
            expect(result == false).assertTrue();

            ashmem.closeAshmem()
        }catch(error){
Z
zhangpa2021 已提交
4167
            console.info("SUB_Softbus_IPC_Ashmem_0700: error " + error);
J
jiyong 已提交
4168
        }
Z
zhangpa2021 已提交
4169
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0700---------------------------");
J
jiyong 已提交
4170 4171 4172 4173 4174 4175 4176 4177 4178
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0800
     * @tc.name    Mapreadandwriteashmem interface creates a shared file map with the protection level of read-write
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0800",0,function(){
Z
zhangpa2021 已提交
4179
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0800---------------------------");
J
jiyong 已提交
4180 4181 4182
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 1024)
Z
zhangpa2021 已提交
4183
            console.info("SUB_Softbus_IPC_Ashmem_0800: ashmem " + ashmem);
J
jiyong 已提交
4184 4185

            let result = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4186
            console.info("SUB_Softbus_IPC_Ashmem_0800: run mapAshmem success, result is " + result);
J
jiyong 已提交
4187 4188 4189 4190

            ashmem.closeAshmem()

        }catch(error){
Z
zhangpa2021 已提交
4191
            console.info("SUB_Softbus_IPC_Ashmem_0800: error " + error);
J
jiyong 已提交
4192
        }
Z
zhangpa2021 已提交
4193
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0800---------------------------");
J
jiyong 已提交
4194 4195 4196 4197 4198 4199 4200 4201 4202
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_0900
     * @tc.name    Mapreadandwriteashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_0900",0,function(){
Z
zhangpa2021 已提交
4203
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_0900---------------------------");
J
jiyong 已提交
4204 4205
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4206
            console.info("SUB_Softbus_IPC_Ashmem_0900: ashmem " + ashmem);
J
jiyong 已提交
4207 4208

            let result = ashmem.mapAshmem(rpc.Ashmem.PROT_READ);
Z
zhangpa2021 已提交
4209
            console.info("SUB_Softbus_IPC_Ashmem_0900: run mapAshmem success, result is " + result);
J
jiyong 已提交
4210 4211
            expect(result == true).assertTrue();

Z
zhangpa2021 已提交
4212
            ashmem.closeAshmem()
Z
zhangpa2021 已提交
4213
            console.info("SUB_Softbus_IPC_Ashmem_0900: run unmapAshmem success");
Z
zhangpa2021 已提交
4214
            expect(ashmem.mapReadAndWriteAshmem()).assertFalse();
J
jiyong 已提交
4215

Z
zhangpa2021 已提交
4216

J
jiyong 已提交
4217
        }catch(error){
Z
zhangpa2021 已提交
4218
            console.info("SUB_Softbus_IPC_Ashmem_0900: error " + error);
J
jiyong 已提交
4219
        }
Z
zhangpa2021 已提交
4220
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_0900---------------------------");
J
jiyong 已提交
4221 4222 4223 4224 4225 4226 4227 4228 4229
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1000
     * @tc.name    Mapreadonlyashmem interface creates a shared file map with the protection level of read-write
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1000",0,function(){
Z
zhangpa2021 已提交
4230
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1000---------------------------");
J
jiyong 已提交
4231 4232 4233
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4234
            console.info("SUB_Softbus_IPC_Ashmem_1000: ashmem " + ashmem);
J
jiyong 已提交
4235 4236

            let result = ashmem.mapReadOnlyAshmem();
Z
zhangpa2021 已提交
4237
            console.info("SUB_Softbus_IPC_Ashmem_1000: run mapReadAndWriteAshmem success, result is " + result);
J
jiyong 已提交
4238 4239 4240 4241
            expect(result == true).assertTrue();

            ashmem.closeAshmem();
        }catch(error){
Z
zhangpa2021 已提交
4242
            console.info("SUB_Softbus_IPC_Ashmem_1000: error " + error);
J
jiyong 已提交
4243
        }
Z
zhangpa2021 已提交
4244
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1000---------------------------");
J
jiyong 已提交
4245 4246 4247
    })

    /*
Z
zhangpa2021 已提交
4248
     * @tc.number  SUB_Softbus_IPC_Ashmem_1100
J
jiyong 已提交
4249 4250 4251 4252 4253
     * @tc.name    Mapreadonlyashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1100",0,function(){
Z
zhangpa2021 已提交
4254
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1100---------------------------");
J
jiyong 已提交
4255 4256 4257
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 1024)
Z
zhangpa2021 已提交
4258
            console.info("SUB_Softbus_IPC_Ashmem_1100: ashmem " + ashmem);
J
jiyong 已提交
4259 4260

            let result = ashmem.mapAshmem(rpc.Ashmem.PROT_WRITE);
Z
zhangpa2021 已提交
4261
            console.info("SUB_Softbus_IPC_Ashmem_1100: run mapAshmem success, result is " + result);
J
jiyong 已提交
4262 4263 4264
            expect(result == true).assertTrue();

            ashmem.unmapAshmem();
Z
zhangpa2021 已提交
4265
            console.info("SUB_Softbus_IPC_Ashmem_1100: run unmapAshmem success");
Z
zhangpa2021 已提交
4266
            ashmem.closeAshmem()
J
jiyong 已提交
4267
            let result2 = ashmem.mapReadOnlyAshmem();
Z
zhangpa2021 已提交
4268
            console.info("SUB_Softbus_IPC_Ashmem_1100: run mapReadAndWriteAshmem success, result2 is " + result2);
J
jiyong 已提交
4269 4270
            expect(result2 == false).assertTrue();
        }catch(error){
Z
zhangpa2021 已提交
4271
            console.info("SUB_Softbus_IPC_Ashmem_1100: error " + error);
J
jiyong 已提交
4272
        }
Z
zhangpa2021 已提交
4273
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1100---------------------------");
J
jiyong 已提交
4274 4275 4276 4277 4278 4279 4280 4281 4282
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1200
     * @tc.name    Mapreadonlyashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1200",0,function(){
Z
zhangpa2021 已提交
4283
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1200---------------------------");
J
jiyong 已提交
4284 4285 4286 4287
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 1024);

            let resultwrite = ashmem.setProtection(rpc.Ashmem.PROT_WRITE)
Z
zhangpa2021 已提交
4288
            console.info("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, resultwrite is " + resultwrite);
J
jiyong 已提交
4289 4290 4291
            expect(resultwrite == true).assertTrue();

            let resultread = ashmem.setProtection(rpc.Ashmem.PROT_READ)
Z
zhangpa2021 已提交
4292
            console.info("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, resultread is " + resultread);
J
jiyong 已提交
4293 4294 4295
            expect(resultread == false).assertTrue();

            let resultreadAndwrite = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4296
            console.info("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, mapReadAndWriteAshmem is "
J
jiyong 已提交
4297 4298 4299 4300
                         + resultreadAndwrite);
            expect(resultreadAndwrite == false).assertTrue();

            let resultnone = ashmem.setProtection(rpc.Ashmem.PROT_NONE)
Z
zhangpa2021 已提交
4301
            console.info("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, resultnone is " + resultnone);
J
jiyong 已提交
4302 4303 4304
            expect(resultnone == true).assertTrue();

            let resultread2 = ashmem.setProtection(rpc.Ashmem.PROT_READ)
Z
zhangpa2021 已提交
4305
            console.info("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, resultread2 is " + resultread2);
J
jiyong 已提交
4306 4307 4308 4309
            expect(resultread2 == false).assertTrue();

            ashmem.closeAshmem()
        }catch(error){
Z
zhangpa2021 已提交
4310
            console.info("SUB_Softbus_IPC_Ashmem_1200: error " + error);
J
jiyong 已提交
4311
        }
Z
zhangpa2021 已提交
4312
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1200---------------------------");
J
jiyong 已提交
4313 4314 4315 4316 4317 4318 4319 4320 4321
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1300
     * @tc.name    Setprotection exception input parameter verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1300",0,function(){
Z
zhangpa2021 已提交
4322
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1300---------------------------");
J
jiyong 已提交
4323 4324 4325
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 1024);
Z
zhangpa2021 已提交
4326
            console.info("SUB_Softbus_IPC_Ashmem_1300: ashmem " + ashmem);
J
jiyong 已提交
4327 4328

            let result = ashmem.setProtection(3);
Z
zhangpa2021 已提交
4329
            console.info("SUB_Softbus_IPC_Ashmem_1300: run setProtection success, result is " + result);
Z
zhangpa2021 已提交
4330
            expect(result == true).assertTrue();
J
jiyong 已提交
4331 4332 4333

            ashmem.closeAshmem()
        }catch(error){
Z
zhangpa2021 已提交
4334
            console.info("SUB_Softbus_IPC_Ashmem_1300: error " + error);
J
jiyong 已提交
4335
        }
Z
zhangpa2021 已提交
4336
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1300---------------------------");
J
jiyong 已提交
4337 4338 4339 4340 4341 4342 4343 4344 4345
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1400
     * @tc.name    The writetoashmem interface writes the shared file associated with the object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1400",0,function(){
Z
zhangpa2021 已提交
4346
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1200---------------------------");
J
jiyong 已提交
4347
        try{
J
jiyong 已提交
4348 4349
            let mapSize = 4096
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", mapSize)
Z
zhangpa2021 已提交
4350
            console.info("SUB_Softbus_IPC_Ashmem_1400: ashmem " + ashmem);
J
jiyong 已提交
4351 4352

            let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4353
            console.info("SUB_Softbus_IPC_Ashmem_1400: run mapReadAndWriteAshmem success, result2 is "
J
jiyong 已提交
4354 4355 4356 4357 4358 4359
                         + resultMapRAndW);
            expect(resultMapRAndW == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3, 4, 5]);

            let result = ashmem.writeToAshmem(bytes, bytes.length, 0);
Z
zhangpa2021 已提交
4360
            console.info("SUB_Softbus_IPC_Ashmem_1400: run writeToAshmem success, result is " + result);
J
jiyong 已提交
4361 4362 4363 4364
            expect(result == true).assertTrue();

            ashmem.closeAshmem();
        }catch(error){
Z
zhangpa2021 已提交
4365
            console.info("SUB_Softbus_IPC_Ashmem_1400: error " + error);
J
jiyong 已提交
4366
        }
Z
zhangpa2021 已提交
4367
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1400---------------------------");
J
jiyong 已提交
4368 4369 4370 4371 4372 4373 4374 4375 4376
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1500
     * @tc.name    The writetoashmem interface writes the shared file associated with the object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1500",0,function(){
Z
zhangpa2021 已提交
4377
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1500---------------------------");
J
jiyong 已提交
4378 4379
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4380
            console.info("SUB_Softbus_IPC_Ashmem_1500: ashmem " + ashmem);
J
jiyong 已提交
4381 4382

            let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4383
            console.info("SUB_Softbus_IPC_Ashmem_1500: run mapReadAndWriteAshmem success, result2 is " 
J
jiyong 已提交
4384 4385 4386 4387 4388
                         + resultMapRAndW);
            expect(resultMapRAndW == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3, 4, 5]);
            let result = ashmem.writeToAshmem(bytes, bytes.length, 0);
Z
zhangpa2021 已提交
4389
            console.info("SUB_Softbus_IPC_Ashmem_1500: run writeToAshmem success, result is " +result);
J
jiyong 已提交
4390 4391 4392
            expect(result == true).assertTrue();

            let resultread = ashmem.setProtection(rpc.Ashmem.PROT_READ);
Z
zhangpa2021 已提交
4393
            console.info("SUB_Softbus_IPC_Ashmem_1500: run setProtection success, resultread is " + resultread);
J
jiyong 已提交
4394 4395 4396
            expect(resultread == true).assertTrue()

            let result2 = ashmem.writeToAshmem(bytes, bytes.length, 0);
Z
zhangpa2021 已提交
4397
            console.info("SUB_Softbus_IPC_Ashmem_1500: run writeToAshmem success, result is2 " + result2);
J
jiyong 已提交
4398 4399 4400 4401
            expect(result2 == false).assertTrue()

            ashmem.closeAshmem();
        }catch(error){
Z
zhangpa2021 已提交
4402
            console.info("SUB_Softbus_IPC_Ashmem_1500: error " +error);
J
jiyong 已提交
4403
        }
Z
zhangpa2021 已提交
4404
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1500---------------------------");
J
jiyong 已提交
4405 4406 4407 4408 4409 4410 4411 4412 4413
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1600
     * @tc.name    Writetoashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1600",0,function(){
Z
zhangpa2021 已提交
4414
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1600---------------------------");
J
jiyong 已提交
4415 4416 4417
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096);
Z
zhangpa2021 已提交
4418
            console.info("SUB_Softbus_IPC_Ashmem_1600: ashmem " + ashmem);
J
jiyong 已提交
4419 4420

            let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4421
            console.info("SUB_Softbus_IPC_Ashmem_1600: run mapReadAndWriteAshmem success, result2 is " 
J
jiyong 已提交
4422 4423 4424 4425 4426 4427
                         + resultMapRAndW);
            expect(resultMapRAndW == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3, 4, 5]);
            let size = bytes.length + 10;
            let result = ashmem.writeToAshmem(bytes, 3, 0);
Z
zhangpa2021 已提交
4428
            console.info("SUB_Softbus_IPC_Ashmem_1600: run writeToAshmem success, result is " + result);
Z
zhangpa2021 已提交
4429
            expect(result == true).assertTrue();
J
jiyong 已提交
4430 4431 4432 4433

            ashmem.closeAshmem()

        }catch(error){
Z
zhangpa2021 已提交
4434
            console.info("SUB_Softbus_IPC_Ashmem_1600: error " + error);
J
jiyong 已提交
4435
        }
Z
zhangpa2021 已提交
4436
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1600---------------------------");
J
jiyong 已提交
4437 4438 4439 4440 4441 4442 4443 4444 4445
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1700
     * @tc.name    Read data from the shared file associated with readfromashmem
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1700",0,function(){
Z
zhangpa2021 已提交
4446
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1700---------------------------");
J
jiyong 已提交
4447 4448 4449
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4450
            console.info("SUB_Softbus_IPC_Ashmem_1700: ashmem " + ashmem);
J
jiyong 已提交
4451 4452

            let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4453
            console.info("SUB_Softbus_IPC_Ashmem_1600: run mapReadAndWriteAshmem success, result2 is " 
J
jiyong 已提交
4454 4455 4456 4457 4458
                         + resultMapRAndW);
            expect(resultMapRAndW == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3, 4, 5]);
            let result = ashmem.writeToAshmem(bytes, bytes.length, 0);
Z
zhangpa2021 已提交
4459
            console.info("SUB_Softbus_IPC_Ashmem_1700: run writeToAshmem success, result is " + result);
J
jiyong 已提交
4460 4461 4462
            expect(result == true).assertTrue();

            var resultRead = ashmem.readFromAshmem(bytes.length, 0);
Z
zhangpa2021 已提交
4463
            console.info("SUB_Softbus_IPC_Ashmem_1700: run readFromAshmem success, result is " + resultRead);
J
jiyong 已提交
4464 4465 4466 4467 4468 4469 4470 4471 4472
            expect(resultRead[0] == bytes[0]).assertTrue();
            expect(resultRead[1] == bytes[1]).assertTrue();
            expect(resultRead[2] == bytes[2]).assertTrue();
            expect(resultRead[3] == bytes[3]).assertTrue();
            expect(resultRead[4] == bytes[4]).assertTrue();

            ashmem.closeAshmem()

        }catch(error){
Z
zhangpa2021 已提交
4473
            console.info("SUB_Softbus_IPC_Ashmem_1700: error " + error);
J
jiyong 已提交
4474
        }
Z
zhangpa2021 已提交
4475
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1700---------------------------");
J
jiyong 已提交
4476 4477 4478 4479 4480 4481 4482 4483 4484
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1800
     * @tc.name    Readfromashmem exception validation
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1800",0,function(){
Z
zhangpa2021 已提交
4485
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1800---------------------------");
J
jiyong 已提交
4486 4487 4488
        try{

            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096);
Z
zhangpa2021 已提交
4489
            console.info("SUB_Softbus_IPC_Ashmem_1800: ashmem " + ashmem);
J
jiyong 已提交
4490 4491

            let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4492
            console.info("SUB_Softbus_IPC_Ashmem_1800: run mapReadAndWriteAshmem success, result2 is " 
J
jiyong 已提交
4493 4494 4495 4496 4497
                         + resultMapRAndW);
            expect(resultMapRAndW == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3, 4, 5]);
            let result = ashmem.writeToAshmem(bytes, bytes.length, 1);
Z
zhangpa2021 已提交
4498
            console.info("SUB_Softbus_IPC_Ashmem_1800: run writeToAshmem success, result is " + result);
J
jiyong 已提交
4499 4500 4501
            expect(result == true).assertTrue()

            let result2 = ashmem.readFromAshmem(bytes.length, 3);
Z
zhangpa2021 已提交
4502
            console.info("SUB_Softbus_IPC_Ashmem_1800: run readFromAshmem success, result2 is " + result2);
J
jiyong 已提交
4503 4504 4505 4506 4507 4508 4509
            expect(bytes[2] == result2[0]).assertTrue();
            expect(bytes[3] == result2[1]).assertTrue();
            expect(bytes[4] == result2[2]).assertTrue();

            ashmem.closeAshmem()

        }catch(error){
Z
zhangpa2021 已提交
4510
            console.info("SUB_Softbus_IPC_Ashmem_1800: error " + error);
J
jiyong 已提交
4511
        }
Z
zhangpa2021 已提交
4512
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1800---------------------------");
J
jiyong 已提交
4513 4514 4515 4516 4517 4518 4519 4520 4521
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_1900
     * @tc.name    Createashmemfromexisting copies the ashmem object description and creates a new object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_1900",0,function(){
Z
zhangpa2021 已提交
4522
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_1900---------------------------");
J
jiyong 已提交
4523 4524
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 4096)
Z
zhangpa2021 已提交
4525
            console.info("SUB_Softbus_IPC_Ashmem_1900: ashmem " + ashmem);
J
jiyong 已提交
4526 4527

            let resultWriteAndRead = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4528
            console.info("SUB_Softbus_IPC_Ashmem_1900:  run mapReadAndWriteAshmem result is " + resultWriteAndRead);
J
jiyong 已提交
4529 4530 4531 4532
            expect(resultWriteAndRead == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3]);
            let result = ashmem.writeToAshmem(bytes, bytes.length, 1);
Z
zhangpa2021 已提交
4533
            console.info("SUB_Softbus_IPC_Ashmem_1900: run writeToAshmem success, result is " + result);
J
jiyong 已提交
4534 4535 4536 4537
            expect(result == true).assertTrue()

            let newashmem = rpc.Ashmem.createAshmemFromExisting(ashmem);
            let resultWriteAndRead2 = newashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4538
            console.info("SUB_Softbus_IPC_Ashmem_1900:  run mapReadAndWriteAshmem result is " + resultWriteAndRead2);
J
jiyong 已提交
4539 4540 4541
            expect(resultWriteAndRead2 == true).assertTrue();

            let result2 = newashmem.readFromAshmem(bytes.length, 1);
Z
zhangpa2021 已提交
4542
            console.info("SUB_Softbus_IPC_Ashmem_1900: run readFromAshmem success, result2 is " + result2);
J
jiyong 已提交
4543 4544 4545 4546 4547 4548 4549 4550
            expect(result == true).assertTrue()
            expect(result2[0] == bytes[0]).assertTrue()
            expect(result2[1] == bytes[1]).assertTrue()
            expect(result2[2] == bytes[2]).assertTrue()

            ashmem.closeAshmem();
            newashmem.closeAshmem();
        }catch(error){
Z
zhangpa2021 已提交
4551
            console.info("SUB_Softbus_IPC_Ashmem_1900: error " + error);
J
jiyong 已提交
4552
        }
Z
zhangpa2021 已提交
4553
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_1900---------------------------");
J
jiyong 已提交
4554 4555 4556 4557 4558 4559 4560 4561 4562 4563
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_2000
     * @tc.name    Create a shared memory object and call writeashmem to write the shared anonymous
      object into the messageparcel object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_2000",0,function(){
Z
zhangpa2021 已提交
4564
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_2000---------------------------");
J
jiyong 已提交
4565 4566 4567
        try{
            let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 1024);
            let data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
4568
            console.info("SUB_Softbus_IPC_Ashmem_2000: ashmem " + ashmem);
J
jiyong 已提交
4569 4570

            let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
Z
zhangpa2021 已提交
4571
            console.info("SUB_Softbus_IPC_Ashmem_2000: run mapReadAndWriteAshmem result is " + resultMapRAndW);
J
jiyong 已提交
4572 4573 4574 4575 4576
            expect(resultMapRAndW == true).assertTrue();

            let bytes = new Int8Array([1, 2, 3]);
            let result = ashmem.writeToAshmem(bytes, bytes.length, 1);

Z
zhangpa2021 已提交
4577
            console.info("SUB_Softbus_IPC_Ashmem_2000: run writeToAshmem success, result is " + result);
J
jiyong 已提交
4578 4579 4580
            expect(result == true).assertTrue()

            let result2 = data.writeAshmem(ashmem)
Z
zhangpa2021 已提交
4581
            console.info("SUB_Softbus_IPC_Ashmem_2000: run writeAshmem success, result is " + result2);
J
jiyong 已提交
4582 4583 4584
            expect(result2 == true).assertTrue();

            let retReadAshmem = data.readAshmem();
Z
zhangpa2021 已提交
4585
            console.info("SUB_Softbus_IPC_Ashmem_2000: run readAshmem is " + retReadAshmem);
J
jiyong 已提交
4586 4587

            let retBytes = retReadAshmem.readFromAshmem(bytes.length, 1);
Z
zhangpa2021 已提交
4588
            console.info("SUB_Softbus_IPC_Ashmem_2000: run readFromAshmem result is " + retBytes);
J
jiyong 已提交
4589 4590 4591 4592 4593 4594 4595
            for (let i = 0; i < bytes.length; i++) {
                expect(retBytes[i]).assertEqual(bytes[i])
            }

            ashmem.closeAshmem()
            data.reclaim()
        }catch(error){
Z
zhangpa2021 已提交
4596
            console.info("SUB_Softbus_IPC_Ashmem_2000: error " +error);
J
jiyong 已提交
4597
        }
Z
zhangpa2021 已提交
4598
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_2000---------------------------");
J
jiyong 已提交
4599 4600 4601 4602 4603 4604 4605 4606 4607 4608
    })

    /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_2100
     * @tc.name    Create a non shared memory object and call writeashmem to write the messageparcel object
      object into the messageparcel object
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_Ashmem_2100",0,function(){
Z
zhangpa2021 已提交
4609
        console.info("---------------------start SUB_Softbus_IPC_Ashmem_2100---------------------------");
J
jiyong 已提交
4610 4611 4612
        try{
            let data = rpc.MessageParcel.create()
            let data2 = rpc.MessageParcel.create()
Z
zhangpa2021 已提交
4613
            console.info("SUB_Softbus_IPC_Ashmem_2100: create MessageParcel object success");
J
jiyong 已提交
4614 4615 4616

            var flag = false;
            let result = data.writeAshmem(data2)
Z
zhangpa2021 已提交
4617
            console.info("SUB_Softbus_IPC_Ashmem_2100: run writeAshmem success, result is " + result);
J
jiyong 已提交
4618 4619 4620 4621 4622

            flag = true;
            data.reclaim()
            data2.reclaim()
        }catch(error){
Z
zhangpa2021 已提交
4623
            console.info("SUB_Softbus_IPC_Ashmem_2100: error " + error);
J
jiyong 已提交
4624 4625
            expect(flag == false).assertTrue();
        }
Z
zhangpa2021 已提交
4626
        console.info("---------------------end SUB_Softbus_IPC_Ashmem_2100---------------------------");
J
jiyong 已提交
4627 4628
    })

Z
zhangpa2021 已提交
4629 4630 4631 4632 4633 4634 4635
 /*
     * @tc.number  SUB_Softbus_IPC_Ashmem_2300
     * @tc.name    Test the mapped memory is executable
     * @tc.desc    Function test
     * @tc.level   0
     */
 it("SUB_Softbus_IPC_Ashmem_2300",0,function(){
Z
zhangpa2021 已提交
4636
    console.info("---------------------start SUB_Softbus_IPC_Ashmem_2300---------------------------");
Z
zhangpa2021 已提交
4637 4638 4639 4640
    try{
        let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", 1024);

        let resultwrite = ashmem.setProtection(rpc.Ashmem.PROT_EXEC)
Z
zhangpa2021 已提交
4641
        console.info("SUB_Softbus_IPC_Ashmem_2300: run setProtection success, resultwrite is " + resultwrite);
Z
zhangpa2021 已提交
4642 4643 4644 4645
        expect(resultwrite == true).assertTrue();

        ashmem.closeAshmem()
    }catch(error){
Z
zhangpa2021 已提交
4646
        console.info("SUB_Softbus_IPC_Ashmem_2300: error " + error);
Z
zhangpa2021 已提交
4647
    }
Z
zhangpa2021 已提交
4648
    console.info("---------------------end SUB_Softbus_IPC_Ashmem_2300---------------------------");
Z
zhangpa2021 已提交
4649 4650
})

J
jiyong 已提交
4651 4652 4653 4654 4655 4656 4657
    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0100
     * @tc.name    Call sendrequestresult interface to send data
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0100",0,async function(done){
Z
zhangpa2021 已提交
4658
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0100---------------------------");
J
jiyong 已提交
4659 4660 4661 4662 4663 4664
        try{
            let data = rpc.MessageParcel.create();
            let reply = rpc.MessageParcel.create();
            let option = new rpc.MessageOption();
            let sequenceable = new MySequenceable(1, "aaa");
            let result = data.writeSequenceable(sequenceable);
Z
zhangpa2021 已提交
4665
            console.info("SUB_Softbus_IPC_IRemoteObject_0100: run writeSequenceable success, result is " + result);
J
jiyong 已提交
4666 4667

            await gIRemoteObject.sendRequest(CODE_WRITESEQUENCEABLE, data, reply, option).then((result) => {
Z
zhangpa2021 已提交
4668
                console.info("SUB_Softbus_IPC_IRemoteObject_0100: sendRequest success, result is " + result.errCode);
J
jiyong 已提交
4669 4670 4671
                expect(result.errCode == 0).assertTrue();
                let ret = new MySequenceable(0, "");
                var shortArryDataReply = result.reply.readSequenceable(ret);
Z
zhangpa2021 已提交
4672
                console.info("SUB_Softbus_IPC_IRemoteObject_0100: run readSequenceable is success, result is "
J
jiyong 已提交
4673 4674 4675 4676 4677 4678 4679 4680 4681 4682
                             + shortArryDataReply);
                expect(shortArryDataReply == true).assertTrue()
                expect(ret.num).assertEqual(1)
                expect(ret.str).assertEqual("aaa")
            });

            data.reclaim();
            reply.reclaim();
            done();
        }catch(error){
Z
zhangpa2021 已提交
4683
            console.info("SUB_Softbus_IPC_IRemoteObject_0100: error " + error);
J
jiyong 已提交
4684
        }
Z
zhangpa2021 已提交
4685
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0100---------------------------");
J
jiyong 已提交
4686 4687 4688 4689 4690 4691 4692 4693 4694 4695
    })

    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0200
     * @tc.name    Test that messageparcel passes through the same process, and the client
     *             receives the reply message in promise
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0200", 0,async function(done){
Z
zhangpa2021 已提交
4696
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0200---------------------------");
J
jiyong 已提交
4697 4698
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
4699
            console.info("SUB_Softbus_IPC_IRemoteObject_0200: create object successfully.");
J
jiyong 已提交
4700 4701 4702 4703 4704 4705 4706 4707 4708
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();
            expect(data.writeByte(1)).assertTrue()
            expect(data.writeShort(2)).assertTrue()
            expect(data.writeInt(3)).assertTrue()
            expect(data.writeLong(10000)).assertTrue()
            expect(data.writeFloat(1.2)).assertTrue()
            expect(data.writeDouble(10.2)).assertTrue()
            expect(data.writeBoolean(true)).assertTrue()
Z
zhangpa2021 已提交
4709
            expect(data.writeChar(5)).assertTrue()
J
jiyong 已提交
4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722
            expect(data.writeString("HelloWorld")).assertTrue()
            expect(data.writeSequenceable(new MySequenceable(1, "aaa"))).assertTrue()

            await gIRemoteObject.sendRequest(CODE_ALL_TYPE, data, reply, option).then((result) => {
                console.info("SUB_Softbus_IPC_IRemoteObject_0200: sendRequest done, error code: " + result.errCode);
                expect(result.errCode).assertEqual(0)
                expect(result.reply.readByte()).assertEqual(1)
                expect(result.reply.readShort()).assertEqual(2)
                expect(result.reply.readInt()).assertEqual(3)
                expect(result.reply.readLong()).assertEqual(10000)
                expect(result.reply.readFloat()).assertEqual(1.2)
                expect(result.reply.readDouble()).assertEqual(10.2)
                expect(result.reply.readBoolean()).assertTrue()
Z
zhangpa2021 已提交
4723
                expect(result.reply.readChar()).assertEqual(5)
J
jiyong 已提交
4724 4725 4726 4727 4728 4729 4730 4731 4732 4733
                expect(result.reply.readString()).assertEqual("HelloWorld")
                let s = new MySequenceable(0, '')
                expect(result.reply.readSequenceable(s)).assertTrue()
                expect(s.num).assertEqual(1)
                expect(s.str).assertEqual("aaa")
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
4734
            console.info("SUB_Softbus_IPC_IRemoteObject_0200:error = " + error);
J
jiyong 已提交
4735
        }
Z
zhangpa2021 已提交
4736
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0200---------------------------");
J
jiyong 已提交
4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747
        done();
    });

    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0300
     * @tc.name    Test that messageparcel passes through the same process, and the client
     *             receives the reply message in the callback function
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0300", 0,async function(done){
Z
zhangpa2021 已提交
4748
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0300---------------------------");
J
jiyong 已提交
4749 4750
        try{
            var data = rpc.MessageParcel.create();
Z
zhangpa2021 已提交
4751
            console.info("SUB_Softbus_IPC_IRemoteObject_0300: create object successfully.");
J
jiyong 已提交
4752 4753 4754 4755 4756 4757 4758 4759 4760 4761
            var reply = rpc.MessageParcel.create();
            var option = new rpc.MessageOption();

            expect(data.writeByte(1)).assertTrue()
            expect(data.writeShort(2)).assertTrue()
            expect(data.writeInt(3)).assertTrue()
            expect(data.writeLong(10000)).assertTrue()
            expect(data.writeFloat(1.2)).assertTrue()
            expect(data.writeDouble(10.2)).assertTrue()
            expect(data.writeBoolean(true)).assertTrue()
Z
zhangpa2021 已提交
4762
            expect(data.writeChar(10)).assertTrue()
J
jiyong 已提交
4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776
            expect(data.writeString("HelloWorld")).assertTrue()
            expect(data.writeSequenceable(new MySequenceable(1, "aaa"))).assertTrue()

            const CODE_IREMOTEOBJECT_0200 = 21;
            await gIRemoteObject.sendRequest(CODE_ALL_TYPE, data, reply, option, (err, result) => {
                console.info("SUB_Softbus_IPC_IRemoteObject_0300:sendRequest done, error code: " + result.errCode)
                expect(result.errCode).assertEqual(0)
                expect(result.reply.readByte()).assertEqual(1)
                expect(result.reply.readShort()).assertEqual(2)
                expect(result.reply.readInt()).assertEqual(3)
                expect(result.reply.readLong()).assertEqual(10000)
                expect(result.reply.readFloat()).assertEqual(1.2)
                expect(result.reply.readDouble()).assertEqual(10.2)
                expect(result.reply.readBoolean()).assertTrue()
Z
zhangpa2021 已提交
4777
                expect(result.reply.readChar()).assertEqual(10)
J
jiyong 已提交
4778 4779 4780 4781 4782 4783 4784 4785 4786 4787
                expect(result.reply.readString()).assertEqual("HelloWorld")
                let s = new MySequenceable(0, '')
                expect(result.reply.readSequenceable(s)).assertTrue()
                expect(s.num).assertEqual(1)
                expect(s.str).assertEqual("aaa")
            });
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
4788
            console.info("SUB_Softbus_IPC_IRemoteObject_0300:error = " + error);
J
jiyong 已提交
4789
        }
Z
zhangpa2021 已提交
4790
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0300---------------------------");
J
jiyong 已提交
4791 4792 4793 4794 4795 4796 4797 4798 4799
    });

    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0400
     * @tc.name    Iremoteobject, register death notification verification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0400", 0,async function(){
Z
zhangpa2021 已提交
4800
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0400---------------------------");
J
jiyong 已提交
4801
        try{
Z
zhangpa2021 已提交
4802 4803
            let object = new TestAbilityStub("Test1")
            var resultAdd1 = object.addDeathRecipient(null, 0)
Z
zhangpa2021 已提交
4804
            console.info("SUB_Softbus_IPC_IRemoteObject_0400:run addDeathRecipient first result is " + resultAdd1);
Z
zhangpa2021 已提交
4805
            expect(resultAdd1 == false).assertTrue();
J
jiyong 已提交
4806

Z
zhangpa2021 已提交
4807
            var resultRemove1 = object.removeDeathRecipient(null, 0)
Z
zhangpa2021 已提交
4808
            console.info("SUB_Softbus_IPC_IRemoteObject_0400:run removeDeathRecipient1 result is " + resultRemove1);
Z
zhangpa2021 已提交
4809
            expect(resultRemove1 == false).assertTrue();
J
jiyong 已提交
4810

Z
zhangpa2021 已提交
4811
            let isDead = object.isObjectDead()
Z
zhangpa2021 已提交
4812
            console.info("SUB_Softbus_IPC_IRemoteObject_0400:run  isDead result is " + isDead);
Z
zhangpa2021 已提交
4813
            expect(isDead == false).assertTrue();
J
jiyong 已提交
4814
        } catch (error) {
Z
zhangpa2021 已提交
4815
            console.info("SUB_Softbus_IPC_IRemoteObject_0400:error = " + error);
J
jiyong 已提交
4816
        }
Z
zhangpa2021 已提交
4817
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0400---------------------------");
J
jiyong 已提交
4818 4819 4820 4821 4822 4823 4824 4825 4826 4827
    });

    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0500
     * @tc.name    Do not get the server agent, do not create a remoteobject instance, and directly getcallingpid,
     *             getcallingpid, getcallingdeviceid, getlocaldeviceid
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0500", 0,async function(){
Z
zhangpa2021 已提交
4828
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0500---------------------------");
J
jiyong 已提交
4829 4830
        try{
            let callingPid = rpc.IPCSkeleton.getCallingPid()
Z
zhangpa2021 已提交
4831
            console.info("SUB_Softbus_IPC_IRemoteObject_0500: run getCallingPid success, callingPid is " + callingPid);
J
jiyong 已提交
4832 4833

            let callingUid = rpc.IPCSkeleton.getCallingUid()
Z
zhangpa2021 已提交
4834
            console.info("SUB_Softbus_IPC_IRemoteObject_0500: run getCallingPid success, callingPid is " + callingUid);
J
jiyong 已提交
4835 4836

            let callingDeviceID = rpc.IPCSkeleton.getCallingDeviceID()
Z
zhangpa2021 已提交
4837
            console.info("SUB_Softbus_IPC_IRemoteObject_0500: run getCallingDeviceID success, callingDeviceID is "
J
jiyong 已提交
4838 4839 4840 4841
                         + callingDeviceID);
            expect(callingDeviceID == "").assertTrue();

            let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID()
Z
zhangpa2021 已提交
4842
            console.info("SUB_Softbus_IPC_IRemoteObject_0500: run getLocalDeviceID success, localDeviceID is "
J
jiyong 已提交
4843 4844 4845
            + localDeviceID);
            expect(localDeviceID == "").assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
4846
            console.info("SUB_Softbus_IPC_IRemoteObject_0500:error = " + error);
J
jiyong 已提交
4847
        }
Z
zhangpa2021 已提交
4848
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0500---------------------------");
J
jiyong 已提交
4849 4850 4851 4852 4853 4854 4855 4856 4857
    });

    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0600
     * @tc.name    Querylocalinterface searches for objects based on descriptors
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0600", 0,async function(){
Z
zhangpa2021 已提交
4858
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0600---------------------------");
J
jiyong 已提交
4859 4860
        try{
            let object = new TestAbilityStub("Test1");
Z
zhangpa2021 已提交
4861
            console.info("SUB_Softbus_IPC_IRemoteObject_0600: run TestAbilityStub success");
J
jiyong 已提交
4862 4863

            let result = object.isObjectDead()
Z
zhangpa2021 已提交
4864
            console.info("SUB_Softbus_IPC_IRemoteObject_0600: run isObjectDead success, result is " + result);
J
jiyong 已提交
4865 4866 4867
            expect(result == false).assertTrue()

            let callingPid = object.getCallingPid()
Z
zhangpa2021 已提交
4868
            console.info("SUB_Softbus_IPC_IRemoteObject_0600: run getCallingPid success, callingPid is " + callingPid);
J
jiyong 已提交
4869 4870

            let callingUid = object.getCallingUid()
Z
zhangpa2021 已提交
4871
            console.info("SUB_Softbus_IPC_IRemoteObject_0600: run getCallingPid success, callingPid is " + callingUid);
J
jiyong 已提交
4872 4873

            object.attachLocalInterface(object, "Test1")
Z
zhangpa2021 已提交
4874
            console.info("SUB_Softbus_IPC_IRemoteObject_0600: run attachLocalInterface success");
J
jiyong 已提交
4875 4876

            let res = object.queryLocalInterface("Test1")
Z
zhangpa2021 已提交
4877
            console.info("SUB_Softbus_IPC_IRemoteObject_0600: run queryLocalInterface success, res2 is " + res);
J
jiyong 已提交
4878
        } catch (error) {
Z
zhangpa2021 已提交
4879
            console.info("SUB_Softbus_IPC_IRemoteObject_0600:error = " + error);
J
jiyong 已提交
4880
        }
Z
zhangpa2021 已提交
4881
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0600---------------------------");
J
jiyong 已提交
4882 4883 4884 4885 4886 4887 4888 4889 4890
    });

    /*
     * @tc.number  SUB_Softbus_IPC_IRemoteObject_0700
     * @tc.name    Getinterfacedescriptor to get the interface description
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IRemoteObject_0700", 0,async function(){
Z
zhangpa2021 已提交
4891
        console.info("---------------------start SUB_Softbus_IPC_IRemoteObject_0700---------------------------");
J
jiyong 已提交
4892 4893 4894 4895
        try{
            let object = new TestAbilityStub("Test1223");

            let result = object.isObjectDead()
Z
zhangpa2021 已提交
4896
            console.info("SUB_Softbus_IPC_IRemoteObject_0700: run isObjectDead success, result is " + result);
J
jiyong 已提交
4897 4898 4899
            expect(result == false).assertTrue()

            let callingPid = object.getCallingPid()
Z
zhangpa2021 已提交
4900
            console.info("SUB_Softbus_IPC_IRemoteObject_0700: run getCallingPid success, callingPid is " + callingPid);
J
jiyong 已提交
4901 4902

            let callingUid = object.getCallingUid()
Z
zhangpa2021 已提交
4903
            console.info("SUB_Softbus_IPC_IRemoteObject_0700: run getCallingPid success, callingPid is " + callingUid);
J
jiyong 已提交
4904 4905

            object.attachLocalInterface(object, "test1")
Z
zhangpa2021 已提交
4906
            console.info("SUB_Softbus_IPC_IRemoteObject_0700: run attachLocalInterface success");
J
jiyong 已提交
4907 4908

            let result2 = object.getInterfaceDescriptor();
Z
zhangpa2021 已提交
4909
            console.info("SUB_Softbus_IPC_IRemoteObject_0700: run getInterfaceDescriptor success, result2 is "
J
jiyong 已提交
4910 4911 4912 4913
                         + result2);
            expect(result2 == "test1").assertTrue();

        } catch (error) {
Z
zhangpa2021 已提交
4914
            console.info("SUB_Softbus_IPC_IRemoteObject_0700:error = " + error);
J
jiyong 已提交
4915
        }
Z
zhangpa2021 已提交
4916
        console.info("---------------------end SUB_Softbus_IPC_IRemoteObject_0700---------------------------");
J
jiyong 已提交
4917 4918 4919 4920 4921 4922 4923 4924 4925
    });

    /*
     * @tc.number  SUB_Softbus_IPC_RemoteProxy_0100
     * @tc.name    Call adddeathrecipient to register the death notification
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_RemoteProxy_0100", 0,async function(){
Z
zhangpa2021 已提交
4926
        console.info("---------------------start SUB_Softbus_IPC_RemoteProxy_0100---------------------------");
J
jiyong 已提交
4927 4928 4929
        try{
            let recipient = new MyDeathRecipient(gIRemoteObject, null)
            var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0)
Z
zhangpa2021 已提交
4930
            console.info("SUB_Softbus_IPC_RemoteProxy_0100:run addDeathRecipient first result is " + resultAdd1);
J
jiyong 已提交
4931 4932 4933
            expect(resultAdd1 == true).assertTrue();

            var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0)
Z
zhangpa2021 已提交
4934
            console.info("SUB_Softbus_IPC_RemoteProxy_0100:run addDeathRecipient second result is " + resultAdd2);
J
jiyong 已提交
4935 4936 4937
            expect(resultAdd2 == true).assertTrue();

            var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0)
Z
zhangpa2021 已提交
4938
            console.info("SUB_Softbus_IPC_RemoteProxy_0100:run removeDeathRecipient1 result is " + resultRemove1);
J
jiyong 已提交
4939 4940 4941
            expect(resultRemove1 == true).assertTrue();

            var resultRemove2 = gIRemoteObject.removeDeathRecipient(recipient, 0)
Z
zhangpa2021 已提交
4942
            console.info("SUB_Softbus_IPC_RemoteProxy_0100:run  removeDeathRecipient2 result is " + resultRemove2);
J
jiyong 已提交
4943 4944 4945
            expect(resultRemove2 == true).assertTrue();

            var resultRemove3 = gIRemoteObject.removeDeathRecipient(recipient, 0)
Z
zhangpa2021 已提交
4946
            console.info("SUB_Softbus_IPC_RemoteProxy_0100:run  removeDeathRecipient3 result is " + resultRemove3);
J
jiyong 已提交
4947 4948
            expect(resultRemove3 == false).assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
4949
            console.info("SUB_Softbus_IPC_RemoteProxy_0100:error = " + error);
J
jiyong 已提交
4950
        }
Z
zhangpa2021 已提交
4951
        console.info("---------------------end SUB_Softbus_IPC_RemoteProxy_0100---------------------------");
J
jiyong 已提交
4952 4953 4954 4955 4956 4957 4958 4959 4960
    });

    /*
     * @tc.number  SUB_Softbus_IPC_RemoteProxy_0200
     * @tc.name    Call isobjectdead to check whether the object is dead
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_RemoteProxy_0200", 0,async function(){
Z
zhangpa2021 已提交
4961
        console.info("---------------------start SUB_Softbus_IPC_RemoteProxy_0200---------------------------");
J
jiyong 已提交
4962
        try{
Z
zhangpa2021 已提交
4963 4964 4965 4966
            var flag = false
            let recipient = new MyDeathRecipient(gIRemoteObject, null)
            var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0)
            console.info("SUB_Softbus_IPC_RemoteProxy_0200:run addDeathRecipient first result is " + resultAdd1);
J
jiyong 已提交
4967 4968
            expect(resultAdd1 == true).assertTrue();

Z
zhangpa2021 已提交
4969 4970 4971
            var isDead1 = gIRemoteObject.isObjectDead();
            console.info("SUB_Softbus_IPC_RemoteProxy_0200: run isObjectDead result is " + isDead1);
            expect(isDead1 == false).assertTrue();
J
jiyong 已提交
4972

Z
zhangpa2021 已提交
4973 4974
            var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0)
            console.info("SUB_Softbus_IPC_RemoteProxy_0200:run addDeathRecipient second result is " + resultAdd2);
J
jiyong 已提交
4975 4976
            expect(resultAdd2 == true).assertTrue();

Z
zhangpa2021 已提交
4977 4978
            var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0)
            console.info("SUB_Softbus_IPC_RemoteProxy_0200:run removeDeathRecipient1 result is " + resultRemove1);
J
jiyong 已提交
4979 4980
            expect(resultRemove1 == true).assertTrue();

Z
zhangpa2021 已提交
4981 4982
            var isDead2 = gIRemoteObject.isObjectDead();
            console.info("SUB_Softbus_IPC_RemoteProxy_0200: run isObjectDead2 result is " + isDead2);
J
jiyong 已提交
4983
            expect(isDead1 == false).assertTrue();
Z
zhangpa2021 已提交
4984
            flag = true
J
jiyong 已提交
4985
        } catch (error) {
Z
zhangpa2021 已提交
4986 4987
            console.info("SUB_Softbus_IPC_RemoteProxy_0200:error = " + error);
            expect(flag == false).assertTrue();
J
jiyong 已提交
4988
        }
Z
zhangpa2021 已提交
4989
        console.info("---------------------end SUB_Softbus_IPC_RemoteProxy_0200---------------------------");
J
jiyong 已提交
4990 4991 4992 4993 4994 4995 4996 4997 4998
    });

    /*
     * @tc.number  SUB_Softbus_IPC_RemoteProxy_0300
     * @tc.name    Getinterfacedescriptor to get the object interface description
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_RemoteProxy_0300", 0,async function(){
Z
zhangpa2021 已提交
4999
        console.info("---------------------start SUB_Softbus_IPC_RemoteProxy_0300---------------------------");
J
jiyong 已提交
5000 5001 5002 5003
        try{
            let object = new TestAbilityStub("Test0300");

            let result = object.getInterfaceDescriptor()
Z
zhangpa2021 已提交
5004
            console.info("SUB_Softbus_IPC_RemoteProxy_0300: run getInterfaceDescriptor success, result is " + result);
J
jiyong 已提交
5005 5006 5007
            expect(result == "Test0300").assertTrue();

        } catch (error) {
Z
zhangpa2021 已提交
5008
            console.info("SUB_Softbus_IPC_RemoteProxy_0300:error = " + error);
J
jiyong 已提交
5009
        }
Z
zhangpa2021 已提交
5010
        console.info("---------------------end SUB_Softbus_IPC_RemoteProxy_0300---------------------------");
J
jiyong 已提交
5011 5012 5013 5014 5015 5016 5017 5018 5019
    });

    /*
     * @tc.number  SUB_Softbus_IPC_RemoteProxy_0400
     * @tc.name    Querylocalinterface searches for objects based on descriptors
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_RemoteProxy_0400", 0,async function(){
Z
zhangpa2021 已提交
5020
        console.info("---------------------start SUB_Softbus_IPC_RemoteProxy_0400---------------------------");
J
jiyong 已提交
5021 5022 5023 5024
        try{
            let object = new TestAbilityStub("Test0400");

            let result = object.isObjectDead()
Z
zhangpa2021 已提交
5025
            console.info("SUB_Softbus_IPC_RemoteProxy_0400: run getInterfaceDescriptor success, result is " + result);
J
jiyong 已提交
5026 5027 5028
            expect(result == false).assertTrue()

            let res = object.attachLocalInterface(object, "Test2")
Z
zhangpa2021 已提交
5029
            console.info("SUB_Softbus_IPC_RemoteProxy_0400: run attachLocalInterface success, res is " + res);
J
jiyong 已提交
5030 5031

            let res2 = object.queryLocalInterface('Test2');
Z
zhangpa2021 已提交
5032
            console.info("SUB_Softbus_IPC_RemoteProxy_0400: run queryLocalInterface success, res2 is " + res2);
J
jiyong 已提交
5033 5034

            let resultDescrip = object.getInterfaceDescriptor()
Z
zhangpa2021 已提交
5035
            console.info("SUB_Softbus_IPC_RemoteProxy_0400: run getInterfaceDescriptor success resultDescrip is "
J
jiyong 已提交
5036 5037 5038
                         + resultDescrip);
            expect(resultDescrip == "Test2").assertTrue();
        } catch (error) {
Z
zhangpa2021 已提交
5039
            console.info("SUB_Softbus_IPC_RemoteProxy_0400:error = " + error);
J
jiyong 已提交
5040
        }
Z
zhangpa2021 已提交
5041
        console.info("---------------------end SUB_Softbus_IPC_RemoteProxy_0400---------------------------");
J
jiyong 已提交
5042 5043 5044 5045 5046 5047 5048 5049
    });

    /*
     * @tc.number  SUB_Softbus_IPC_RemoteProxy_0500
     * @tc.name    Transaction constant validation
     * @tc.desc    Function test
     * @tc.level   0
     */
Z
zhangpa2021 已提交
5050
    it("SUB_Softbus_IPC_RemoteProxy_0500", 0, async function(){
Z
zhangpa2021 已提交
5051
        console.info("SUB_Softbus_IPC_RemoteProxy_0500 is starting-------------")
J
jiyong 已提交
5052
        try {
Z
zhangpa2021 已提交
5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064
            
                expect(rpc.RemoteProxy.PING_TRANSACTION).assertEqual(1599098439);

                expect(rpc.RemoteProxy.DUMP_TRANSACTION).assertEqual(1598311760);
                
                expect(rpc.RemoteProxy.INTERFACE_TRANSACTION).assertEqual(1598968902);
               
                expect(rpc.RemoteProxy.MIN_TRANSACTION_ID).assertEqual(0x1);
             
                expect(rpc.RemoteProxy.MAX_TRANSACTION_ID).assertEqual(0x00FFFFFF);
                
           
J
jiyong 已提交
5065
        } catch (error) {
Z
zhangpa2021 已提交
5066
            console.info("SUB_Softbus_IPC_RemoteProxy_0500 error is" + error);
J
jiyong 已提交
5067
        }
Z
zhangpa2021 已提交
5068
        console.info("---------------------end SUB_Softbus_IPC_RemoteProxy_0500---------------------------");
J
jiyong 已提交
5069 5070 5071 5072 5073 5074 5075 5076 5077
    })

    /*
     * @tc.number  SUB_Softbus_IPC_IPCSkeleton_1000
     * @tc.name    Create an empty object and verify the function of the flushcommands interface
     * @tc.desc    Function test
     * @tc.level   0
     */
    it('SUB_Softbus_IPC_IPCSkeleton_1000', 0, async function() {
Z
zhangpa2021 已提交
5078
        console.info("---------------------start SUB_Softbus_IPC_IPCSkeleton_1000---------------------------");
J
jiyong 已提交
5079 5080 5081 5082
        try {
            console.info("SUB_Softbus_IPC_IPCSkeleton_1000")
            let remoteObject = {};
            let ret = rpc.IPCSkeleton.flushCommands(remoteObject);
Z
zhangpa2021 已提交
5083
            console.info("RpcServer: flushCommands result: " + ret);
J
jiyong 已提交
5084 5085
        }
        catch (error) {
Z
zhangpa2021 已提交
5086
            console.info("SUB_Softbus_IPC_IPCSkeleton_1000 error is :" + error)
J
jiyong 已提交
5087
        }
Z
zhangpa2021 已提交
5088
        console.info("---------------------end SUB_Softbus_IPC_IPCSkeleton_1000---------------------------");
J
jiyong 已提交
5089 5090 5091 5092 5093 5094 5095 5096 5097 5098
    })

    /*
     * @tc.number  SUB_Softbus_IPC_IPCSkeleton_2000
     * @tc.name    Do not get the server agent, do not create a remoteobject instance, and directly getcallingpid,
     *             getcallingpid, getcallingdeviceid, getlocaldeviceid
     * @tc.desc    Function test
     * @tc.level   0
     */
    it('SUB_Softbus_IPC_IPCSkeleton_2000', 0, async function() {
Z
zhangpa2021 已提交
5099
        console.info("---------------------start SUB_Softbus_IPC_IPCSkeleton_2000---------------------------");
J
jiyong 已提交
5100 5101
        try{
            let getCallingPid = rpc.IPCSkeleton.getCallingPid();
Z
zhangpa2021 已提交
5102
            console.info("SUB_Softbus_IPC_IPCSkeleton_2000: run  getCallingPid result is :" + getCallingPid);
Z
zhangpa2021 已提交
5103 5104
            expect(getCallingPid.assertEqual(nll)).assertFale();

J
jiyong 已提交
5105
            let getCallingUid = rpc.IPCSkeleton.getCallingUid();
Z
zhangpa2021 已提交
5106
            console.info("SUB_Softbus_IPC_IPCSkeleton_2000: run getCallingUid result is :" + getCallingUid);
Z
zhangpa2021 已提交
5107 5108 5109
            expect(getCallingUid.assertEqual(nll)).assertFale();

            let getCallingToKenId = rpc.IPCSkeleton.getCallingToKenId();
Z
zhangpa2021 已提交
5110
            console.info("SUB_Softbus_IPC_IPCSkeleton_2000: run getCallingToKenId result is :" + getCallingToKenId);
Z
zhangpa2021 已提交
5111 5112
            expect(getCallingToKenId.assertEqual(nll)).assertFale();

J
jiyong 已提交
5113
            let getLocalDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
Z
zhangpa2021 已提交
5114
            console.info("SUB_Softbus_IPC_IPCSkeleton_2000: run getLocalDeviceID result is :" + getLocalDeviceID);
Z
zhangpa2021 已提交
5115 5116
            expect(getLocalDeviceID.assertEqual(nll)).assertFale();

J
jiyong 已提交
5117
            let getCallingDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
Z
zhangpa2021 已提交
5118
            console.info("SUB_Softbus_IPC_IPCSkeleton_2000: run getCallingDeviceID result is :" + getCallingDeviceID);
Z
zhangpa2021 已提交
5119
            expect(getCallingDeviceID.assertEqual(nll)).assertFale();
J
jiyong 已提交
5120
        } catch (error){
Z
zhangpa2021 已提交
5121
            console.info("SUB_Softbus_IPC_IPCSkeleton_2000: error = " + error);
J
jiyong 已提交
5122
        }
Z
zhangpa2021 已提交
5123
        console.info("---------------------end SUB_Softbus_IPC_IPCSkeleton_2000---------------------------");
J
jiyong 已提交
5124 5125 5126 5127 5128 5129 5130 5131 5132
    })

    /*
     * @tc.number  SUB_Softbus_IPC_IPCSkeleton_3000
     * @tc.name    Basic method of testing ipcskeleton
     * @tc.desc    Function test
     * @tc.level   0
     */
    it("SUB_Softbus_IPC_IPCSkeleton_3000", 0,async function(done){
Z
zhangpa2021 已提交
5133
        console.info("---------------------start SUB_Softbus_IPC_IPCSkeleton_3000---------------------------");
J
jiyong 已提交
5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177
        try{
            let object = rpc.IPCSkeleton.getContextObject();
            let callingPid = rpc.IPCSkeleton.getCallingPid();
            let callingUid = rpc.IPCSkeleton.getCallingUid();
            let callingDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
            let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
            let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
            let id = rpc.IPCSkeleton.resetCallingIdentity();
            let ret = rpc.IPCSkeleton.setCallingIdentity(id);
            expect(object.getInterfaceDescriptor()).assertEqual("");
            expect(callingDeviceID).assertEqual("");
            expect(localDeviceID).assertEqual("");
            expect(isLocalCalling).assertTrue();
            expect(id).assertEqual("");
            expect(ret).assertTrue();
            expect(rpc.IPCSkeleton.flushCommands(gIRemoteObject)).assertEqual(0);
            console.info("SUB_Softbus_IPC_IPCSkeleton_3000: callingPid: " + callingPid + ", callingUid: " + callingUid
                         + ", callingDeviceID: " + callingDeviceID + ", localDeviceID: " + localDeviceID
                         + ", isLocalCalling: " + isLocalCalling);
            let option = new rpc.MessageOption();
            let data = rpc.MessageParcel.create();
            let reply = rpc.MessageParcel.create();
            expect(data.writeInterfaceToken("rpcTestAbility")).assertTrue();
            console.info("SUB_Softbus_IPC_IPCSkeleton_3000: start send request");
            await gIRemoteObject.sendRequest(CODE_IPCSKELETON, data, reply, option)
                .then(function(result) {
                    console.info("SUB_Softbus_IPC_IPCSkeleton_3000: sendRequest done, error code: " + result.errCode)
                    expect(result.errCode).assertEqual(0);
                    result.reply.readException();
                    expect(result.reply.readInt()).assertEqual(callingPid);
                    expect(result.reply.readInt()).assertEqual(callingUid);
                    expect(result.reply.readString()).assertEqual("");
                    expect(result.reply.readString()).assertEqual("");
                    expect(result.reply.readBoolean()).assertTrue();
                    expect(result.reply.readInt()).assertEqual(callingPid);
                    expect(result.reply.readInt()).assertEqual(callingUid);
                    expect(result.reply.readInt()).assertEqual(callingPid);
                    expect(result.reply.readInt()).assertEqual(callingUid);
                    expect(result.reply.readInt()).assertEqual(101);
                })
            data.reclaim();
            reply.reclaim();
            done();
        } catch (error) {
Z
zhangpa2021 已提交
5178
            console.info("SUB_Softbus_IPC_IPCSkeleton_3000:error = " + error);
J
jiyong 已提交
5179
        }
Z
zhangpa2021 已提交
5180
        console.info("---------------------end SUB_Softbus_IPC_IPCSkeleton_3000---------------------------");
J
jiyong 已提交
5181 5182
    });

Z
zhangpa2021 已提交
5183
    console.info("-----------------------SUB_Softbus_IPC_MessageParce_Test is end-----------------------");
J
jiyong 已提交
5184
});
Z
zhangpa2021 已提交
5185
}