diff --git a/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js b/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js index e7fed51be1651389593f7db87ebd8e910a175a64..713dcf07298179fff1bc430ef06aa2bdd2bedd3f 100755 --- a/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js +++ b/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js @@ -73,6 +73,50 @@ export default function actsRpcClientJsTest() { const CODE_ONREMOTEMESSAGE_OR_ONREMOTE = 32; const CODE_ONREMOTEMESSAGEREQUEST = 33; + const ErrorCode = { + /* Check param failed */ + CHECK_PARAM_ERROR:401, + + /* Os mmap function failed */ + OS_MMAP_ERROR:1900001, + + /* Os ioctl function failed */ + OS_IOCTL_ERROR:1900002, + + /* Write to ashmem failed */ + WRITE_TO_ASHMEM_ERROR:1900003, + + /* Read from ashmem failed */ + READ_FROM_ASHMEM_ERROR:1900004, + + /* Only proxy object permitted */ + ONLY_PROXY_OBJECT_PERMITTED_ERROR:1900005, + + /* Only remote object permitted */ + ONLY_REMOTE_OBJECT_PERMITTED_ERROR:1900006, + + /* Communication failed */ + COMMUNICATION_ERROR:1900007, + + /* Proxy or remote object is invalid */ + PROXY_OR_REMOTE_OBJECT_INVALID_ERROR:1900008, + + /* Write data to message sequence failed */ + WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR:1900009, + + /* Read data from message sequence failed */ + READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR:1900010, + + /* Parcel memory alloc failed */ + PARCEL_MEMORY_ALLOC_ERROR:1900011, + + /* Call js method failed */ + CALL_JS_METHOD_ERROR:1900012, + + /* Os dup function failed */ + OS_DUP_ERROR:1900013 + } + function connectAbility() { let want = { "bundleName":"ohos.rpc.test.server", @@ -94,6 +138,13 @@ export default function actsRpcClientJsTest() { } }; FA.connectAbility(want, connect) + try { + let descriptor = gIRemoteObject.getDescriptor(); + console.info("RpcClient: descriptor is " + descriptor); + } catch(error) { + console.info("rpc get interface descriptor fail, errorCode " + error.code); + console.info("rpc get interface descriptor fail, errorMessage " + error.message); + } return new Promise((resolve, reject) =>{ console.info("start connect local ability, wait 5 seconds") setTimeout(()=>{ @@ -151,6 +202,22 @@ export default function actsRpcClientJsTest() { } } + class MyregisterDeathRecipient { + constructor(gIRemoteObject, done) { + this.gIRemoteObject = gIRemoteObject + this.done = done + } + + onRemoteDied() { + console.info("server died") + expect(this.proxy.unregisterDeathRecipient(this, 0)).assertTrue() + let _done = this.done + setTimeout(function() { + _done() + }, 1000) + } + } + class TestAbilityStub extends rpc.RemoteObject { constructor(descriptor) { super(descriptor) @@ -199,6 +266,53 @@ export default function actsRpcClientJsTest() { } } + class TestAbilityMessageStub extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor) + } + + onRemoteMessageRequest(code, data, reply, option) { + console.info("TestAbilityMessageStub: onRemoteMessageRequest called, code: " + code) + let descriptor = data.readInterfaceToken() + if (descriptor !== "TestAbilityMessageStub") { + console.error("received unknown descriptor: " + descriptor) + return false + } + switch (code) { + case 1: + { + 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.writeNoException() + 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) + return true + } + default: + { + console.error("default case, code: " + code) + return false + } + } + } + } class TestListener extends rpc.RemoteObject { constructor(descriptor, checkResult) { @@ -6029,13 +6143,228 @@ export default function actsRpcClientJsTest() { console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_15800---------------------------"); }); + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_15900 + * @tc.name Call the 401 interface to set the writeString of MessageSequence + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_15900", 0, function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_15900---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: create object successfully."); + var token = ''; + for(var i = 0; i < 40*K; i++){ + token += 'a'; + }; + var result = data.writeString(token); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900:run writeStringis is " + result); + data.reclaim(); + } catch (error) { + let errCode = ErrorCode.CHECK_PARAM_ERROR + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_15900---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16000 + * @tc.name Call the 1900011 interface, write the interface descriptor, and read interfacetoken + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16000", 0, function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16000---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: create object successfully"); + data.setSize(0); + data.setCapacity(0); + var token = "hello ruan zong xian"; + data.writeInterfaceToken(token); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000:run writeInterfaceToken result "); + data.reclaim(); + } catch (error) { + let errCode = ErrorCode.PARCEL_MEMORY_ALLOC_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16000---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16100 + * @tc.name Call the 1900009 interface, write the interface descriptor, and read interfacetoken + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16100", 0, function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16100---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: create object successfully."); + data.setSize(true); + data.setCapacity(true); + var token = "hello ruan zong xian"; + data.writeInterfaceToken(token); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100:run writeInterfaceToken result is "); + + data.reclaim(); + } catch (error) { + let errCode = ErrorCode.WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorCode " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16100---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16200 + * @tc.name Call the setcapacity interface to set the capacity of messageparcel + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16200", 0, function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16200---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16200: create object successfully."); + let sequenceable = new MySequenceable(1, "aaa"); + data.writeParcelable(sequenceable); + let ret = new MySequenceable(0, ""); + data.setCapacity(0); + data.readParcelable(ret); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16200: readParcelable is." + ret); + } catch (error) { + let errCode = ErrorCode.PARCEL_MEMORY_ALLOC_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16200---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16300 + * @tc.name Call the 1900008 interface to serialize the remote object and pass in the empty object + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16300", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16300---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: create object successfully."); + var token = {} + var result = data.writeRemoteObject(token); + } catch (error) { + let errCode = ErrorCode.PROXY_OR_REMOTE_OBJECT_INVALID_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + data.reclaim(); + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16300---------------------------"); + }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_00100 - * @tc.name Basic method of testing messageoption - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16400 + * @tc.name Call the writeparcelable 1900012 interface to write the custom serialized + * object to the MessageSequence instance + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16400", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16400---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400: create object successfully."); + let sequenceable = new MySequenceableCode(1, "aaa"); + data.writeParcelable(sequenceable); + data.setCapacity(0); + data.setSize(0); + let ret = new MySequenceable(1, ""); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400 : setCapacity and setSize"); + data.readParcelable(ret); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: readParcelable is." + ret); + } catch (error) { + let errCode = ErrorCode.CALL_JS_METHOD_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.message); + expect(error.message != null).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.code); + } + data.reclaim(); + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16400---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16500 + * @tc.name Call the writeinterfacetoken interface, write the interface descriptor, and read interfacetoken + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16500", 0, function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16500---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + var token = "hello ruan zong xian"; + data.writeInterfaceToken(token); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:run writeInterfaceToken result is success"); + data.setCapacity(0); + data.setSize(0); + var resultToken = data.readInterfaceToken(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:run readInterfaceToken result is " + resultToken); + data.reclaim(); + } catch (error) { + let errCode = ErrorCode.READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.message); + expect(error.message != null).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.code); + expect(error.code != errCode).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16500---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_16600 + * @tc.name Test 1900013 messageparcel delivery file descriptor object + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageParcel_16600", 0,async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_16600---------------------------"); + try { + let filePath = "path/to/file"; + let fd = fileio.openSync(filePath, null); + let newFd = rpc.MessageSequence.dupFileDescriptor(fd); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: newFd " +newFd); + } catch(error) { + let errCode = ErrorCode.OS_DUP_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorCode " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorMessage" + error.message); + expect(error.message != null).assertTrue(); + } + done() + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_16600---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_00100 + * @tc.name Basic method of testing messageoption + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_MessageOption_00100",0,function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_00100---------------------------"); try{ @@ -6266,11 +6595,11 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01000 - * @tc.name Basic method of testing messageoption - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01000 + * @tc.name Basic method of testing messageoption + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_MessageOption_01000",0,async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01000---------------------------"); try{ @@ -6312,11 +6641,11 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01100 - * @tc.name Basic method of testing messageoption - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01100 + * @tc.name Basic method of testing messageoption + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_MessageOption_01100",0, async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01100---------------------------"); try{ @@ -6353,11 +6682,11 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01200 - * @tc.name Basic method of testing messageoption - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01200 + * @tc.name Basic method of testing messageoption + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_MessageOption_01200",0, async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01200---------------------------"); try{ @@ -6393,11 +6722,11 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01300 - * @tc.name MessageOption sendMessageRequest test - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01300 + * @tc.name MessageOption sendMessageRequest test + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_MessageOption_01300",0, async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01300---------------------------"); try{ @@ -6431,12 +6760,148 @@ export default function actsRpcClientJsTest() { console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageOption_01300---------------------------"); }) + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01400 + * @tc.name MessageOption sendMessageRequest test + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageOption_01400",0, async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01400---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: create object successfully."); + var reply = rpc.MessageSequence.create(); + var option = new rpc.MessageOption(); + var token = "option"; + data.writeString(token); + let isAsyncData0 = option.isAsync(); + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: run isAsync is " + isAsyncData0); + expect(isAsyncData0).assertEqual(false); + if (gIRemoteObject == undefined) + { + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: gIRemoteObject is undefined"); + } + await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => { + expect(result.errCode).assertEqual(0); + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: sendMessageRequest is " + result.errCode); + let isAsyncData = option.isAsync(); + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: run isAsync is " + isAsyncData); + expect(isAsyncData).assertEqual(false); + var replyReadResult = result.reply.readString(); + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: run readString is " + replyReadResult); + expect(replyReadResult).assertEqual(token); + }); + data.reclaim(); + reply.reclaim(); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01400: error " + error); + expect(error == null).assertTrue(); + } + done(); + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageOption_01400---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01500 + * @tc.name MessageOption setAsync is true test + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageOption_01500",0, async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01500---------------------------"); + try{ + var data = rpc.MessageSequence.create(); + var reply = rpc.MessageSequence.create(); + var option = new rpc.MessageOption(); + option.setAsync(true); + var token = "option"; + data.writeString(token); + if (gIRemoteObject == undefined) + { + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01500: gIRemoteObject is undefined"); + } + await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => { + expect(result.errCode).assertEqual(0); + let isAsyncData = option.isAsync(); + expect(isAsyncData).assertTrue(); + var replyReadResult = result.reply.readString(); + expect(replyReadResult).assertEqual(""); + }); + data.reclaim(); + reply.reclaim(); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01500: error " + error); + expect(error == null).assertTrue(); + } + done(); + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageOption_01500---------------------------"); + }) + + /* - * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_00100 - * @tc.name Exception parameter validation of the created anonymous shared memory object - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01600 + * @tc.name setAsync is false sendMessageRequest test + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageOption_01600",0, async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01600---------------------------"); + try{ + + var data = rpc.MessageSequence.create(); + var reply = rpc.MessageSequence.create(); + var option = new rpc.MessageOption(); + option.setAsync(false); + var token = "option"; + data.writeString(token); + if (gIRemoteObject == undefined) + { + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01600: gIRemoteObject is undefined"); + } + await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => { + expect(result.errCode).assertEqual(0); + let isAsyncData = option.isAsync(); + expect(isAsyncData).assertEqual(false); + var replyReadResult = result.reply.readString(); + expect(replyReadResult).assertEqual(token); + }); + data.reclaim(); + reply.reclaim(); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01600: error " + error); + expect(error == null).assertTrue(); + } + done(); + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageOption_01600---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01700 + * @tc.name setAsync sendMessageRequest test + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_MessageOption_01700",0, async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01700---------------------------"); + try{ + var option = new rpc.MessageOption(); + option.setAsync(3); + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01700: setAsync is success") + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01700: error " + error); + expect(error != null).assertTrue(); + } + done(); + console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageOption_01700---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_00100 + * @tc.name Exception parameter validation of the created anonymous shared memory object + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_Ashmem_00100",0,function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_00100---------------------------"); try{ @@ -6452,11 +6917,11 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_00200 - * @tc.name Call the getashmemsize interface to get the size of the shared memory object - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_00200 + * @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_Compatibility_Ashmem_00200",0,function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_00200---------------------------"); try{ @@ -7210,32 +7675,578 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_00100 - * @tc.name Call sendrequestresult interface to send data - * @tc.desc Function test - * @tc.level 0 - */ - it("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100",0,async function(done){ - console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_00100---------------------------"); + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03000 + * @tc.name mapTypedAshmem interface creates shared file mappings + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03000",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03000---------------------------"); 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); - console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100: run writeSequenceableis is " + result); - - await gIRemoteObject.sendRequest(CODE_WRITESEQUENCEABLE, data, reply, option).then((result) => { - console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100: sendRequestis is " + result.errCode); - expect(result.errCode == 0).assertTrue(); - let ret = new MySequenceable(0, ""); - var shortArryDataReply = result.reply.readSequenceable(ret); - console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100: run readSequenceable is " - + shortArryDataReply); - expect(shortArryDataReply == true).assertTrue() - expect(ret.num).assertEqual(1) - expect(ret.str).assertEqual("aaa") - }); + let ashmem = rpc.Ashmem.create("JsAshmemTest", 4*K) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03000: ashmem " + ashmem); + let result = ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03000: run mapTypedAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03000: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03000---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03100 + * @tc.name mapTypedAshmem exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03100",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03100---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", (2*G - 1)) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03100: ashmem " + ashmem); + let result = ashmem.mapTypedAshmem(999); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03100: run mapTypedAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03100: errorCode " + error.code); + expect(error.code == 401).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03100: errormessage" + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03100---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03200 + * @tc.name mapTypedAshmem exception errorcode validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03200",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03200---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", (2*G)) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03200: ashmem " + ashmem); + let result = ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03200: run mapTypedAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03200: errorCode " + error.code); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03200: errormessage" + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03200---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03300 + * @tc.name mapReadWriteAshmem interface creates a shared file map with the protection level of read-write + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03300",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03300---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", K) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03300: ashmem " + ashmem); + ashmem.mapReadWriteAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03300: run mapReadWriteAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03300: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03300---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03400 + * @tc.name mapReadWriteAshmem exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03400",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03400---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", 4096) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03400: ashmem " + ashmem); + ashmem.mapTypedAshmem(rpc.Ashmem.PROT_READ); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03400: run mapTypedAshmem is success"); + ashmem.unmapAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03400: run unmapAshmem success"); + ashmem.mapReadWriteAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03400: run mapReadWriteAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03400: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03400---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03500 + * @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_Compatibility_Ashmem_03500",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03500---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", 4096) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03500: ashmem " + ashmem); + ashmem.mapReadonlyAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03500: run mapReadonlyAshmem is success"); + ashmem.closeAshmem(); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03500: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03500---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03600 + * @tc.name mapReadWriteAshmem exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03600",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03600---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", K); + ashmem.setProtectionType(rpc.Ashmem.PROT_WRITE) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03600: run setProtectionType is success"); + + ashmem.setProtectionType(rpc.Ashmem.PROT_READ) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03600: run setProtectionType is success"); + + ashmem.mapReadWriteAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03600: run mapReadWriteAshmem success"); + + ashmem.setProtectionType(rpc.Ashmem.PROT_NONE) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03600: run setProtectionType is success"); + + ashmem.setProtectionType(rpc.Ashmem.PROT_READ) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03600: run setProtectionType is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03600: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03600---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03700 + * @tc.name setProtectionType exception input parameter verification + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03700",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03700---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", K); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03700: ashmem " + ashmem); + ashmem.setProtectionType(3); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03700: run setProtectionType is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03700: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03700---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03800 + * @tc.name The writetoashmem interface writes the shared file associated with the object + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03800",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03800---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", 4096) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03800: ashmem " + ashmem); + ashmem.mapReadWriteAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03800: run mapReadWriteAshmem is success"); + let bytes = [1, 2, 3, 4, 5]; + let result = ashmem.writeToAshmem(bytes, bytes.length, 0); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03800: run writeToAshmemis is " +result); + expect(result).assertTrue(); + ashmem.setProtectionType(rpc.Ashmem.PROT_READ); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03800: run setProtectionType is success"); + let result2 = ashmem.writeToAshmem(bytes, bytes.length, 0); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03800: run writeToAshmemis is2 " + result2); + expect(result2).assertEqual(false) + ashmem.closeAshmem(); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03800: error " +error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03800---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_03900 + * @tc.name Create a non shared memory object and call setProtectionType to write the messageparcel object + * object into the messageparcel object + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_03900",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_03900---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", K); + ashmem.setProtectionType(rpc.Ashmem.PROT_EXEC) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03900: run setProtectioniswrite is success"); + ashmem.closeAshmem() + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_03900: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_03900---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04000 + * @tc.name Mapreadonlyashmem exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04000",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04000---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", K) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04000: ashmem " + ashmem); + + ashmem.mapTypedAshmem(rpc.Ashmem.PROT_WRITE); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04000: run mapTypedAshmem is success"); + + ashmem.unmapAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04000: run unmapAshmem success"); + ashmem.closeAshmem() + + ashmem.mapReadonlyAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04000: run mapReadonlyAshmem is success"); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04000: error " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04000---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04100 + * @tc.name create is errorcode 401 exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04100",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04100---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", (2*G + 1)); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: ashmem " + ashmem); + }catch(error){ + let errCode = ErrorCode.CHECK_PARAM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04100---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04200 + * @tc.name mapReadWriteAshmem exception validation 1900001 + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04200",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04200---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", (4*G - 1)); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: ashmem " + ashmem); + ashmem.mapReadWriteAshmem(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: run mapReadWriteAshmem is success"); + }catch(error){ + let errCode = ErrorCode.OS_MMAP_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04200---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04300 + * @tc.name create 401 exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04300",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04300---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", 0); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: ashmem " + ashmem); + }catch(error){ + let errCode = ErrorCode.CHECK_PARAM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04300---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04400 + * @tc.name setProtectionType exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04400",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04400---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04400: ashmem " + ashmem); + ashmem.setProtectionType(0); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04400: run setProtectionType is success"); + }catch(error){ + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04400: error " + error); + expect(error).assertEqual(null); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04400---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04500 + * @tc.name 401 exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04500",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04500---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: ashmem " + ashmem); + ashmem.setProtectionType(rpc.Ashmem.PROT_WRITE, rpc.Ashmem.PROT_READ); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: run setProtectionType is success"); + }catch(error){ + let errCode = ErrorCode.CHECK_PARAM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorCode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04500---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04600 + * @tc.name setProtectionType is 1900002 exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04600",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04600---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: ashmem " + ashmem); + ashmem.setProtectionType(null); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: run setProtectionType is success"); + }catch(error){ + let errCode = ErrorCode.OS_IOCTL_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorCode " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorMessage " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04600---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04700 + * @tc.name writeAshmem errCode 1900003 exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04700",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04700---------------------------"); + try{ + let data = rpc.MessageSequence.create(); + let data2 = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: create MessageSequence object success"); + data.writeAshmem(data2); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: run writeAshmemis is " ); + data.reclaim(); + data2.reclaim(); + }catch(error){ + let errCode = ErrorCode.WRITE_TO_ASHMEM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.message); + expect(error != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04700---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04800 + * @tc.name readAshmem exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_04800",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04800---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("ashmem", 1024); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: ashmem " + ashmem); + ashmem.mapReadWriteAshmem(); + var ByteArrayVar = [1, 2, 3, 4, 5]; + ashmem.writeAshmem(ByteArrayVar, 5, 0); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: run writeAshmem is success"); + let readResult = ashmem.readAshmem(5, 0); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: readAshmem is : " + readResult); + }catch(error){ + let errCode = ErrorCode.READ_FROM_ASHMEM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: error " + error.code); + expect(error.code != errCode).assertEqual(null); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04800---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_04900 + * @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_Compatibility_Ashmem_04900",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_04900---------------------------"); + try{ + let mapSize = 2*G; + let ashmem = rpc.Ashmem.create("JsAshmemTest ", mapSize) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: run create success " + ashmem); + let size = ashmem.getAshmemSize() + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: run getAshmemSize success, size is " + size); + expect(size).assertEqual(mapSize); + ashmem.closeAshmem(); + }catch(error){ + let errCode = ErrorCode.CHECK_PARAM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errorcode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errormessage " + error.message); + expect(error != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_04900---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_05000 + * @tc.name mapTypedAshmem errorcode 401 exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_05000",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_05000---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", (2*G - 1)) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: ashmem " + ashmem); + let result = ashmem.mapTypedAshmem(999); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: run mapAshmemis is " + result); + expect(result).assertEqual(false); + ashmem.closeAshmem() + }catch(error){ + let errCode = ErrorCode.CHECK_PARAM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errorcode " + error.code); + expect(error.code == errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errormessage " + error.message); + expect(error != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_05000---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_05100 + * @tc.name mapTypedAshmem exception validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_05100",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_05100---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", (2*G - 1)) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: ashmem " + ashmem); + let result = ashmem.mapTypedAshmem(999); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: run mapTypedAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + let errCode = ErrorCode.OS_MMAP_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.message); + expect(error != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_05100---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_Ashmem_05200 + * @tc.name mapTypedAshmem exception errorcode validation + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_Ashmem_05200",0,function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_Ashmem_05200---------------------------"); + try{ + let ashmem = rpc.Ashmem.create("JsAshmemTest", (2*G - 1)) + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: ashmem " + ashmem); + let result = ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: run mapTypedAshmem is success"); + ashmem.closeAshmem() + }catch(error){ + let errCode = ErrorCode.CHECK_PARAM_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.message); + expect(error != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_Ashmem_05200---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_00100 + * @tc.name Call sendrequestresult interface to send data + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100",0,async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_00100---------------------------"); + 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); + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100: run writeSequenceableis is " + result); + + await gIRemoteObject.sendRequest(CODE_WRITESEQUENCEABLE, data, reply, option).then((result) => { + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100: sendRequestis is " + result.errCode); + expect(result.errCode == 0).assertTrue(); + let ret = new MySequenceable(0, ""); + var shortArryDataReply = result.reply.readSequenceable(ret); + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00100: run readSequenceable is " + + shortArryDataReply); + expect(shortArryDataReply == true).assertTrue() + expect(ret.num).assertEqual(1) + expect(ret.str).assertEqual("aaa") + }); data.reclaim(); reply.reclaim(); @@ -7599,14 +8610,152 @@ export default function actsRpcClientJsTest() { done(); console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_00900---------------------------"); }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_01100 + * @tc.name getDescriptor to get the interface description + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IRemoteObject_01100", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_01100---------------------------"); + try{ + let object = new TestAbilityMessageStub("Test1223"); + + let result = object.isObjectDead(); + expect(result == false).assertTrue() + let callingPid = object.getCallingPid() + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01100: run getCallingPid success,callingPid " + callingPid); + expect(callingPid != null).assertTrue(); + let callingUid = object.getCallingUid() + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01100: run getCallingPid success,callingPid " + callingUid); + expect(callingUid != null).assertTrue(); + object.modifyLocalInterface(object, "test1") + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01100: run modifyLocalInterface success"); + let result2 = object.getDescriptor(); + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01100: run getDescriptor is " + result2); + expect(result2 != null).assertTrue(); + + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01100:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01100---------------------------"); + }); + /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00100 - * @tc.name Call adddeathrecipient to register the death notification - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_01200 + * @tc.name Test that MessageSequence 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_Compatibility_IRemoteObject_01200", 0,async function(done){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_01200---------------------------"); + try{ + let object = new TestAbilityMessageStub("TestAbilityMessageStub") + var data = rpc.MessageSequence.create(); + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01200: create object successfully."); + var reply = rpc.MessageSequence.create(); + var option = new rpc.MessageOption(); + data.writeInterfaceToken("TestAbilityMessageStub"); + data.writeByte(2); + data.writeShort(3); + data.writeInt(4); + data.writeLong(5); + data.writeFloat(1.2); + data.writeDouble(10.2); + data.writeBoolean(true); + data.writeChar(5); + data.writeString("HelloWorld"); + data.writeParcelable(new MySequenceable(1, "aaa")); + console.info("data is success"); + + function sendRequestCallback(result) { + try{ + console.info("sendRequest Callback") + console.info("sendRequest done, error code: " + result.errCode) + expect(result.errCode).assertEqual(0) + result.reply.readException() + 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(5) + expect(result.reply.readString()).assertEqual("HelloWorld") + let s = new MySequenceable(null, null) + expect(result.reply.readParcelable(s)).assertTrue() + expect(s.num).assertEqual(1) + expect(s.str).assertEqual("aaa") + } finally { + result.data.reclaim(); + result.reply.reclaim(); + console.info("test done") + done() + } + } + + console.info("start send request") + object.sendMessageRequest(CODE_SAME_PROCESS, data, reply, option, sendRequestCallback) + + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01200:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01200---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_01300 + * @tc.name Iremoteobject, register death notification verification + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_01300---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + gIRemoteObject.registerDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:run registerDeathRecipient is done"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01300---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_01400 + * @tc.name Iremoteobject, register death notification verification + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_01400---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + gIRemoteObject.registerDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:run registerDeathRecipient is done"); + gIRemoteObject.unregisterDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:run unregisterDeathRecipient is done"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01400---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00100 + * @tc.name Call adddeathrecipient to register the death notification + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00100", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00100---------------------------"); try{ @@ -7630,11 +8779,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00200 - * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00200 + * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00200", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00200---------------------------"); try{ @@ -7650,11 +8799,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00300 - * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00300 + * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00300", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00300---------------------------"); try{ @@ -7670,11 +8819,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00400 - * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00400 + * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00400---------------------------"); try{ @@ -7692,11 +8841,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number sendfile/trans_file_func_test.cppRemoteProxy_00500 - * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number sendfile/trans_file_func_test.cppRemoteProxy_00500 + * @tc.name AddDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00500---------------------------"); try{ @@ -7714,11 +8863,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00600 - * @tc.name Call isobjectdead to check whether the object is dead - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00600 + * @tc.name Call isobjectdead to check whether the object is dead + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00600---------------------------"); try{ @@ -7761,11 +8910,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00700 - * @tc.name Getinterfacedescriptor to get the object interface description - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00700 + * @tc.name Getinterfacedescriptor to get the object interface description + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00700", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00700---------------------------"); try{ @@ -7781,11 +8930,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00800 - * @tc.name Querylocalinterface searches for objects based on descriptors - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00800 + * @tc.name Querylocalinterface searches for objects based on descriptors + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00800", 0,async function(){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_00800---------------------------"); try{ @@ -7809,11 +8958,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00900 - * @tc.name Transaction constant validation - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_00900 + * @tc.name Transaction constant validation + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_RemoteProxy_00900", 0, async function(){ console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00900 is starting-------------") try { @@ -7829,11 +8978,240 @@ export default function actsRpcClientJsTest() { }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_00100 - * @tc.name Create an empty object and verify the function of the flushcommands interface - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01000 + * @tc.name Call isobjectdead to check whether the object is dead + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01000---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null) + var isDead = gIRemoteObject.isObjectDead(); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: run isObjectDead result is " + isDead); + expect(isDead == false).assertTrue(); + + var resultAdd1 = gIRemoteObject.registerDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: registerDeathRecipient is success"); + + var isDead1 = gIRemoteObject.isObjectDead(); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: run isObjectDead result is " + isDead1); + expect(isDead1 == false).assertTrue(); + + var resultRemove1 = gIRemoteObject.unregisterDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: unregisterDeathRecipient is success"); + + var resultAdd2 = gIRemoteObject.registerDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: registerDeathRecipient is success"); + + var resultRemove2 = gIRemoteObject.unregisterDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: unregisterDeathRecipient is success"); + + var resultRemove3 = gIRemoteObject.unregisterDeathRecipient(recipient, 0) + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: unregisterDeathRecipient is success"); + + var isDead2 = gIRemoteObject.isObjectDead(); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000: run isObjectDead2 result is " + isDead2); + expect(isDead2 == false).assertTrue(); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01000---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01100 + * @tc.name getDescriptor to get the object interface description + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01100", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01100---------------------------"); + try{ + let object = new TestAbilityStub("Test0300"); + let result = object.getDescriptor() + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01100: run getDescriptor result is " + result); + expect(result).assertEqual("Test0300"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01100:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01100---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01200 + * @tc.name getLocalInterface searches for objects based on descriptors + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01200", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01200---------------------------"); + try{ + let object = new TestAbilityStub("Test0400"); + + let result = object.isObjectDead(); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01200: run getDescriptor is " + result); + expect(result).assertEqual(false); + object.modifyLocalInterface(object, "Test2"); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01200: run modifyLocalInterface success"); + let res2 = object.getLocalInterface('Test2'); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01200: run getLocalInterface success, res2 is " + res2); + let resultDescrip = object.getDescriptor() + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01200: run getDescriptor success resultDescrip is " + resultDescrip); + expect(resultDescrip != null).assertTrue(); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01200:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01200---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01300 + * @tc.name Call registerDeathRecipient to register the death notification + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01300---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + gIRemoteObject.registerDeathRecipient(recipient, 0); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: registerDeathRecipient is success"); + gIRemoteObject.registerDeathRecipient(recipient, 0); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: registerDeathRecipient is success"); + gIRemoteObject.unregisterDeathRecipient(recipient, 0); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: unregisterDeathRecipient is success"); + gIRemoteObject.unregisterDeathRecipient(recipient, 0); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: unregisterDeathRecipient is success"); + gIRemoteObject.unregisterDeathRecipient(recipient, 0); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: unregisterDeathRecipient is success"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01300---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01400 + * @tc.name registerDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01400---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + gIRemoteObject.registerDeathRecipient(recipient, -(2*G)); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400: registerDeathRecipient is success"); + gIRemoteObject.unregisterDeathRecipient(recipient, -(2*G)); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400: unregisterDeathRecipient is success"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01400---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01500 + * @tc.name registerDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01500---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + gIRemoteObject.registerDeathRecipient(recipient, (2*G - 1)); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500: registerDeathRecipient is success"); + gIRemoteObject.unregisterDeathRecipient(recipient, (2*G - 1)); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500: unregisterDeathRecipient is success"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01500---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01600 + * @tc.name registerDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01600---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + var resultAdd = gIRemoteObject.registerDeathRecipient(recipient, 2*G); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600: registerDeathRecipient is success"); + var resultRemove = gIRemoteObject.unregisterDeathRecipient(recipient, 2*G); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600: unregisterDeathRecipient is success"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01600---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01700 + * @tc.name registerDeathRecipient Validates the interface flags input parameter boundary value + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01700---------------------------"); + try{ + let recipient = new MyregisterDeathRecipient(gIRemoteObject, null); + var resultAdd = gIRemoteObject.registerDeathRecipient(recipient, -(2*G + 1)); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700: registerDeathRecipient is success"); + var resultRemove = gIRemoteObject.unregisterDeathRecipient(recipient, -(2*G + 1)); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700: unregisterDeathRecipient is success"); + } catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700:error = " + error); + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01700---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_RemoteProxy_01800 + * @tc.name getLocalInterface 1900005 searches for objects based on descriptors + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_RemoteProxy_01800---------------------------"); + try{ + let object = new TestAbilityStub("Test0400"); + let result = object.isObjectDead(); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800: run getDescriptor is " + result); + expect(result).assertEqual(false); + object.modifyLocalInterface(object, "Test2"); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800: run modifyLocalInterface success"); + let res2 = object.getLocalInterface(null); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800: run getLocalInterface success, res2 is " + res2); + } catch (error) { + let errCode = ErrorCode.ONLY_PROXY_OBJECT_PERMITTED_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.code); + expect(error.code != errCode).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.message); + expect(error.message != null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01800---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_00100 + * @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_Compatibility_IPCSkeleton_00100", 0, async function() { console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_00100---------------------------"); try { @@ -8123,11 +9501,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200 - * @tc.name Basic method of testing ipcskeleton - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200 + * @tc.name Basic method of testing ipcskeleton + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200", 0,async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200---------------------------"); try{ @@ -8180,11 +9558,11 @@ export default function actsRpcClientJsTest() { }); /* - * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300 - * @tc.name IPCSkeleton sendMessageRequest API test - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300 + * @tc.name IPCSkeleton sendMessageRequest API test + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300", 0,async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300---------------------------"); try{ @@ -8218,6 +9596,90 @@ export default function actsRpcClientJsTest() { console.info("---------------------end SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300---------------------------"); }); + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01400 + * @tc.name Create an empty object and verify the function of the flushCmdBuffer interface + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01400", 0, async function() { + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_01400---------------------------"); + try { + let remoteObject = new TestRemoteObject("aaa"); + let ret = rpc.IPCSkeleton.flushCmdBuffer(remoteObject); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01400 RpcServer: flushCmdBuffer is success"); + } + catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01400 error is :" + error) + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IPCSkeleton_01400---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01500 + * @tc.name Create an empty object and verify the function of the flushCmdBuffer interface + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01500", 0, async function() { + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_01500---------------------------"); + try { + let remoteObject = {}; + let ret = rpc.IPCSkeleton.flushCmdBuffer(remoteObject); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01500 RpcServer: flushCmdBuffer is success"); + } + catch (error) { + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01500 error is :" + error) + expect(error == null).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IPCSkeleton_01500---------------------------"); + }) + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 + * @tc.name Basic method of testing ipcskeleton 1900007 + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600", 0,async function(){ + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600---------------------------"); + try{ + let object = rpc.IPCSkeleton.getContextObject(); + object.getDescriptor(); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600: is success"); + } catch (error) { + let errCode = ErrorCode.COMMUNICATION_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.message) + expect(error.message != null).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.code) + expect(error.code == errCode).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600---------------------------"); + }); + + /* + * @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 + * @tc.name Create an empty object and verify the function of the flushCmdBuffer interface 1900006 + * @tc.desc Function test + * @tc.level 0 + */ + it("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700", 0, async function() { + console.info("---------------------start SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700---------------------------"); + try { + let remoteObject = null; + rpc.IPCSkeleton.flushCmdBuffer(remoteObject); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 RpcServer: flushCmdBuffer is success"); + } + catch (error) { + let errCode = ErrorCode.ONLY_REMOTE_OBJECT_PERMITTED_ERROR; + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.message) + expect(error.message != null).assertTrue(); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.code) + expect(error.code != errCode).assertTrue(); + } + console.info("---------------------end SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700---------------------------"); + }) console.info("-----------------------SUB_Softbus_IPC_Compatibility_MessageParce_Test is end-----------------------"); }); }