提交 551daf22 编写于 作者: J jiyong

ipc client and server modify

Signed-off-by: Njiyong <jiyong@huawei.com>
上级 26236f8d
...@@ -56,7 +56,8 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -56,7 +56,8 @@ describe('ActsRpcClientJsTest', function(){
}; };
let connect = { let connect = {
onConnect:function (elementName, remoteProxy) { onConnect:function (elementName, remoteProxy) {
console.log('RpcClient: onConnect called, instance of proxy: ' + (remoteProxy instanceof rpc.RemoteProxy)) console.log('RpcClient: onConnect called, instance of proxy: '
+ (remoteProxy instanceof rpc.RemoteProxy))
gIRemoteObject = remoteProxy gIRemoteObject = remoteProxy
}, },
...@@ -2418,23 +2419,18 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -2418,23 +2419,18 @@ describe('ActsRpcClientJsTest', function(){
let context = FA.getContext() let context = FA.getContext()
await context.getFilesDir() await context.getFilesDir()
.then(async function(path) { .then(async function(path) {
console.info("data: " + path)
expect(path != null).assertTrue() expect(path != null).assertTrue()
let basePath = path; let basePath = path;
let filePath = basePath + "/test1.txt"; let filePath = basePath + "/test1.txt";
let fd = fileio.openSync(filePath, 0o2| 0o100 | 0o2000, 0o666); let fd = fileio.openSync(filePath, 0o2| 0o100 | 0o2000, 0o666);
console.info("open file, fd: " + fd)
expect(fd >= 0).assertTrue() expect(fd >= 0).assertTrue()
let str = "HELLO RPC"
let bytesWr = fileio.writeSync(fd, str); let bytesWr = fileio.writeSync(fd, str);
console.log("SUB_Softbus_IPC_IRemoteObject_9700 bytesWr is" + bytesWr);
let option = new rpc.MessageOption() let option = new rpc.MessageOption()
let data = rpc.MessageParcel.create() let data = rpc.MessageParcel.create()
let reply = rpc.MessageParcel.create() let reply = rpc.MessageParcel.create()
let result = data.containFileDescriptors() let result = data.containFileDescriptors()
expect(result == true).assertTrue() expect(result == true).assertTrue()
let writeInt = data.writeInt(bytesWr) let writeInt = data.writeInt(bytesWr)
console.log("The result is :" + writeInt)
expect(writeInt == true).assertTrue() expect(writeInt == true).assertTrue()
let writeFileDescriptor = data.writeFileDescriptor(fd) let writeFileDescriptor = data.writeFileDescriptor(fd)
console.log("The result is :" + writeFileDescriptor) console.log("The result is :" + writeFileDescriptor)
...@@ -2462,13 +2458,7 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -2462,13 +2458,7 @@ describe('ActsRpcClientJsTest', function(){
rpc.MessageParcel.closeFileDescriptor(fd); rpc.MessageParcel.closeFileDescriptor(fd);
rpc.MessageParcel.closeFileDescriptor(dupFd); rpc.MessageParcel.closeFileDescriptor(dupFd);
}) })
try { fileio.writeSync(fd, str)
console.info("after close fd, write again")
fileio.writeSync(fd, str)
expect(0).assertEqual(1) // should not go here
} catch(e) {
console.error("got exception: " + e)
}
}) })
done() done()
console.log("---------------------end SUB_Softbus_IPC_IRemoteObject_9700---------------------------"); console.log("---------------------end SUB_Softbus_IPC_IRemoteObject_9700---------------------------");
...@@ -2923,13 +2913,13 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -2923,13 +2913,13 @@ describe('ActsRpcClientJsTest', function(){
it("SUB_Softbus_IPC_Ashmem_0200",0,function(){ it("SUB_Softbus_IPC_Ashmem_0200",0,function(){
console.log("---------------------start SUB_Softbus_IPC_Ashmem_0200---------------------------"); console.log("---------------------start SUB_Softbus_IPC_Ashmem_0200---------------------------");
try{ try{
let map_size = 4096; let mapSize = 4096;
let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", map_size) let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", mapSize)
console.log("SUB_Softbus_IPC_Ashmem_0200: run createAshmem success"); console.log("SUB_Softbus_IPC_Ashmem_0200: run createAshmem success");
let size = ashmem.getAshmemSize() let size = ashmem.getAshmemSize()
console.log("SUB_Softbus_IPC_Ashmem_0200: run getAshmemSize success, size is " + size); console.log("SUB_Softbus_IPC_Ashmem_0200: run getAshmemSize success, size is " + size);
expect(size == map_size).assertTrue(); expect(size == mapSize).assertTrue();
ashmem.closeAshmem(); ashmem.closeAshmem();
}catch(error){ }catch(error){
...@@ -2947,13 +2937,13 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -2947,13 +2937,13 @@ describe('ActsRpcClientJsTest', function(){
it("SUB_Softbus_IPC_Ashmem_0300",0,function(){ it("SUB_Softbus_IPC_Ashmem_0300",0,function(){
console.log("---------------------start SUB_Softbus_IPC_Ashmem_0300---------------------------"); console.log("---------------------start SUB_Softbus_IPC_Ashmem_0300---------------------------");
try{ try{
let map_size = 4096; let mapSize = 4096;
let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", map_size) let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", mapSize)
console.log("SUB_Softbus_IPC_Ashmem_0300: run createAshmem success"); console.log("SUB_Softbus_IPC_Ashmem_0300: run createAshmem success");
let size = ashmem.getAshmemSize() let size = ashmem.getAshmemSize()
console.log("SUB_Softbus_IPC_Ashmem_0300: run getAshmemSize success, size is " + size); console.log("SUB_Softbus_IPC_Ashmem_0300: run getAshmemSize success, size is " + size);
expect(size == map_size).assertTrue(); expect(size == mapSize).assertTrue();
ashmem.closeAshmem(); ashmem.closeAshmem();
}catch(error){ }catch(error){
...@@ -3194,7 +3184,8 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -3194,7 +3184,8 @@ describe('ActsRpcClientJsTest', function(){
expect(resultread == false).assertTrue(); expect(resultread == false).assertTrue();
let resultreadAndwrite = ashmem.mapReadAndWriteAshmem(); let resultreadAndwrite = ashmem.mapReadAndWriteAshmem();
console.log("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, mapReadAndWriteAshmem is " + resultreadAndwrite); console.log("SUB_Softbus_IPC_Ashmem_1200: run setProtection success, mapReadAndWriteAshmem is "
+ resultreadAndwrite);
expect(resultreadAndwrite == false).assertTrue(); expect(resultreadAndwrite == false).assertTrue();
let resultnone = ashmem.setProtection(rpc.Ashmem.PROT_NONE) let resultnone = ashmem.setProtection(rpc.Ashmem.PROT_NONE)
...@@ -3245,8 +3236,8 @@ describe('ActsRpcClientJsTest', function(){ ...@@ -3245,8 +3236,8 @@ describe('ActsRpcClientJsTest', function(){
it("SUB_Softbus_IPC_Ashmem_1400",0,function(){ it("SUB_Softbus_IPC_Ashmem_1400",0,function(){
console.log("---------------------start SUB_Softbus_IPC_Ashmem_1200---------------------------"); console.log("---------------------start SUB_Softbus_IPC_Ashmem_1200---------------------------");
try{ try{
let map_size = 4096 let mapSize = 4096
let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", map_size) let ashmem = rpc.Ashmem.createAshmem("JsAshmemTest", mapSize)
console.log("SUB_Softbus_IPC_Ashmem_1400: ashmem " + ashmem); console.log("SUB_Softbus_IPC_Ashmem_1400: ashmem " + ashmem);
let resultMapRAndW = ashmem.mapReadAndWriteAshmem(); let resultMapRAndW = ashmem.mapReadAndWriteAshmem();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册