!5094 fix: fix xts case fail

Merge pull request !5094 from xuxiaoqing/master
This commit is contained in:
openharmony_ci 2024-01-18 08:49:57 +00:00 committed by Gitee
commit 4792e266cd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 20 additions and 9 deletions

View File

@ -389,6 +389,7 @@
"ServerEnableDiscoveryPolicy";
"ServerSetDiscoveryPolicy";
"ClientResetIdleTimeoutById";
"IsSessionExceedLimit";
extern "C++" {
OHOS::StreamAdaptor*;
Communication::SoftBus*;

View File

@ -31,9 +31,6 @@ int32_t TransOnChannelOpened(const char *sessionName, const ChannelInfo *channel
TRANS_LOGW(TRANS_SDK, "[client] invalid param.");
return SOFTBUS_INVALID_PARAM;
}
if (IsSessionExceedLimit()) {
return SOFTBUS_TRANS_SESSION_CNT_EXCEEDS_LIMIT;
}
int32_t ret = SOFTBUS_ERR;
int32_t udpPort = 0;

View File

@ -15,6 +15,7 @@
#include "client_trans_stream.h"
#include "client_trans_session_manager.h"
#include "client_trans_udp_stream_interface.h"
#include "session.h"
#include "softbus_errcode.h"
@ -137,6 +138,10 @@ int32_t TransOnstreamChannelOpened(const ChannelInfo *channel, int32_t *streamPo
return SOFTBUS_INVALID_PARAM;
}
if (channel->isServer) {
if (IsSessionExceedLimit()) {
*streamPort = 0;
return SOFTBUS_TRANS_SESSION_CNT_EXCEEDS_LIMIT;
}
VtpStreamOpenParam p1 = { "DSOFTBUS_STREAM", channel->myIp,
NULL, -1, streamType, (uint8_t*)channel->sessionKey, channel->keyLen };

View File

@ -313,6 +313,7 @@ if (defined(ohos_lite)) {
"$dsoftbus_root_path/sdk/transmission/ipc/standard/src",
"$dsoftbus_root_path/sdk/transmission/ipc/standard/include",
"$dsoftbus_root_path/core/frame/standard/init/include",
"$dsoftbus_root_path/sdk/transmission/session/include",
]
deps = trans_sdk_test_common_deps

View File

@ -16,12 +16,13 @@
#include <gtest/gtest.h>
#include "securec.h"
#include "client_trans_session_callback.h"
#include "client_trans_session_manager.h"
#include "client_trans_udp_manager.h"
#include "session.h"
#include "softbus_def.h"
#include "softbus_errcode.h"
#include "session.h"
#include "trans_udp_channel_manager.h"
#include "client_trans_session_callback.h"
using namespace std;
using namespace testing::ext;
@ -88,6 +89,8 @@ void ClientTransUdpManagerTest::SetUpTestCase(void)
{
int ret = ClientTransUdpMgrInit(&g_sessionCb);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransClientInit();
EXPECT_EQ(ret, SOFTBUS_OK);
}
void ClientTransUdpManagerTest::TearDownTestCase(void) {}

View File

@ -16,11 +16,12 @@
#include <gtest/gtest.h>
#include <securec.h>
#include "client_trans_session_manager.h"
#include "client_trans_stream.c"
#include "client_trans_stream.h"
#include "client_trans_udp_manager.h"
#include "softbus_adapter_mem.h"
#include "trans_server_proxy.h"
#include "client_trans_udp_manager.h"
#include "client_trans_stream.h"
#include "client_trans_stream.c"
using namespace testing::ext;
namespace OHOS {
@ -215,12 +216,14 @@ HWTEST_F(ClientTransStreamTest, TransSendStream001, TestSize.Level0)
*/
HWTEST_F(ClientTransStreamTest, TransOnstreamChannelOpened001, TestSize.Level0)
{
int ret = TransClientInit();
EXPECT_EQ(ret, SOFTBUS_OK);
ChannelInfo *channel = (ChannelInfo*)SoftBusMalloc(sizeof(ChannelInfo));
ASSERT_TRUE(channel != nullptr);
(void)memset_s(channel, sizeof(ChannelInfo), 0, sizeof(ChannelInfo));
int32_t streamPort = 2;
int32_t ret = TransOnstreamChannelOpened(NULL, &streamPort);
ret = TransOnstreamChannelOpened(NULL, &streamPort);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransOnstreamChannelOpened(channel, NULL);
@ -251,6 +254,7 @@ HWTEST_F(ClientTransStreamTest, TransOnstreamChannelOpened001, TestSize.Level0)
if (channel != nullptr) {
SoftBusFree(channel);
}
TransClientDeinit();
}
/**