1 /*
2 * Copyright (c) 2021 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
18 #include "net_trans_common.h"
19 #include "wifi_utils.h"
20
21 using namespace testing::ext;
22
23 class TransFuncTest : public testing::Test {
24 public:
25 // 测试套前置和后置操作
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28
29 // 测试用例前置和后置操作
30 void SetUp();
31 void TearDown();
32 };
33
SetUp()34 void TransFuncTest::SetUp() {}
35
TearDown()36 void TransFuncTest::TearDown() {}
37
SetUpTestCase()38 void TransFuncTest::SetUpTestCase()
39 {
40 LOG("SetUp begin");
41 AddPermission();
42 sleep(1);
43 system("pidof accesstoken_ser | xargs kill -9");
44 sleep(1);
45 TestSetUp();
46
47 int ret = RegisterDeviceStateDefCallback();
48 EXPECT_EQ(SOFTBUS_OK, ret) << "call reg node state callback fail";
49 ret = CheckRemoteDeviceIsNull(BOOL_TRUE);
50 ASSERT_EQ(SOFTBUS_OK, ret) << "get node fail,please check network";
51
52 LOG("SetUp end");
53 }
54
TearDownTestCase()55 void TransFuncTest::TearDownTestCase()
56 {
57 int ret = UnRegisterDeviceStateDefCallback();
58 EXPECT_EQ(SOFTBUS_OK, ret) << "call unReg node state callback fail";
59
60 TestTearDown();
61 }
62
63 /**
64 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0100
65 * @tc.name : SendByte Packet size 1B, send and receive successful
66 * @tc.desc : Test the SendByte specification
67 * @tc.type : FUNC
68 * @tc.size : MediumTest
69 */
70 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0100, TestSize.Level3)
71 {
72 int ret;
73 ret = CreateSsAndOpenSession4Data();
74 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
75
76 int size = 1;
77 ret = SendData4Data(DATA_TYPE_BYTE, size);
78 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
79
80 ret = CloseSessionAndRemoveSs4Data();
81 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
82 }
83
84 /**
85 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0200
86 * @tc.name : SendByte Packet size 2K, send and receive successful
87 * @tc.desc : Test the SendByte specification
88 * @tc.type : FUNC
89 * @tc.size : MediumTest
90 */
91 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0200, TestSize.Level3)
92 {
93 int ret;
94 ret = CreateSsAndOpenSession4Data();
95 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
96
97 int size = 2 * 1024 * 1024;
98 ret = SendData4Data(DATA_TYPE_BYTE, size);
99 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,2M) fail";
100
101 ret = CloseSessionAndRemoveSs4Data();
102 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
103 }
104
105 /**
106 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0300
107 * @tc.name : SendByte Packet size 4MB, send and receive successful
108 * @tc.desc : Test the SendByte specification
109 * @tc.type : FUNC
110 * @tc.size : MediumTest
111 */
112 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0300, TestSize.Level3)
113 {
114 int ret;
115 ret = CreateSsAndOpenSession4Data();
116 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
117
118 int size = TRANS_BYTES_LENGTH_MAX;
119 ret = SendData4Data(DATA_TYPE_BYTE, size);
120 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,Max) fail";
121
122 ret = CloseSessionAndRemoveSs4Data();
123 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
124 }
125
126 /**
127 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0400
128 * @tc.name : SendByte Packet size 0, send and receive failed
129 * @tc.desc : Test the SendByte specification
130 * @tc.type : FUNC
131 * @tc.size : MediumTest
132 */
133 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0400, TestSize.Level3)
134 {
135 int ret;
136 ret = CreateSsAndOpenSession4Data();
137 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
138
139 int size = 0;
140 string emptyStr = "";
141 int sessionId = GetCurrentSessionId4Data();
142 ret = SendBytes(sessionId, emptyStr.c_str(), size);
143 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
144
145 ret = CloseSessionAndRemoveSs4Data();
146 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
147 }
148
149 /**
150 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0500
151 * @tc.name : SendByte Packet size 4MB + 1, send and receive failed
152 * @tc.desc : Test the SendByte specification
153 * @tc.type : FUNC
154 * @tc.size : MediumTest
155 */
156 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0500, TestSize.Level3)
157 {
158 int ret;
159 ret = CreateSsAndOpenSession4Data();
160 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
161
162 int size = TRANS_BYTES_LENGTH_MAX + 1;
163 ret = SendData4Data(DATA_TYPE_BYTE, size);
164 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
165
166 ret = CloseSessionAndRemoveSs4Data();
167 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
168 }
169
170 /**
171 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0600
172 * @tc.name : SendByte Packet size 1B ,Proxy channel, send and receive successful
173 * @tc.desc : Test the SendByte specification
174 * @tc.type : FUNC
175 * @tc.size : MediumTest
176 */
177 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0600, TestSize.Level3)
178 {
179 int ret;
180 ret = CreateSsAndOpenSession4Proxy();
181 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
182
183 int size = 1;
184 ret = SendData4Message(DATA_TYPE_BYTE, size);
185 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
186
187 ret = CloseSessionAndRemoveSs4Proxy();
188 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
189 }
190
191 /**
192 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0700
193 * @tc.name : SendByte Packet size 2K, Proxy channel, send and receive successful
194 * @tc.desc : Test the SendByte specification
195 * @tc.type : FUNC
196 * @tc.size : MediumTest
197 */
198 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0700, TestSize.Level3)
199 {
200 int ret;
201 ret = CreateSsAndOpenSession4Proxy();
202 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
203
204 int size = 2 * 1024;
205 ret = SendData4Message(DATA_TYPE_BYTE, size);
206 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(byte,2M) fail";
207
208 ret = CloseSessionAndRemoveSs4Proxy();
209 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
210 }
211
212 /**
213 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_0900
214 * @tc.name : SendByte Packet size 0, Proxy channel, send and receive failed
215 * @tc.desc : Test the SendByte specification
216 * @tc.type : FUNC
217 * @tc.size : MediumTest
218 */
219 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0900, TestSize.Level3)
220 {
221 int ret;
222 ret = CreateSsAndOpenSession4Proxy();
223 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
224
225 int size = 0;
226 string emptyStr = "";
227 int sessionId = GetCurrentSessionId4Proxy();
228 ret = SendBytes(sessionId, emptyStr.c_str(), size);
229 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
230
231 ret = CloseSessionAndRemoveSs4Proxy();
232 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
233 }
234
235 /**
236 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_1000
237 * @tc.name : SendByte Packet size 4k + 1, Proxy channel, send and receive failed
238 * @tc.desc : Test the SendByte specification
239 * @tc.type : FUNC
240 * @tc.size : MediumTest
241 */
242 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_1000, TestSize.Level3)
243 {
244 int ret;
245 ret = CreateSsAndOpenSession4Proxy();
246 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
247
248 int size = 4 * 1024 + 1;
249 ret = SendData4Message(DATA_TYPE_BYTE, size);
250 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
251
252 ret = CloseSessionAndRemoveSs4Proxy();
253 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
254 }
255
256 /**
257 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_1100
258 * @tc.name : SendByte Packet size Max by session Negotiate, send and receive failed
259 * @tc.desc : Test the SendByte specification
260 * @tc.type : FUNC
261 * @tc.size : MediumTest
262 */
263 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_1100, TestSize.Level3)
264 {
265 int ret;
266 ret = CreateSsAndOpenSession4Data();
267 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
268
269 int optionvalue = 0;
270 ret = GetSessionOption(GetCurrentSessionId4Data(), SESSION_OPTION_MAX_SENDBYTES_SIZE,
271 &optionvalue, sizeof(optionvalue));
272 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
273 LOG("GetSessionOption optionvalue = %d", optionvalue);
274 int size = optionvalue;
275 ret = SendData4Data(DATA_TYPE_BYTE, size);
276 EXPECT_EQ(SOFTBUS_OK, ret) << "call sendbytes(Max) fail";
277
278 ret = CloseSessionAndRemoveSs4Data();
279 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
280 }
281
282 /**
283 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_Fun_1200
284 * @tc.name : SendByte Packet size Max + 1 by session Negotiate, send and receive failed
285 * @tc.desc : Test the SendByte specification
286 * @tc.type : FUNC
287 * @tc.size : MediumTest
288 */
289 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_1200, TestSize.Level3)
290 {
291 int ret;
292 ret = CreateSsAndOpenSession4Data();
293 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
294
295 int optionvalue = 0;
296 ret = GetSessionOption(GetCurrentSessionId4Data(), SESSION_OPTION_MAX_SENDBYTES_SIZE,
297 &optionvalue, sizeof(optionvalue));
298 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
299 LOG("GetSessionOption optionvalue = %d", optionvalue);
300 int size = optionvalue + 1;
301 ret = SendData4Data(DATA_TYPE_BYTE, size);
302 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(Max + 1) fail";
303
304 ret = CloseSessionAndRemoveSs4Data();
305 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
306 }
307
308 /**
309 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0100
310 * @tc.name : SendMessage Packet size 1B, session type is TYPE_BYTES send and receive failed
311 * @tc.desc : Test the SendMessage specification
312 * @tc.type : FUNC
313 * @tc.size : MediumTest
314 */
315 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0100, TestSize.Level3)
316 {
317 int ret;
318 ret = CreateSsAndOpenSession4Data();
319 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
320
321 int size = 1;
322 ret = SendData4Data(DATA_TYPE_MSG, size);
323 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(msg, 1B) fail";
324
325 ret = CloseSessionAndRemoveSs4Data();
326 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
327 }
328
329 /**
330 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0200
331 * @tc.name : SendMessage Packet size 1K, session type is TYPE_BYTES send and receive failed
332 * @tc.desc : Test the SendMessage specification
333 * @tc.type : FUNC
334 * @tc.size : MediumTest
335 */
336 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0200, TestSize.Level3)
337 {
338 int ret;
339 ret = CreateSsAndOpenSession4Data();
340 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
341
342 int size = 1024;
343 ret = SendData4Data(DATA_TYPE_MSG, size);
344 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(msg,1K) fail";
345
346 ret = CloseSessionAndRemoveSs4Data();
347 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
348 }
349
350 /**
351 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0300
352 * @tc.name : SendMessage Packet size 4K, session type is TYPE_BYTES send and receive failed
353 * @tc.desc : Test the SendMessage specification
354 * @tc.type : FUNC
355 * @tc.size : MediumTest
356 */
357 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0300, TestSize.Level3)
358 {
359 int ret;
360 ret = CreateSsAndOpenSession4Data();
361 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
362
363 int size = TRANS_MESSAGE_LENGTH_MAX;
364 ret = SendData4Data(DATA_TYPE_MSG, size);
365 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(msg,Max) fail";
366
367 ret = CloseSessionAndRemoveSs4Data();
368 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
369 }
370
371 /**
372 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0400
373 * @tc.name : SendMessage Packet size 0, session type is TYPE_BYTES send and receive failed
374 * @tc.desc : Test the SendMessage specification
375 * @tc.type : FUNC
376 * @tc.size : MediumTest
377 */
378 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0400, TestSize.Level3)
379 {
380 int ret;
381 ret = CreateSsAndOpenSession4Data();
382 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
383
384 int size = 0;
385 string emptyStr = "";
386 int sessionId = GetCurrentSessionId4Data();
387 ret = SendMessage(sessionId, emptyStr.c_str(), size);
388 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(empty) fail";
389
390 ret = CloseSessionAndRemoveSs4Data();
391 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
392 }
393
394 /**
395 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0500
396 * @tc.name : SendMessage Packet size 4K+1, session type is TYPE_BYTES send and receive failed
397 * @tc.desc : Test the SendMessage specification
398 * @tc.type : FUNC
399 * @tc.size : MediumTest
400 */
401 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0500, TestSize.Level3)
402 {
403 int ret;
404 ret = CreateSsAndOpenSession4Data();
405 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
406
407 int size = TRANS_MESSAGE_LENGTH_MAX + 1;
408 char* dataMoreMax = (char*)malloc(size);
409 ASSERT_TRUE(dataMoreMax != NULL) << "malloc fail";
410
411 int sessionId = GetCurrentSessionId4Data();
412 ret = SendMessage(sessionId, &dataMoreMax, size);
413 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(Max+1) fail";
414
415 ret = CloseSessionAndRemoveSs4Data();
416 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
417 free(dataMoreMax);
418 }
419
420 /**
421 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0600
422 * @tc.name : SendMessage Packet size 1B, proxy channel, send and receive successful
423 * @tc.desc : Test the SendMessage specification
424 * @tc.type : FUNC
425 * @tc.size : MediumTest
426 */
427 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0600, TestSize.Level3)
428 {
429 int ret;
430 ret = CreateSsAndOpenSession4Proxy();
431 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
432
433 int size = 1;
434 ret = SendData4Message(DATA_TYPE_MSG, size);
435 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg, 1B) fail";
436
437 ret = CloseSessionAndRemoveSs4Proxy();
438 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
439 }
440
441 /**
442 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0700
443 * @tc.name : SendMessage Packet size 1K, proxy channel, send and receive successful
444 * @tc.desc : [G-DISTRIBUTED-0206]禁止修改传输的默认协议,新增或者变更默认传输协议必须通过协商机制来实现
445 * @tc.type : FUNC
446 * @tc.size : MediumTest
447 */
448 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0700, TestSize.Level3)
449 {
450 int ret;
451 ret = CreateSsAndOpenSession4Proxy();
452 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
453
454 int size = 1024;
455 ret = SendData4Message(DATA_TYPE_MSG, size);
456 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg,1K) fail";
457
458 ret = CloseSessionAndRemoveSs4Proxy();
459 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
460 }
461
462 /**
463 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_0900
464 * @tc.name : SendMessage Packet size 0, proxy channel, send and receive failed
465 * @tc.desc : Test the SendMessage specification
466 * @tc.type : FUNC
467 * @tc.size : MediumTest
468 */
469 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0900, TestSize.Level3)
470 {
471 int ret;
472 ret = CreateSsAndOpenSession4Proxy();
473 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
474
475 int size = 0;
476 string emptystr = "";
477 int sessionId = GetCurrentSessionId4Proxy();
478 ret = SendMessage(sessionId, emptystr.c_str(), size);
479 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(empty) fail";
480
481 ret = CloseSessionAndRemoveSs4Proxy();
482 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
483 }
484
485 /**
486 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_1000
487 * @tc.name : SendMessage Packet size 4kb +1, proxy channel, send and receive failed
488 * @tc.desc : Test the SendMessage specification
489 * @tc.type : FUNC
490 * @tc.size : MediumTest
491 */
492 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_1000, TestSize.Level3)
493 {
494 int ret;
495 ret = CreateSsAndOpenSession4Proxy();
496 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
497
498 int size = TRANS_PROXY_MESSAGE_LENGTH_MAX + 1;
499 ret = SendData4Message(DATA_TYPE_MSG, size);
500 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(Max+1) fail";
501
502 ret = CloseSessionAndRemoveSs4Proxy();
503 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
504 }
505
506 /**
507 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_1100
508 * @tc.name : SendMessage Packet size Max by session Negotiate, proxy channel, send and receive failed
509 * @tc.desc : Test the SendMessage specification
510 * @tc.type : FUNC
511 * @tc.size : MediumTest
512 */
513 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_1100, TestSize.Level3)
514 {
515 int ret;
516 ret = CreateSsAndOpenSession4Proxy();
517 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
518
519 int optionvalue = 0;
520 ret = GetSessionOption(GetCurrentSessionId4Proxy(), SESSION_OPTION_MAX_SENDMESSAGE_SIZE,
521 &optionvalue, sizeof(optionvalue));
522 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
523 LOG("GetSessionOption optionvalue = %d", optionvalue);
524 int size = optionvalue;
525 ret = SendData4Message(DATA_TYPE_MSG, size);
526 EXPECT_EQ(SOFTBUS_OK, ret) << "call sendmsg(Max) fail";
527
528 ret = CloseSessionAndRemoveSs4Proxy();
529 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
530 }
531
532 /**
533 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_Fun_1200
534 * @tc.name : SendMessage Packet size Max +1 by session Negotiate, proxy channel, send and receive failed
535 * @tc.desc : Test the SendMessage specification
536 * @tc.type : FUNC
537 * @tc.size : MediumTest
538 */
539 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_1200, TestSize.Level3)
540 {
541 int ret;
542 ret = CreateSsAndOpenSession4Proxy();
543 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
544
545 int optionvalue = 0;
546 ret = GetSessionOption(GetCurrentSessionId4Proxy(), SESSION_OPTION_MAX_SENDMESSAGE_SIZE,
547 &optionvalue, sizeof(optionvalue));
548 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
549 LOG("GetSessionOption optionvalue = %d", optionvalue);
550 int size = optionvalue + 1;
551 ret = SendData4Message(DATA_TYPE_MSG, size);
552 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(Max+1) fail";
553
554 ret = CloseSessionAndRemoveSs4Proxy();
555 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
556 }
557
558 /**
559 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0100
560 * @tc.name : SendByte By P2P Packet size 1B, send and receive successful
561 * @tc.desc : [G-DISTRIBUTED-0206]禁止修改传输的默认协议,新增或者变更默认传输协议必须通过协商机制来实现
562 * @tc.type : FUNC
563 * @tc.size : MediumTest
564 */
565 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0100, TestSize.Level3)
566 {
567 int ret;
568 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
569 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
570
571 ret = OpenSession4DataByP2p();
572 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
573
574 int size = 1;
575 ret = SendData4Data(DATA_TYPE_BYTE, size);
576 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
577
578 ret = CloseSessionAndRemoveSs4Data();
579 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
580 }
581
582 /**
583 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0200
584 * @tc.name : SendByte By P2P Packet size 2K, send and receive successful
585 * @tc.desc : Test the SendByte specification
586 * @tc.type : FUNC
587 * @tc.size : MediumTest
588 */
589 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0200, TestSize.Level3)
590 {
591 int ret;
592 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
593 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
594
595 ret = OpenSession4DataByP2p();
596 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
597
598 int size = 2 * 1024 * 1024;
599 ret = SendData4Data(DATA_TYPE_BYTE, size);
600 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,2M) fail";
601
602 ret = CloseSessionAndRemoveSs4Data();
603 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
604 }
605
606 /**
607 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0300
608 * @tc.name : SendByte By P2P Packet size 4MB, send and receive successful
609 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
610 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
611 * @tc.type : FUNC
612 * @tc.size : MediumTest
613 */
614 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0300, TestSize.Level3)
615 {
616 int ret;
617 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
618 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
619
620 ret = OpenSession4DataByP2p();
621 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
622
623 int size = TRANS_BYTES_LENGTH_MAX;
624 ret = SendData4Data(DATA_TYPE_BYTE, size);
625 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,Max) fail";
626
627 ret = CloseSessionAndRemoveSs4Data();
628 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
629 }
630
631 /**
632 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0400
633 * @tc.name : SendByte By P2P Packet size 0, send and receive failed
634 * @tc.desc : Test the SendByte specification
635 * @tc.type : FUNC
636 * @tc.size : MediumTest
637 */
638 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0400, TestSize.Level3)
639 {
640 int ret;
641 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
642 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
643
644 ret = OpenSession4DataByP2p();
645 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
646
647 int size = 0;
648 string emptyStr = "";
649 int sessionId = GetCurrentSessionId4Data();
650 ret = SendBytes(sessionId, emptyStr.c_str(), size);
651 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
652
653 ret = CloseSessionAndRemoveSs4Data();
654 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
655 }
656
657 /**
658 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0500
659 * @tc.name : SendByte By P2P Packet size 4MB + 1, send and receive failed
660 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
661 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
662 * @tc.type : FUNC
663 * @tc.size : MediumTest
664 */
665 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0500, TestSize.Level3)
666 {
667 int ret;
668 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
669 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
670
671 ret = OpenSession4DataByP2p();
672 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
673
674 int size = TRANS_BYTES_LENGTH_MAX + 1;
675 ret = SendData4Data(DATA_TYPE_BYTE, size);
676 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
677
678 ret = CloseSessionAndRemoveSs4Data();
679 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
680 }
681
682 /**
683 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0600
684 * @tc.name : SendByte By P2P Packet size 1B ,Proxy channel, send and receive failed
685 * @tc.desc : Test the SendByte specification
686 * @tc.type : FUNC
687 * @tc.size : MediumTest
688 */
689 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0600, TestSize.Level3)
690 {
691 int ret;
692 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
693 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
694
695 ret = OpenSession4ProxyByP2p();
696 ASSERT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
697
698 int size = 1;
699 ret = SendData4Message(DATA_TYPE_BYTE, size);
700 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
701
702 ret = CloseSessionAndRemoveSs4Proxy();
703 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
704 }
705
706 /**
707 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0700
708 * @tc.name : SendByte By P2P Packet size Max by session Negotiate, send and receive successful
709 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
710 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
711 * @tc.type : FUNC
712 * @tc.size : MediumTest
713 */
714 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0700, TestSize.Level3)
715 {
716 int ret;
717 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
718 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
719
720 ret = OpenSession4DataByP2p();
721 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
722
723 int optionvalue = 0;
724 ret = GetSessionOption(GetCurrentSessionId4Data(), SESSION_OPTION_MAX_SENDBYTES_SIZE,
725 &optionvalue, sizeof(optionvalue));
726 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
727 LOG("GetSessionOption optionvalue = %d", optionvalue);
728 int size = optionvalue;
729 ret = SendData4Data(DATA_TYPE_BYTE, size);
730 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,Max) fail";
731
732 ret = CloseSessionAndRemoveSs4Data();
733 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
734 }
735
736 /**
737 * @tc.number : SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0800
738 * @tc.name : SendByte By P2P Packet size Max + 1 by session Negotiate, send and receive failed
739 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
740 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
741 * @tc.type : FUNC
742 * @tc.size : MediumTest
743 */
744 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_P2P_Fun_0800, TestSize.Level3)
745 {
746 int ret;
747 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
748 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
749
750 ret = OpenSession4DataByP2p();
751 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
752
753 int optionvalue = 0;
754 ret = GetSessionOption(GetCurrentSessionId4Data(), SESSION_OPTION_MAX_SENDBYTES_SIZE,
755 &optionvalue, sizeof(optionvalue));
756 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
757 LOG("GetSessionOption optionvalue = %d", optionvalue);
758 int size = optionvalue + 1;
759 ret = SendData4Data(DATA_TYPE_BYTE, size);
760 EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
761
762 ret = CloseSessionAndRemoveSs4Data();
763 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
764 }
765
766 /**
767 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0100
768 * @tc.name : SendMessage By P2P Packet size 1B, send and receive failed
769 * @tc.desc : Test the SendMessage specification
770 * @tc.type : FUNC
771 * @tc.size : MediumTest
772 */
773 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0100, TestSize.Level3)
774 {
775 int ret;
776 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
777 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
778
779 ret = OpenSession4DataByP2p();
780 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
781 int size = 1;
782 ret = SendData4Data(DATA_TYPE_MSG, size);
783 EXPECT_NE(SOFTBUS_OK, ret) << "SendData4Data(msg, 1B) fail";
784
785 ret = CloseSessionAndRemoveSs4Data();
786 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
787 }
788
789 /**
790 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0200
791 * @tc.name : SendMessage Packet size 1B, proxy channel, send and receive successful
792 * @tc.desc : Test the SendMessage specification
793 * @tc.type : FUNC
794 * @tc.size : MediumTest
795 */
796 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0200, TestSize.Level3)
797 {
798 int ret;
799 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
800 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
801
802 ret = OpenSession4ProxyByP2p();
803 EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
804
805 int size = 1;
806 ret = SendData4Message(DATA_TYPE_MSG, size);
807 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg, 1B) fail";
808
809 ret = CloseSessionAndRemoveSs4Proxy();
810 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
811 }
812
813 /**
814 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0300
815 * @tc.name : SendMessage Packet size 1K, proxy channel, send and receive successful
816 * @tc.desc : Test the SendMessage specification
817 * @tc.type : FUNC
818 * @tc.size : MediumTest
819 */
820 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0300, TestSize.Level3)
821 {
822 int ret;
823 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
824 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
825
826 ret = OpenSession4ProxyByP2p();
827 EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
828
829 int size = 1024;
830 ret = SendData4Message(DATA_TYPE_MSG, size);
831 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg,1K) fail";
832
833 ret = CloseSessionAndRemoveSs4Proxy();
834 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
835 }
836
837 /**
838 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0400
839 * @tc.name : SendMessage Packet size 4k, proxy channel, send and receive successful
840 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
841 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
842 * @tc.type : FUNC
843 * @tc.size : MediumTest
844 */
845 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0400, TestSize.Level3)
846 {
847 int ret;
848 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
849 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
850
851 ret = OpenSession4ProxyByP2p();
852 EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
853
854 int size = TRANS_PROXY_MESSAGE_LENGTH_MAX;
855 ret = SendData4Message(DATA_TYPE_MSG, size);
856 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg,Max) fail";
857
858 ret = CloseSessionAndRemoveSs4Proxy();
859 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
860 }
861
862 /**
863 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0500
864 * @tc.name : SendMessage Packet size 0, proxy channel, send and receive failed
865 * @tc.desc : Test the SendMessage specification
866 * @tc.type : FUNC
867 * @tc.size : MediumTest
868 */
869 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0500, TestSize.Level3)
870 {
871 int ret;
872 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
873 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
874
875 ret = OpenSession4ProxyByP2p();
876 ASSERT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
877
878 int size = 0;
879 string emptystr = "";
880 int sessionId = GetCurrentSessionId4Proxy();
881 ret = SendMessage(sessionId, emptystr.c_str(), size);
882 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(empty) fail";
883
884 ret = CloseSessionAndRemoveSs4Proxy();
885 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
886 }
887
888 /**
889 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0600
890 * @tc.name : SendMessage Packet size 4kb +1, proxy channel, send and receive failed
891 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
892 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
893 * @tc.type : FUNC
894 * @tc.size : MediumTest
895 */
896 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0600, TestSize.Level3)
897 {
898 int ret;
899 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
900 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
901
902 ret = OpenSession4ProxyByP2p();
903 ASSERT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
904
905 int size = 4 * TRANS_PROXY_MESSAGE_LENGTH_MAX + 1;
906 ret = SendData4Message(DATA_TYPE_MSG, size);
907 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(Max+1) fail";
908
909 ret = CloseSessionAndRemoveSs4Proxy();
910 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
911 }
912
913 /**
914 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0700
915 * @tc.name : SendMessage Packet size max by session Negotiate, proxy channel, send and receive successful
916 * @tc.desc : Test the SendMessage specification
917 * @tc.type : FUNC
918 * @tc.size : MediumTest
919 */
920 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0700, TestSize.Level3)
921 {
922 int ret;
923 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
924 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
925
926 ret = OpenSession4ProxyByP2p();
927 EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
928
929 int optionvalue = 0;
930 ret = GetSessionOption(GetCurrentSessionId4Proxy(), SESSION_OPTION_MAX_SENDMESSAGE_SIZE,
931 &optionvalue, sizeof(optionvalue));
932 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
933 LOG("GetSessionOption optionvalue = %d", optionvalue);
934 int size = optionvalue;
935 ret = SendData4Message(DATA_TYPE_MSG, size);
936 EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg,Max) fail";
937
938 ret = CloseSessionAndRemoveSs4Proxy();
939 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
940 }
941
942 /**
943 * @tc.number : SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0800
944 * @tc.name : SendMessage Packet size Max +1 by session Negotiate, proxy channel, send and receive failed
945 * @tc.desc : [G-DISTRIBUTED-0210] 使用消息传输接口,消息大小不超过4K字节,超过时需要业务对消息进行分包
946 * 处理,或者改为使用字节传输接口,字节传输可支持最大4M字节
947 * @tc.type : FUNC
948 * @tc.size : MediumTest
949 */
950 HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_P2P_Fun_0800, TestSize.Level3)
951 {
952 int ret;
953 ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, GetSessionListenser4Proxy());
954 ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss [Proxy] fail";
955
956 ret = OpenSession4ProxyByP2p();
957 ASSERT_EQ(SOFTBUS_OK, ret) << "OpenSession Proxy fail";
958
959 int optionvalue = 0;
960 ret = GetSessionOption(GetCurrentSessionId4Proxy(), SESSION_OPTION_MAX_SENDMESSAGE_SIZE,
961 &optionvalue, sizeof(optionvalue));
962 EXPECT_EQ(SOFTBUS_OK, ret) << "GetSessionOption fail";
963 LOG("GetSessionOption optionvalue = %d", optionvalue);
964 int size = optionvalue + 1;
965 ret = SendData4Message(DATA_TYPE_MSG, size);
966 EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(Max+1) fail";
967
968 ret = CloseSessionAndRemoveSs4Proxy();
969 EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
970 }