mirror of
https://gitee.com/openharmony/xts_dcts
synced 2024-11-23 07:39:59 +00:00
commit
5a9febfcc8
@ -6201,6 +6201,803 @@ export default function RpcRequestEtsUnitTest() {
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1850---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1860
|
||||
* @tc.name : test Call the writeremoteobjectarray interface to write the object array to the MessageSequence
|
||||
* instance, and call readremoteobjectarray to read the data
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1860", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1860---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try {
|
||||
let count = 0;
|
||||
function checkResult(num, str) {
|
||||
expect(num).assertEqual(123);
|
||||
expect(str).assertEqual("rpcListenerTest");
|
||||
count++;
|
||||
console.info("check result done, count: " + count);
|
||||
if (count == 3) {
|
||||
done();
|
||||
};
|
||||
};
|
||||
data.writeInterfaceToken("rpcTestAbility");
|
||||
let listeners = [new TestListener("rpcListener", checkResult),
|
||||
new TestListener("rpcListener2", checkResult),
|
||||
new TestListener("rpcListener3", checkResult)];
|
||||
data.writeRemoteObjectArray(listeners);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_REMOTEOBJECTARRAY, data, reply, option).then((result) => {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1860: sendMessageRequest is " + result.errCode);
|
||||
expect(result.errCode).assertEqual(0);
|
||||
expect(result.code).assertEqual(CODE_WRITE_REMOTEOBJECTARRAY);
|
||||
expect(result.data).assertEqual(data);
|
||||
expect(result.reply).assertEqual(reply);
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1860 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1860---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1870
|
||||
* @tc.name : test Call the writeremoteobjectarray interface to write the object array to the MessageSequence instance,
|
||||
* and call readremoteobjectarray (objects: iremoteobject []) to read the data
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1870", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1870---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try {
|
||||
let count = 0;
|
||||
function checkResult(num, str) {
|
||||
expect(num).assertEqual(123);
|
||||
expect(str).assertEqual("rpcListenerTest");
|
||||
count++;
|
||||
console.info("check result done, count: " + count);
|
||||
if (count == 3) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
data.writeInterfaceToken("rpcTestAbility");
|
||||
let listeners = [new TestListener("rpcListener", checkResult),
|
||||
new TestListener("rpcListener2", checkResult),
|
||||
new TestListener("rpcListener3", checkResult)];
|
||||
data.writeRemoteObjectArray(listeners);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_REMOTEOBJECTARRAY, data, reply, option).then((result) => {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1870: sendMessageRequest is " + result.errCode);
|
||||
expect(result.errCode == 0).assertTrue();
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1870 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1870---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1880
|
||||
* @tc.name : test Test MessageSequence to pass an array of iremoteobject objects across processes
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1880", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1880---------------------------");
|
||||
let count = 0;
|
||||
function checkResult(num, str) {
|
||||
expect(num).assertEqual(123);
|
||||
expect(str).assertEqual("rpcListenerTest");
|
||||
count++;
|
||||
console.info("check result done, count: " + count);
|
||||
if (count == 3) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try {
|
||||
let listeners = [new TestListener("rpcListener", checkResult),
|
||||
new TestListener("rpcListener2", checkResult),
|
||||
new TestListener("rpcListener3", checkResult)];
|
||||
data.writeRemoteObjectArray(listeners);
|
||||
data.writeInt(123);
|
||||
data.writeString("rpcListenerTest");
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_REMOTEOBJECTARRAY_1, data, reply, option)
|
||||
.then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
result.reply.readException();
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1880 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1880---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1890
|
||||
* @tc.name : test Test MessageSequence to pass the array of iremoteobject objects across processes. The server
|
||||
* constructs an empty array in onremoterequest and reads it from MessageSequence
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1890", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1890---------------------------");
|
||||
let count = 0;
|
||||
function checkResult(num, str) {
|
||||
expect(num).assertEqual(123);
|
||||
expect(str).assertEqual("rpcListenerTest");
|
||||
count++;
|
||||
console.info("check result done, count: " + count);
|
||||
if (count == 3) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try {
|
||||
let listeners = [new TestListener("rpcListener", checkResult),
|
||||
new TestListener("rpcListener2", checkResult),
|
||||
new TestListener("rpcListener3", checkResult)];
|
||||
data.writeRemoteObjectArray(listeners);
|
||||
data.readRemoteObjectArray();
|
||||
data.writeInt(123);
|
||||
data.writeString("rpcListenerTest");
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_REMOTEOBJECTARRAY_2, data, reply, option)
|
||||
.then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
result.reply.readException();
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1890 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1890---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1900
|
||||
* @tc.name : test WriteRemoteObjectArray 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_1900", 0,async function(){
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1900---------------------------");
|
||||
let data = rpc.MessageSequence.create();
|
||||
try{
|
||||
let count = 0;
|
||||
function checkResult(num, str) {
|
||||
expect(num).assertEqual(123);
|
||||
expect(str).assertEqual("rpcListenerTest");
|
||||
count++;
|
||||
console.info("check result done, count: " + count);
|
||||
if (count == 3) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
let listeners = [new TestListener("rpcListener", checkResult),
|
||||
new TestListener("rpcListener2", checkResult),
|
||||
new TestListener("rpcListener3", checkResult)];
|
||||
data.reclaim();
|
||||
data.writeRemoteObjectArray(listeners);
|
||||
expect(data.getSize() == 0).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1900 error: " + 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_1900---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1910
|
||||
* @tc.name : test ReadRemoteObjectArray 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_1910", 0,async function(){
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1910---------------------------");
|
||||
let data = rpc.MessageSequence.create();
|
||||
try{
|
||||
let count = 0;
|
||||
function checkResult(num, str) {
|
||||
expect(num).assertEqual(123);
|
||||
expect(str).assertEqual("rpcListenerTest");
|
||||
count++;
|
||||
console.info("check result done, count: " + count);
|
||||
if (count == 3) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
let listeners = [new TestListener("rpcListener", checkResult),
|
||||
new TestListener("rpcListener2", checkResult),
|
||||
new TestListener("rpcListener3", checkResult)];
|
||||
data.writeRemoteObjectArray(listeners);
|
||||
data.reclaim();
|
||||
data.readRemoteObjectArray();
|
||||
expect(data.getSize() == 0).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1910 error: " + 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_1910 ---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1920
|
||||
* @tc.name : test dupFileDescriptor is call os dup function 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_1920", 0,async function(){
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1920---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
try{
|
||||
rpc.MessageSequence.dupFileDescriptor(-1);
|
||||
expect(data.getSize() == 0).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1920 error: " + error);
|
||||
let errCode = `${rpc.ErrorCode.OS_DUP_ERROR}`;
|
||||
expect(error.code == errCode).assertTrue();
|
||||
expect(error.message != null).assertTrue();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1920 ---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1930
|
||||
* @tc.name : test Writes the specified anonymous shared object to this MessageSequence
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改IPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1930", 0, function(){
|
||||
console.info("--------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1930--------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
try{
|
||||
let ashmem = rpc.Ashmem.create("ashmem", 1024);
|
||||
data.writeAshmem(ashmem);
|
||||
ashmem.unmapAshmem();
|
||||
ashmem.closeAshmem();
|
||||
} catch (error) {
|
||||
expect(error == null).assertTrue();
|
||||
}finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
}
|
||||
console.info("--------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1930--------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1940
|
||||
* @tc.name : test Test the function of serializing the readAshmem interface in MessageSequence mode
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改IPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1940", 0, function(){
|
||||
console.info("--------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1940--------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
try{
|
||||
let ashmem = rpc.Ashmem.create("ashmem", 1024);
|
||||
data.writeAshmem(ashmem);
|
||||
let ashmemdata = data.readAshmem();
|
||||
expect(ashmemdata != null).assertTrue();
|
||||
ashmem.unmapAshmem();
|
||||
ashmem.closeAshmem();
|
||||
} catch (error) {
|
||||
expect(error).assertEqual(null);
|
||||
}finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
}
|
||||
console.info("--------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1940--------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1950
|
||||
* @tc.name : test To test the function of handling the exception of the writeAshmem interface in MessageSequence mode
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改IPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1950", 0, function(){
|
||||
console.info("--------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1950--------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
try{
|
||||
let ashmem = "";
|
||||
data.writeAshmem(ashmem);
|
||||
expect(data.getSize() == 0).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1950 error: " + error);
|
||||
let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
|
||||
expect(error.code == errCode).assertTrue();
|
||||
expect(error.message != null).assertTrue();
|
||||
}finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
}
|
||||
console.info("--------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1950--------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1960
|
||||
* @tc.name : test WriteAshmem 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_1960", 0,async function(){
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1960---------------------------");
|
||||
let data = rpc.MessageSequence.create();
|
||||
try{
|
||||
let ashmem = rpc.Ashmem.create("JsAshmemTest", 1024);
|
||||
data.reclaim();
|
||||
data.writeAshmem(ashmem);
|
||||
ashmem.unmapAshmem();
|
||||
ashmem.closeAshmem();
|
||||
expect(data.getSize() == 0).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1960 error: " + 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_1960 ---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1970
|
||||
* @tc.name : test readAshmem 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_1970", 0,async function(){
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1970---------------------------");
|
||||
let data = rpc.MessageSequence.create();
|
||||
try{
|
||||
let ashmem = rpc.Ashmem.create("JsAshmemTest", 1024);
|
||||
data.writeAshmem(ashmem);
|
||||
data.reclaim();
|
||||
data.readAshmem();
|
||||
ashmem.unmapAshmem();
|
||||
ashmem.closeAshmem();
|
||||
expect(data.getSize() == 0).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1970 error: " + 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_1970 ---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1980
|
||||
* @tc.name : test Call the getRawDataCapacity interface to get the maximum amount of raw data that a MessageSequence
|
||||
* can hold
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1980", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1980---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try{
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
data.writeIntArray([1, 2, 3, 4, 5]);
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_INTARRAY, data, reply, option).then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
expect(result.reply.getRawDataCapacity()).assertEqual(128 * M);
|
||||
expect(result.reply.readIntArray()).assertDeepEquals([1, 2, 3, 4, 5]);
|
||||
expect(result.reply.getRawDataCapacity()).assertEqual(128 * M);
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1980 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1980---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_1990
|
||||
* @tc.name : test Test MessageSequence to deliver rawdata data
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_1990", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_1990---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try{
|
||||
let arr = [1, 2, 3, 4, 5];
|
||||
data.writeInt(arr.length);
|
||||
data.writeRawData(arr, arr.length);
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
let size = result.reply.readInt();
|
||||
expect(size).assertEqual(arr.length);
|
||||
expect(result.reply.getRawDataCapacity()).assertEqual(128 * M);
|
||||
let newReadResult = result.reply.readRawData(size);
|
||||
expect(newReadResult[0]).assertEqual(arr[0]);
|
||||
expect(newReadResult[1]).assertEqual(arr[1]);
|
||||
expect(newReadResult[2]).assertEqual(arr[2]);
|
||||
expect(newReadResult[3]).assertEqual(arr[3]);
|
||||
expect(newReadResult[4]).assertEqual(arr[4]);
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_1990 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_1990---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2000
|
||||
* @tc.name : test Test MessageSequence to pass abnormal rawdata data, and expand the capacity for verification
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2000", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2000---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try{
|
||||
let arr = [1, 2, 3, 4, 5];
|
||||
data.writeInt(arr.length + 1);
|
||||
data.writeRawData(arr, (arr.length + 1));
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
let size = result.reply.readInt();
|
||||
expect(size).assertEqual(arr.length + 1);
|
||||
expect(result.reply.getRawDataCapacity()).assertEqual(128 * M);
|
||||
let newReadResult = result.reply.readRawData(size);
|
||||
expect(newReadResult[0]).assertEqual(arr[0]);
|
||||
expect(newReadResult[1]).assertEqual(arr[1]);
|
||||
expect(newReadResult[2]).assertEqual(arr[2]);
|
||||
expect(newReadResult[3]).assertEqual(arr[3]);
|
||||
expect(newReadResult[4]).assertEqual(arr[4]);
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2000 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2000---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2010
|
||||
* @tc.name : test Test MessageSequence to pass exception rawdata data data interception verification
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2010", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2010---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try{
|
||||
let arr = [1, 2, 3, 4, 5];
|
||||
data.writeInt(arr.length - 1);
|
||||
data.writeRawData(arr, (arr.length - 1));
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
let size = result.reply.readInt();
|
||||
expect(size).assertEqual(arr.length - 1);
|
||||
expect(result.reply.getRawDataCapacity()).assertEqual(128 * M);
|
||||
let newReadResult = result.reply.readRawData(size);
|
||||
expect(newReadResult[0]).assertEqual(arr[0]);
|
||||
expect(newReadResult[1]).assertEqual(arr[1]);
|
||||
expect(newReadResult[2]).assertEqual(arr[2]);
|
||||
expect(newReadResult[3]).assertEqual(arr[3]);
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2010 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2010---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2020
|
||||
* @tc.name : test Test MessageSequence to deliver out-of-bounds RawData data
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2020", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2020---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try{
|
||||
let arr = [-129, 2, 3, 4, 128];
|
||||
data.writeInt(arr.length);
|
||||
data.writeRawData(arr, arr.length);
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
let size = result.reply.readInt();
|
||||
expect(size).assertEqual(arr.length);
|
||||
expect(result.reply.getRawDataCapacity()).assertEqual(128 * M);
|
||||
let newReadResult = result.reply.readRawData(size);
|
||||
expect(newReadResult[0]).assertEqual(arr[0]);
|
||||
expect(newReadResult[1]).assertEqual(arr[1]);
|
||||
expect(newReadResult[2]).assertEqual(arr[2]);
|
||||
expect(newReadResult[3]).assertEqual(arr[3]);
|
||||
expect(newReadResult[4]).assertEqual(arr[4]);
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2020 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2020---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2030
|
||||
* @tc.name : test Test MessageSequence to deliver illegal RawData data
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2030", 0, async function () {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2030---------------------------");
|
||||
let data: rpc.MessageSequence = new rpc.MessageSequence();
|
||||
try {
|
||||
let arr = ["aaa", 1, 2, 3];
|
||||
data.writeInt(arr.length);
|
||||
data.writeRawData(arr, arr.length);
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2030 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2030---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2040
|
||||
* @tc.name : test Test fixed MessageSequence space size 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_2040", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2040---------------------------");
|
||||
let data: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let reply: rpc.MessageSequence = rpc.MessageSequence.create();
|
||||
let option: rpc.MessageOption = new rpc.MessageOption();
|
||||
try{
|
||||
expect(data.getRawDataCapacity()).assertEqual(128 * M);
|
||||
let rawdata = [1, 2, 3];
|
||||
data.writeInt(rawdata.length);
|
||||
data.writeRawData(rawdata, rawdata.length);
|
||||
expect(gIRemoteObject != undefined).assertTrue();
|
||||
await gIRemoteObject.sendMessageRequest(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
|
||||
expect(result.errCode).assertEqual(0);
|
||||
let size = result.reply.readInt();
|
||||
expect(result.reply.readRawData(size) != rawdata).assertTrue();
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2040 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2040---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2050
|
||||
* @tc.name : test Test MessageSequence delivery file descriptor object
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2050", 0, async function () {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2050---------------------------");
|
||||
try {
|
||||
let testab = new TestProxy(gIRemoteObject).asObject();
|
||||
expect(testab != null).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2050 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2050---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2060
|
||||
* @tc.name : test Test that the asObject interface is called by a RemoteObject and returns itself
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2060", 0, async function () {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2060---------------------------");
|
||||
try {
|
||||
let testAbilityStub = new TestAbilityStub("testObject");
|
||||
expect(testAbilityStub.asObject() != null).assertTrue();
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2060 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2060---------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number : SUB_DSoftbus_RPC_API_NEW_MessageSequence_2070
|
||||
* @tc.name : test Test the function of the getReadPosition interface
|
||||
* @tc.desc : [G-DISTRIBUTED-0212]禁止修改RPC中定义的数据结构和接口,并提供对应完整实现
|
||||
* @tc.level : 3
|
||||
* @tc.type : Compatibility
|
||||
* @tc.size : MediumTest
|
||||
*/
|
||||
it("SUB_DSoftbus_RPC_API_NEW_MessageSequence_2070", 0, async function (done) {
|
||||
console.info("---------------------start SUB_DSoftbus_RPC_API_NEW_MessageSequence_2070---------------------------");
|
||||
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);
|
||||
data.writeShort(3);
|
||||
data.writeInt(4);
|
||||
data.writeLong(5);
|
||||
data.writeFloat(1.2);
|
||||
data.writeDouble(10.2);
|
||||
data.writeBoolean(true);
|
||||
data.writeChar(97);
|
||||
data.writeString("");
|
||||
data.writeParcelable(new MySequenceable(1, "aaa"));
|
||||
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.getReadPosition()).assertEqual(4);
|
||||
expect(result.reply.readShort()).assertEqual(3);
|
||||
expect(result.reply.getReadPosition()).assertEqual(4 + 4);
|
||||
expect(result.reply.readInt()).assertEqual(4);
|
||||
expect(result.reply.getReadPosition()).assertEqual((4 + 4) + 4);
|
||||
expect(result.reply.readLong()).assertEqual(5);
|
||||
expect(result.reply.getReadPosition()).assertEqual(((4 + 4) + 4) + 8);
|
||||
expect(result.reply.readFloat()).assertEqual(1.2);
|
||||
expect(result.reply.getReadPosition()).assertEqual((((4 + 4) + 4) + 8) + 8);
|
||||
expect(result.reply.readDouble()).assertEqual(10.2);
|
||||
expect(result.reply.getReadPosition()).assertEqual(((((4 + 4) + 4) + 8) + 8) + 8);
|
||||
expect(result.reply.readBoolean()).assertTrue();
|
||||
expect(result.reply.getReadPosition()).assertEqual((((((4 + 4) + 4) + 8) + 8) + 8) + 4);
|
||||
expect(result.reply.readChar()).assertEqual(97);
|
||||
expect(result.reply.getReadPosition()).assertEqual(((((((4 + 4) + 4) + 8) + 8) + 8) + 4) + 4);
|
||||
expect(result.reply.readString()).assertEqual("");
|
||||
expect(result.reply.getReadPosition()).assertEqual((((((((4 + 4) + 4) + 8) + 8) + 8) + 4) + 4) + 8);
|
||||
let s = new MySequenceable(null, null);
|
||||
result.reply.readParcelable(s);
|
||||
expect(result.reply.getReadPosition()).assertEqual(((((((((4 + 4) + 4) + 8) + 8) + 8) + 4) + 4) + 8) + (12 + 8));
|
||||
expect(s.num).assertEqual(1);
|
||||
expect(s.str).assertEqual("aaa");
|
||||
});
|
||||
} catch (error) {
|
||||
console.info(logTag + "SUB_DSoftbus_RPC_API_NEW_MessageSequence_2070 error: " + error);
|
||||
expect(error == null).assertTrue();
|
||||
} finally{
|
||||
console.info(logTag + "reclaim done");
|
||||
data.reclaim();
|
||||
reply.reclaim();
|
||||
done();
|
||||
}
|
||||
console.info("---------------------end SUB_DSoftbus_RPC_API_NEW_MessageSequence_2070---------------------------");
|
||||
});
|
||||
console.info("-----------------------SUB_DSoftbus_RPC_API_NEW_onRemoteRequest_Test is end-----------------------");
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user