Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
0794a504
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0794a504
编写于
10月 11, 2022
作者:
Y
yang-qibo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sendMessageRequest接口适配用例
Signed-off-by:
N
yang-qibo
<
yangqibo1@huawei.com
>
上级
5c49f339
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
6326 addition
and
6333 deletion
+6326
-6333
communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js
...ion/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js
+6326
-6333
未找到文件。
communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js
浏览文件 @
0794a504
...
...
@@ -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 send
RequestAsync
API test
* @tc.name MessageParcel send
MessageRequest
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 send
RequestAsync
Asynchronous
* @tc.name Invoke the writestring interface to write data to the messageparcel instance send
MessageRequest
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. send
RequestAsync
asynchronously verifies
* @tc.name Invoke the writestring interface to write data to the messageparcel instance. send
MessageRequest
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 send
RequestAsync
test
* @tc.name MessageOption send
MessageRequest
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 send
RequestAsync
API Test
* @tc.name IRemoteObject send
MessageRequest
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 send
RequestAsync
API test
* @tc.name IPCSkeleton send
MessageRequest
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录