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