mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2025-02-26 14:26:49 +00:00
commit
9fd430b72d
@ -29,11 +29,14 @@ ohos_unittest("TransTcpDirectCoreTest") {
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"$dsoftbus_root_path/core/connection/interface",
|
||||
"$dsoftbus_root_path/core/transmission/common/include",
|
||||
"$dsoftbus_root_path/core/transmission/ipc/include",
|
||||
"$dsoftbus_root_path/core/transmission/trans_channel/tcp_direct/include",
|
||||
"$dsoftbus_root_path/core/transmission/trans_channel/proxy/include",
|
||||
"$dsoftbus_root_path/core/transmission/trans_channel/qos/interface",
|
||||
"$dsoftbus_root_path/core/transmission/interface",
|
||||
"$dsoftbus_root_path/core/transmission/session/include",
|
||||
"$dsoftbus_root_path/core/transmission/trans_channel/manager/include",
|
||||
"$dsoftbus_root_path/core/transmission/trans_channel/manager/src",
|
||||
"$dsoftbus_root_path/core/transmission/pending_packet/include",
|
||||
"$dsoftbus_root_path/core/connection/p2p/interface",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_protocol_def.h"
|
||||
|
||||
#include "trans_channel_callback.c"
|
||||
#include "trans_channel_manager.h"
|
||||
#include "trans_tcp_direct_listener.c"
|
||||
#include "trans_tcp_direct_manager.c"
|
||||
#include "trans_tcp_direct_message.c"
|
||||
@ -44,6 +46,7 @@ namespace OHOS {
|
||||
#define DC_MSG_PACKET_HEAD_SIZE_LEN 24
|
||||
#define MODULE_P2P_LISTEN 16
|
||||
#define MSG_FLAG_REQUEST 0
|
||||
#define TEST_PKG_NAME "com.test.trans.demo.pkgname"
|
||||
|
||||
class TransTcpDirectTest : public testing::Test {
|
||||
public:
|
||||
@ -523,4 +526,65 @@ HWTEST_F(TransTcpDirectTest, OnSessionOpenFailProcTest001, TestSize.Level1)
|
||||
{
|
||||
OnSessionOpenFailProc(NULL, SOFTBUS_TRANS_HANDSHAKE_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnpackReplyErrCodeTest001
|
||||
* @tc.desc: UnpackReplyErrCodeTest001, with wrong parms.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(TransTcpDirectTest, UnpackReplyErrCodeTest001, TestSize.Level1)
|
||||
{
|
||||
int32_t errCode = SOFTBUS_ERR;
|
||||
int32_t ret = UnpackReplyErrCode(NULL, &errCode);
|
||||
EXPECT_NE(SOFTBUS_OK, ret);
|
||||
|
||||
ret = UnpackReplyErrCode(NULL, NULL);
|
||||
EXPECT_NE(SOFTBUS_OK, ret);
|
||||
|
||||
string str = "testData";
|
||||
cJSON *msg = cJSON_Parse(str.c_str());
|
||||
ret = UnpackReplyErrCode(msg, NULL);
|
||||
EXPECT_NE(SOFTBUS_OK, ret);
|
||||
|
||||
string errDesc = "testDesc";
|
||||
str = PackError(SOFTBUS_ERR, errDesc.c_str());
|
||||
cJSON *json = cJSON_Parse(str.c_str());
|
||||
ret = UnpackReplyErrCode(json, &errCode);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TransServerOnChannelOpenFailedTest001
|
||||
* @tc.desc: TransServerOnChannelOpenFailedTest001, with wrong parms.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(TransTcpDirectTest, TransServerOnChannelOpenFailedTest001, TestSize.Level1)
|
||||
{
|
||||
(void)TransChannelInit();
|
||||
const char *pkgName = TEST_PKG_NAME;
|
||||
int32_t ret = TransServerOnChannelOpenFailed(pkgName, 0, -1, 0, SOFTBUS_ERR);
|
||||
EXPECT_NE(SOFTBUS_OK, ret);
|
||||
|
||||
ret = TransServerOnChannelOpenFailed(NULL, 0, -1, 0, SOFTBUS_ERR);
|
||||
EXPECT_NE(SOFTBUS_OK, ret);
|
||||
TransChannelDeinit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TransGetAuthTypeByNetWorkIdTest001
|
||||
* @tc.desc: TransGetAuthTypeByNetWorkIdTest001, with wrong parms.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(TransTcpDirectTest, TransGetAuthTypeByNetWorkIdTest001, TestSize.Level1)
|
||||
{
|
||||
(void)TransChannelInit();
|
||||
string networkId = "testNetworkId";
|
||||
bool ret = TransGetAuthTypeByNetWorkId(networkId.c_str());
|
||||
EXPECT_NE(true, ret);
|
||||
TransChannelDeinit();
|
||||
}
|
||||
|
||||
} // namespace OHOS
|
Loading…
x
Reference in New Issue
Block a user