• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "securec.h"
18 #include "softbus_def.h"
19 #include "softbus_errcode.h"
20 #include "session.h"
21 #include "trans_udp_channel_manager.h"
22 #include "client_trans_session_callback.h"
23 #include "client_trans_udp_manager.c"
24 
25 using namespace std;
26 using namespace testing::ext;
27 
28 const char *g_sessionName = "ohos.distributedschedule.dms.test";
29 const char *g_networkid = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00";
30 const char *g_groupid = "TEST_GROUP_ID";
31 
32 namespace OHOS {
33 #define TEST_CHANNELID 5
34 #define TEST_SESSIONID 1
35 #define TEST_COUNT 2
36 #define STREAM_DATA_LENGTH 10
37 #define TEST_EVENT_ID 2
38 class ClientTransUdpManagerStaticTest : public testing::Test {
39 public:
ClientTransUdpManagerStaticTest()40     ClientTransUdpManagerStaticTest() {}
~ClientTransUdpManagerStaticTest()41     ~ClientTransUdpManagerStaticTest() {}
42     static void SetUpTestCase(void);
43     static void TearDownTestCase(void);
SetUp()44     void SetUp() override {}
TearDown()45     void TearDown() override {}
46 };
47 
SetUpTestCase(void)48 void ClientTransUdpManagerStaticTest::SetUpTestCase(void) {}
49 
TearDownTestCase(void)50 void ClientTransUdpManagerStaticTest::TearDownTestCase(void) {}
51 
52 /**
53  * @tc.name: ClientTransUdpManagerStaticTest001
54  * @tc.desc: client trans udp manager static test, use the wrong or normal parameter.
55  * @tc.type: FUNC
56  * @tc.require:
57  */
58 HWTEST_F(ClientTransUdpManagerStaticTest, ClientTransUdpManagerStaticTest001, TestSize.Level0)
59 {
60     int32_t ret;
61     char sendStringData[STREAM_DATA_LENGTH] = "diudiudiu";
62     StreamData tmpData = {
63         sendStringData,
64         STREAM_DATA_LENGTH,
65     };
66     char str[STREAM_DATA_LENGTH] = "oohoohooh";
67     StreamData tmpData2 = {
68         str,
69         STREAM_DATA_LENGTH,
70     };
71 
72     StreamFrameInfo tmpf = {};
73     int32_t sessionId = 0;
74     QosTv tvList;
75     OnStreamReceived(TEST_CHANNELID, &tmpData, &tmpData2, &tmpf);
76 
77     ret = OnFileGetSessionId(TEST_CHANNELID, &sessionId);
78     EXPECT_EQ(SOFTBUS_ERR, ret);
79 
80     OnUdpChannelOpened(TEST_CHANNELID);
81     OnUdpChannelClosed(TEST_CHANNELID);
82     OnQosEvent(TEST_CHANNELID, TEST_EVENT_ID, TEST_COUNT, &tvList);
83 
84     ret = TransDeleteUdpChannel(TEST_CHANNELID);
85     EXPECT_EQ(SOFTBUS_ERR, ret);
86 
87     UdpChannel channel;
88     ret = TransGetUdpChannel(TEST_CHANNELID, &channel);
89     EXPECT_EQ(SOFTBUS_ERR, ret);
90 }
91 } // namespace OHOS