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
16 #include <gtest/gtest.h>
17 #include <securec.h>
18
19 #include "bus_center_server_proxy.h"
20 #include "softbus_access_token_test.h"
21 #include "softbus_bus_center.h"
22 #include "softbus_common.h"
23 #include "softbus_error_code.h"
24 #include "softbus_utils.h"
25
26 namespace OHOS {
27 using namespace testing::ext;
28
29 class BusCenterServerProxyTest : public testing::Test {
30 public:
31 static void SetUpTestCase();
32 static void TearDownTestCase();
33 void SetUp();
34 void TearDown();
35 };
36
SetUpTestCase()37 void BusCenterServerProxyTest::SetUpTestCase() { }
38
TearDownTestCase()39 void BusCenterServerProxyTest::TearDownTestCase() { }
40
SetUp()41 void BusCenterServerProxyTest::SetUp() { }
42
TearDown()43 void BusCenterServerProxyTest::TearDown() { }
44
45 /*
46 * @tc.name: ServerIpcGetAllOnlineNodeInfo_TEST_001
47 * @tc.desc: ServerIpcGetAllOnlineNodeInfo return value is equal to SOFTBUS_SERVER_NOT_INIT
48 * @tc.type: FUNC
49 * @tc.require:
50 */
51 HWTEST_F(BusCenterServerProxyTest, ServerIpcGetAllOnlineNodeInfo_TEST_001, TestSize.Level1)
52 {
53 const char *pkgName = "001";
54 void **info = nullptr;
55 uint32_t infoTypeLen = 0;
56 int32_t *infoNum = nullptr;
57 int32_t ret = ServerIpcGetAllOnlineNodeInfo(pkgName, info, infoTypeLen, infoNum);
58 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
59 }
60
61 /*
62 * @tc.name: ServerIpcGetLocalDeviceInfo_TEST_001
63 * @tc.desc: ServerIpcGetLocalDeviceInfo return value is equal to SOFTBUS_SERVER_NOT_INIT
64 * @tc.type: FUNC
65 * @tc.require:
66 */
67 HWTEST_F(BusCenterServerProxyTest, ServerIpcGetLocalDeviceInfo_TEST_001, TestSize.Level1)
68 {
69 const char *pkgName = "001";
70 void *info = nullptr;
71 uint32_t infoTypeLen = 0;
72 int32_t ret = ServerIpcGetLocalDeviceInfo(pkgName, info, infoTypeLen);
73 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
74 }
75
76 /*
77 * @tc.name: ServerIpcGetNodeKeyInfo_TEST_001
78 * @tc.desc: ServerIpcGetNodeKeyInfo return value is equal to SOFTBUS_SERVER_NOT_INIT
79 * @tc.type: FUNC
80 * @tc.require:
81 */
82 HWTEST_F(BusCenterServerProxyTest, ServerIpcGetNodeKeyInfo_TEST_001, TestSize.Level1)
83 {
84 const char *pkgName = "001";
85 const char *networkId = "123";
86 int32_t key = 1;
87 unsigned char array[10] = { 0 };
88 unsigned char *buf = array;
89 uint32_t len = 0;
90 int32_t ret = ServerIpcGetNodeKeyInfo(pkgName, networkId, key, buf, len);
91 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
92 }
93
94 /*
95 * @tc.name: ServerIpcSetNodeDataChangeFlag_TEST_001
96 * @tc.desc: ServerIpcSetNodeDataChangeFlag return value is equal to SOFTBUS_SERVER_NOT_INIT
97 * @tc.type: FUNC
98 * @tc.require:
99 */
100 HWTEST_F(BusCenterServerProxyTest, ServerIpcSetNodeDataChangeFlag_TEST_001, TestSize.Level1)
101 {
102 const char *pkgName = "001";
103 const char *networkId = "123";
104 uint16_t dataChangeFlag = 0;
105 int32_t ret = ServerIpcSetNodeDataChangeFlag(pkgName, networkId, dataChangeFlag);
106 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
107 }
108
109 /*
110 * @tc.name: ServerIpcRegDataLevelChangeCb_TEST_001
111 * @tc.desc: ServerIpcRegDataLevelChangeCb return value is equal to SOFTBUS_SERVER_NOT_INIT
112 * @tc.type: FUNC
113 * @tc.require:
114 */
115 HWTEST_F(BusCenterServerProxyTest, ServerIpcRegDataLevelChangeCb_TEST_001, TestSize.Level1)
116 {
117 const char *pkgName = "001";
118 int32_t ret = ServerIpcRegDataLevelChangeCb(pkgName);
119 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
120 }
121
122 /*
123 * @tc.name: ServerIpcUnregDataLevelChangeCb_TEST_001
124 * @tc.desc: ServerIpcUnregDataLevelChangeCb return value is equal to SOFTBUS_SERVER_NOT_INIT
125 * @tc.type: FUNC
126 * @tc.require:
127 */
128 HWTEST_F(BusCenterServerProxyTest, ServerIpcUnregDataLevelChangeCb_TEST_001, TestSize.Level1)
129 {
130 const char *pkgName = "001";
131 int32_t ret = ServerIpcUnregDataLevelChangeCb(pkgName);
132 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
133 }
134
135 /*
136 * @tc.name: ServerIpcJoinLNN_TEST_001
137 * @tc.desc: ServerIpcJoinLNN return value is equal to SOFTBUS_SERVER_NOT_INIT
138 * @tc.type: FUNC
139 * @tc.require:
140 */
141 HWTEST_F(BusCenterServerProxyTest, ServerIpcJoinLNN_TEST_001, TestSize.Level1)
142 {
143 const char *pkgName = "001";
144 void *addr = nullptr;
145 uint32_t addrTypeLen = 0;
146 int32_t ret = ServerIpcJoinLNN(pkgName, addr, addrTypeLen, false);
147 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
148 }
149
150 /*
151 * @tc.name: ServerIpcLeaveLNN_TEST_001
152 * @tc.desc: ServerIpcLeaveLNN return value is equal to SOFTBUS_SERVER_NOT_INIT
153 * @tc.type: FUNC
154 * @tc.require:
155 */
156 HWTEST_F(BusCenterServerProxyTest, ServerIpcLeaveLNN_TEST_001, TestSize.Level1)
157 {
158 const char *pkgName = "001";
159 const char *networkId = "123";
160 int32_t ret = ServerIpcLeaveLNN(pkgName, networkId);
161 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
162 }
163
164 /*
165 * @tc.name: ServerIpcStartTimeSync_TEST_001
166 * @tc.desc: ServerIpcStartTimeSync return value is equal to SOFTBUS_SERVER_NOT_INIT
167 * @tc.type: FUNC
168 * @tc.require:
169 */
170 HWTEST_F(BusCenterServerProxyTest, ServerIpcStartTimeSync_TEST_001, TestSize.Level1)
171 {
172 const char *pkgName = "001";
173 const char *targetNetworkId = "111";
174 int32_t accuracy = 1;
175 int32_t period = 1;
176 int32_t ret = ServerIpcStartTimeSync(pkgName, targetNetworkId, accuracy, period);
177 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
178 }
179
180 /*
181 * @tc.name: ServerIpcStopTimeSync_TEST_001
182 * @tc.desc: ServerIpcStopTimeSync return value is equal to SOFTBUS_SERVER_NOT_INIT
183 * @tc.type: FUNC
184 * @tc.require:
185 */
186 HWTEST_F(BusCenterServerProxyTest, ServerIpcStopTimeSync_TEST_001, TestSize.Level1)
187 {
188 const char *pkgName = "001";
189 const char *targetNetworkId = "1234";
190 int32_t ret = ServerIpcStopTimeSync(pkgName, targetNetworkId);
191 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
192 }
193
194 /*
195 * @tc.name: ServerIpcPublishLNN_TEST_001
196 * @tc.desc: ServerIpcPublishLNN return value is equal to SOFTBUS_SERVER_NOT_INIT
197 * @tc.type: FUNC
198 * @tc.require:
199 */
200 HWTEST_F(BusCenterServerProxyTest, ServerIpcPublishLNN_TEST_001, TestSize.Level1)
201 {
202 const char *pkgName = "001";
203 const PublishInfo *info = nullptr;
204 int32_t ret = ServerIpcPublishLNN(pkgName, info);
205 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
206 }
207
208 /*
209 * @tc.name: ServerIpcStopPublishLNN_TEST_001
210 * @tc.desc: ServerIpcStopPublishLNN return value is equal to SOFTBUS_SERVER_NOT_INIT
211 * @tc.type: FUNC
212 * @tc.require:
213 */
214 HWTEST_F(BusCenterServerProxyTest, ServerIpcStopPublishLNN_TEST_001, TestSize.Level1)
215 {
216 const char *pkgName = "001";
217 int32_t publishId = 123;
218 int32_t ret = ServerIpcStopPublishLNN(pkgName, publishId);
219 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
220 }
221
222 /*
223 * @tc.name: ServerIpcRefreshLNN_TEST_001
224 * @tc.desc: ServerIpcRefreshLNN return value is equal to SOFTBUS_SERVER_NOT_INIT
225 * @tc.type: FUNC
226 * @tc.require:
227 */
228 HWTEST_F(BusCenterServerProxyTest, ServerIpcRefreshLNN_TEST_001, TestSize.Level1)
229 {
230 const char *pkgName = "001";
231 const SubscribeInfo *info = nullptr;
232 int32_t ret = ServerIpcRefreshLNN(pkgName, info);
233 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
234 }
235
236 /*
237 * @tc.name: ServerIpcStopRefreshLNN_TEST_001
238 * @tc.desc: ServerIpcStopRefreshLNN return value is equal to SOFTBUS_SERVER_NOT_INIT
239 * @tc.type: FUNC
240 * @tc.require:
241 */
242 HWTEST_F(BusCenterServerProxyTest, ServerIpcStopRefreshLNN_TEST_001, TestSize.Level1)
243 {
244 const char *pkgName = "001";
245 int32_t refreshId = 123;
246 int32_t ret = ServerIpcStopRefreshLNN(pkgName, refreshId);
247 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
248 }
249
250 /*
251 * @tc.name: ServerIpcActiveMetaNode_TEST_001
252 * @tc.desc: ServerIpcActiveMetaNode return value is equal to SOFTBUS_SERVER_NOT_INIT
253 * @tc.type: FUNC
254 * @tc.require:
255 */
256 HWTEST_F(BusCenterServerProxyTest, ServerIpcActiveMetaNode_TEST_001, TestSize.Level1)
257 {
258 const char *pkgName = "001";
259 const MetaNodeConfigInfo *info = nullptr;
260 char testtId = 'a';
261 char *metaNodeId = &testtId;
262 int32_t ret = ServerIpcActiveMetaNode(pkgName, info, metaNodeId);
263 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
264 }
265
266 /*
267 * @tc.name: ServerIpcDeactiveMetaNode_TEST_001
268 * @tc.desc: ServerIpcDeactiveMetaNode return value is equal to SOFTBUS_SERVER_NOT_INIT
269 * @tc.type: FUNC
270 * @tc.require:
271 */
272 HWTEST_F(BusCenterServerProxyTest, ServerIpcDeactiveMetaNode_TEST_001, TestSize.Level1)
273 {
274 const char *pkgName = "001";
275 const char *metaNodeId = "123";
276 int32_t ret = ServerIpcDeactiveMetaNode(pkgName, metaNodeId);
277 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
278 }
279
280 /*
281 * @tc.name: ServerIpcGetAllMetaNodeInfo_TEST_001
282 * @tc.desc: ServerIpcGetAllMetaNodeInfo return value is equal to SOFTBUS_SERVER_NOT_INIT
283 * @tc.type: FUNC
284 * @tc.require:
285 */
286 HWTEST_F(BusCenterServerProxyTest, ServerIpcGetAllMetaNodeInfo_TEST_001, TestSize.Level1)
287 {
288 const char *pkgName = "001";
289 MetaNodeInfo *infos = nullptr;
290 int32_t testNum = 123;
291 int32_t *infoNum = &testNum;
292 int32_t ret = ServerIpcGetAllMetaNodeInfo(pkgName, infos, infoNum);
293 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
294 }
295
296 /*
297 * @tc.name: ServerIpcShiftLNNGear_TEST_001
298 * @tc.desc: ServerIpcShiftLNNGear return value is equal to SOFTBUS_SERVER_NOT_INIT
299 * @tc.type: FUNC
300 * @tc.require:
301 */
302 HWTEST_F(BusCenterServerProxyTest, ServerIpcShiftLNNGear_TEST_001, TestSize.Level1)
303 {
304 const char *pkgName = "001";
305 const char *callerId = "123";
306 const char *targetNetworkId = "111";
307 const GearMode *mode = nullptr;
308 int32_t ret = ServerIpcShiftLNNGear(pkgName, callerId, targetNetworkId, mode);
309 EXPECT_EQ(ret, SOFTBUS_SERVER_NOT_INIT);
310 }
311
312 /*
313 * @tc.name: ServerIpcSyncTrustedRelationShip_TEST_001
314 * @tc.desc: ServerIpcSyncTrustedRelationShip return value is equal to SOFTBUS_TRANS_PROXY_REMOTE_NULL
315 * @tc.type: FUNC
316 * @tc.require:
317 */
318 HWTEST_F(BusCenterServerProxyTest, ServerIpcSyncTrustedRelationShip_TEST_001, TestSize.Level1)
319 {
320 const char *pkgName = "001";
321 const char *msg = "123";
322 uint32_t msgLen = 123;
323 int32_t ret = ServerIpcSyncTrustedRelationShip(pkgName, msg, msgLen);
324 EXPECT_EQ(ret, SOFTBUS_TRANS_PROXY_REMOTE_NULL);
325 }
326
327 } // namespace OHOS
328