Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
82dd9fee
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
82dd9fee
编写于
2月 12, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1869 新增L0设备dsoftbus北向接口xts用例,更新元能力和包管理xts测试用例
Merge pull request !1869 from 温藤野/master
上级
3fddfae2
749427d9
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
1707 addition
and
0 deletion
+1707
-0
aafwk_lite/ability_hal/src/ability_mgr_test.c
aafwk_lite/ability_hal/src/ability_mgr_test.c
+46
-0
appexecfwk_lite/appexecfwk_hal/BUILD.gn
appexecfwk_lite/appexecfwk_hal/BUILD.gn
+1
-0
appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c
appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c
+116
-0
build_lite/BUILD.gn
build_lite/BUILD.gn
+1
-0
communication_lite/dsoftbus_hal/BUILD.gn
communication_lite/dsoftbus_hal/BUILD.gn
+33
-0
communication_lite/dsoftbus_hal/Test.tmpl
communication_lite/dsoftbus_hal/Test.tmpl
+19
-0
communication_lite/dsoftbus_hal/src/discovery_service_test.c
communication_lite/dsoftbus_hal/src/discovery_service_test.c
+437
-0
communication_lite/dsoftbus_hal/src/session_test.c
communication_lite/dsoftbus_hal/src/session_test.c
+518
-0
communication_lite/dsoftbus_hal/src/softbus_bus_center_test.c
...unication_lite/dsoftbus_hal/src/softbus_bus_center_test.c
+536
-0
未找到文件。
aafwk_lite/ability_hal/src/ability_mgr_test.c
浏览文件 @
82dd9fee
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "ability_manager.h"
#include "ability_manager.h"
#include "want.h"
#include "want.h"
static
int32_t
g_errorCode
=
-
1
;
/**
/**
* @brief register a test suit named AbilityMgrTestSuite
* @brief register a test suit named AbilityMgrTestSuite
...
@@ -191,4 +192,49 @@ LITE_TEST_CASE(AbilityMgrTestSuite, testSetWantDateIllegal, Function | MediumTes
...
@@ -191,4 +192,49 @@ LITE_TEST_CASE(AbilityMgrTestSuite, testSetWantDateIllegal, Function | MediumTes
printf
(
"------end testSetWantDateIllegal------
\n
"
);
printf
(
"------end testSetWantDateIllegal------
\n
"
);
}
}
/**
* @tc.number : SUB_AAFWK_ABILITY_0008
* @tc.name : testStartAbility parameter illegal test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
AbilityMgrTestSuite
,
testStartAbilityIllegal
,
Function
|
MediumTest
|
Level2
)
{
printf
(
"------start testStartAbilityIllegal------
\n
"
);
int
result
=
StartAbility
(
NULL
);
printf
(
"ret is %d
\n
"
,
result
);
int
expect
=
8
;
TEST_ASSERT_TRUE
(
result
==
expect
);
printf
(
"------end testStartAbilityIllegal------
\n
"
);
}
/**
* @tc.number : SUB_AAFWK_ABILITY_0008
* @tc.name : testSetIntParam parameter illegal test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
AbilityMgrTestSuite
,
testSetIntParamIllegal
,
Function
|
MediumTest
|
Level2
)
{
printf
(
"------start testSetIntParamIllegal------
\n
"
);
int
result
=
SetIntParam
(
NULL
,
NULL
,
0
,
0
);
printf
(
"ret is %d
\n
"
,
result
);
int
expect
=
0
;
TEST_ASSERT_TRUE
(
result
==
expect
);
printf
(
"------end testSetIntParamIllegal------
\n
"
);
}
/**
* @tc.number : SUB_AAFWK_ABILITY_0009
* @tc.name : testSetStrParam parameter illegal test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
AbilityMgrTestSuite
,
testSetStrParamIllegal
,
Function
|
MediumTest
|
Level2
)
{
printf
(
"------start testSetStrParamIllegal------
\n
"
);
int
result
=
SetStrParam
(
NULL
,
NULL
,
0
,
NULL
,
0
);
printf
(
"ret is %d
\n
"
,
result
);
int
expect
=
0
;
TEST_ASSERT_TRUE
(
result
==
expect
);
printf
(
"------end testSetStrParamIllegal------
\n
"
);
}
RUN_TEST_SUITE
(
AbilityMgrTestSuite
);
RUN_TEST_SUITE
(
AbilityMgrTestSuite
);
appexecfwk_lite/appexecfwk_hal/BUILD.gn
浏览文件 @
82dd9fee
...
@@ -18,6 +18,7 @@ hctest_suite("ActsBundleMgrTest") {
...
@@ -18,6 +18,7 @@ hctest_suite("ActsBundleMgrTest") {
include_dirs = [
include_dirs = [
"${aafwk_lite_path}/interfaces/kits/want_lite",
"${aafwk_lite_path}/interfaces/kits/want_lite",
"${appexecfwk_lite_path}/interfaces/kits/bundle_lite/slite",
"${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
"${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
]
]
cflags = [ "-Wno-error" ]
cflags = [ "-Wno-error" ]
...
...
appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c
浏览文件 @
82dd9fee
...
@@ -196,4 +196,120 @@ LITE_TEST_CASE(BundleMgrTestSuite, testSetElementDeviceIDIllegal, Function | Med
...
@@ -196,4 +196,120 @@ LITE_TEST_CASE(BundleMgrTestSuite, testSetElementDeviceIDIllegal, Function | Med
printf
(
"------end testSetElementDeviceIDIllegal------
\n
"
);
printf
(
"------end testSetElementDeviceIDIllegal------
\n
"
);
}
}
/**
* @tc.number : SUB_APPEXECFWK_0009
* @tc.name : ClearAbilityInfo parameter legal test with module info
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BundleMgrTestSuite
,
testClearModuleInfoIllegal
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"------start testClearModuleInfoIllegal------
\n
"
);
ModuleInfo
moduleInfo
=
{
0
};
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
moduleInfo
.
moduleName
=
"test"
;
ClearModuleInfo
(
NULL
);
TEST_ASSERT_EQUAL_STRING
(
moduleInfo
.
moduleName
,
"test"
);
printf
(
"------end testClearModuleInfoIllegal------
\n
"
);
}
/**
* @tc.number : SUB_APPEXECFWK_0010
* @tc.name : GetBundleInfo parameter legal test.
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BundleMgrTestSuite
,
testGetBundleInfoRight
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"------start testGetBundleInfoRight------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
const
char
*
bundleName
=
"com.openharmony.testjsdemo"
;
int32_t
flags
=
0
;
printf
(
"bundleName is %s
\n
"
,
bundleName
);
sleep
(
2
);
uint8_t
ret
=
GetBundleInfo
(
bundleName
,
flags
,
&
bundleInfo
);
printf
(
"getBundleInfo ret is %d
\n
"
,
ret
);
TEST_ASSERT_EQUAL_STRING
(
bundleInfo
.
bundleName
,
NULL
);
TEST_ASSERT_TRUE
(
ret
==
2
);
flags
=
1
;
printf
(
"bundleName is %s
\n
"
,
bundleName
);
ret
=
GetBundleInfo
(
bundleName
,
flags
,
&
bundleInfo
);
sleep
(
2
);
printf
(
"getBundleInfo ret is %d
\n
"
,
ret
);
TEST_ASSERT_TRUE
(
ret
==
2
);
TEST_ASSERT_EQUAL_STRING
(
bundleInfo
.
bundleName
,
NULL
);
ClearBundleInfo
(
&
bundleInfo
);
printf
(
"------end testGetBundleInfoRight------
\n
"
);
}
/**
* @tc.number : SUB_APPEXECFWK_0011
* @tc.name : GetBundleInfo parameter illegal test.
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BundleMgrTestSuite
,
testGetBundleInfoIllegal
,
Function
|
MediumTest
|
Level2
)
{
printf
(
"------start testGetBundleInfoIllegal------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
const
char
*
bundleName
=
"com.openharmony.nothishap"
;
int32_t
flags
=
0
;
uint8_t
ret
=
GetBundleInfo
(
bundleName
,
flags
,
&
bundleInfo
);
TEST_ASSERT_TRUE
(
ret
==
2
);
ret
=
GetBundleInfo
(
NULL
,
flags
,
&
bundleInfo
);
printf
(
"abilityInfo2 is %d
\n
"
,
ret
);
TEST_ASSERT_TRUE
(
ret
==
1
);
ret
=
GetBundleInfo
(
""
,
flags
,
&
bundleInfo
);
TEST_ASSERT_TRUE
(
ret
==
2
);
ret
=
GetBundleInfo
(
"com.openharmony.testjsdemo"
,
2
,
&
bundleInfo
);
sleep
(
2
);
TEST_ASSERT_TRUE
(
ret
!=
1
);
printf
(
"------end testGetBundleInfoIllegal------
\n
"
);
}
/**
* @tc.number : SUB_APPEXECFWK_0012
* @tc.name : GetBundleInfos parameter legal test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BundleMgrTestSuite
,
testGetBundleInfosRight
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"------start testGetBundleInfosRight------
\n
"
);
BundleInfo
*
bundleInfos
=
NULL
;
int32_t
flags
=
0
;
int32_t
length
=
0
;
uint8_t
ret
=
GetBundleInfos
(
flags
,
&
bundleInfos
,
&
length
);
sleep
(
2
);
printf
(
"getBundleInfo ret is %d
\n
"
,
ret
);
TEST_ASSERT_TRUE
(
ret
==
2
);
flags
=
1
;
ret
=
GetBundleInfos
(
flags
,
&
bundleInfos
,
&
length
);
printf
(
"getBundleInfo ret is %d
\n
"
,
ret
);
sleep
(
2
);
TEST_ASSERT_TRUE
(
ret
==
2
);
free
(
bundleInfos
);
printf
(
"------end testGetBundleInfosRight------
\n
"
);
}
/**
* @tc.number : SUB_APPEXECFWK_0013
* @tc.name : GetBundleInfos parameter illegal test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BundleMgrTestSuite
,
testGetBundleInfosIllegal
,
Function
|
MediumTest
|
Level2
)
{
printf
(
"------start testGetBundleInfosIllegal------
\n
"
);
BundleInfo
*
bundleInfos
=
{
NULL
};
int32_t
*
length
=
NULL
;
int32_t
flags
=
0
;
uint8_t
ret
=
GetBundleInfos
(
flags
,
NULL
,
length
);
TEST_ASSERT_TRUE
(
ret
!=
2
);
ret
=
GetBundleInfos
(
flags
,
&
bundleInfos
,
NULL
);
printf
(
"ret is %d
\n
"
,
ret
);
TEST_ASSERT_TRUE
(
ret
==
2
);
ret
=
GetBundleInfos
(
2
,
&
bundleInfos
,
length
);
printf
(
"ret is %d
\n
"
,
ret
);
TEST_ASSERT_TRUE
(
ret
==
2
);
printf
(
"------end testGetBundleInfosIllegal------
\n
"
);
}
RUN_TEST_SUITE
(
BundleMgrTestSuite
);
RUN_TEST_SUITE
(
BundleMgrTestSuite
);
build_lite/BUILD.gn
浏览文件 @
82dd9fee
...
@@ -32,6 +32,7 @@ lite_component("acts_component") {
...
@@ -32,6 +32,7 @@ lite_component("acts_component") {
} else {
} else {
if (ohos_kernel_type == "liteos_m") {
if (ohos_kernel_type == "liteos_m") {
all_features += [
all_features += [
"//test/xts/acts/communication_lite/dsoftbus_hal:ActsDsoftbusMgrTest",
"//test/xts/acts/aafwk_lite/ability_hal:ActsAbilityMgrTest",
"//test/xts/acts/aafwk_lite/ability_hal:ActsAbilityMgrTest",
"//test/xts/acts/appexecfwk_lite/appexecfwk_hal:ActsBundleMgrTest",
"//test/xts/acts/appexecfwk_lite/appexecfwk_hal:ActsBundleMgrTest",
"//test/xts/acts/communication_lite/lwip_hal:ActsLwipTest",
"//test/xts/acts/communication_lite/lwip_hal:ActsLwipTest",
...
...
communication_lite/dsoftbus_hal/BUILD.gn
0 → 100644
浏览文件 @
82dd9fee
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/lite/build/suite_lite.gni")
hctest_suite("ActsDsoftbusMgrTest") {
suite_name = "acts"
sources = [
"src/discovery_service_test.c",
"src/session_test.c",
"src/softbus_bus_center_test.c",
]
include_dirs = [
"//foundation/communication/dsoftbus/interfaces/kits/transport",
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
"//foundation/communication/dsoftbus/interfaces/kits/common",
"//foundation/communication/dsoftbus/core/common/include",
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
"//foundation/communication/dsoftbus/adapter/common/include",
"//foundation/communication/dsoftbus/adapter/default_config/spec_config",
]
cflags = [ "-Wno-error" ]
}
communication_lite/dsoftbus_hal/Test.tmpl
0 → 100644
浏览文件 @
82dd9fee
{
"description": "Config for $module test cases",
"environment": [
{
"type": "device",
"label": "wifiiot"
}
],
"kits": [
{
"type": "DeployKit",
"timeout": "20000",
"burn_file": "$subsystem/$module.bin"
}
],
"driver": {
"type": "CTestLite"
}
}
communication_lite/dsoftbus_hal/src/discovery_service_test.c
0 → 100644
浏览文件 @
82dd9fee
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include <unistd.h>
#include "hctest.h"
#include "securec.h"
#include "session.h"
#include "softbus_bus_center.h"
#include "softbus_errcode.h"
#include "discovery_service.h"
static
int
g_subscribeId
=
0
;
static
int
g_publishId
=
0
;
static
const
char
*
g_pkgName
=
"Softbus_Kits"
;
static
const
char
*
g_erroPkgName
=
"Softbus_Erro_Kits"
;
static
const
int32_t
ERRO_CAPDATA_LEN
=
514
;
static
int
GetSubscribeId
(
void
)
{
g_subscribeId
++
;
return
g_subscribeId
;
}
static
int
GetPublishId
(
void
)
{
g_publishId
++
;
return
g_publishId
;
}
static
SubscribeInfo
g_sInfo
=
{
.
subscribeId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
isSameAccount
=
true
,
.
isWakeRemote
=
false
,
.
capability
=
"dvKit"
,
.
capabilityData
=
(
unsigned
char
*
)
"capdata3"
,
.
dataLen
=
sizeof
(
"capdata3"
)
};
static
PublishInfo
g_pInfo
=
{
.
publishId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
capability
=
"dvKit"
,
.
capabilityData
=
(
unsigned
char
*
)
"capdata4"
,
.
dataLen
=
sizeof
(
"capdata4"
)
};
static
PublishInfo
g_pInfo1
=
{
.
publishId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
capability
=
"dvKit"
,
.
capabilityData
=
NULL
,
.
dataLen
=
0
};
static
SubscribeInfo
g_sInfo1
=
{
.
subscribeId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
isSameAccount
=
true
,
.
isWakeRemote
=
false
,
.
capability
=
"hicall"
,
.
capabilityData
=
NULL
,
.
dataLen
=
0
};
static
void
TestDeviceFound
(
void
)
{
printf
(
"[client]TestDeviceFound
\n
"
);
}
static
void
TestDiscoverFailed
(
void
)
{
printf
(
"[client]TestDiscoverFailed
\n
"
);
}
static
void
TestDiscoverySuccess
(
void
)
{
printf
(
"[client]TestDiscoverySuccess
\n
"
);
}
static
void
TestPublishSuccess
(
void
)
{
printf
(
"[client]TestPublishSuccess
\n
"
);
}
static
void
TestPublishFail
(
void
)
{
printf
(
"[client]TestPublishFail
\n
"
);
}
static
IDiscoveryCallback
g_subscribeCb
=
{
.
OnDeviceFound
=
TestDeviceFound
,
.
OnDiscoverFailed
=
TestDiscoverFailed
,
.
OnDiscoverySuccess
=
TestDiscoverySuccess
};
static
IPublishCallback
g_publishCb
=
{
.
OnPublishSuccess
=
TestPublishSuccess
,
.
OnPublishFail
=
TestPublishFail
};
LITE_TEST_SUIT
(
dsoftbus
,
discoveryservice
,
DiscoveryServiceTestSuite
);
static
BOOL
DiscoveryServiceTestSuiteSetUp
(
void
)
{
printf
(
"----------test case with DiscoveryServiceTestSuite start-------------
\n
"
);
return
TRUE
;
}
static
BOOL
DiscoveryServiceTestSuiteTearDown
(
void
)
{
printf
(
"----------test case with DiscoveryServiceTestSuite end-------------
\n
"
);
return
TRUE
;
}
/**
* @tc.name: PublishServiceTest001
* @tc.desc: Verify wrong parameter
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
PublishServiceTest001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
PublishInfo
testInfo
=
{
.
publishId
=
GetPublishId
(),
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
capability
=
"dvKit"
,
.
capabilityData
=
(
unsigned
char
*
)
"capdata2"
,
.
dataLen
=
sizeof
(
"capdata2"
)
};
ret
=
PublishService
(
NULL
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
PublishService
(
g_pkgName
,
NULL
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
PublishService
(
g_pkgName
,
&
testInfo
,
NULL
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
medium
=
(
ExchanageMedium
)(
COAP
+
1
);
ret
=
PublishService
(
g_pkgName
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
medium
=
COAP
;
testInfo
.
mode
=
(
DiscoverMode
)(
DISCOVER_MODE_ACTIVE
+
1
);
ret
=
PublishService
(
g_pkgName
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
mode
=
DISCOVER_MODE_ACTIVE
;
testInfo
.
freq
=
(
ExchangeFreq
)(
SUPER_HIGH
+
1
);
ret
=
PublishService
(
g_pkgName
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
freq
=
LOW
;
testInfo
.
capabilityData
=
NULL
;
ret
=
PublishService
(
g_pkgName
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
capabilityData
=
(
unsigned
char
*
)
"capdata1"
;
testInfo
.
dataLen
=
ERRO_CAPDATA_LEN
;
ret
=
PublishService
(
g_pkgName
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
dataLen
=
sizeof
(
"capdata1"
);
ret
=
PublishService
(
g_erroPkgName
,
&
testInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
}
/**
* @tc.name: PublishServiceTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
PublishServiceTest002
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
g_pInfo
.
publishId
=
GetPublishId
();
ret
=
PublishService
(
g_pkgName
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
g_pInfo1
.
publishId
=
GetPublishId
();
ret
=
PublishService
(
g_pkgName
,
&
g_pInfo1
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: PublishServiceTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
PublishServiceTest003
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
g_pInfo
.
publishId
=
GetPublishId
();
ret
=
PublishService
(
g_pkgName
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: UnPublishServiceTest001
* @tc.desc: Verify wrong parameter
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
UnPublishServiceTest001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
tmpId
=
GetPublishId
();
g_pInfo
.
publishId
=
tmpId
;
PublishService
(
g_pkgName
,
&
g_pInfo
,
&
g_publishCb
);
ret
=
UnPublishService
(
NULL
,
tmpId
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
UnPublishService
(
g_erroPkgName
,
tmpId
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
}
/**
* @tc.name: UnPublishServiceTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
UnPublishServiceTest002
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
tmpId1
=
GetPublishId
();
int
tmpId2
=
GetPublishId
();
g_pInfo
.
publishId
=
tmpId1
;
PublishService
(
g_pkgName
,
&
g_pInfo
,
&
g_publishCb
);
g_pInfo1
.
publishId
=
tmpId2
;
PublishService
(
g_pkgName
,
&
g_pInfo1
,
&
g_publishCb
);
ret
=
UnPublishService
(
g_pkgName
,
tmpId1
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
ret
=
UnPublishService
(
g_pkgName
,
tmpId2
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: UnPublishServiceTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
UnPublishServiceTest003
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
tmpId
=
GetPublishId
();
g_pInfo
.
publishId
=
tmpId
;
PublishService
(
g_pkgName
,
&
g_pInfo
,
&
g_publishCb
);
ret
=
UnPublishService
(
g_pkgName
,
tmpId
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: StartDiscoveryTest001
* @tc.desc: Verify wrong parameter
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
StartDiscoveryTest001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
SubscribeInfo
testInfo
=
{
.
subscribeId
=
GetSubscribeId
(),
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
isSameAccount
=
true
,
.
isWakeRemote
=
false
,
.
capability
=
"dvKit"
,
.
capabilityData
=
(
unsigned
char
*
)
"capdata3"
,
.
dataLen
=
sizeof
(
"capdata3"
)
};
ret
=
StartDiscovery
(
NULL
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
StartDiscovery
(
g_erroPkgName
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
StartDiscovery
(
g_pkgName
,
NULL
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
StartDiscovery
(
g_pkgName
,
&
testInfo
,
NULL
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
medium
=
(
ExchanageMedium
)(
COAP
+
1
);
ret
=
StartDiscovery
(
g_pkgName
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
medium
=
COAP
;
testInfo
.
mode
=
(
DiscoverMode
)(
DISCOVER_MODE_ACTIVE
+
1
);
ret
=
StartDiscovery
(
g_pkgName
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
mode
=
DISCOVER_MODE_ACTIVE
;
testInfo
.
freq
=
(
ExchangeFreq
)(
SUPER_HIGH
+
1
);
ret
=
StartDiscovery
(
g_pkgName
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
freq
=
LOW
;
testInfo
.
capabilityData
=
NULL
;
ret
=
StartDiscovery
(
g_pkgName
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
capabilityData
=
(
unsigned
char
*
)
"capdata1"
;
testInfo
.
dataLen
=
ERRO_CAPDATA_LEN
;
ret
=
StartDiscovery
(
g_pkgName
,
&
testInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
testInfo
.
dataLen
=
sizeof
(
"capdata1"
);
}
/**
* @tc.name: StartDiscoveryTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
StartDiscoveryTest002
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
g_sInfo
.
subscribeId
=
GetSubscribeId
();
ret
=
StartDiscovery
(
g_pkgName
,
&
g_sInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
g_sInfo1
.
subscribeId
=
GetSubscribeId
();
ret
=
StartDiscovery
(
g_pkgName
,
&
g_sInfo1
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: StartDiscoveryTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
StartDiscoveryTest003
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
g_sInfo
.
subscribeId
=
GetSubscribeId
();
ret
=
StartDiscovery
(
g_pkgName
,
&
g_sInfo
,
&
g_subscribeCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: StopDiscoveryTest001
* @tc.desc: Verify wrong parameter
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
StopDiscoveryTest001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
tmpId
=
GetSubscribeId
();
g_sInfo
.
subscribeId
=
tmpId
;
StartDiscovery
(
g_pkgName
,
&
g_sInfo
,
&
g_subscribeCb
);
ret
=
StopDiscovery
(
NULL
,
tmpId
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
StopDiscovery
(
g_erroPkgName
,
tmpId
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
}
/**
* @tc.name: StopDiscoveryTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
StopDiscoveryTest002
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
tmpId1
=
GetSubscribeId
();
int
tmpId2
=
GetSubscribeId
();
g_sInfo
.
subscribeId
=
tmpId1
;
StartDiscovery
(
g_pkgName
,
&
g_sInfo
,
&
g_subscribeCb
);
g_sInfo1
.
subscribeId
=
tmpId2
;
StartDiscovery
(
g_pkgName
,
&
g_sInfo1
,
&
g_subscribeCb
);
ret
=
StopDiscovery
(
g_pkgName
,
tmpId1
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
ret
=
StopDiscovery
(
g_pkgName
,
tmpId2
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
/**
* @tc.name: StopDiscoveryTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
DiscoveryServiceTestSuite
,
StopDiscoveryTest003
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
tmpId
=
GetSubscribeId
();
g_sInfo
.
subscribeId
=
tmpId
;
StartDiscovery
(
g_pkgName
,
&
g_sInfo
,
&
g_subscribeCb
);
ret
=
StopDiscovery
(
g_pkgName
,
tmpId
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_DISCOVER_MANAGER_NOT_INIT
);
}
RUN_TEST_SUITE
(
DiscoveryServiceTestSuite
);
\ No newline at end of file
communication_lite/dsoftbus_hal/src/session_test.c
0 → 100644
浏览文件 @
82dd9fee
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include <unistd.h>
#include "hctest.h"
#include "securec.h"
#include "session.h"
#include "softbus_def.h"
#include "softbus_config_type.h"
#include "softbus_bus_center.h"
#include "softbus_errcode.h"
#define TEST_PKG_NAME "com.softbus.test"
#define DEFAULT_NODE_STATE_CB_NUM 9
#define LOG2_DBG(fmt, ...) printf("DEBUG:%s:%s:%d " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOG2_INFO(fmt, ...) printf("INFO:%s:%d " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOG2_WARN(fmt, ...) printf("WARN:%s:%d " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOG2_ERR(fmt, ...) printf("ERROR:%s:%d " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
enum
StatusNum
{
TRANS_STATE_NONE
=
0
,
// 0
TRANS_STATE_INIT
,
// 1
TRANS_STATE_CREATE_SESSION_SERVER
,
// 2
TRANS_SET_FILE_SEND_LISTENER
,
// 3
TRANS_STATE_OPEN
,
// 4
TRANS_STATE_SEND_BYTE
,
// 5
TRANS_STATE_SEND_MESSAGE
,
// 6
TRANS_STATE_SEND_FILE
,
// 7
TRANS_STATE_CLOSE
,
// 8
TRANS_STATE_REMOVE_SESSION_SERVER
,
// 9
TRANS_STATE_CREATE_PHONE
=
10
,
// 10
TRANS_STATE_GET_SESSION_NAME
,
// 11
TRANS_STATE_GET_DEVICE_ID
,
// 12
TRANS_CLEAR_LOG
,
TRANS_TEST_FIN
,
LNN_STATE_JOINLNN
=
20
,
// 20
LNN_STATE_LEAVELNN
,
// 21
};
const
char
*
g_pkgName
=
"dms"
;
const
char
*
g_sessionName
=
"ohos.distributedschedule.dms.test"
;
const
char
*
g_networkid
=
"ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"
;
const
char
*
g_groupid
=
"TEST_GROUP_ID"
;
const
char
*
g_testModuleName
=
"com.plrdtest.dsoftbus"
;
const
char
*
g_testSessionName
=
"com.plrdtest.dsoftbus.JtOnOpenFileSession"
;
const
char
*
g_testSessionNamE2
=
"com.plrdtest.dsoftbus.JtOpenFileSession"
;
static
SessionAttribute
g_sessionAttr
=
{
.
dataType
=
TYPE_BYTES
,
};
const
int
FILE_NUM
=
4
;
int32_t
g_sessionId
=
-
1
;
int32_t
g_stateDebug
=
LNN_STATE_JOINLNN
;
static
void
TestChangeDebugState
(
int32_t
state
)
{
g_stateDebug
=
state
;
LOG2_INFO
(
"change to debug state: %d"
,
state
);
}
static
int
OnSendFileProcess
(
int
sessionId
,
uint64_t
bytesUpload
,
uint64_t
bytesTotal
)
{
LOG2_INFO
(
"OnSendFileProcess sessionId = %d, bytesUpload = %llu, total = %llu
\n
"
,
sessionId
,
bytesUpload
,
bytesTotal
);
return
0
;
}
static
int
OnSendFileFinished
(
int
sessionId
,
const
char
*
firstFile
)
{
LOG2_INFO
(
"OnSendFileFinished sessionId = %d, first file = %s
\n
"
,
sessionId
,
firstFile
);
TestChangeDebugState
(
TRANS_STATE_CLOSE
);
return
0
;
}
static
void
OnFileTransError
(
int
sessionId
)
{
LOG2_INFO
(
"OnFileTransError sessionId = %d
\n
"
,
sessionId
);
}
static
IFileSendListener
g_fileSendListener
=
{
.
OnSendFileProcess
=
OnSendFileProcess
,
.
OnSendFileFinished
=
OnSendFileFinished
,
.
OnFileTransError
=
OnFileTransError
,
};
static
ISessionListener
g_sessionlistener
=
{
.
OnSessionOpened
=
1
,
};
static
int
OnReceiveFileStarted
(
int
sessionId
,
const
char
*
files
,
int
fileCnt
)
{
LOG2_INFO
(
"File receive start sessionId = %d, first file = %s, fileCnt = %d
\n
"
,
sessionId
,
files
,
fileCnt
);
return
0
;
}
static
void
OnReceiveFileFinished
(
int
sessionId
,
const
char
*
files
,
int
fileCnt
)
{
LOG2_INFO
(
"File receive finished sessionId = %d, first file = %s, fileCnt = %d
\n
"
,
sessionId
,
files
,
fileCnt
);
}
static
IFileReceiveListener
g_fileRecvListener
=
{
.
OnReceiveFileStarted
=
OnReceiveFileStarted
,
.
OnReceiveFileFinished
=
OnReceiveFileFinished
,
.
OnFileTransError
=
OnFileTransError
,
};
LITE_TEST_SUIT
(
dsoftbus
,
session
,
SessionTestSuite
);
static
BOOL
SessionTestSuiteSetUp
(
void
)
{
printf
(
"----------test case with SessionTestSuite start-------------
\n
"
);
return
TRUE
;
}
static
BOOL
SessionTestSuiteTearDown
(
void
)
{
printf
(
"----------test case with SessionTestSuite end-------------
\n
"
);
return
TRUE
;
}
/**
* @tc.name: TestCreateSessionServer001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC99
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestCreateSessionServer001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
CreateSessionServer
(
NULL
,
g_sessionName
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
CreateSessionServer
(
g_pkgName
,
NULL
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
CreateSessionServer
(
g_pkgName
,
g_sessionName
,
NULL
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
CreateSessionServer
(
g_pkgName
,
g_sessionName
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
RemoveSessionServer
(
g_pkgName
,
g_sessionName
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
ret
);
}
/**
* @tc.name: TestCreateSessionServer002
* @tc.desc: extern module active publish, use the normal parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestCreateSessionServer002
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
CreateSessionServer
(
g_pkgName
,
g_sessionName
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
RemoveSessionServer
(
g_pkgName
,
g_sessionName
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
ret
);
}
/**
* @tc.name: TestCreateSessionServer003
* @tc.desc: extern module active publish, use the same normal parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestCreateSessionServer003
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
CreateSessionServer
(
g_pkgName
,
g_sessionName
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
CreateSessionServer
(
g_pkgName
,
g_sessionName
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
RemoveSessionServer
(
g_pkgName
,
g_sessionName
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
ret
);
}
/**
* @tc.name: TestCreateSessionServer004
* @tc.desc: extern module active publish, create 9 sessionServer, succ 8, failed at 9th.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestCreateSessionServer004
,
Function
|
MediumTest
|
Level0
)
{
int
ret
,
i
;
char
const
*
sessionName
[
MAX_SESSION_SERVER_NUMBER
+
1
]
=
{
"ohos.distributedschedule.dms.test0"
,
"ohos.distributedschedule.dms.test1"
,
"ohos.distributedschedule.dms.test2"
,
"ohos.distributedschedule.dms.test3"
,
"ohos.distributedschedule.dms.test4"
,
"ohos.distributedschedule.dms.test5"
,
"ohos.distributedschedule.dms.test6"
,
"ohos.distributedschedule.dms.test7"
,
"ohos.distributedschedule.dms.test8"
};
for
(
i
=
0
;
i
<
MAX_SESSION_SERVER_NUMBER
;
i
++
)
{
ret
=
CreateSessionServer
(
g_pkgName
,
sessionName
[
i
],
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
}
ret
=
CreateSessionServer
(
g_pkgName
,
sessionName
[
i
],
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
for
(
i
=
0
;
i
<
MAX_SESSION_SERVER_NUMBER
;
i
++
)
{
ret
=
RemoveSessionServer
(
g_pkgName
,
sessionName
[
i
]);
TEST_ASSERT_EQUAL_INT
(
-
1
,
ret
);
}
}
/**
* @tc.name: TestRemoveSessionServer001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestRemoveSessionServer001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
RemoveSessionServer
(
NULL
,
g_sessionName
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
RemoveSessionServer
(
g_pkgName
,
NULL
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
}
/**
* @tc.name: TestRemoveSessionServer002
* @tc.desc: extern module active publish, use the same parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestRemoveSessionServer002
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
CreateSessionServer
(
g_pkgName
,
g_sessionName
,
&
g_sessionlistener
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
RemoveSessionServer
(
g_pkgName
,
g_sessionName
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
ret
);
ret
=
RemoveSessionServer
(
g_pkgName
,
g_sessionName
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
ret
);
}
/**
* @tc.name: TestOpenSession001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestOpenSession001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
g_sessionAttr
.
dataType
=
TYPE_BYTES
;
ret
=
OpenSession
(
NULL
,
g_sessionName
,
g_networkid
,
g_groupid
,
&
g_sessionAttr
);
TEST_ASSERT_EQUAL_INT
(
INVALID_SESSION_ID
,
ret
);
ret
=
OpenSession
(
g_sessionName
,
NULL
,
g_networkid
,
g_groupid
,
&
g_sessionAttr
);
TEST_ASSERT_EQUAL_INT
(
INVALID_SESSION_ID
,
ret
);
ret
=
OpenSession
(
g_sessionName
,
g_sessionName
,
NULL
,
g_groupid
,
&
g_sessionAttr
);
TEST_ASSERT_EQUAL_INT
(
INVALID_SESSION_ID
,
ret
);
ret
=
OpenSession
(
g_sessionName
,
g_sessionName
,
g_networkid
,
NULL
,
&
g_sessionAttr
);
TEST_ASSERT_EQUAL_INT
(
INVALID_SESSION_ID
,
ret
);
ret
=
OpenSession
(
g_sessionName
,
g_sessionName
,
g_networkid
,
g_groupid
,
NULL
);
TEST_ASSERT_EQUAL_INT
(
INVALID_SESSION_ID
,
ret
);
g_sessionAttr
.
dataType
=
TYPE_BUTT
;
ret
=
OpenSession
(
g_sessionName
,
g_sessionName
,
g_networkid
,
g_groupid
,
&
g_sessionAttr
);
g_sessionAttr
.
dataType
=
TYPE_BYTES
;
TEST_ASSERT_EQUAL_INT
(
INVALID_SESSION_ID
,
ret
);
CloseSession
(
ret
);
}
/**
* @tc.name: TestSendBytes001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestSendBytes001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
sessionId
=
1
;
const
char
*
data
=
"testdata"
;
uint32_t
len
=
strlen
(
data
);
uint32_t
maxLen
;
ret
=
SendBytes
(
-
1
,
data
,
len
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_TRANS_INVALID_SESSION_ID
,
ret
);
ret
=
SendBytes
(
sessionId
,
NULL
,
len
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
SendBytes
(
sessionId
,
data
,
0
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
SoftbusGetConfig
(
SOFTBUS_INT_MAX_BYTES_LENGTH
,
(
unsigned
char
*
)
&
maxLen
,
sizeof
(
maxLen
));
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_OK
,
ret
);
ret
=
SendMessage
(
sessionId
,
data
,
maxLen
+
1
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
}
/**
* @tc.name: TestSendMessage001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestSendMessage001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
sessionId
=
1
;
const
char
*
data
=
"testdata"
;
uint32_t
len
=
strlen
(
data
);
uint32_t
maxLen
;
ret
=
SendMessage
(
-
1
,
data
,
len
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_TRANS_INVALID_SESSION_ID
,
ret
);
ret
=
SendMessage
(
sessionId
,
NULL
,
len
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
SendMessage
(
sessionId
,
data
,
0
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
SoftbusGetConfig
(
SOFTBUS_INT_MAX_MESSAGE_LENGTH
,
(
unsigned
char
*
)
&
maxLen
,
sizeof
(
maxLen
));
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_OK
,
ret
);
ret
=
SendMessage
(
sessionId
,
data
,
maxLen
+
1
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
}
/**
* @tc.name: TestSendStream001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestSendStream001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
sessionId
=
1
;
const
StreamData
streamData
=
{
0
};
const
StreamData
ext
=
{
0
};
const
StreamFrameInfo
param
=
{
0
};
ret
=
SendStream
(
-
1
,
&
streamData
,
&
ext
,
&
param
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_TRANS_INVALID_SESSION_ID
,
ret
);
ret
=
SendStream
(
sessionId
,
NULL
,
&
ext
,
&
param
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
SendStream
(
sessionId
,
&
streamData
,
NULL
,
&
param
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
ret
=
SendStream
(
sessionId
,
&
streamData
,
&
ext
,
NULL
);
TEST_ASSERT_EQUAL_INT
(
SOFTBUS_INVALID_PARAM
,
ret
);
}
/**
* @tc.name: TestQosReport00
* @tc.desc: test the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestQosReport001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
QosReport
(
1
,
1
,
QOS_IMPROVE
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
ret
=
QosReport
(
1
,
1
,
QOS_RECOVER
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
ret
=
QosReport
(
1
,
1
,
QOS_IMPROVE
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
}
/**
* @tc.name: TestSetFileSendListener001
* @tc.desc: test the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestSetFileSendListener001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
=
SetFileSendListener
(
g_testModuleName
,
g_testSessionName
,
NULL
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
SetFileSendListener
(
g_testModuleName
,
g_testSessionName
,
&
g_fileSendListener
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
}
/**
* @tc.name: TestSendFile001
* @tc.desc: test the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestSendFile001
,
Function
|
MediumTest
|
Level0
)
{
const
char
*
sfileList
[]
=
{
"/data/big.tar"
,
"/data/richu.jpg"
,
"/data/richu-002.jpg"
,
"/data/richu-003.jpg"
,
};
int
ret
=
SendFile
(
g_sessionId
,
NULL
,
NULL
,
FILE_NUM
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
SendFile
(
g_sessionId
,
sfileList
,
NULL
,
0
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
SendFile
(
g_sessionId
,
sfileList
,
NULL
,
FILE_NUM
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
}
/**
* @tc.name: TestSetFileReceiveListener001
* @tc.desc: test the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestSetFileReceiveListener001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
=
SetFileReceiveListener
(
g_testModuleName
,
g_testSessionNamE2
,
NULL
,
"/data/"
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
SetFileReceiveListener
(
g_testModuleName
,
g_testSessionNamE2
,
&
g_fileRecvListener
,
"/data/"
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
}
/**
* @tc.name: TestGetMySessionName
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestGetMySessionName001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
sessionId
;
int
len
=
5
;
g_sessionAttr
.
dataType
=
TYPE_BYTES
;
sessionId
=
OpenSession
(
g_sessionName
,
g_sessionName
,
g_networkid
,
g_groupid
,
&
g_sessionAttr
);
ret
=
GetMySessionName
(
sessionId
,
NULL
,
len
);
TEST_ASSERT_EQUAL_INT
(
ret
,
SOFTBUS_INVALID_PARAM
);
}
/**
* @tc.name: TestGetPeerSessionName001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestGetPeerSessionName001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
sessionId
;
int
len
=
5
;
g_sessionAttr
.
dataType
=
TYPE_BYTES
;
sessionId
=
OpenSession
(
g_sessionName
,
g_sessionName
,
g_networkid
,
g_groupid
,
&
g_sessionAttr
);
ret
=
GetPeerSessionName
(
sessionId
,
NULL
,
len
);
TEST_ASSERT_EQUAL_INT
(
ret
,
SOFTBUS_INVALID_PARAM
);
}
/**
* @tc.name: TestGetPeerDeviceId001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestGetPeerDeviceId001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
int
sessionId
;
int
len
=
5
;
g_sessionAttr
.
dataType
=
TYPE_BYTES
;
sessionId
=
OpenSession
(
g_sessionName
,
g_sessionName
,
g_networkid
,
g_groupid
,
&
g_sessionAttr
);
ret
=
GetPeerDeviceId
(
sessionId
,
NULL
,
len
);
TEST_ASSERT_EQUAL_INT
(
ret
,
SOFTBUS_INVALID_PARAM
);
}
/**
* @tc.name: TestGetSessionSide001
* @tc.desc: extern module active publish, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
SessionTestSuite
,
TestGetSessionSide001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
=
GetSessionSide
(
g_sessionId
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
}
RUN_TEST_SUITE
(
SessionTestSuite
);
\ No newline at end of file
communication_lite/dsoftbus_hal/src/softbus_bus_center_test.c
0 → 100644
浏览文件 @
82dd9fee
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include <unistd.h>
#include "hctest.h"
#include "securec.h"
#include "session.h"
#include "softbus_bus_center.h"
#include "softbus_errcode.h"
#define TEST_PKG_NAME "com.softbus.test"
#define DEFAULT_NODE_STATE_CB_NUM 9
#define ERRO_CAPDATA_LEN 514
#define DEFAULT_LOCAL_DEVICE_TYPE_ID 0
char
TEST_PKG_ERROR_NAME
[]
=
"com.softbus.error.test"
;
static
int32_t
g_subscribeId
=
0
;
static
int32_t
g_publishId
=
0
;
LITE_TEST_SUIT
(
dsoftbus
,
buscenter
,
BusCenterTestSuite
);
static
BOOL
BusCenterTestSuiteSetUp
(
void
)
{
printf
(
"----------test case with DsoftbusMgrTest start-------------
\n
"
);
return
TRUE
;
}
static
BOOL
BusCenterTestSuiteTearDown
(
void
)
{
printf
(
"----------test case with DsoftbusMgrTest end-------------
\n
"
);
return
TRUE
;
}
static
int32_t
GetPublishId
(
void
)
{
g_publishId
++
;
return
g_publishId
;
}
static
int32_t
GetSubscribeId
(
void
)
{
g_subscribeId
++
;
return
g_subscribeId
;
}
static
void
TestDeviceFound
(
const
DeviceInfo
*
device
)
{
printf
(
"[client]TestDeviceFound
\n
"
);
}
static
void
TestDiscoverResult
(
int32_t
refreshId
,
RefreshResult
reason
)
{
printf
(
"[client]TestDiscoverResult:%d
\n
"
,
reason
);
}
static
void
OnJoinLNNDone
(
ConnectionAddr
*
addr
,
const
char
*
networkId
,
int32_t
retCode
)
{
(
void
)
addr
;
(
void
)
networkId
;
(
void
)
retCode
;
}
static
void
OnLeaveLNNDone
(
const
char
*
networkId
,
int32_t
retCode
)
{
(
void
)
networkId
;
(
void
)
retCode
;
}
static
void
OnNodeOnline
(
NodeBasicInfo
*
info
)
{
(
void
)
info
;
}
static
INodeStateCb
g_nodeStateCb
=
{
.
events
=
EVENT_NODE_STATE_ONLINE
,
.
onNodeOnline
=
OnNodeOnline
,
};
static
void
TestPublishResult
(
int
publishId
,
PublishResult
reason
)
{
printf
(
"[client]TestPublishResult:%d
\n
"
,
reason
);
}
static
void
OnTimeSyncResult
(
const
TimeSyncResultInfo
*
info
,
int32_t
retCode
)
{
(
void
)
info
;
(
void
)
retCode
;
}
static
ITimeSyncCb
g_timeSyncCb
=
{
.
onTimeSyncResult
=
OnTimeSyncResult
,
};
static
PublishInfo
g_pInfo
=
{
.
publishId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
capability
=
"dvKit"
,
.
capabilityData
=
(
unsigned
char
*
)
"capdata4"
,
.
dataLen
=
sizeof
(
"capdata4"
)
};
static
PublishInfo
g_pInfo1
=
{
.
publishId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
capability
=
"dvKit"
,
.
capabilityData
=
NULL
,
.
dataLen
=
0
};
static
IPublishCb
g_publishCb
=
{
.
OnPublishResult
=
TestPublishResult
};
static
IRefreshCallback
g_refreshCb
=
{
.
OnDeviceFound
=
TestDeviceFound
,
.
OnDiscoverResult
=
TestDiscoverResult
};
static
SubscribeInfo
g_sInfo
=
{
.
subscribeId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
isSameAccount
=
true
,
.
isWakeRemote
=
false
,
.
capability
=
"dvKit"
,
.
capabilityData
=
(
unsigned
char
*
)
"capdata3"
,
.
dataLen
=
sizeof
(
"capdata3"
)
};
static
SubscribeInfo
g_sInfo1
=
{
.
subscribeId
=
1
,
.
mode
=
DISCOVER_MODE_ACTIVE
,
.
medium
=
COAP
,
.
freq
=
MID
,
.
isSameAccount
=
true
,
.
isWakeRemote
=
false
,
.
capability
=
"hicall"
,
.
capabilityData
=
NULL
,
.
dataLen
=
0
,
};
/**
* @tc.number : testJoinLNN0001
* @tc.name : parameter is NULL
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testJoinLNN0001
,
Function
|
MediumTest
|
Level0
)
{
printf
(
"------start testJoinLNN------
\n
"
);
ConnectionAddr
addr
;
int32_t
ret
=
JoinLNN
(
NULL
,
&
addr
,
OnJoinLNNDone
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
JoinLNN
(
TEST_PKG_NAME
,
NULL
,
OnJoinLNNDone
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
JoinLNN
(
TEST_PKG_NAME
,
&
addr
,
NULL
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
printf
(
"------end testJoinLNN------
\n
"
);
}
/**
* @tc.number : testLeaveLNN001
* @tc.name : bus center LeaveLNN interface exception test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testLeaveLNN001
,
Function
|
MediumTest
|
Level0
)
{
printf
(
"------start testLeaveLNN001------
\n
"
);
const
char
*
errNetIdLenMore
=
"012345678998765432100123456789987654321001234567899876543210abcde"
;
const
char
*
networkId
=
"0123456789987654321001234567899876543210012345678998765432100123"
;
BusCenterClientInit
();
int32_t
ret
=
LeaveLNN
(
NULL
,
OnLeaveLNNDone
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
LeaveLNN
(
networkId
,
NULL
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_INVALID_PARAM
);
ret
=
LeaveLNN
(
errNetIdLenMore
,
OnLeaveLNNDone
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
printf
(
"------end testLeaveLNN001------
\n
"
);
}
/*
* @tc.name: testRegNodeDeviceStateCb001
* @tc.desc: get all node info interface test
* @tc.type: FUNC
* @tc.require: AR000FK6J4
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testRegNodeDeviceStateCb001
,
Function
|
MediumTest
|
Level0
)
{
int32_t
ret
=
RegNodeDeviceStateCb
(
TEST_PKG_NAME
,
&
g_nodeStateCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_OK
);
ret
=
UnregNodeDeviceStateCb
(
&
g_nodeStateCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_OK
);
}
/*
* @tc.name: testRegNodeDeviceStateCb002
* @tc.desc: get all node info interface test
* @tc.type: FUNC
* @tc.require: AR000FK6J4
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testRegNodeDeviceStateCb002
,
Function
|
MediumTest
|
Level0
)
{
int32_t
i
;
int32_t
ret
=
0
;
for
(
i
=
0
;
i
<=
DEFAULT_NODE_STATE_CB_NUM
;
++
i
)
{
if
(
i
<
DEFAULT_NODE_STATE_CB_NUM
)
{
ret
=
RegNodeDeviceStateCb
(
TEST_PKG_NAME
,
&
g_nodeStateCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_OK
);
}
else
{
ret
=
RegNodeDeviceStateCb
(
TEST_PKG_NAME
,
&
g_nodeStateCb
);
TEST_ASSERT_TRUE
(
ret
!=
SOFTBUS_OK
);
}
}
for
(
i
=
0
;
i
<
DEFAULT_NODE_STATE_CB_NUM
;
++
i
)
{
ret
=
UnregNodeDeviceStateCb
(
&
g_nodeStateCb
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_OK
);
}
}
/*
* @tc.name: testGetAllNodeDeviceInfo001
* @tc.desc: get all node info interface test
* @tc.type: FUNC
* @tc.require: AR000FK6J4
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testGetAllNodeDeviceInfo001
,
Function
|
MediumTest
|
Level0
)
{
printf
(
"------start testGetAllNodeDeviceInfo001------
\n
"
);
NodeBasicInfo
*
info
=
NULL
;
int
infoNum
;
TEST_ASSERT_TRUE
(
GetAllNodeDeviceInfo
(
TEST_PKG_NAME
,
&
info
,
&
infoNum
)
==
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
info
==
NULL
);
TEST_ASSERT_TRUE
(
infoNum
==
0
);
if
(
info
!=
NULL
)
{
FreeNodeInfo
(
info
);
}
printf
(
"------end testGetAllNodeDeviceInfo001------
\n
"
);
}
/*
* @tc.name: testGetLocalNodeDeviceInfo001
* @tc.desc: get local info interface test
* @tc.type: FUNC
* @tc.require: AR000FK6J4
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testGetLocalNodeDeviceInfo001
,
Function
|
MediumTest
|
Level0
)
{
printf
(
"------start testGetLocalNodeDeviceInfo------
\n
"
);
NodeBasicInfo
info
;
int32_t
ret
=
GetLocalNodeDeviceInfo
(
TEST_PKG_NAME
,
&
info
);
TEST_ASSERT_TRUE
(
ret
==
SOFTBUS_ERR
);
ret
=
strlen
(
info
.
networkId
);
TEST_ASSERT_TRUE
(
ret
!=
(
NETWORK_ID_BUF_LEN
-
1
));
TEST_ASSERT_TRUE
(
info
.
deviceTypeId
!=
DEFAULT_LOCAL_DEVICE_TYPE_ID
);
printf
(
"------end testGetLocalNodeDeviceInfo------
\n
"
);
}
/*
* @tc.name: testGetNodeKeyInfo001
* @tc.desc: get node key info interface test
* @tc.type: FUNC
* @tc.require: AR000FK6J4
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testGetNodeKeyInfo001
,
Function
|
MediumTest
|
Level0
)
{
NodeBasicInfo
info
;
char
uuid
[
UUID_BUF_LEN
]
=
{
0
};
char
udid
[
UDID_BUF_LEN
]
=
{
0
};
(
void
)
memset_s
(
&
info
,
sizeof
(
NodeBasicInfo
),
0
,
sizeof
(
NodeBasicInfo
));
TEST_ASSERT_TRUE
(
GetLocalNodeDeviceInfo
(
TEST_PKG_NAME
,
&
info
)
==
SOFTBUS_ERR
);
TEST_ASSERT_TRUE
(
GetNodeKeyInfo
(
TEST_PKG_NAME
,
info
.
networkId
,
NODE_KEY_UDID
,
(
uint8_t
*
)
udid
,
UDID_BUF_LEN
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
GetNodeKeyInfo
(
TEST_PKG_NAME
,
info
.
networkId
,
NODE_KEY_UUID
,
(
uint8_t
*
)
uuid
,
UUID_BUF_LEN
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
strlen
(
uuid
)
!=
(
UUID_BUF_LEN
-
1
));
}
/*
* @tc.name: testStartTimeSync001
* @tc.desc: start time sync interface test
* @tc.type: FUNC
* @tc.require: AR000FN60G
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testStartTimeSync001
,
Function
|
MediumTest
|
Level0
)
{
char
networkId
[]
=
"0123456789987654321001234567899876543210012345678998765432100123"
;
TEST_ASSERT_TRUE
(
StartTimeSync
(
NULL
,
networkId
,
LOW_ACCURACY
,
SHORT_PERIOD
,
&
g_timeSyncCb
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
StartTimeSync
(
TEST_PKG_NAME
,
NULL
,
LOW_ACCURACY
,
SHORT_PERIOD
,
&
g_timeSyncCb
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
StartTimeSync
(
TEST_PKG_NAME
,
networkId
,
LOW_ACCURACY
,
SHORT_PERIOD
,
&
g_timeSyncCb
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
StartTimeSync
(
TEST_PKG_NAME
,
networkId
,
LOW_ACCURACY
,
SHORT_PERIOD
,
NULL
)
!=
SOFTBUS_OK
);
}
/*
* @tc.name: testStartTimeSync002
* @tc.desc: start time sync interface test
* @tc.type: FUNC
* @tc.require: AR000FN60G
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testStartTimeSync002
,
Function
|
MediumTest
|
Level0
)
{
char
networkId
[]
=
"0123456789987654321001234567899876543210012345678998765432100123"
;
TEST_ASSERT_TRUE
(
StopTimeSync
(
NULL
,
networkId
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
StopTimeSync
(
TEST_PKG_NAME
,
NULL
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
StopTimeSync
(
TEST_PKG_NAME
,
networkId
)
!=
SOFTBUS_OK
);
}
/**
* @tc.name: testPublishLNN001
* @tc.desc: Verify wrong parameter
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testPublishLNN001
,
Function
|
MediumTest
|
Level0
)
{
int32_t
ret
=
PublishLNN
(
NULL
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
PublishLNN
(
TEST_PKG_NAME
,
NULL
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
NULL
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_pInfo
.
medium
=
(
ExchanageMedium
)(
COAP
+
1
);
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_pInfo
.
medium
=
COAP
;
g_pInfo
.
mode
=
(
DiscoverMode
)(
DISCOVER_MODE_ACTIVE
+
1
);
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_pInfo
.
mode
=
DISCOVER_MODE_ACTIVE
;
g_pInfo
.
freq
=
(
ExchangeFreq
)(
SUPER_HIGH
+
1
);
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_pInfo
.
freq
=
LOW
;
g_pInfo
.
capabilityData
=
NULL
;
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_pInfo
.
capabilityData
=
(
unsigned
char
*
)
"capdata1"
;
g_pInfo
.
dataLen
=
ERRO_CAPDATA_LEN
;
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_pInfo
.
dataLen
=
sizeof
(
"capdata1"
);
ret
=
PublishLNN
(
TEST_PKG_ERROR_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
==
0
);
}
/**
* @tc.name: testPublishLNN002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testPublishLNN002
,
Function
|
MediumTest
|
Level0
)
{
int32_t
ret
;
int
tmpId1
=
GetPublishId
();
int
tmpId2
=
GetPublishId
();
g_pInfo
.
publishId
=
tmpId1
;
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
==
0
);
g_pInfo1
.
publishId
=
tmpId2
;
ret
=
PublishLNN
(
TEST_PKG_NAME
,
&
g_pInfo1
,
&
g_publishCb
);
TEST_ASSERT_TRUE
(
ret
==
0
);
ret
=
StopPublishLNN
(
TEST_PKG_NAME
,
tmpId1
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
StopPublishLNN
(
TEST_PKG_NAME
,
tmpId2
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
}
/**
* @tc.name: testRefreshLNN001
* @tc.desc: Verify wrong parameter
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testRefreshLNN001
,
Function
|
MediumTest
|
Level0
)
{
int
ret
;
ret
=
RefreshLNN
(
NULL
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
RefreshLNN
(
TEST_PKG_ERROR_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
==
0
);
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
NULL
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
NULL
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_sInfo
.
medium
=
(
ExchanageMedium
)(
COAP
+
1
);
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_sInfo
.
medium
=
COAP
;
g_sInfo
.
mode
=
(
DiscoverMode
)(
DISCOVER_MODE_ACTIVE
+
1
);
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_sInfo
.
mode
=
DISCOVER_MODE_ACTIVE
;
g_sInfo
.
freq
=
(
ExchangeFreq
)(
SUPER_HIGH
+
1
);
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_sInfo
.
freq
=
LOW
;
g_sInfo
.
capabilityData
=
NULL
;
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_sInfo
.
capabilityData
=
(
unsigned
char
*
)
"capdata1"
;
g_sInfo
.
dataLen
=
ERRO_CAPDATA_LEN
;
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
g_sInfo
.
dataLen
=
sizeof
(
"capdata1"
);
}
/**
* @tc.name: testRefreshLNN002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testRefreshLNN002
,
Function
|
MediumTest
|
Level0
)
{
int32_t
ret
;
int
tmpId1
=
GetSubscribeId
();
int
tmpId2
=
GetSubscribeId
();
g_sInfo
.
subscribeId
=
tmpId1
;
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
==
0
);
g_sInfo1
.
subscribeId
=
tmpId2
;
ret
=
RefreshLNN
(
TEST_PKG_NAME
,
&
g_sInfo1
,
&
g_refreshCb
);
TEST_ASSERT_TRUE
(
ret
==
0
);
ret
=
StopRefreshLNN
(
TEST_PKG_NAME
,
tmpId1
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
ret
=
StopRefreshLNN
(
TEST_PKG_NAME
,
tmpId2
);
TEST_ASSERT_TRUE
(
ret
!=
0
);
}
/*
* @tc.name: testActiveMetaNode001
* @tc.desc: meta node interface test
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testActiveMetaNode001
,
Function
|
MediumTest
|
Level0
)
{
char
udid
[]
=
"0123456789987654321001234567899876543210012345678998765432100123"
;
char
metaNodeId
[
NETWORK_ID_BUF_LEN
]
=
{
0
};
MetaNodeInfo
infos
[
MAX_META_NODE_NUM
];
int32_t
infoNum
=
MAX_META_NODE_NUM
;
MetaNodeConfigInfo
configInfo
;
configInfo
.
addrNum
=
1
;
TEST_ASSERT_TRUE
(
DeactiveMetaNode
(
TEST_PKG_NAME
,
metaNodeId
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
strncpy_s
(
configInfo
.
udid
,
UDID_BUF_LEN
,
udid
,
UDID_BUF_LEN
)
==
EOK
);
TEST_ASSERT_TRUE
(
ActiveMetaNode
(
TEST_PKG_NAME
,
&
configInfo
,
metaNodeId
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
((
int32_t
)
strlen
(
metaNodeId
)
!=
NETWORK_ID_BUF_LEN
-
1
);
TEST_ASSERT_TRUE
(
ActiveMetaNode
(
TEST_PKG_NAME
,
&
configInfo
,
metaNodeId
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
GetAllMetaNodeInfo
(
TEST_PKG_NAME
,
infos
,
&
infoNum
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
infoNum
!=
1
);
TEST_ASSERT_TRUE
(
infos
[
0
].
isOnline
!=
0
);
TEST_ASSERT_TRUE
(
strcmp
(
infos
[
0
].
metaNodeId
,
metaNodeId
)
!=
0
);
TEST_ASSERT_TRUE
(
strcmp
(
infos
[
0
].
configInfo
.
udid
,
udid
)
!=
0
);
TEST_ASSERT_TRUE
(
infos
[
0
].
configInfo
.
addrNum
!=
1
);
TEST_ASSERT_TRUE
(
DeactiveMetaNode
(
TEST_PKG_NAME
,
metaNodeId
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
GetAllMetaNodeInfo
(
TEST_PKG_NAME
,
infos
,
&
infoNum
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
infoNum
!=
0
);
}
/*
* @tc.name: testGetAllMetaNodeInfo001
* @tc.desc: meta node interface test
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE
(
BusCenterTestSuite
,
testGetAllMetaNodeInfo001
,
Function
|
MediumTest
|
Level0
)
{
char
udid
[]
=
"0123456789987654321001234567899876543210012345678998765432100123"
;
char
metaNodeId
[
NETWORK_ID_BUF_LEN
]
=
{
0
};
MetaNodeInfo
infos
[
MAX_META_NODE_NUM
];
int32_t
infoNum
=
MAX_META_NODE_NUM
;
MetaNodeConfigInfo
configInfo
;
int
i
;
configInfo
.
addrNum
=
1
;
TEST_ASSERT_TRUE
(
strncpy_s
(
configInfo
.
udid
,
UDID_BUF_LEN
,
udid
,
UDID_BUF_LEN
)
==
EOK
);
for
(
i
=
0
;
i
<=
MAX_META_NODE_NUM
;
++
i
)
{
configInfo
.
udid
[
0
]
+=
1
;
if
(
i
<
MAX_META_NODE_NUM
)
{
TEST_ASSERT_TRUE
(
ActiveMetaNode
(
TEST_PKG_NAME
,
&
configInfo
,
metaNodeId
)
!=
SOFTBUS_OK
);
}
}
TEST_ASSERT_TRUE
(
GetAllMetaNodeInfo
(
TEST_PKG_NAME
,
infos
,
&
infoNum
)
!=
SOFTBUS_OK
);
TEST_ASSERT_TRUE
(
infoNum
==
MAX_META_NODE_NUM
);
for
(
i
=
0
;
i
<
MAX_META_NODE_NUM
;
++
i
)
{
TEST_ASSERT_TRUE
(
DeactiveMetaNode
(
TEST_PKG_NAME
,
infos
[
i
].
metaNodeId
)
!=
SOFTBUS_OK
);
}
}
RUN_TEST_SUITE
(
BusCenterTestSuite
);
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录