1 /*
2  * Copyright (c) 2024 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 #include <cstring>
16 #include <gtest/gtest.h>
17 #include <securec.h>
18 
19 #include "softbus_common.h"
20 #include "client_bus_center_manager.c"
21 
22 namespace OHOS {
23 using namespace testing::ext;
24 
25 
26 class ClientBusMangerTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase()34 void ClientBusMangerTest::SetUpTestCase()
35 {
36 }
37 
TearDownTestCase()38 void ClientBusMangerTest::TearDownTestCase()
39 {
40 }
41 
SetUp()42 void ClientBusMangerTest::SetUp()
43 {
44     BusCenterClientInit();
45 }
46 
TearDown()47 void ClientBusMangerTest::TearDown()
48 {
49 }
50 
51 /*
52 * @tc.name: IS_SAME_CONNECTION_ADDR_Test_001
53 * @tc.desc: PreLink lane test
54 * @tc.type: FUNC
55 * @tc.require: AR000FN5VC
56 */
57 HWTEST_F(ClientBusMangerTest, IS_SAME_CONNECTION_ADDR_Test_001, TestSize.Level1)
58 {
59     const ConnectionAddr addr1 = {
60         .type = CONNECTION_ADDR_MAX,
61         .info.session.sessionId = 1,
62     };
63     const ConnectionAddr addr2 = {
64         .type = CONNECTION_ADDR_SESSION,
65         .info.session.sessionId = 2,
66     };
67     int32_t ret = IsSameConnectionAddr(&addr1, &addr2);
68     EXPECT_EQ(ret, false);
69 }
70 
71 /*
72 * @tc.name: IS_SAME_CONNECTION_ADDR_Test_002
73 * @tc.desc: PreLink lane test
74 * @tc.type: FUNC
75 * @tc.require: AR000FN5VC
76 */
77 HWTEST_F(ClientBusMangerTest, IS_SAME_CONNECTION_ADDR_Test_002, TestSize.Level1)
78 {
79     const ConnectionAddr addr1 = {
80         .type = CONNECTION_ADDR_SESSION,
81         .info.session.sessionId = 1,
82     };
83     const ConnectionAddr addr2 = {
84         .type = CONNECTION_ADDR_SESSION,
85         .info.session.sessionId = 2,
86     };
87     int32_t ret = IsSameConnectionAddr(&addr1, &addr2);
88     EXPECT_EQ(ret, false);
89 }
90 
91 /*
92 * @tc.name: IS_SAME_CONNECTION_ADDR_Test_003
93 * @tc.desc: PreLink lane test
94 * @tc.type: FUNC
95 * @tc.require: AR000FN5VC
96 */
97 HWTEST_F(ClientBusMangerTest, IS_SAME_CONNECTION_ADDR_Test_003, TestSize.Level1)
98 {
99     const ConnectionAddr addr1 = {
100         .type = CONNECTION_ADDR_BR,
101         .info.br.brMac = 1,
102     };
103     const ConnectionAddr addr2 = {
104         .type = CONNECTION_ADDR_BR,
105         .info.br.brMac = 2,
106     };
107     int32_t ret = IsSameConnectionAddr(&addr1, &addr2);
108     EXPECT_EQ(ret, false);
109 }
110 
111 /*
112 * @tc.name: IS_SAME_CONNECTION_ADDR_Test_004
113 * @tc.desc: PreLink lane test
114 * @tc.type: FUNC
115 * @tc.require: AR000FN5VC
116 */
117 HWTEST_F(ClientBusMangerTest, IS_SAME_CONNECTION_ADDR_Test_004, TestSize.Level1)
118 {
119     const ConnectionAddr addr1 = {
120         .type = CONNECTION_ADDR_WLAN,
121         .info.ip.port = 1,
122     };
123     const ConnectionAddr addr2 = {
124         .type = CONNECTION_ADDR_WLAN,
125         .info.ip.port = 2,
126     };
127     int32_t ret = IsSameConnectionAddr(&addr1, &addr2);
128     EXPECT_EQ(ret, false);
129 }
130 }
131