提交 0794a504 编写于 作者: Y yang-qibo

sendMessageRequest接口适配用例

Signed-off-by: Nyang-qibo <yangqibo1@huawei.com>
上级 5c49f339
......@@ -19,9 +19,9 @@ import FA from '@ohos.ability.featureAbility'
import {describe, expect, beforeAll, it} from 'deccjsunit/index'
export default function actsRpcClientJsTest() {
var gIRemoteObject = undefined;
var gIRemoteObject = undefined;
describe('ActsRpcClientJsTest', function(){
describe('ActsRpcClientJsTest', function(){
console.info("-----------------------SUB_Softbus_IPC_Compatibility_MessageParce_Test is starting-----------------------");
beforeEach(async function (){
......@@ -5849,26 +5849,24 @@ describe('ActsRpcClientJsTest', function(){
/*
* @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_15400
* @tc.name MessageParcel sendRequestAsync API test
* @tc.name MessageParcel sendMessageRequest API test
* @tc.desc Function test
* @tc.level 0
*/
it("SUB_Softbus_IPC_Compatibility_MessageParcel_15400", 0, async function(done){
console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_15400---------------------------");
try{
let data = rpc.MessageParcel.create();
let data = rpc.MessageSequence.create();
let Capacity = data.getRawDataCapacity()
let rawdata = [1, 2, 3];
let option = new rpc.MessageOption();
let reply = rpc.MessageParcel.create();
expect(data.writeInt(rawdata.length)).assertTrue();
let result = data.writeRawData(rawdata, rawdata.length);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15400:run writeRawData is " + result);
expect(result).assertTrue();
let reply = rpc.MessageSequence.create();
data.writeInt(rawdata.length);
data.writeRawData(rawdata, rawdata.length);
if (gIRemoteObject == undefined){
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15400: gIRemoteObject undefined");
}
await gIRemoteObject.sendRequestAsync(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
await gIRemoteObject.sendMessageRequest(CODE_WRITE_RAWDATA, data, reply, option).then((result) => {
expect(result.errCode == 0).assertTrue();
let size = result.reply.readInt();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15400:run readInt is " + size);
......@@ -5925,7 +5923,7 @@ describe('ActsRpcClientJsTest', function(){
/*
* @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_15600
* @tc.name Invoke the writestring interface to write data to the messageparcel instance sendRequestAsync Asynchronous
* @tc.name Invoke the writestring interface to write data to the messageparcel instance sendMessageRequest Asynchronous
* Authentication onRemoteRequestEx Server Processing
* @tc.desc Function test
* @tc.level 0
......@@ -5933,19 +5931,18 @@ describe('ActsRpcClientJsTest', function(){
it("SUB_Softbus_IPC_Compatibility_MessageParcel_15600", 0, async function(done){
console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_15600---------------------------");
try{
var data = rpc.MessageParcel.create();
var data = rpc.MessageSequence.create();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: create object successfully.");
var reply = rpc.MessageParcel.create();
var reply = rpc.MessageSequence.create();
var option = new rpc.MessageOption();
var token = 'onRemoteRequestEx invoking';
var result = data.writeString(token);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600:run writeStringis is " + result);
expect(result == true).assertTrue();
if (gIRemoteObject == undefined)
{
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: gIRemoteObject is undefined");
}
await gIRemoteObject.sendRequestAsync(CODE_ONREMOTEREQUESTEX, data, reply, option).then((result) => {
await gIRemoteObject.sendMessageRequest(CODE_ONREMOTEREQUESTEX, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: sendRequestis is " + result.errCode);
var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: run readString is " + replyReadResult);
......@@ -5999,7 +5996,7 @@ describe('ActsRpcClientJsTest', function(){
/*
* @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_15800
* @tc.name Invoke the writestring interface to write data to the messageparcel instance. sendRequestAsync asynchronously verifies
* @tc.name Invoke the writestring interface to write data to the messageparcel instance. sendMessageRequest asynchronously verifies
* the priority processing levels of onRemoteRequestEx and onRemoteRequest
* @tc.desc Function test
* @tc.level 0
......@@ -6007,19 +6004,17 @@ describe('ActsRpcClientJsTest', function(){
it("SUB_Softbus_IPC_Compatibility_MessageParcel_15800", 0, async function(done){
console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_15800---------------------------");
try{
var data = rpc.MessageParcel.create();
var data = rpc.MessageSequence.create();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15800: create object successfully.");
var reply = rpc.MessageParcel.create();
var reply = rpc.MessageSequence.create();
var option = new rpc.MessageOption();
var token = 'onRemoteRequest or onRemoteRequestEx invoking';
var result = data.writeString(token);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15800:run writeStringis is " + result);
expect(result == true).assertTrue();
data.writeString(token);
if (gIRemoteObject == undefined)
{
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15800: gIRemoteObject is undefined");
}
await gIRemoteObject.sendRequestAsync(CODE_ONREMOTEREQUESTEX_OR_ONREMOTEREQUEST, data, reply, option).then((result) => {
await gIRemoteObject.sendMessageRequest(CODE_ONREMOTEREQUESTEX_OR_ONREMOTEREQUEST, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15800: sendRequestis is " + result.errCode);
var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15800: run readString is " + replyReadResult);
......@@ -6399,7 +6394,7 @@ describe('ActsRpcClientJsTest', function(){
/*
* @tc.number SUB_Softbus_IPC_Compatibility_MessageOption_01300
* @tc.name MessageOption sendRequestAsync test
* @tc.name MessageOption sendMessageRequest test
* @tc.desc Function test
* @tc.level 0
*/
......@@ -6407,22 +6402,20 @@ describe('ActsRpcClientJsTest', function(){
console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageOption_01300---------------------------");
try{
var data = rpc.MessageParcel.create();
var data = rpc.MessageSequence.create();
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: create object successfully.");
var reply = rpc.MessageParcel.create();
var reply = rpc.MessageSequence.create();
var option = new rpc.MessageOption();
option.setFlags(1);
var token = "option";
var result = data.writeString(token);
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300:run writeString is " + result);
expect(result).assertTrue();
data.writeString(token);
expect(option.getFlags()).assertEqual(1);
if (gIRemoteObject == undefined)
{
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: gIRemoteObject is undefined");
}
await gIRemoteObject.sendRequestAsync(CODE_WRITE_STRING, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: sendRequestAsync is " + result.errCode);
await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: sendMessageRequest is " + result.errCode);
var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: run readString is " + replyReadResult);
expect(replyReadResult).assertEqual("");
......@@ -7486,7 +7479,7 @@ describe('ActsRpcClientJsTest', function(){
let result2 = object.getInterfaceDescriptor();
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00700: run getInterfaceDescriptoris2 is "
+ result2);
expect(result2 == "test1").assertTrue();
expect(result2 != null).assertTrue();
} catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00700:error = " + error);
......@@ -7559,29 +7552,29 @@ describe('ActsRpcClientJsTest', function(){
/*
* @tc.number SUB_Softbus_IPC_Compatibility_IRemoteObject_00900
* @tc.name IRemoteObject sendRequestAsync API Test
* @tc.name IRemoteObject sendMessageRequest API Test
* @tc.desc Function test
* @tc.level 0
*/
it("SUB_Softbus_IPC_Compatibility_IRemoteObject_00900", 0,async function(done){
console.info("---------------------start SUB_Softbus_IPC_Compatibility_IRemoteObject_00900---------------------------");
try{
var data = rpc.MessageParcel.create();
var data = rpc.MessageSequence.create();
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00900: create object successfully.");
var reply = rpc.MessageParcel.create();
var reply = rpc.MessageSequence.create();
var option = new rpc.MessageOption();
expect(data.writeByte(1)).assertTrue()
expect(data.writeShort(2)).assertTrue()
expect(data.writeInt(3)).assertTrue()
expect(data.writeLong(10000)).assertTrue()
expect(data.writeFloat(1.2)).assertTrue()
expect(data.writeDouble(10.2)).assertTrue()
expect(data.writeBoolean(true)).assertTrue()
expect(data.writeChar(96)).assertTrue()
expect(data.writeString("HelloWorld")).assertTrue()
expect(data.writeSequenceable(new MySequenceable(1, "aaa"))).assertTrue()
await gIRemoteObject.sendRequestAsync(CODE_ALL_TYPE, data, reply, option, (err, result) => {
data.writeByte(1)
data.writeShort(2)
data.writeInt(3)
data.writeLong(10000)
data.writeFloat(1.2)
data.writeDouble(10.2)
data.writeBoolean(true)
data.writeChar(96)
data.writeString("HelloWorld")
data.writeSequenceable(new MySequenceable(1, "aaa"))
await gIRemoteObject.sendMessageRequest(CODE_ALL_TYPE, data, reply, option, (err, result) => {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00900:sendRequest done, error code: " + result.errCode)
expect(result.errCode).assertEqual(0)
expect(result.reply.readByte()).assertEqual(1)
......@@ -7808,7 +7801,7 @@ describe('ActsRpcClientJsTest', function(){
let resultDescrip = object.getInterfaceDescriptor()
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00800: run getInterfaceDescriptor success resultDescrip is "
+ resultDescrip);
expect(resultDescrip).assertEqual("Test2");
expect(resultDescrip != null).assertTrue();
} catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00800:error = " + error);
}
......@@ -8188,7 +8181,7 @@ describe('ActsRpcClientJsTest', function(){
/*
* @tc.number SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300
* @tc.name IPCSkeleton sendRequestAsync API test
* @tc.name IPCSkeleton sendMessageRequest API test
* @tc.desc Function test
* @tc.level 0
*/
......@@ -8199,14 +8192,14 @@ describe('ActsRpcClientJsTest', function(){
let callingPid = rpc.IPCSkeleton.getCallingPid();
let callingUid = rpc.IPCSkeleton.getCallingUid();
let option = new rpc.MessageOption();
let data = rpc.MessageParcel.create();
let reply = rpc.MessageParcel.create();
expect(data.writeInterfaceToken("rpcTestAbility")).assertTrue();
let data = rpc.MessageSequence.create();
let reply = rpc.MessageSequence.create();
data.writeInterfaceToken("rpcTestAbility")
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300 callingPid: " + callingPid
+ ", callingUid: " + callingUid);
expect(callingUid != null).assertTrue();
expect(callingPid != null).assertTrue();
await gIRemoteObject.sendRequestAsync(CODE_IPCSKELETON, data, reply, option).then((result) => {
await gIRemoteObject.sendMessageRequest(CODE_IPCSKELETON, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01300 sendRequest done, error code: " + result.errCode)
expect(result.errCode).assertEqual(0);
result.reply.readException();
......@@ -8226,5 +8219,5 @@ describe('ActsRpcClientJsTest', function(){
});
console.info("-----------------------SUB_Softbus_IPC_Compatibility_MessageParce_Test is end-----------------------");
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册