未验证 提交 4923df2e 编写于 作者: O openharmony_ci 提交者: Gitee

!540 IPC分支覆盖率提升UT补充

Merge pull request !540 from 张泊远yg/master
...@@ -51,3 +51,15 @@ HWTEST_F(DbinderDeathRecipientUnitTest, OnRemoteDied001, TestSize.Level1) ...@@ -51,3 +51,15 @@ HWTEST_F(DbinderDeathRecipientUnitTest, OnRemoteDied001, TestSize.Level1)
wptr<IRemoteObject> remote = nullptr; wptr<IRemoteObject> remote = nullptr;
dbinderDeathRecipient.OnRemoteDied(remote); dbinderDeathRecipient.OnRemoteDied(remote);
} }
HWTEST_F(DbinderDeathRecipientUnitTest, OnRemoteDied002, TestSize.Level1)
{
DbinderDeathRecipient dbinderDeathRecipient;
int handle = 1;
sptr<IRemoteObject> result = nullptr;
std::u16string descriptor = std::u16string();
result = new (std::nothrow) IPCObjectProxy(handle, descriptor);
IRemoteObject *object = result.GetRefPtr();
wptr<IRemoteObject> remote = object;
dbinderDeathRecipient.OnRemoteDied(remote);
}
\ No newline at end of file
...@@ -236,3 +236,12 @@ HWTEST_F(DBinderRemoteListenerUnitTest, GetPeerSession_001, TestSize.Level1) ...@@ -236,3 +236,12 @@ HWTEST_F(DBinderRemoteListenerUnitTest, GetPeerSession_001, TestSize.Level1)
const std::string peerDeviceId = ""; const std::string peerDeviceId = "";
EXPECT_EQ(dBinderRemoteListener_.OpenSoftbusSession(peerDeviceId), nullptr); EXPECT_EQ(dBinderRemoteListener_.OpenSoftbusSession(peerDeviceId), nullptr);
} }
HWTEST_F(DBinderRemoteListenerUnitTest, GetPeerSession_002, TestSize.Level1)
{
DBinderRemoteListener dBinderRemoteListener_(DBinderService::GetInstance());
const std::string peerDeviceId = "12345";
EXPECT_EQ(dBinderRemoteListener_.OpenSoftbusSession(peerDeviceId), nullptr);
dBinderRemoteListener_.softbusManager_ = ISessionService::GetInstance();
dBinderRemoteListener_.OpenSoftbusSession(peerDeviceId);
}
\ No newline at end of file
...@@ -134,6 +134,9 @@ HWTEST_F(DBinderServiceUnitTest, ReStartRemoteListener001, TestSize.Level1) ...@@ -134,6 +134,9 @@ HWTEST_F(DBinderServiceUnitTest, ReStartRemoteListener001, TestSize.Level1)
dBinderService->remoteListener_ = nullptr; dBinderService->remoteListener_ = nullptr;
bool res = dBinderService->ReStartRemoteListener(); bool res = dBinderService->ReStartRemoteListener();
EXPECT_EQ(res, false); EXPECT_EQ(res, false);
dBinderService->remoteListener_ = std::make_shared<DBinderRemoteListener>(dBinderService);
bool res2 = dBinderService->ReStartRemoteListener();
EXPECT_EQ(res2, false);
} }
/** /**
...@@ -431,8 +434,39 @@ HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinder001, TestSize.Level1) ...@@ -431,8 +434,39 @@ HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinder001, TestSize.Level1)
binder_uintptr_t binderObject = 12345; binder_uintptr_t binderObject = 12345;
uint32_t pid = 0; uint32_t pid = 0;
uint32_t uid = 0; uint32_t uid = 0;
bool res = dBinderService->MakeRemoteBinder(serviceName, deviceID, binderObject, pid, uid); EXPECT_EQ(dBinderService->MakeRemoteBinder(serviceName, deviceID, binderObject, pid, uid), nullptr);
EXPECT_EQ(res, false); }
/**
* @tc.name: MakeRemoteBinder002
* @tc.desc: Verify the MakeRemoteBinder function
* @tc.type: FUNC
*/
HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinder002, TestSize.Level1)
{
sptr<DBinderService> dBinderService = DBinderService::GetInstance();
std::u16string serviceName;
std::string deviceID("001");
binder_uintptr_t binderObject = 12345;
uint32_t pid = 0;
uint32_t uid = 0;
EXPECT_EQ(dBinderService->MakeRemoteBinder(serviceName, deviceID, binderObject, pid, uid), nullptr);
}
/**
* @tc.name: MakeRemoteBinderTest003
* @tc.desc: Verify the MakeRemoteBinder function
* @tc.type: FUNC
*/
HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinderTest003, TestSize.Level1)
{
sptr<DBinderService> dBinderService = DBinderService::GetInstance();
std::u16string serviceName;
std::string deviceID("001");
binder_uintptr_t binderObject = 12345;
uint32_t pid = 10;
uint32_t uid = 10;
EXPECT_EQ(dBinderService->MakeRemoteBinder(serviceName, deviceID, binderObject, pid, uid), nullptr);
} }
/** /**
...@@ -442,8 +476,8 @@ HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinder001, TestSize.Level1) ...@@ -442,8 +476,8 @@ HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinder001, TestSize.Level1)
*/ */
HWTEST_F(DBinderServiceUnitTest, SendEntryToRemote001, TestSize.Level1) HWTEST_F(DBinderServiceUnitTest, SendEntryToRemote001, TestSize.Level1)
{ {
const std::string serviceName = "testServiceName"; std::string serviceName = "testServiceName";
const std::string deviceID = "testDeviceID"; std::string deviceID = "testDeviceID";
binder_uintptr_t binderObject = 161561; binder_uintptr_t binderObject = 161561;
sptr<DBinderService> dBinderService = DBinderService::GetInstance(); sptr<DBinderService> dBinderService = DBinderService::GetInstance();
sptr<DBinderServiceStub> stub = new DBinderServiceStub(serviceName, deviceID, binderObject); sptr<DBinderServiceStub> stub = new DBinderServiceStub(serviceName, deviceID, binderObject);
...@@ -642,6 +676,19 @@ HWTEST_F(DBinderServiceUnitTest, NoticeDeviceDieTest002, TestSize.Level1) ...@@ -642,6 +676,19 @@ HWTEST_F(DBinderServiceUnitTest, NoticeDeviceDieTest002, TestSize.Level1)
EXPECT_EQ(dBinderService->NoticeDeviceDie(deviceID), DBINDER_SERVICE_NOTICE_DIE_ERR); EXPECT_EQ(dBinderService->NoticeDeviceDie(deviceID), DBINDER_SERVICE_NOTICE_DIE_ERR);
} }
/**
* @tc.name: NoticeDeviceDieTest003
* @tc.desc: Verify the NoticeDeviceDie function
* @tc.type: FUNC
*/
HWTEST_F(DBinderServiceUnitTest, NoticeDeviceDieTest003, TestSize.Level1)
{
sptr<DBinderService> dBinderService = DBinderService::GetInstance();
std::string deviceID("123456");
dBinderService->remoteListener_ = std::make_shared<DBinderRemoteListener>(dBinderService);
dBinderService->NoticeDeviceDie(deviceID);
}
/** /**
* @tc.name: NoticeServiceDieTest001 * @tc.name: NoticeServiceDieTest001
* @tc.desc: Verify the NoticeServiceDie function * @tc.desc: Verify the NoticeServiceDie function
...@@ -695,7 +742,7 @@ HWTEST_F(DBinderServiceUnitTest, NoticeServiceDieInnerTest003, TestSize.Level1) ...@@ -695,7 +742,7 @@ HWTEST_F(DBinderServiceUnitTest, NoticeServiceDieInnerTest003, TestSize.Level1)
dBinderService->StartRemoteListener(); dBinderService->StartRemoteListener();
std::u16string serviceName(u"testServer"); std::u16string serviceName(u"testServer");
std::string deviceID("123456"); std::string deviceID("123456");
EXPECT_EQ(dBinderService->NoticeServiceDieInner(serviceName, deviceID), DBINDER_SERVICE_NOTICE_DIE_ERR); EXPECT_EQ(dBinderService->NoticeServiceDieInner(serviceName, deviceID), ERR_NONE);
} }
/** /**
...@@ -834,6 +881,13 @@ HWTEST_F(DBinderServiceUnitTest, MakeSessionByReplyMessageTest001, TestSize.Leve ...@@ -834,6 +881,13 @@ HWTEST_F(DBinderServiceUnitTest, MakeSessionByReplyMessageTest001, TestSize.Leve
struct DHandleEntryTxRx replyMessage; struct DHandleEntryTxRx replyMessage;
dBinderService->MakeSessionByReplyMessage(&replyMessage); dBinderService->MakeSessionByReplyMessage(&replyMessage);
EXPECT_EQ(dBinderService->HasDBinderStub(replyMessage.binderObject), false); EXPECT_EQ(dBinderService->HasDBinderStub(replyMessage.binderObject), false);
std::string serviceName("testServer");
std::string deviceID;
binder_uintptr_t binderObject = 161561;
sptr<DBinderServiceStub> stub = new DBinderServiceStub(serviceName, deviceID, binderObject);
replyMessage.stub = reinterpret_cast<binder_uintptr_t>(stub.GetRefPtr());
dBinderService->MakeSessionByReplyMessage(&replyMessage);
} }
/** /**
...@@ -1045,38 +1099,6 @@ HWTEST_F(DBinderServiceUnitTest, IsSameStubObjectTest002, TestSize.Level1) ...@@ -1045,38 +1099,6 @@ HWTEST_F(DBinderServiceUnitTest, IsSameStubObjectTest002, TestSize.Level1)
EXPECT_EQ(res, true); EXPECT_EQ(res, true);
} }
/**
* @tc.name: MakeRemoteBinder002
* @tc.desc: Verify the MakeRemoteBinder function
* @tc.type: FUNC
*/
HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinder002, TestSize.Level1)
{
sptr<DBinderService> dBinderService = DBinderService::GetInstance();
std::u16string serviceName;
std::string deviceID("001");
binder_uintptr_t binderObject = 12345;
uint32_t pid = 0;
uint32_t uid = 0;
EXPECT_EQ(dBinderService->MakeRemoteBinder(serviceName, deviceID, binderObject, pid, uid), nullptr);
}
/**
* @tc.name: MakeRemoteBinderTest003
* @tc.desc: Verify the MakeRemoteBinder function
* @tc.type: FUNC
*/
HWTEST_F(DBinderServiceUnitTest, MakeRemoteBinderTest003, TestSize.Level1)
{
sptr<DBinderService> dBinderService = DBinderService::GetInstance();
std::u16string serviceName;
std::string deviceID("001");
binder_uintptr_t binderObject = 12345;
uint32_t pid = 10;
uint32_t uid = 10;
EXPECT_EQ(dBinderService->MakeRemoteBinder(serviceName, deviceID, binderObject, pid, uid), nullptr);
}
/** /**
* @tc.name: SendEntryToRemoteTest002 * @tc.name: SendEntryToRemoteTest002
* @tc.desc: Verify the SendEntryToRemote function * @tc.desc: Verify the SendEntryToRemote function
...@@ -1119,8 +1141,8 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest001, TestSize.Level1) ...@@ -1119,8 +1141,8 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest001, TestSize.Level1)
sptr<IRemoteObject> remoteObject = nullptr; sptr<IRemoteObject> remoteObject = nullptr;
dBinderService->LoadSystemAbilityComplete("test", 2, remoteObject); dBinderService->LoadSystemAbilityComplete("test", 2, remoteObject);
dBinderService->LoadSystemAbilityComplete(srcNetworkId, systemAbilityId, remoteObject); dBinderService->LoadSystemAbilityComplete(srcNetworkId, systemAbilityId, remoteObject);
remoteObject = new IPCObjectProxy(1); sptr<IRemoteObject> remoteObject1 = new IPCObjectProxy(1);
dBinderService->LoadSystemAbilityComplete(srcNetworkId, systemAbilityId, remoteObject); dBinderService->LoadSystemAbilityComplete(srcNetworkId, systemAbilityId, remoteObject1);
} }
/** /**
...@@ -1176,6 +1198,10 @@ HWTEST_F(DBinderServiceUnitTest, StopThreadPool001, TestSize.Level1) ...@@ -1176,6 +1198,10 @@ HWTEST_F(DBinderServiceUnitTest, StopThreadPool001, TestSize.Level1)
dBinderService->threadPoolStarted_ = false; dBinderService->threadPoolStarted_ = false;
bool res = dBinderService->StartThreadPool(); bool res = dBinderService->StartThreadPool();
EXPECT_EQ(res, false); EXPECT_EQ(res, false);
bool res2 = dBinderService->StopThreadPool();
EXPECT_EQ(res2, true);
dBinderService->threadPoolStarted_ = true;
dBinderService->StopThreadPool();
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册