Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
02f51d64
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
大约 1 年 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
02f51d64
编写于
12月 13, 2022
作者:
O
openharmony_ci
提交者:
Gitee
12月 13, 2022
浏览文件
操作
浏览文件
下载
差异文件
!534 IPC分支覆盖率用例补充
Merge pull request !534 from 张泊远yg/master
上级
f7be6e37
e8c038fb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
516 addition
and
1 deletion
+516
-1
ipc/native/test/unittest/common/BUILD.gn
ipc/native/test/unittest/common/BUILD.gn
+39
-0
ipc/native/test/unittest/common/rpc_feature_set_unittest.cpp
ipc/native/test/unittest/common/rpc_feature_set_unittest.cpp
+163
-0
services/dbinder/test/unittest/BUILD.gn
services/dbinder/test/unittest/BUILD.gn
+1
-0
services/dbinder/test/unittest/dbinder_death_recipient_unittest.cpp
...binder/test/unittest/dbinder_death_recipient_unittest.cpp
+53
-0
services/dbinder/test/unittest/dbinder_remote_listener_unittest.cpp
...binder/test/unittest/dbinder_remote_listener_unittest.cpp
+97
-0
services/dbinder/test/unittest/dbinder_service_stub_unittest.cpp
...s/dbinder/test/unittest/dbinder_service_stub_unittest.cpp
+19
-0
services/dbinder/test/unittest/dbinder_service_unittest.cpp
services/dbinder/test/unittest/dbinder_service_unittest.cpp
+144
-1
未找到文件。
ipc/native/test/unittest/common/BUILD.gn
浏览文件 @
02f51d64
...
@@ -295,6 +295,44 @@ ohos_unittest("InvokerFactoryTest") {
...
@@ -295,6 +295,44 @@ ohos_unittest("InvokerFactoryTest") {
"//foundation/communication/ipc/test/resource/ipc/ohos_test.xml"
"//foundation/communication/ipc/test/resource/ipc/ohos_test.xml"
}
}
ohos_unittest("RPCFeatureUnitTest") {
module_out_path = MODULE_OUTPUT_PATH
include_dirs = [
"//utils/system/safwk/native/include",
"//commonlibrary/c_utils/base/include",
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
"//foundation/communication/ipc/ipc/native/src/mock/include",
"//foundation/communication/ipc/ipc/native/c/rpc/include",
"//foundation/communication/ipc/ipc/native/c/adapter/access_token/include",
"//foundation/communication/ipc/ipc/native/c/rpc/src/",
]
sources = [ "rpc_feature_set_unittest.cpp" ]
configs = [
"$SUBSYSTEM_DIR:ipc_util_config",
"$IPC_TEST_ROOT:ipc_test_config",
]
deps = [
"$IPC_TEST_ROOT/auxiliary/native:TestAssistance",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
external_deps = [
"c_utils:utils",
"hitrace_native:libhitracechain",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"samgr:samgr_proxy",
]
resource_config_file =
"//foundation/communication/ipc/test/resource/ipc/ohos_test.xml"
}
###############################################################################
###############################################################################
group("unittest") {
group("unittest") {
testonly = true
testonly = true
...
@@ -306,6 +344,7 @@ group("unittest") {
...
@@ -306,6 +344,7 @@ group("unittest") {
":IPCMockUnitTest",
":IPCMockUnitTest",
":IPCNativeUnitTest",
":IPCNativeUnitTest",
":InvokerFactoryTest",
":InvokerFactoryTest",
":RPCFeatureUnitTest",
]
]
if (support_jsapi) {
if (support_jsapi) {
deps += [ ":IPCNapiUnitTest" ]
deps += [ ":IPCNapiUnitTest" ]
...
...
ipc/native/test/unittest/common/rpc_feature_set_unittest.cpp
0 → 100644
浏览文件 @
02f51d64
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "securec.h"
#include "string_ex.h"
#include "rpc_feature_set.h"
using
namespace
testing
::
ext
;
using
namespace
OHOS
;
class
RpcFeatureSetTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
);
static
void
TearDownTestCase
(
void
);
void
SetUp
();
void
TearDown
();
};
void
RpcFeatureSetTest
::
SetUpTestCase
()
{
}
void
RpcFeatureSetTest
::
TearDownTestCase
()
{
}
void
RpcFeatureSetTest
::
SetUp
()
{
}
void
RpcFeatureSetTest
::
TearDown
()
{
}
/**
* @tc.name: SetFeatureTransData001
* @tc.desc: Verify the IPCObjectProxy::SetFeatureTransData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
SetFeatureTransData001
,
TestSize
.
Level1
)
{
FeatureTransData
*
data
=
nullptr
;
uint32_t
size
=
(
uint32_t
)
sizeof
(
FeatureTransData
);
bool
res
=
SetFeatureTransData
(
data
,
size
);
EXPECT_EQ
(
res
,
false
);
}
/**
* @tc.name: SetFeatureTransData002
* @tc.desc: Verify the IPCObjectProxy::SetFeatureTransData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
SetFeatureTransData002
,
TestSize
.
Level1
)
{
FeatureTransData
data
;
data
.
magicNum
=
123456
;
uint32_t
size
=
0
;
bool
res
=
SetFeatureTransData
(
&
data
,
size
);
EXPECT_EQ
(
res
,
false
);
}
/**
* @tc.name: SetFeatureTransData003
* @tc.desc: Verify the IPCObjectProxy::SetFeatureTransData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
SetFeatureTransData003
,
TestSize
.
Level1
)
{
FeatureTransData
data
;
data
.
magicNum
=
123456
;
data
.
tag
=
1
;
data
.
tokenId
=
54321
;
uint32_t
size
=
(
uint32_t
)
sizeof
(
FeatureTransData
);
bool
res
=
SetFeatureTransData
(
&
data
,
size
);
EXPECT_EQ
(
res
,
true
);
}
/**
* @tc.name: GetTokenFromData001
* @tc.desc: Verify the IPCObjectProxy::GetTokenFromData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
GetTokenFromData001
,
TestSize
.
Level1
)
{
FeatureTransData
*
data
=
nullptr
;
uint32_t
size
=
(
uint32_t
)
sizeof
(
FeatureTransData
);
uint32_t
ret
=
GetTokenFromData
(
data
,
size
);
EXPECT_EQ
(
ret
,
0x0
);
}
/**
* @tc.name: GetTokenFromData001
* @tc.desc: Verify the IPCObjectProxy::GetTokenFromData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
GetTokenFromData002
,
TestSize
.
Level1
)
{
FeatureTransData
data
;
data
.
magicNum
=
123456
;
uint32_t
size
=
0
;
uint32_t
ret
=
GetTokenFromData
(
&
data
,
size
);
EXPECT_EQ
(
ret
,
0x0
);
}
/**
* @tc.name: GetTokenFromData001
* @tc.desc: Verify the IPCObjectProxy::GetTokenFromData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
GetTokenFromData003
,
TestSize
.
Level1
)
{
FeatureTransData
data
;
data
.
magicNum
=
123456
;
data
.
tag
=
0
;
uint32_t
size
=
(
uint32_t
)
sizeof
(
FeatureTransData
);
uint32_t
ret
=
GetTokenFromData
(
&
data
,
size
);
EXPECT_EQ
(
ret
,
0x0
);
}
/**
* @tc.name: GetTokenFromData004
* @tc.desc: Verify the IPCObjectProxy::GetTokenFromData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
GetTokenFromData004
,
TestSize
.
Level1
)
{
FeatureTransData
data
;
data
.
magicNum
=
(
'R'
<<
24
)
|
(
'F'
<<
16
)
|
(
'S'
<<
8
)
|
43
;
data
.
tag
=
3
;
uint32_t
size
=
(
uint32_t
)
sizeof
(
FeatureTransData
);
uint32_t
ret
=
GetTokenFromData
(
&
data
,
size
);
EXPECT_EQ
(
ret
,
0x0
);
}
/**
* @tc.name: GetTokenFromData005
* @tc.desc: Verify the IPCObjectProxy::GetTokenFromData function
* @tc.type: FUNC
*/
HWTEST_F
(
RpcFeatureSetTest
,
GetTokenFromData005
,
TestSize
.
Level1
)
{
FeatureTransData
data
;
data
.
tokenId
=
123456
;
data
.
magicNum
=
(
'R'
<<
24
)
|
(
'F'
<<
16
)
|
(
'S'
<<
8
)
|
43
;
data
.
tag
=
0
;
uint32_t
size
=
(
uint32_t
)
sizeof
(
FeatureTransData
);
uint32_t
ret
=
GetTokenFromData
(
&
data
,
size
);
EXPECT_EQ
(
ret
,
123456
);
}
\ No newline at end of file
services/dbinder/test/unittest/BUILD.gn
浏览文件 @
02f51d64
...
@@ -29,6 +29,7 @@ ohos_unittest("RPCDbinderTest") {
...
@@ -29,6 +29,7 @@ ohos_unittest("RPCDbinderTest") {
]
]
sources = [
sources = [
"dbinder_death_recipient_unittest.cpp",
"dbinder_remote_listener_unittest.cpp",
"dbinder_remote_listener_unittest.cpp",
"dbinder_service_stub_unittest.cpp",
"dbinder_service_stub_unittest.cpp",
"dbinder_service_unittest.cpp",
"dbinder_service_unittest.cpp",
...
...
services/dbinder/test/unittest/dbinder_death_recipient_unittest.cpp
0 → 100644
浏览文件 @
02f51d64
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "dbinder_service.h"
#include "gtest/gtest.h"
#include "rpc_log.h"
#include "log_tags.h"
#include "session_impl.h"
#define private public
#include "dbinder_death_recipient.h"
#undef private
using
namespace
testing
::
ext
;
using
namespace
OHOS
;
using
namespace
OHOS
::
HiviewDFX
;
using
Communication
::
SoftBus
::
Session
;
using
Communication
::
SoftBus
::
SessionImpl
;
class
DbinderDeathRecipientUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
);
static
void
TearDownTestCase
(
void
);
void
SetUp
();
void
TearDown
();
static
constexpr
HiLogLabel
LABEL
=
{
LOG_CORE
,
LOG_ID_RPC
,
"DBinderRemoteListenerUnitTest"
};
};
void
DbinderDeathRecipientUnitTest
::
SetUp
()
{}
void
DbinderDeathRecipientUnitTest
::
TearDown
()
{}
void
DbinderDeathRecipientUnitTest
::
SetUpTestCase
()
{}
void
DbinderDeathRecipientUnitTest
::
TearDownTestCase
()
{}
HWTEST_F
(
DbinderDeathRecipientUnitTest
,
OnRemoteDied001
,
TestSize
.
Level1
)
{
DbinderDeathRecipient
dbinderDeathRecipient
;
wptr
<
IRemoteObject
>
remote
=
nullptr
;
dbinderDeathRecipient
.
OnRemoteDied
(
remote
);
}
\ No newline at end of file
services/dbinder/test/unittest/dbinder_remote_listener_unittest.cpp
浏览文件 @
02f51d64
...
@@ -125,17 +125,114 @@ HWTEST_F(DBinderRemoteListenerUnitTest, senddatatoremote_002, TestSize.Level1)
...
@@ -125,17 +125,114 @@ HWTEST_F(DBinderRemoteListenerUnitTest, senddatatoremote_002, TestSize.Level1)
EXPECT_EQ
(
dBinderRemoteListener_
.
SendDataToRemote
(
deviceId
,
&
message
),
false
);
EXPECT_EQ
(
dBinderRemoteListener_
.
SendDataToRemote
(
deviceId
,
&
message
),
false
);
}
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
senddatatoremote_003
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
"123"
;
DHandleEntryTxRx
message
;
message
.
head
.
len
=
sizeof
(
DHandleEntryTxRx
);
EXPECT_EQ
(
dBinderRemoteListener_
.
SendDataToRemote
(
deviceId
,
&
message
),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
startlistener_001
,
TestSize
.
Level1
)
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
startlistener_001
,
TestSize
.
Level1
)
{
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
std
::
shared_ptr
<
DBinderRemoteListener
>
listener
=
nullptr
;
EXPECT_EQ
(
dBinderRemoteListener_
.
StartListener
(
listener
),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
startlistener_002
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
std
::
shared_ptr
<
DBinderRemoteListener
>
listener
=
nullptr
;
std
::
shared_ptr
<
DBinderRemoteListener
>
listener
=
nullptr
;
listener
=
std
::
make_shared
<
DBinderRemoteListener
>
(
DBinderService
::
GetInstance
());
EXPECT_EQ
(
dBinderRemoteListener_
.
StartListener
(
listener
),
false
);
EXPECT_EQ
(
dBinderRemoteListener_
.
StartListener
(
listener
),
false
);
}
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
StopListener_001
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
dBinderRemoteListener_
.
softbusManager_
=
nullptr
;
EXPECT_EQ
(
dBinderRemoteListener_
.
StopListener
(),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
StopListener_002
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
dBinderRemoteListener_
.
softbusManager_
=
ISessionService
::
GetInstance
();
EXPECT_EQ
(
dBinderRemoteListener_
.
StopListener
(),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
closedatabussession_001
,
TestSize
.
Level1
)
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
closedatabussession_001
,
TestSize
.
Level1
)
{
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
""
;
const
std
::
string
deviceId
=
""
;
EXPECT_EQ
(
dBinderRemoteListener_
.
CloseDatabusSession
(
deviceId
),
false
);
EXPECT_EQ
(
dBinderRemoteListener_
.
CloseDatabusSession
(
deviceId
),
false
);
}
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
closedatabussession_002
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
"123"
;
dBinderRemoteListener_
.
softbusManager_
=
ISessionService
::
GetInstance
();
EXPECT_EQ
(
dBinderRemoteListener_
.
CloseDatabusSession
(
deviceId
),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
QueryOrNewDeviceLock_001
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
""
;
dBinderRemoteListener_
.
QueryOrNewDeviceLock
(
deviceId
);
const
std
::
string
deviceId1
=
"123456"
;
std
::
shared_ptr
<
DeviceLock
>
lockInfo
=
nullptr
;
lockInfo
=
dBinderRemoteListener_
.
QueryOrNewDeviceLock
(
deviceId1
);
EXPECT_TRUE
(
lockInfo
!=
nullptr
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
SendDataReply_001
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
""
;
EXPECT_EQ
(
dBinderRemoteListener_
.
SendDataReply
(
deviceId
,
nullptr
),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
SendDataReply_002
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
""
;
DHandleEntryTxRx
message
;
message
.
deviceIdInfo
.
fromDeviceId
[
0
]
=
't'
;
EXPECT_EQ
(
dBinderRemoteListener_
.
SendDataReply
(
deviceId
,
&
message
),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
SendDataReply_003
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
deviceId
=
"12345"
;
DHandleEntryTxRx
message
;
message
.
deviceIdInfo
.
fromDeviceId
[
0
]
=
't'
;
EXPECT_EQ
(
dBinderRemoteListener_
.
SendDataReply
(
deviceId
,
&
message
),
false
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
OpenSoftbusSession_001
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
peerDeviceId
=
"12345"
;
dBinderRemoteListener_
.
softbusManager_
=
ISessionService
::
GetInstance
();
EXPECT_EQ
(
dBinderRemoteListener_
.
OpenSoftbusSession
(
peerDeviceId
),
nullptr
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
OpenSoftbusSession_002
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
peerDeviceId
=
""
;
dBinderRemoteListener_
.
softbusManager_
=
ISessionService
::
GetInstance
();
EXPECT_EQ
(
dBinderRemoteListener_
.
OpenSoftbusSession
(
peerDeviceId
),
nullptr
);
}
HWTEST_F
(
DBinderRemoteListenerUnitTest
,
GetPeerSession_001
,
TestSize
.
Level1
)
{
DBinderRemoteListener
dBinderRemoteListener_
(
DBinderService
::
GetInstance
());
const
std
::
string
peerDeviceId
=
""
;
EXPECT_EQ
(
dBinderRemoteListener_
.
OpenSoftbusSession
(
peerDeviceId
),
nullptr
);
}
\ No newline at end of file
services/dbinder/test/unittest/dbinder_service_stub_unittest.cpp
浏览文件 @
02f51d64
...
@@ -152,6 +152,25 @@ HWTEST_F(DBinderServiceStubUnitTest, ProcessProto002, TestSize.Level1)
...
@@ -152,6 +152,25 @@ HWTEST_F(DBinderServiceStubUnitTest, ProcessProto002, TestSize.Level1)
EXPECT_EQ
(
ret
,
DBINDER_SERVICE_PROCESS_PROTO_ERR
);
EXPECT_EQ
(
ret
,
DBINDER_SERVICE_PROCESS_PROTO_ERR
);
}
}
/**
* @tc.name: ProcessProto003
* @tc.desc: Verify the ProcessProto function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceStubUnitTest
,
ProcessProto003
,
TestSize
.
Level1
)
{
const
std
::
string
service
=
"serviceTest"
;
const
std
::
string
device
=
"deviceTest"
;
binder_uintptr_t
object
=
11
;
DBinderServiceStub
dBinderServiceStub
(
service
,
device
,
object
);
uint32_t
code
=
11
;
MessageParcel
data
;
MessageParcel
reply
;
MessageOption
option
;
int32_t
ret
=
dBinderServiceStub
.
ProcessProto
(
code
,
data
,
reply
,
option
);
EXPECT_EQ
(
ret
,
DBINDER_SERVICE_PROCESS_PROTO_ERR
);
}
/**
/**
* @tc.name: OnRemoteRequest001
* @tc.name: OnRemoteRequest001
* @tc.desc: Verify the OnRemoteRequest function
* @tc.desc: Verify the OnRemoteRequest function
...
...
services/dbinder/test/unittest/dbinder_service_unittest.cpp
浏览文件 @
02f51d64
...
@@ -108,6 +108,21 @@ HWTEST_F(DBinderServiceUnitTest, StartDBinderService002, TestSize.Level1)
...
@@ -108,6 +108,21 @@ HWTEST_F(DBinderServiceUnitTest, StartDBinderService002, TestSize.Level1)
EXPECT_EQ
(
res
,
false
);
EXPECT_EQ
(
res
,
false
);
}
}
/**
* @tc.name: StartDBinderService003
* @tc.desc: Verify the StartDBinderService function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
StartDBinderService003
,
TestSize
.
Level1
)
{
sptr
<
DBinderService
>
dBinderService
;
std
::
shared_ptr
<
RpcSystemAbilityCallback
>
callbackImpl
=
nullptr
;
DBinderService
::
mainThreadCreated_
=
false
;
dBinderService
->
remoteListener_
=
nullptr
;
bool
res
=
dBinderService
->
StartDBinderService
(
callbackImpl
);
EXPECT_EQ
(
res
,
false
);
}
/**
/**
* @tc.name: ReStartRemoteListener001
* @tc.name: ReStartRemoteListener001
* @tc.desc: Verify the ReStartRemoteListener function
* @tc.desc: Verify the ReStartRemoteListener function
...
@@ -134,6 +149,20 @@ HWTEST_F(DBinderServiceUnitTest, StartRemoteListener001, TestSize.Level1)
...
@@ -134,6 +149,20 @@ HWTEST_F(DBinderServiceUnitTest, StartRemoteListener001, TestSize.Level1)
EXPECT_EQ
(
res
,
false
);
EXPECT_EQ
(
res
,
false
);
}
}
/**
* @tc.name: StartRemoteListener002
* @tc.desc: Verify the StartRemoteListener function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
StartRemoteListener002
,
TestSize
.
Level1
)
{
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
dBinderService
->
remoteListener_
=
std
::
make_shared
<
DBinderRemoteListener
>
(
dBinderService
);
bool
res
=
dBinderService
->
StartRemoteListener
();
EXPECT_EQ
(
res
,
true
);
}
/**
/**
* @tc.name: RegisterRemoteProxy001
* @tc.name: RegisterRemoteProxy001
* @tc.desc: Verify the RegisterRemoteProxy function
* @tc.desc: Verify the RegisterRemoteProxy function
...
@@ -261,7 +290,7 @@ HWTEST_F(DBinderServiceUnitTest, StopRemoteListener001, TestSize.Level1)
...
@@ -261,7 +290,7 @@ HWTEST_F(DBinderServiceUnitTest, StopRemoteListener001, TestSize.Level1)
{
{
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
std
::
shared_ptr
<
DBinderRemoteListener
>
testListener
=
std
::
make_shared
<
DBinderRemoteListener
>
(
dBinderService
);
std
::
shared_ptr
<
DBinderRemoteListener
>
testListener
=
std
::
make_shared
<
DBinderRemoteListener
>
(
dBinderService
);
EXPECT_EQ
(
dBinderService
->
StartRemoteListener
(),
fals
e
);
EXPECT_EQ
(
dBinderService
->
StartRemoteListener
(),
tru
e
);
dBinderService
->
StopRemoteListener
();
dBinderService
->
StopRemoteListener
();
}
}
...
@@ -1092,4 +1121,118 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest001, TestSize.Level1)
...
@@ -1092,4 +1121,118 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest001, TestSize.Level1)
dBinderService
->
LoadSystemAbilityComplete
(
srcNetworkId
,
systemAbilityId
,
remoteObject
);
dBinderService
->
LoadSystemAbilityComplete
(
srcNetworkId
,
systemAbilityId
,
remoteObject
);
remoteObject
=
new
IPCObjectProxy
(
1
);
remoteObject
=
new
IPCObjectProxy
(
1
);
dBinderService
->
LoadSystemAbilityComplete
(
srcNetworkId
,
systemAbilityId
,
remoteObject
);
dBinderService
->
LoadSystemAbilityComplete
(
srcNetworkId
,
systemAbilityId
,
remoteObject
);
}
/**
* @tc.name: SendMessageToRemote001
* @tc.desc: Verify the SendMessageToRemote function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
SendMessageToRemote001
,
TestSize
.
Level1
)
{
uint32_t
dBinderCode
=
4
;
uint32_t
reason
=
0
;
std
::
shared_ptr
<
DHandleEntryTxRx
>
replyMessage
=
std
::
make_shared
<
DHandleEntryTxRx
>
();
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
dBinderService
->
remoteListener_
=
std
::
make_shared
<
DBinderRemoteListener
>
(
dBinderService
);
dBinderService
->
SendMessageToRemote
(
dBinderCode
,
reason
,
replyMessage
);
dBinderCode
=
1
;
dBinderService
->
SendMessageToRemote
(
dBinderCode
,
reason
,
replyMessage
);
DBinderService
*
temp
=
new
DBinderService
();
DBinderService
::
instance_
=
temp
;
dBinderService
=
DBinderService
::
GetInstance
();
EXPECT_EQ
(
dBinderService
,
DBinderService
::
instance_
);
}
/**
* @tc.name: StartThreadPool001
* @tc.desc: Verify the StartThreadPool function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
StartThreadPool001
,
TestSize
.
Level1
)
{
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
dBinderService
->
threadPoolStarted_
=
true
;
bool
res1
=
dBinderService
->
StartThreadPool
();
EXPECT_EQ
(
res1
,
true
);
dBinderService
->
threadPoolStarted_
=
false
;
dBinderService
->
threadPool_
=
nullptr
;
dBinderService
->
StartThreadPool
();
dBinderService
->
threadPool_
=
std
::
make_unique
<
ThreadPool
>
(
"DBinderRemoteListener"
);
bool
res2
=
dBinderService
->
StartThreadPool
();
EXPECT_EQ
(
res2
,
true
);
}
/**
* @tc.name: StopThreadPool001
* @tc.desc: Verify the StopThreadPool function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
StopThreadPool001
,
TestSize
.
Level1
)
{
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
dBinderService
->
threadPoolStarted_
=
true
;
dBinderService
->
StartThreadPool
();
dBinderService
->
threadPoolStarted_
=
false
;
bool
res
=
dBinderService
->
StartThreadPool
();
EXPECT_EQ
(
res
,
false
);
}
/**
* @tc.name: AddAsynMessageTask001
* @tc.desc: Verify the AddAsynMessageTask function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
AddAsynMessageTask001
,
TestSize
.
Level1
)
{
std
::
shared_ptr
<
struct
DHandleEntryTxRx
>
message
=
std
::
make_shared
<
struct
DHandleEntryTxRx
>
();
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
dBinderService
->
AddAsynMessageTask
(
message
);
}
/**
* @tc.name: IsSameSession002
* @tc.desc: Verify the IsSameSession function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
IsSameSession002
,
TestSize
.
Level1
)
{
std
::
shared_ptr
<
struct
SessionInfo
>
oldSession
=
std
::
make_shared
<
struct
SessionInfo
>
();
std
::
shared_ptr
<
struct
SessionInfo
>
newSession
=
std
::
make_shared
<
struct
SessionInfo
>
();
oldSession
->
stubIndex
=
1
;
oldSession
->
toPort
=
2
;
oldSession
->
fromPort
=
3
;
oldSession
->
type
=
4
;
oldSession
->
serviceName
[
0
]
=
't'
;
newSession
->
stubIndex
=
2
;
newSession
->
toPort
=
2
;
newSession
->
fromPort
=
3
;
newSession
->
type
=
4
;
newSession
->
serviceName
[
0
]
=
't'
;
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
EXPECT_EQ
(
dBinderService
->
IsSameSession
(
oldSession
,
newSession
),
false
);
newSession
->
stubIndex
=
1
;
newSession
->
toPort
=
12
;
EXPECT_EQ
(
dBinderService
->
IsSameSession
(
oldSession
,
newSession
),
false
);
newSession
->
toPort
=
2
;
newSession
->
fromPort
=
13
;
EXPECT_EQ
(
dBinderService
->
IsSameSession
(
oldSession
,
newSession
),
false
);
newSession
->
fromPort
=
3
;
newSession
->
type
=
14
;
EXPECT_EQ
(
dBinderService
->
IsSameSession
(
oldSession
,
newSession
),
false
);
newSession
->
type
=
4
;
EXPECT_EQ
(
dBinderService
->
IsSameSession
(
oldSession
,
newSession
),
true
);
}
/**
* @tc.name: AttachSessionObject001
* @tc.desc: Verify the AttachSessionObject function
* @tc.type: FUNC
*/
HWTEST_F
(
DBinderServiceUnitTest
,
AttachSessionObject001
,
TestSize
.
Level1
)
{
std
::
shared_ptr
<
struct
SessionInfo
>
object
=
nullptr
;
binder_uintptr_t
stub
=
0
;
sptr
<
DBinderService
>
dBinderService
=
DBinderService
::
GetInstance
();
EXPECT_EQ
(
dBinderService
->
AttachSessionObject
(
object
,
stub
),
true
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录