diff --git a/communication/dsoftbus_rpcets/rpcclient/entry/src/main/ets/test/RpcRequestEtsUnit.test.ets b/communication/dsoftbus_rpcets/rpcclient/entry/src/main/ets/test/RpcRequestEtsUnit.test.ets index 827a312..11eded9 100644 --- a/communication/dsoftbus_rpcets/rpcclient/entry/src/main/ets/test/RpcRequestEtsUnit.test.ets +++ b/communication/dsoftbus_rpcets/rpcclient/entry/src/main/ets/test/RpcRequestEtsUnit.test.ets @@ -58,8 +58,6 @@ export default function RpcRequestEtsUnitTest() { const CODE_WRITE_REMOTEOBJECT = 1; const CODE_INTERFACETOKEN = 2; const CODE_WRITE_STRING = 3; - const CODE_WRITE_INT = 4; - const CODE_ALL_TYPE = 5; let gIRemoteObject = null; let testservice = null; @@ -747,1012 +745,6 @@ export default function RpcRequestEtsUnitTest() { done(); } console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0190---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0200 - * @tc.name : test setCapacity Sets the storage capacity of the null MessageSequence instance. The getCapacity - obtains the current MessageSequence capacity - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0200", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0200---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - expect(data.getCapacity()).assertEqual(0); - data.setCapacity(100); - data.writeString("constant"); - expect(data.getCapacity()).assertEqual(100); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.getCapacity()).assertEqual(("constant".length * 2) + 8); - expect(result.reply.readString()).assertEqual("constant"); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0200 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0200---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0210 - * @tc.name : test setCapacity Sets the storage capacity of the MessageSequence instance. The getCapacity - obtains the current MessageSequence capacity - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0210", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0210---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeString("constant"); - data.setCapacity(100); - expect(data.getCapacity()).assertEqual(100); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.readString()).assertEqual("constant"); - expect(result.reply.getCapacity()).assertEqual(("constant".length * 2) + 8); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0210 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0210---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0220 - * @tc.name : test Setcapacity test: size limit verification of MessageSequence instance - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0220", 0, async function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0220---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - expect(data.getCapacity()).assertEqual(0); - data.writeString("constant"); - let getSizedata = data.getSize(); - data.setCapacity(getSizedata + 1); - data.setCapacity(getSizedata); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0220 error: " + error); - let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`; - expect(error.message != null).assertTrue(); - expect(error.code == errCode).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0220---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0230 - * @tc.name : test SetCapacity Tests the storage capacity threshold of the MessageSequence instance - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0230", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0230---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeString("constant"); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - let getSizeresult = result.reply.getSize(); - expect(result.reply.getCapacity()).assertEqual(("constant".length * 2) + 8); - result.reply.setCapacity(getSizeresult + 1); - result.reply.setCapacity(getSizeresult); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0230 error: " + error); - let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`; - expect(error.message != null).assertTrue(); - expect(error.code == errCode).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0230---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0240 - * @tc.name : test Setcapacity test storage capacity boundary value verification of MessageSequence instance - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0240", 0, async function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0240---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - expect(data.getSize()).assertEqual(0); - data.setCapacity(M); - expect(data.getCapacity()).assertEqual(M); - data.setCapacity(2 * G); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0240 error: " + error); - let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`; - expect(error.message != null).assertTrue(); - expect(error.code == errCode).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0240---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0250 - * @tc.name : test readParcelable is Call JS callback function failedv Error message verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0250", 0, async function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0250---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let sequenceable = new MySequenceableCode(1, "aaa"); - data.writeParcelable(sequenceable); - data.setCapacity(0); - data.setSize(0); - let ret = new MySequenceable(1, ""); - data.readParcelable(ret); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0250 error: " + error); - let errCode = `${rpc.ErrorCode.CALL_JS_METHOD_ERROR}`; - expect(error.message != null).assertTrue(); - expect(error.code != errCode).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0250---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0260 - * @tc.name : test Invoke the writeinterfacetoken interface, write the interface descriptor, and verify the error - * code that fails to be read from the interfacetoken interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0260", 0, function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0260---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let token = "hello ruan zong xian"; - data.writeInterfaceToken(token); - data.setCapacity(0); - data.setSize(0); - data.readInterfaceToken(); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0260 error: " + error); - let errCode = `${rpc.ErrorCode.READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR}`; - expect(error.message != null).assertTrue(); - expect(error.code != errCode).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0260---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0270 - * @tc.name : test writeInterfaceToken Sequence memory alloc failed Error message verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0270", 0, function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0270---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - data.setSize(0); - data.setCapacity(0); - let token = "hello ruan zong xian"; - data.writeInterfaceToken(token); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0270 error: " + error); - let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`; - expect(error.code == errCode).assertTrue(); - expect(error.message != null).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0270---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0280 - * @tc.name : test writeInterfaceToken Write data to message sequence failed Error message verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0280", 0, function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0280---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - data.setSize(true); - data.setCapacity(true); - let token = "hello ruan zong xian"; - data.writeInterfaceToken(token); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0280 error: " + error); - let errCode = `${rpc.ErrorCode.WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR}`; - expect(error.code != errCode).assertTrue(); - expect(error.message != null).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0280---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0290 - * @tc.name : testsetSize is write data to message sequence failed Error verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改IPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0290", 0,async function(){ - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0290---------------------------"); - let data = rpc.MessageSequence.create(); - try{ - data.reclaim(); - data.setSize(0); - } catch (error) { - let errCode = `${rpc.ErrorCode.WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR}`; - expect(error.code == errCode).assertTrue(); - expect(error.message != null).assertTrue(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0290---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0300 - * @tc.name : test readParcelable Sequence memory alloc failed Error message verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0300", 0, function () { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0300---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let sequenceable = new MySequenceable(1, "aaa"); - data.writeParcelable(sequenceable); - let ret = new MySequenceable(0, ""); - data.setCapacity(0); - data.readParcelable(ret); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0300 error: " + error); - let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`; - expect(error.code == errCode).assertTrue(); - expect(error.message != null).assertTrue(); - } finally{ - data.reclaim(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0300---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0310 - * @tc.name : test Obtaining the Writable and Readable Byte Spaces of MessageSequence - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0310", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0310---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - expect(data.getWritableBytes()).assertEqual(0); - data.writeInt(10); - expect(data.getWritableBytes()).assertEqual(60); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.readInt()).assertEqual(10); - expect(result.reply.getReadableBytes()).assertEqual(0); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0310 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0310---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0320 - * @tc.name : test Obtains the writeable and readable byte space and read position of the MessageSequence - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0320", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0320---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(10); - expect(data.getWritePosition()).assertEqual(4); - expect(data.getWritableBytes()).assertEqual(60); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.getReadableBytes()).assertEqual(4); - expect(result.reply.getReadPosition()).assertEqual(0); - expect(result.reply.readInt()).assertEqual(10); - expect(result.reply.getReadableBytes()).assertEqual(0); - expect(result.reply.getReadPosition()).assertEqual(4); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0320 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0320---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0330 - * @tc.name : test Get the space size of MessageSequence to pass rawdata data - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0330", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0330---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(10); - expect(data.getWritePosition()).assertEqual(4); - expect(data.getWritableBytes()).assertEqual(60); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.getReadPosition()).assertEqual(0); - expect(result.reply.getReadableBytes()).assertEqual(4); - expect(result.reply.readInt()).assertEqual(10); - expect(result.reply.getReadPosition()).assertEqual(4); - expect(result.reply.getReadableBytes()).assertEqual(0); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0330 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0330---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0340 - * @tc.name : test Obtains the write and read positions of the MessageSequence - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0340", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0340---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - expect(data.getWritePosition()).assertEqual(0); - data.writeInt(10); - expect(data.getWritePosition()).assertEqual(4); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.getReadPosition()).assertEqual(0); - expect(result.reply.readInt()).assertEqual(10); - expect(result.reply.getReadPosition()).assertEqual(4); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0340 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0340---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0350 - * @tc.name : test Basic test of the rewindWrite interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0350", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0350---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - expect(data.getWritePosition()).assertEqual(0); - data.writeInt(4); - expect(data.getWritePosition()).assertEqual(4); - data.rewindWrite(0); - expect(data.getWritePosition()).assertEqual(0); - data.writeInt(5); - expect(data.getWritePosition()).assertEqual(4); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode == 0).assertTrue(); - expect(result.reply.getReadPosition()).assertEqual(0); - expect(result.reply.readInt()).assertEqual(5); - expect(result.reply.getReadPosition()).assertEqual(4); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0350 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0350---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0360 - * @tc.name : test RewindWrite interface write position cheap extension test - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0360", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0360---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - expect(data.getWritePosition()).assertEqual(0); - data.writeInt(4); - expect(data.getWritePosition()).assertEqual(4); - data.rewindWrite(3); - expect(data.getWritePosition()).assertEqual(3); - data.writeInt(5); - expect(data.getWritePosition()).assertEqual(3 + 4); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode == 0).assertTrue(); - expect(result.reply.readInt() != 5).assertTrue(); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0360 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0360---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0370 - * @tc.name : test Test the boundary value of the rewindWrite interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0370", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0370---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let token = ''; - for (let i = 0; i < (40 * K - 1); i++) { - token += 'a'; - } - expect(data.getWritePosition()).assertEqual(0); - data.writeString(token); - expect(data.getWritePosition()).assertEqual(token.length * 2 + 6); - data.rewindWrite((token.length * 2 + 6) - 1); - expect(data.getWritePosition()).assertEqual((token.length * 2 + 6) - 1); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0370 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0370---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0380 - * @tc.name : test Test the critical value of the rewindWrite interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0380", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0380---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let token = ''; - for (let i = 0; i < (40 * K - 1); i++) { - token += 'a'; - } - expect(data.getWritePosition()).assertEqual(0); - data.writeString(token); - expect(data.getWritePosition()).assertEqual(token.length * 2 + 6); - data.rewindWrite((token.length * 2 + 6) + 1); - expect(data.getWritePosition()).assertEqual(token.length * 2 + 6); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0380 errorMessage " + error.message); - expect(error != null).assertTrue(); - } finally{ - data.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0380---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0390 - * @tc.name : test Test the function of the getWritePosition interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0390", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0390---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeByte(2); - expect(data.getWritePosition()).assertEqual(4); - data.writeShort(3); - expect(data.getWritePosition()).assertEqual(4 + 4); - data.writeInt(4); - expect(data.getWritePosition()).assertEqual((4 + 4) + 4); - data.writeLong(5); - expect(data.getWritePosition()).assertEqual(((4 + 4) + 4) + 8); - data.writeFloat(1.2); - expect(data.getWritePosition()).assertEqual((((4 + 4) + 4) + 8) + 8); - data.writeDouble(10.2); - expect(data.getWritePosition()).assertEqual(((((4 + 4) + 4) + 8) + 8) + 8); - data.writeBoolean(true); - expect(data.getWritePosition()).assertEqual((((((4 + 4) + 4) + 8) + 8) + 8) + 4); - data.writeChar(97); - expect(data.getWritePosition()).assertEqual(((((((4 + 4) + 4) + 8) + 8) + 8) + 4) + 4); - data.writeString(""); - expect(data.getWritePosition()).assertEqual((((((((4 + 4) + 4) + 8) + 8) + 8) + 4) + 4) + 8); - data.writeParcelable(new MySequenceable(1, "aaa")); - expect(data.getWritePosition()).assertEqual(((((((((4 + 4) + 4) + 8) + 8) + 8) + 4) + 4) + 8) + (12 + 8)); - await gIRemoteObject.sendMessageRequest(CODE_ALL_TYPE, data, reply, option).then((result) => { - 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(); - expect(result.reply.readChar()).assertEqual(97); - expect(result.reply.readString()).assertEqual(""); - let s = new MySequenceable(null, null); - result.reply.readParcelable(s); - expect(s.num).assertEqual(1); - expect(s.str).assertEqual("aaa"); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0390 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0390---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0400 - * @tc.name : test Test on the null value of the getWritePosition interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0400", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0400---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let str = ""; - data.writeString(str); - expect(data.getWritePosition()).assertEqual(8); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0400 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0400---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0410 - * @tc.name : test Invoke the rewindWrite interface, Set 0-bit offset and write the data after offset - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0410", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0410---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(4); - data.rewindWrite(0); - data.writeInt(5); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode == 0).assertTrue(); - expect(result.reply.readInt()).assertEqual(5); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0410 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0410---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0420 - * @tc.name : test Invoke the rewindWrite interface, Set 1-bit offset and write the data after offset - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0420", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0420---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(4); - data.rewindWrite(1); - data.writeInt(5); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.readInt() != 5).assertTrue(); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0420 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0420---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0430 - * @tc.name : testrewindWrite is write data to message sequence failed Error verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改IPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0430", 0,async function(){ - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0430---------------------------"); - let data = rpc.MessageSequence.create(); - try{ - data.reclaim(); - data.rewindWrite(0); - } catch (error) { - let errCode = `${rpc.ErrorCode.WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR}`; - expect(error.code == errCode).assertTrue(); - expect(error.message != null).assertTrue(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0430---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0440 - * @tc.name : test Invoke the rewindRead interface,Set 0-bit offset and read the data after offset - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0440", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0440---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(12); - data.writeString("parcel"); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode).assertEqual(0); - expect(result.reply.readInt()).assertEqual(12); - result.reply.rewindRead(0); - expect(result.reply.readInt()).assertEqual(12); - expect(result.reply.readString()).assertEqual(""); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0440 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0440---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0450 - * @tc.name : test Invoke the rewindRead interface,Set 1-bit offset and read the data after offset - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0450", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0440---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(12); - data.writeString("parcel"); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode == 0).assertTrue(); - expect(result.reply.readInt()).assertEqual(12); - result.reply.rewindRead(1); - expect(result.reply.readInt()).assertEqual(0); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0450 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0450---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0460 - * @tc.name : test Basic test of the rewindRead interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0460", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0460---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - let reply: rpc.MessageSequence = rpc.MessageSequence.create(); - let option: rpc.MessageOption = new rpc.MessageOption(); - try{ - data.writeInt(12); - expect(gIRemoteObject != undefined).assertTrue(); - await gIRemoteObject.sendMessageRequest(CODE_WRITE_INT, data, reply, option).then((result) => { - expect(result.errCode == 0).assertTrue(); - expect(result.reply.getReadPosition()).assertEqual(0); - expect(result.reply.readInt()).assertEqual(12); - expect(result.reply.getReadPosition()).assertEqual(4); - result.reply.rewindRead(1); - expect(result.reply.getReadPosition()).assertEqual(1); - expect(result.reply.readInt() != 12).assertTrue(); - expect(result.reply.getReadPosition()).assertEqual(1); - }); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0460 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - reply.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0460---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0470 - * @tc.name : test rewindRead interface write position cheap extension test - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0470", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0470---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - data.writeInt(16); - data.writeString("sequence"); - expect(data.getReadPosition()).assertEqual(0); - expect(data.readInt()).assertEqual(16); - expect(data.getReadPosition()).assertEqual(4); - expect(data.readString()).assertEqual("sequence"); - expect(data.getReadPosition()).assertEqual(4 + ("sequence".length * 2 + 8)); - data.rewindRead(5); - expect(data.getReadPosition()).assertEqual(5); - expect(data.readInt() != 16).assertTrue(); - expect(data.getReadPosition()).assertEqual(4 + 5); - expect(data.readString() != "sequence").assertTrue(); - expect(data.getReadPosition()).assertEqual(4 + 5); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0470 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0470---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0480 - * @tc.name : test Test the boundary value of the rewindRead interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0480", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0480---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let token = ''; - for (let i = 0; i < (40 * K - 1); i++) { - token += 'a'; - } - data.writeString(token); - expect(data.getReadPosition()).assertEqual(0); - expect(data.readString().length).assertEqual(40 * K - 1); - expect(data.getReadPosition()).assertEqual(token.length * 2 + 6); - data.rewindRead((token.length * 2 + 6) - 1); - expect(data.getReadPosition()).assertEqual((token.length * 2 + 6) - 1); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0480 error: " + error); - expect(error == null).assertTrue(); - } finally{ - data.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0480---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0490 - * @tc.name : test Test the critical value of the rewindRead interface - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0490", 0, async function (done) { - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0490---------------------------"); - let data: rpc.MessageSequence = rpc.MessageSequence.create(); - try{ - let token = ''; - for (let i = 0; i < (40 * K - 1); i++) { - token += 'a'; - } - data.writeString(token); - expect(data.getReadPosition()).assertEqual(0); - expect(data.readString().length).assertEqual(40 * K - 1); - expect(data.getReadPosition()).assertEqual(token.length * 2 + 6); - data.rewindRead((token.length * 2 + 6) + 1); - expect(data.getReadPosition()).assertEqual(token.length * 2 + 6); - } catch (error) { - console.info("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0490 errorMessage " + error.message); - expect(error != null).assertTrue(); - } finally{ - data.reclaim(); - done(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0490---------------------------"); - }); - - /* - * @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_0500 - * @tc.name : testrewindRead is read data from message sequence failed Error verification - * @tc.desc : [G-DISTRIBUTED-0212]禁止修改IPC中定义的数据结构和接口,并提供对应完整实现 - * @tc.level : 3 - * @tc.type : Compatibility - * @tc.size : MediumTest - */ - it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_0500", 0,async function(){ - console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_0500---------------------------"); - let data = rpc.MessageSequence.create(); - try{ - data.reclaim(); - data.rewindRead(0); - } catch (error) { - let errCode = `${rpc.ErrorCode.READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR}`; - expect(error.code == errCode).assertTrue(); - expect(error.message != null).assertTrue(); - } - console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_0500---------------------------"); }); console.info(logTag +"-----------------------SUB_DSoftbus_RPC_API_NEW_onRemoteRequest_Test is end-----------------------"); }); diff --git a/communication/dsoftbus_rpcets/rpcserver/entry/src/main/ets/serviceability/ServiceAbility.ts b/communication/dsoftbus_rpcets/rpcserver/entry/src/main/ets/serviceability/ServiceAbility.ts index fda9c5b..7264c57 100644 --- a/communication/dsoftbus_rpcets/rpcserver/entry/src/main/ets/serviceability/ServiceAbility.ts +++ b/communication/dsoftbus_rpcets/rpcserver/entry/src/main/ets/serviceability/ServiceAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -15,27 +15,6 @@ import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility'; import rpc from '@ohos.rpc'; -class MySequenceable { - num = null; - str = null; - 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 { constructor(descriptor) { super(descriptor); @@ -119,464 +98,6 @@ class Stub extends rpc.RemoteObject { console.info("case 3 onRemoteMessageRequest success"); return true; } - case 4: - { - console.info("case 4 start"); - let tmp1:number = data.readInt(); - console.info("The server's readInt result is " + tmp1); - reply.writeInt(tmp1); - console.info("case 4 onRemoteMessageRequest success"); - return true; - } - case 5: - { - console.info("case 5 start"); - let tmp1 = data.readByte(); - let tmp2 = data.readShort(); - let tmp3 = data.readInt(); - let tmp4 = data.readLong(); - let tmp5 = data.readFloat(); - let tmp6 = data.readDouble(); - let tmp7 = data.readBoolean(); - let tmp8 = data.readChar(); - let tmp9 = data.readString(); - let s = new MySequenceable(null, null); - data.readParcelable(s); - reply.writeByte(tmp1); - reply.writeShort(tmp2); - reply.writeInt(tmp3); - reply.writeLong(tmp4); - reply.writeFloat(tmp5); - reply.writeDouble(tmp6); - reply.writeBoolean(tmp7); - reply.writeChar(tmp8); - reply.writeString(tmp9); - reply.writeParcelable(s); - console.info("case 5 onRemoteMessageRequest success"); - return true; - } - case 6: - { - console.info("case 6 start"); - let tmp1:number = data.readByte(); - console.info("The server's readByte result is " + tmp1); - reply.writeByte(tmp1); - console.info("case 6 onRemoteMessageRequest success"); - return true; - } - case 7: - { - console.info("case 7 start"); - let tmp1 = data.readByte(); - let tmp2 = data.readByte(); - let tmp3 = data.readByte(); - let tmp4 = data.readByte(); - let tmp5 = data.readByte(); - console.info("The server's readByte result is " + tmp1 +";" + tmp2 +";" + tmp3 +";" + tmp4 +";" + tmp5); - reply.writeByte(tmp1); - reply.writeByte(tmp2); - reply.writeByte(tmp3); - reply.writeByte(tmp4); - reply.writeByte(tmp5); - console.info("case 7 onRemoteMessageRequest success"); - return true; - } - case 8: - { - console.info("case 8 start"); - let tmp1:number = data.readShort(); - console.info("The server's readShort result is " + tmp1); - reply.writeShort(tmp1); - console.info("case 8 onRemoteMessageRequest success"); - return true; - } - case 9: - { - console.info("case 9 start"); - let tmp1 = data.readShort(); - let tmp2 = data.readShort(); - let tmp3 = data.readShort(); - let tmp4 = data.readShort(); - let tmp5 = data.readShort(); - console.info("The server's readShort result is " + tmp1 +";"+ tmp2 +";" + tmp3 +";" + tmp4 +";" + tmp5); - reply.writeShort(tmp1); - reply.writeShort(tmp2); - reply.writeShort(tmp3); - reply.writeShort(tmp4); - reply.writeShort(tmp5); - console.info("case 9 onRemoteMessageRequest success"); - return true; - } - case 10: - { - console.info("case 10 start"); - let tmp1 = data.readInt(); - let tmp2 = data.readInt(); - let tmp3 = data.readInt(); - let tmp4 = data.readInt(); - let tmp5 = data.readInt(); - console.info("The server's readInt result is " + tmp1 +";" + tmp2 +";" + tmp3 +";" + tmp4 +";" + tmp5); - reply.writeInt(tmp1); - reply.writeInt(tmp2); - reply.writeInt(tmp3); - reply.writeInt(tmp4); - reply.writeInt(tmp5); - console.info("case 10 onRemoteMessageRequest success"); - return true; - } - case 11: - { - console.info("case 11 start"); - let tmp1:number = data.readLong(); - console.info("The server's readLong result is " + tmp1); - reply.writeLong(tmp1); - console.info("case 11 onRemoteMessageRequest success"); - return true; - } - case 12: - { - console.info("case 12 start"); - let tmp1:number = data.readFloat(); - console.info("The server's readFloat result is " + tmp1); - reply.writeFloat(tmp1); - console.info("case 12 onRemoteMessageRequest success"); - return true; - } - case 13: - { - console.info("case 13 start"); - let tmp1:number = data.readDouble(); - console.info("The server's readDouble result is " + tmp1); - reply.writeDouble(tmp1); - console.info("case 13 onRemoteMessageRequest success"); - return true; - } - case 14: - { - console.info("case 14 start"); - let tmp1:boolean = data.readBoolean(); - console.info("The server's readBoolean result is " + tmp1); - reply.writeBoolean(tmp1); - console.info("case 14 onRemoteMessageRequest success"); - return true; - } - case 15: - { - console.info("case 15 start"); - let tmp1:string = data.readChar(); - console.info("The server's readChar result is " + tmp1); - reply.writeChar(tmp1); - console.info("case 15 onRemoteMessageRequest success"); - return true; - } - case 20: - { - console.info("case 1 start"); - let tmp1:number[] = data.readByteArray(); - console.info("The server's readByteArray result is " + tmp1.length); - reply.writeByteArray(tmp1); - console.info("case 1 onRemoteMessageRequest success"); - return true; - } - case 35: - { - console.info("case 2 start"); - let tmp1:number[] = data.readIntArray(); - console.info("The server's readIntArray " + tmp1.length); - reply.writeIntArray(tmp1); - console.info("case 2 onRemoteMessageRequest success"); - return true; - } - case 18: - { - console.info("case 3 start"); - let tmp1:number[] = data.readFloatArray(); - console.info("The server's readFloatArray result is " + tmp1.length); - reply.writeFloatArray(tmp1); - console.info("case 3 onRemoteMessageRequest success"); - return true; - } - case 17: - { - console.info("case 4 start"); - let tmp1:number[] = data.readShortArray(); - console.info("The server's readShortArray result is " + tmp1.length); - reply.writeShortArray(tmp1); - console.info("case 4 onRemoteMessageRequest success"); - return true; - } - case 25: - { - console.info("case 5 start"); - let tmp1:number[] = data.readLongArray(); - console.info("The server's readLongArray result is " + tmp1.length); - reply.writeLongArray(tmp1); - console.info("case 5 onRemoteMessageRequest success"); - return true; - } - case 16: - { - console.info("case 6 start"); - let tmp1:number[] = data.readDoubleArray(); - console.info("The server's readDoubleArray result is " + tmp1.length); - reply.writeDoubleArray(tmp1); - console.info("case 6 onRemoteMessageRequest success"); - return true; - } - case 29: - { - console.info("case 7 start"); - let tmp1:boolean[] = data.readBooleanArray(); - console.info("The server's readBooleanArray result is " + tmp1.length); - reply.writeBooleanArray(tmp1); - console.info("case 7 onRemoteMessageRequest success"); - return true; - } - case 10: - { - console.info("case 8 start"); - let tmp1:string[] = data.readCharArray(); - console.info("The server's readCharArray result is " + tmp1.length); - reply.writeCharArray(tmp1); - console.info("case 8 onRemoteMessageRequest success"); - return true; - } - case 28: - { - console.info("case 9 start"); - let tmp1:string[] = data.readStringArray(); - console.info("The server's readStringArray result is " + tmp1.length); - reply.writeStringArray(tmp1); - console.info("case 9 onRemoteMessageRequest success"); - return true; - } - case 19: - { - console.info("case 19 start"); - let size:number= data.readInt(); - console.info("The server's readInt result is " + size); - let tmp1:any = data.readRawData(size); - console.info("The server's readRawData result is " + tmp1.length); - reply.writeInt(size); - reply.writeRawData(tmp1, tmp1.length); - console.info("case 19 onRemoteMessageRequest success"); - return true; - } - case 21: - { - console.info("case 21 start"); - let s = new MySequenceable(null, null); - let tmp1:boolean = data.readParcelable(s); - console.info("server's readParcelable result is " + tmp1); - reply.writeParcelable(s); - console.info("case 21 onRemoteMessageRequest success"); - return true; - } - case 22: - { - console.info("case 22 start"); - data.readException(); - console.info("readExcepetion "); - let tmp:number = data.readInt(); - console.info("readInt result is " +tmp); - reply.writeNoException(); - console.info("writeNoException result is "); - reply.writeInt(tmp); - console.info("case 22 onRemoteMessageRequest success"); - return true; - } - case 23: - { - console.info("case 23 start"); - let s:any = [new MySequenceable(null, null), new MySequenceable(null, null), - new MySequenceable(null, null)]; - data.readParcelableArray(s); - console.info("readParcelableArray result success"); - reply.writeParcelableArray(s); - console.info("case 23 onRemoteMessageRequest success"); - return true; - } - case 24: - { - console.info("case 24 start"); - let listeners:any = data.readRemoteObjectArray(); - console.info("The server's readRemoteObjectArray result is " + listeners.length); - for (let i = 0; i < listeners.length; i++) { - let option2 = new rpc.MessageOption(); - let data2 = rpc.MessageParcel.create(); - let reply2 = rpc.MessageParcel.create(); - listeners[i].sendRequest(1, data2, reply2, option2) - .then(function(result) { - console.info("send request done, error code: " + result.errCode + ", index: " + i); - }) - .catch(function(e) { - console.error("send request got exception: " + e); - }) - .finally(() => { - data2.reclaim(); - reply2.reclaim(); - console.info("case 24 test done"); - }) - } - console.info("case 24 onRemoteMessageRequest success"); - return true; - } - case 26: - { - console.info("case 26 start"); - let tmp1 = data.readByteArray(); - let tmp2 = data.readShortArray(); - let tmp3 = data.readIntArray(); - let tmp4 = data.readLongArray(); - let tmp5 = data.readFloatArray(); - let tmp6 = data.readDoubleArray(); - let tmp7 = data.readBooleanArray(); - let tmp8 = data.readCharArray(); - let tmp9 = data.readStringArray(); - let s = [new MySequenceable(null, null), new MySequenceable(null, null), - new MySequenceable(null, null)]; - data.readParcelableArray(s); - reply.writeByteArray(tmp1); - reply.writeShortArray(tmp2); - reply.writeIntArray(tmp3); - reply.writeLongArray(tmp4); - reply.writeFloatArray(tmp5); - reply.writeDoubleArray(tmp6); - reply.writeBooleanArray(tmp7); - reply.writeCharArray(tmp8); - reply.writeStringArray(tmp9); - reply.writeParcelableArray(s); - console.info("case 26 onRemoteMessageRequest success"); - return true; - } - case 27: - { - console.info("case 27 start"); - let s:any = new MySequenceable(null, null); - data.readParcelable(s); - console.info("The server's readParcelable result is " + s); - reply.writeParcelable(s); - console.info("case 27 onRemoteMessageRequest success"); - return true; - } - case 31: - { - console.info("case 31 start"); - let callingPid:any = rpc.IPCSkeleton.getCallingPid(); - let callingUid:any = rpc.IPCSkeleton.getCallingUid(); - let callingDeviceID:any = rpc.IPCSkeleton.getCallingDeviceID(); - let localDeviceID:any = rpc.IPCSkeleton.getLocalDeviceID(); - let isLocalCalling:any = rpc.IPCSkeleton.isLocalCalling(); - reply.writeNoException(); - reply.writeInt(callingPid); - reply.writeInt(callingUid); - reply.writeString(callingDeviceID); - reply.writeString(localDeviceID); - reply.writeBoolean(isLocalCalling); - reply.writeInt(this.getCallingPid()); - reply.writeInt(this.getCallingUid()); - console.info("getCallingUid the server result success"); - let id:any = rpc.IPCSkeleton.resetCallingIdentity(); - rpc.IPCSkeleton.setCallingIdentity(id); - reply.writeInt(rpc.IPCSkeleton.getCallingPid()); - reply.writeInt(rpc.IPCSkeleton.getCallingUid()); - reply.writeInt(rpc.IPCSkeleton.flushCommands(this)); - console.info("case 31 onRemoteMessageRequest success"); - return true; - } - case 32: - { - console.info("case 32 starts"); - let callingPid = rpc.IPCSkeleton.getCallingPid(); - let callingUid = rpc.IPCSkeleton.getCallingUid(); - reply.writeNoException(); - reply.writeInt(callingPid); - reply.writeInt(callingUid); - reply.writeInt(this.getCallingPid()); - reply.writeInt(this.getCallingUid()); - console.info("getCallingUid the server result success"); - let id = rpc.IPCSkeleton.resetCallingIdentity(); - rpc.IPCSkeleton.setCallingIdentity(id); - reply.writeInt(rpc.IPCSkeleton.getCallingPid()); - reply.writeInt(rpc.IPCSkeleton.getCallingUid()); - reply.writeInt(rpc.IPCSkeleton.flushCommands(this)); - console.info("case 32 onRemoteMessageRequest success"); - return true; - } - case 33: - { - console.info("case 33 start"); - let listeners:any = data.readRemoteObjectArray(); - console.info("The server's readRemoteObjectArray result is " + listeners.length); - let num:number = data.readInt(); - let str:string = data.readString(); - let len:number = listeners.length; - console.info("num is:" + num + "str is:" + str + "len is:" + len); - for (let i = 0; i < len; i++) { - let option2:any = new rpc.MessageOption(); - let data2:any = rpc.MessageParcel.create(); - let reply2:any = rpc.MessageParcel.create(); - data2.writeInt(num); - data2.writeString(str); - console.info("case 33 start sendRequest"); - listeners[i].sendRequest(1, data2, reply2, option2) - .then(function(result) { - console.info("send request done, error code: " + result.errCode); - console.info("result:" + reply2.readBoolean()); - }) - .catch(function(e) { - console.error("send request got exception: " + e); - }) - .finally(() => { - data2.reclaim(); - reply2.reclaim(); - console.info("case 33 test done"); - }) - } - reply.writeNoException(); - console.info("case 33 onRemoteMessageRequest success"); - return true; - } - case 34: - { - console.info("case 34 start"); - let listeners:any = new Array(3); - data.readRemoteObjectArray(listeners); - let num:number = data.readInt(); - let str:string = data.readString(); - for (let i = 0; i < listeners.length; i++) { - let option2:any = new rpc.MessageOption(); - let data2:any = rpc.MessageParcel.create(); - let reply2:any = rpc.MessageParcel.create(); - data2.writeInt(num); - data2.writeString(str); - console.info("case 34 start sendRequest"); - listeners[i].sendRequest(1, data2, reply2, option2) - .then(function(result) { - console.info("send request done, error code: " + result.errCode + ", index: " + i); - }) - .catch(function(e) { - console.error("send request got exception: " + e); - }) - .finally(() => { - data2.reclaim(); - reply2.reclaim(); - console.info("case 34 test done"); - }) - } - reply.writeNoException(); - console.info("case 34 onRemoteMessageRequest success"); - return true; - } - case 36: - { - console.info("case 36 start"); - let tmp1:string = data.readString(); - console.info("onRemoteRequest readstring is " + tmp1); - reply.writeString("onRemoteMessageRequest invoking"); - console.info("case 36 onRemoteMessageRequest success"); - return true; - } default: this.onRemoteRequest(code, data, reply, option); }