179a732c7Sopenharmony_ci/*
279a732c7Sopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
379a732c7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
479a732c7Sopenharmony_ci * you may not use this file except in compliance with the License.
579a732c7Sopenharmony_ci * You may obtain a copy of the License at
679a732c7Sopenharmony_ci *
779a732c7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
879a732c7Sopenharmony_ci *
979a732c7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1079a732c7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1179a732c7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1279a732c7Sopenharmony_ci * See the License for the specific language governing permissions and
1379a732c7Sopenharmony_ci * limitations under the License.
1479a732c7Sopenharmony_ci */
1579a732c7Sopenharmony_ci#include "UTTest_softbus_connector.h"
1679a732c7Sopenharmony_ci
1779a732c7Sopenharmony_ci#include <securec.h>
1879a732c7Sopenharmony_ci#include <unistd.h>
1979a732c7Sopenharmony_ci#include <cstdlib>
2079a732c7Sopenharmony_ci#include <string>
2179a732c7Sopenharmony_ci#include <thread>
2279a732c7Sopenharmony_ci
2379a732c7Sopenharmony_ci#include "dm_anonymous.h"
2479a732c7Sopenharmony_ci#include "dm_constants.h"
2579a732c7Sopenharmony_ci#include "dm_device_info.h"
2679a732c7Sopenharmony_ci#include "dm_log.h"
2779a732c7Sopenharmony_ci#include "ipc_notify_auth_result_req.h"
2879a732c7Sopenharmony_ci#include "ipc_notify_device_state_req.h"
2979a732c7Sopenharmony_ci#include "ipc_notify_device_found_req.h"
3079a732c7Sopenharmony_ci#include "ipc_notify_discover_result_req.h"
3179a732c7Sopenharmony_ci#include "ipc_notify_publish_result_req.h"
3279a732c7Sopenharmony_ci#include "parameter.h"
3379a732c7Sopenharmony_ci#include "system_ability_definition.h"
3479a732c7Sopenharmony_ci#include "softbus_error_code.h"
3579a732c7Sopenharmony_ci
3679a732c7Sopenharmony_cinamespace OHOS {
3779a732c7Sopenharmony_cinamespace DistributedHardware {
3879a732c7Sopenharmony_ci
3979a732c7Sopenharmony_ciclass SoftbusStateCallbackTest : public ISoftbusStateCallback {
4079a732c7Sopenharmony_cipublic:
4179a732c7Sopenharmony_ci    SoftbusStateCallbackTest() {}
4279a732c7Sopenharmony_ci    virtual ~SoftbusStateCallbackTest() {}
4379a732c7Sopenharmony_ci    void OnDeviceOnline(std::string deviceId, int32_t authForm) {}
4479a732c7Sopenharmony_ci    void OnDeviceOffline(std::string deviceId) {}
4579a732c7Sopenharmony_ci    void DeleteOffLineTimer(std::string udidHash) override {}
4679a732c7Sopenharmony_ci};
4779a732c7Sopenharmony_ci
4879a732c7Sopenharmony_ciclass SoftbusDiscoveryCallbackTest : public ISoftbusDiscoveryCallback {
4979a732c7Sopenharmony_cipublic:
5079a732c7Sopenharmony_ci    SoftbusDiscoveryCallbackTest() {}
5179a732c7Sopenharmony_ci    virtual ~SoftbusDiscoveryCallbackTest() {}
5279a732c7Sopenharmony_ci    void OnDeviceFound(const std::string &pkgName, DmDeviceInfo &info, bool isOnline) override
5379a732c7Sopenharmony_ci    {
5479a732c7Sopenharmony_ci        (void)pkgName;
5579a732c7Sopenharmony_ci        (void)info;
5679a732c7Sopenharmony_ci        (void)isOnline;
5779a732c7Sopenharmony_ci    }
5879a732c7Sopenharmony_ci    void OnDeviceFound(const std::string &pkgName, DmDeviceBasicInfo &info, const int32_t range, bool isOnline) override
5979a732c7Sopenharmony_ci    {
6079a732c7Sopenharmony_ci        (void)pkgName;
6179a732c7Sopenharmony_ci        (void)info;
6279a732c7Sopenharmony_ci        (void)range;
6379a732c7Sopenharmony_ci        (void)isOnline;
6479a732c7Sopenharmony_ci    }
6579a732c7Sopenharmony_ci    void OnDiscoverySuccess(const std::string &pkgName, int32_t subscribeId) override
6679a732c7Sopenharmony_ci    {
6779a732c7Sopenharmony_ci        (void)pkgName;
6879a732c7Sopenharmony_ci        (void)subscribeId;
6979a732c7Sopenharmony_ci    }
7079a732c7Sopenharmony_ci    void OnDiscoveryFailed(const std::string &pkgName, int32_t subscribeId, int32_t failedReason) override
7179a732c7Sopenharmony_ci    {
7279a732c7Sopenharmony_ci        (void)pkgName;
7379a732c7Sopenharmony_ci        (void)subscribeId;
7479a732c7Sopenharmony_ci        (void)failedReason;
7579a732c7Sopenharmony_ci    }
7679a732c7Sopenharmony_ci};
7779a732c7Sopenharmony_ci
7879a732c7Sopenharmony_ciclass SoftbusPublishCallbackTest : public ISoftbusPublishCallback {
7979a732c7Sopenharmony_cipublic:
8079a732c7Sopenharmony_ci    SoftbusPublishCallbackTest() {}
8179a732c7Sopenharmony_ci    virtual ~SoftbusPublishCallbackTest() {}
8279a732c7Sopenharmony_ci    void OnPublishResult(const std::string &pkgName, int32_t publishId, int32_t publishResult) override
8379a732c7Sopenharmony_ci    {
8479a732c7Sopenharmony_ci        (void)pkgName;
8579a732c7Sopenharmony_ci        (void)publishId;
8679a732c7Sopenharmony_ci        (void)publishResult;
8779a732c7Sopenharmony_ci    }
8879a732c7Sopenharmony_ci};
8979a732c7Sopenharmony_ci
9079a732c7Sopenharmony_civoid SoftbusConnectorTest::SetUp()
9179a732c7Sopenharmony_ci{
9279a732c7Sopenharmony_ci}
9379a732c7Sopenharmony_civoid SoftbusConnectorTest::TearDown()
9479a732c7Sopenharmony_ci{
9579a732c7Sopenharmony_ci}
9679a732c7Sopenharmony_civoid SoftbusConnectorTest::SetUpTestCase()
9779a732c7Sopenharmony_ci{
9879a732c7Sopenharmony_ci}
9979a732c7Sopenharmony_civoid SoftbusConnectorTest::TearDownTestCase()
10079a732c7Sopenharmony_ci{
10179a732c7Sopenharmony_ci}
10279a732c7Sopenharmony_ci
10379a732c7Sopenharmony_cibool SoftbusConnectorTest::CheckReturnResult(int ret)
10479a732c7Sopenharmony_ci{
10579a732c7Sopenharmony_ci    return ret == SOFTBUS_IPC_ERR || ret == SOFTBUS_NETWORK_NOT_INIT || ret == SOFTBUS_NETWORK_LOOPER_ERR;
10679a732c7Sopenharmony_ci}
10779a732c7Sopenharmony_ci
10879a732c7Sopenharmony_cinamespace {
10979a732c7Sopenharmony_cistd::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
11079a732c7Sopenharmony_ci
11179a732c7Sopenharmony_ci/**
11279a732c7Sopenharmony_ci * @tc.name: SoftbusConnector_001
11379a732c7Sopenharmony_ci * @tc.desc: set SoftbusConnector to new a pointer, and the pointer nou equal nullptr
11479a732c7Sopenharmony_ci * @tc.type: FUNC
11579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
11679a732c7Sopenharmony_ci */
11779a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, SoftbusConnector_001, testing::ext::TestSize.Level0)
11879a732c7Sopenharmony_ci{
11979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> m_SoftbusConnector = std::make_shared<SoftbusConnector>();
12079a732c7Sopenharmony_ci    ASSERT_NE(m_SoftbusConnector, nullptr);
12179a732c7Sopenharmony_ci}
12279a732c7Sopenharmony_ci
12379a732c7Sopenharmony_ci/**
12479a732c7Sopenharmony_ci * @tc.name: SoftbusConnector_002
12579a732c7Sopenharmony_ci * @tc.desc: set SoftbusConnector to new a pointer, and the pointer nou equal nullptr, and delete it
12679a732c7Sopenharmony_ci * @tc.type: FUNC
12779a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
12879a732c7Sopenharmony_ci */
12979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, SoftbusConnector_002, testing::ext::TestSize.Level0)
13079a732c7Sopenharmony_ci{
13179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> m_SoftbusConnector = std::make_shared<SoftbusConnector>();
13279a732c7Sopenharmony_ci    m_SoftbusConnector.reset();
13379a732c7Sopenharmony_ci    EXPECT_EQ(m_SoftbusConnector, nullptr);
13479a732c7Sopenharmony_ci}
13579a732c7Sopenharmony_ci
13679a732c7Sopenharmony_ci/**
13779a732c7Sopenharmony_ci * @tc.name: RegisterSoftbusDiscoveryCallback_001
13879a732c7Sopenharmony_ci * @tc.desc: set pkgName = "com.ohos.helloworld";call RegisterSoftbusDiscoveryCallback function to corrort, return DM_OK
13979a732c7Sopenharmony_ci * @tc.type: FUNC
14079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
14179a732c7Sopenharmony_ci */
14279a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, RegisterSoftbusDiscoveryCallback_001, testing::ext::TestSize.Level0)
14379a732c7Sopenharmony_ci{
14479a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
14579a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
14679a732c7Sopenharmony_ci    int ret1 = softbusConnector->RegisterSoftbusDiscoveryCallback(
14779a732c7Sopenharmony_ci        pkgName, std::make_shared<SoftbusDiscoveryCallbackTest>());
14879a732c7Sopenharmony_ci    int ret = SoftbusConnector::discoveryCallbackMap_.count(pkgName);
14979a732c7Sopenharmony_ci    EXPECT_EQ(ret1, DM_OK);
15079a732c7Sopenharmony_ci    EXPECT_EQ(ret, 1);
15179a732c7Sopenharmony_ci}
15279a732c7Sopenharmony_ci
15379a732c7Sopenharmony_ci/**
15479a732c7Sopenharmony_ci * @tc.name: UnRegisterSoftbusDiscoveryCallback_001
15579a732c7Sopenharmony_ci * @tc.desc: set pkgName = "com.ohos.helloworld";call UnRegisterSoftbusDiscoveryCallback function to corrort, return
15679a732c7Sopenharmony_ci * DM_OK
15779a732c7Sopenharmony_ci * @tc.type: FUNC
15879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
15979a732c7Sopenharmony_ci */
16079a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, UnRegisterSoftbusDiscoveryCallback_001, testing::ext::TestSize.Level0)
16179a732c7Sopenharmony_ci{
16279a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
16379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
16479a732c7Sopenharmony_ci    int ret = softbusConnector->UnRegisterSoftbusDiscoveryCallback(pkgName);
16579a732c7Sopenharmony_ci    int ret1 = SoftbusConnector::discoveryCallbackMap_.count(pkgName);
16679a732c7Sopenharmony_ci    EXPECT_EQ(ret1, 0);
16779a732c7Sopenharmony_ci    EXPECT_EQ(ret, DM_OK);
16879a732c7Sopenharmony_ci}
16979a732c7Sopenharmony_ci
17079a732c7Sopenharmony_ci/**
17179a732c7Sopenharmony_ci * @tc.name: RegisterSoftbusPublishCallback_001
17279a732c7Sopenharmony_ci * @tc.desc: set pkgName = "com.ohos.helloworld";call RegisterSoftbusPublishCallback function to corrort, return DM_OK
17379a732c7Sopenharmony_ci * @tc.type: FUNC
17479a732c7Sopenharmony_ci * @tc.require: I5N1K3
17579a732c7Sopenharmony_ci */
17679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, RegisterSoftbusPublishCallback_001, testing::ext::TestSize.Level0)
17779a732c7Sopenharmony_ci{
17879a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
17979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
18079a732c7Sopenharmony_ci    int ret1 = softbusConnector->RegisterSoftbusPublishCallback(
18179a732c7Sopenharmony_ci        pkgName, std::make_shared<SoftbusPublishCallbackTest>());
18279a732c7Sopenharmony_ci    int ret = SoftbusConnector::publishCallbackMap_.count(pkgName);
18379a732c7Sopenharmony_ci    EXPECT_EQ(ret1, DM_OK);
18479a732c7Sopenharmony_ci    EXPECT_EQ(ret, 1);
18579a732c7Sopenharmony_ci}
18679a732c7Sopenharmony_ci
18779a732c7Sopenharmony_ci/**
18879a732c7Sopenharmony_ci * @tc.name: UnRegisterSoftbusPublishCallback_001
18979a732c7Sopenharmony_ci * @tc.desc: set pkgName = "com.ohos.helloworld";call UnRegisterSoftbusPublishyCallback function to corrort, return
19079a732c7Sopenharmony_ci * DM_OK
19179a732c7Sopenharmony_ci * @tc.type: FUNC
19279a732c7Sopenharmony_ci * @tc.require: I5N1K3
19379a732c7Sopenharmony_ci */
19479a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, UnRegisterSoftbusPublishCallback_001, testing::ext::TestSize.Level0)
19579a732c7Sopenharmony_ci{
19679a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
19779a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
19879a732c7Sopenharmony_ci    int ret = softbusConnector->UnRegisterSoftbusPublishCallback(pkgName);
19979a732c7Sopenharmony_ci    int ret1 = SoftbusConnector::publishCallbackMap_.count(pkgName);
20079a732c7Sopenharmony_ci    EXPECT_EQ(ret1, 0);
20179a732c7Sopenharmony_ci    EXPECT_EQ(ret, DM_OK);
20279a732c7Sopenharmony_ci}
20379a732c7Sopenharmony_ci
20479a732c7Sopenharmony_ci/**
20579a732c7Sopenharmony_ci * @tc.name: StartDiscovery_001
20679a732c7Sopenharmony_ci * @tc.desc: get StartDiscovery to wrong branch and return SOFTBUS_INVALID_PARAM
20779a732c7Sopenharmony_ci * @tc.type: FUNC
20879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
20979a732c7Sopenharmony_ci */
21079a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, StartDiscovery_001, testing::ext::TestSize.Level0)
21179a732c7Sopenharmony_ci{
21279a732c7Sopenharmony_ci    DmSubscribeInfo dmSubscribeInfo;
21379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
21479a732c7Sopenharmony_ci    int ret = softbusConnector->StartDiscovery(dmSubscribeInfo);
21579a732c7Sopenharmony_ci    EXPECT_TRUE(CheckReturnResult(ret));
21679a732c7Sopenharmony_ci}
21779a732c7Sopenharmony_ci/**
21879a732c7Sopenharmony_ci * @tc.name: StartDiscovery_002
21979a732c7Sopenharmony_ci * @tc.desc: get StartDiscovery to wrong branch and return SOFTBUS_IPC_ERR
22079a732c7Sopenharmony_ci * @tc.type: FUNC
22179a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
22279a732c7Sopenharmony_ci */
22379a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, StartDiscovery_002, testing::ext::TestSize.Level0)
22479a732c7Sopenharmony_ci{
22579a732c7Sopenharmony_ci    uint16_t subscribeId = 0;
22679a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
22779a732c7Sopenharmony_ci    int ret = softbusConnector->StartDiscovery(subscribeId);
22879a732c7Sopenharmony_ci    EXPECT_TRUE(CheckReturnResult(ret));
22979a732c7Sopenharmony_ci}
23079a732c7Sopenharmony_ci
23179a732c7Sopenharmony_ci/**
23279a732c7Sopenharmony_ci * @tc.name: StopDiscovery_001
23379a732c7Sopenharmony_ci * @tc.desc: get StartDiscovery to wrong branch and return ERR_DM_DISCOVERY_FAILED
23479a732c7Sopenharmony_ci * @tc.type: FUNC
23579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
23679a732c7Sopenharmony_ci */
23779a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, StopDiscovery_001, testing::ext::TestSize.Level0)
23879a732c7Sopenharmony_ci{
23979a732c7Sopenharmony_ci    uint16_t subscribeId = static_cast<uint16_t>(123456);
24079a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
24179a732c7Sopenharmony_ci    int ret = softbusConnector->StopDiscovery(subscribeId);
24279a732c7Sopenharmony_ci    EXPECT_NE(ret, 0);
24379a732c7Sopenharmony_ci}
24479a732c7Sopenharmony_ci
24579a732c7Sopenharmony_ci/**
24679a732c7Sopenharmony_ci * @tc.name: PublishDiscovery_001
24779a732c7Sopenharmony_ci * @tc.desc: get PublishDiscovery to wrong branch and return SOFTBUS_INVALID_PARAM
24879a732c7Sopenharmony_ci * @tc.type: FUNC
24979a732c7Sopenharmony_ci * @tc.require: I5N1K3
25079a732c7Sopenharmony_ci */
25179a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, PublishDiscovery_001, testing::ext::TestSize.Level0)
25279a732c7Sopenharmony_ci{
25379a732c7Sopenharmony_ci    DmPublishInfo dmPublishInfo;
25479a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
25579a732c7Sopenharmony_ci    int ret = softbusConnector->PublishDiscovery(dmPublishInfo);
25679a732c7Sopenharmony_ci    EXPECT_TRUE(CheckReturnResult(ret));
25779a732c7Sopenharmony_ci}
25879a732c7Sopenharmony_ci
25979a732c7Sopenharmony_ci/**
26079a732c7Sopenharmony_ci * @tc.name: UnPublishDiscovery_001
26179a732c7Sopenharmony_ci * @tc.desc: get UnPublishDiscovery to wrong branch and return ERR_DM_PUBLISH_FAILED
26279a732c7Sopenharmony_ci * @tc.type: FUNC
26379a732c7Sopenharmony_ci * @tc.require: I5N1K3
26479a732c7Sopenharmony_ci */
26579a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, UnPublishDiscovery_001, testing::ext::TestSize.Level0)
26679a732c7Sopenharmony_ci{
26779a732c7Sopenharmony_ci    int32_t publishId = 123456;
26879a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
26979a732c7Sopenharmony_ci    int ret = softbusConnector->UnPublishDiscovery(publishId);
27079a732c7Sopenharmony_ci    EXPECT_NE(ret, 0);
27179a732c7Sopenharmony_ci}
27279a732c7Sopenharmony_ci
27379a732c7Sopenharmony_ci/**
27479a732c7Sopenharmony_ci * @tc.name: GetUdidByNetworkId_001
27579a732c7Sopenharmony_ci * @tc.desc: get StartDiscovery to wrong branch and return ERR_DM_DISCOVERY_FAILED
27679a732c7Sopenharmony_ci * @tc.type: FUNC
27779a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
27879a732c7Sopenharmony_ci */
27979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetUdidByNetworkId_001, testing::ext::TestSize.Level0)
28079a732c7Sopenharmony_ci{
28179a732c7Sopenharmony_ci    const char *networkId = "123456";
28279a732c7Sopenharmony_ci    std::string udid;
28379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
28479a732c7Sopenharmony_ci    int ret = softbusConnector->GetUdidByNetworkId(networkId, udid);
28579a732c7Sopenharmony_ci    EXPECT_NE(ret, 0);
28679a732c7Sopenharmony_ci}
28779a732c7Sopenharmony_ci
28879a732c7Sopenharmony_ci/**
28979a732c7Sopenharmony_ci * @tc.name: GetUuidByNetworkId_001
29079a732c7Sopenharmony_ci * @tc.desc: get StartDiscovery to wrong branch and return ERR_DM_DISCOVERY_FAILED
29179a732c7Sopenharmony_ci * @tc.type: FUNC
29279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
29379a732c7Sopenharmony_ci */
29479a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetUuidByNetworkId_001, testing::ext::TestSize.Level0)
29579a732c7Sopenharmony_ci{
29679a732c7Sopenharmony_ci    const char *networkId = "123456";
29779a732c7Sopenharmony_ci    std::string uuid;
29879a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
29979a732c7Sopenharmony_ci    int ret = softbusConnector->GetUuidByNetworkId(networkId, uuid);
30079a732c7Sopenharmony_ci    EXPECT_NE(ret, 0);
30179a732c7Sopenharmony_ci}
30279a732c7Sopenharmony_ci
30379a732c7Sopenharmony_ci/**
30479a732c7Sopenharmony_ci * @tc.name: GetSoftbusSession_001
30579a732c7Sopenharmony_ci * @tc.desc: set SoftbusConnector to new a pointer, and the pointer nou equal nullptr, and delete it
30679a732c7Sopenharmony_ci * @tc.type: FUNC
30779a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
30879a732c7Sopenharmony_ci */
30979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetSoftbusSession_001, testing::ext::TestSize.Level0)
31079a732c7Sopenharmony_ci{
31179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
31279a732c7Sopenharmony_ci    std::shared_ptr<SoftbusSession> softSession = softbusConnector->GetSoftbusSession();
31379a732c7Sopenharmony_ci    EXPECT_NE(softSession, nullptr);
31479a732c7Sopenharmony_ci}
31579a732c7Sopenharmony_ci
31679a732c7Sopenharmony_ci/**
31779a732c7Sopenharmony_ci * @tc.name: GetSoftbusSession_001
31879a732c7Sopenharmony_ci * @tc.desc: set SoftbusConnector to new a pointer, and the pointer nou equal nullptr, and delete it
31979a732c7Sopenharmony_ci * @tc.type: FUNC
32079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
32179a732c7Sopenharmony_ci */
32279a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, HaveDeviceInMap_001, testing::ext::TestSize.Level0)
32379a732c7Sopenharmony_ci{
32479a732c7Sopenharmony_ci    std::string deviceId = "12345678";
32579a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_[deviceId];
32679a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
32779a732c7Sopenharmony_ci    bool ret = softbusConnector->HaveDeviceInMap(deviceId);
32879a732c7Sopenharmony_ci    EXPECT_EQ(ret, true);
32979a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_.clear();
33079a732c7Sopenharmony_ci}
33179a732c7Sopenharmony_ci
33279a732c7Sopenharmony_ci/**
33379a732c7Sopenharmony_ci * @tc.name: GetSoftbusSession_001
33479a732c7Sopenharmony_ci * @tc.desc: set SoftbusConnector to new a pointer, and the pointer nou equal nullptr, and delete it
33579a732c7Sopenharmony_ci * @tc.type: FUNC
33679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
33779a732c7Sopenharmony_ci */
33879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, HaveDeviceInMap_002, testing::ext::TestSize.Level0)
33979a732c7Sopenharmony_ci{
34079a732c7Sopenharmony_ci    std::string deviceId = "12345678";
34179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
34279a732c7Sopenharmony_ci    bool ret = softbusConnector->HaveDeviceInMap(deviceId);
34379a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
34479a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_.clear();
34579a732c7Sopenharmony_ci}
34679a732c7Sopenharmony_ci
34779a732c7Sopenharmony_ci/**
34879a732c7Sopenharmony_ci * @tc.name: GetConnectAddrByType_001
34979a732c7Sopenharmony_ci * @tc.desc: set deviceInfo'pointer null, go to first branch, and return nullptr
35079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
35179a732c7Sopenharmony_ci */
35279a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddrByType_001, testing::ext::TestSize.Level0)
35379a732c7Sopenharmony_ci{
35479a732c7Sopenharmony_ci    ConnectionAddrType type;
35579a732c7Sopenharmony_ci    type = CONNECTION_ADDR_MAX;
35679a732c7Sopenharmony_ci    ConnectionAddr *p = nullptr;
35779a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
35879a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddrByType(nullptr, type);
35979a732c7Sopenharmony_ci    EXPECT_EQ(p, ret);
36079a732c7Sopenharmony_ci}
36179a732c7Sopenharmony_ci
36279a732c7Sopenharmony_ci/**
36379a732c7Sopenharmony_ci * @tc.name: GetConnectAddrByType_002
36479a732c7Sopenharmony_ci * @tc.desc:set deviceInfo to some corrort para, and return nullptr
36579a732c7Sopenharmony_ci * @tc.type: FUNC
36679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
36779a732c7Sopenharmony_ci */
36879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddrByType_002, testing::ext::TestSize.Level0)
36979a732c7Sopenharmony_ci{
37079a732c7Sopenharmony_ci    DeviceInfo deviceInfo;
37179a732c7Sopenharmony_ci    deviceInfo.addrNum = 1;
37279a732c7Sopenharmony_ci    ConnectionAddrType type;
37379a732c7Sopenharmony_ci    type = CONNECTION_ADDR_BR;
37479a732c7Sopenharmony_ci    ConnectionAddr *p = nullptr;
37579a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
37679a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddrByType(&deviceInfo, type);
37779a732c7Sopenharmony_ci    EXPECT_EQ(ret, p);
37879a732c7Sopenharmony_ci}
37979a732c7Sopenharmony_ci
38079a732c7Sopenharmony_ci/**
38179a732c7Sopenharmony_ci * @tc.name: GetConnectAddr_001
38279a732c7Sopenharmony_ci * @tc.desc: set deviceId to null, and return nullptr
38379a732c7Sopenharmony_ci * @tc.type: FUNC
38479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
38579a732c7Sopenharmony_ci */
38679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddr_001, testing::ext::TestSize.Level0)
38779a732c7Sopenharmony_ci{
38879a732c7Sopenharmony_ci    std::string deviceId;
38979a732c7Sopenharmony_ci    std::string connectAddr;
39079a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
39179a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddr(deviceId, connectAddr);
39279a732c7Sopenharmony_ci    EXPECT_EQ(ret, nullptr);
39379a732c7Sopenharmony_ci}
39479a732c7Sopenharmony_ci
39579a732c7Sopenharmony_ci/**
39679a732c7Sopenharmony_ci * @tc.name: GetConnectAddr_002
39779a732c7Sopenharmony_ci * @tc.desc:set deviceId nit null set deviceInfo.addrNum = -1; and return nullptr
39879a732c7Sopenharmony_ci * @tc.type: FUNC
39979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
40079a732c7Sopenharmony_ci */
40179a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddr_002, testing::ext::TestSize.Level0)
40279a732c7Sopenharmony_ci{
40379a732c7Sopenharmony_ci    std::string deviceId = "123345";
40479a732c7Sopenharmony_ci    std::string connectAddr;
40579a732c7Sopenharmony_ci    DeviceInfo deviceInfo;
40679a732c7Sopenharmony_ci    deviceInfo.addrNum = -1;
40779a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
40879a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddr(deviceId, connectAddr);
40979a732c7Sopenharmony_ci    EXPECT_EQ(ret, nullptr);
41079a732c7Sopenharmony_ci}
41179a732c7Sopenharmony_ci
41279a732c7Sopenharmony_ci/**
41379a732c7Sopenharmony_ci * @tc.name: GetConnectAddr_003
41479a732c7Sopenharmony_ci * @tc.desc:set deviceInfo.addrNum = 1
41579a732c7Sopenharmony_ci * @tc.type: FUNC
41679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
41779a732c7Sopenharmony_ci */
41879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddr_003, testing::ext::TestSize.Level0)
41979a732c7Sopenharmony_ci{
42079a732c7Sopenharmony_ci    std::string deviceId = "123345";
42179a732c7Sopenharmony_ci    std::shared_ptr<DeviceInfo> deviceInfo = std::make_shared<DeviceInfo>();
42279a732c7Sopenharmony_ci    std::string connectAddr;
42379a732c7Sopenharmony_ci    constexpr char ethIp[] = "0.0.0.0";
42479a732c7Sopenharmony_ci    deviceInfo->addrNum = 1;
42579a732c7Sopenharmony_ci    deviceInfo->addr[0].type = CONNECTION_ADDR_ETH;
42679a732c7Sopenharmony_ci    (void)strncpy_s(deviceInfo->addr[0].info.ip.ip, IP_STR_MAX_LEN, ethIp, strlen(ethIp));
42779a732c7Sopenharmony_ci    deviceInfo->addr[0].info.ip.port = 0;
42879a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_[deviceId] = deviceInfo;
42979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
43079a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddr(deviceId, connectAddr);
43179a732c7Sopenharmony_ci    EXPECT_NE(ret, nullptr);
43279a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_.clear();
43379a732c7Sopenharmony_ci}
43479a732c7Sopenharmony_ci
43579a732c7Sopenharmony_ci/**
43679a732c7Sopenharmony_ci * @tc.name: GetConnectAddr_004
43779a732c7Sopenharmony_ci * @tc.desc:set deviceInfo.addrNum = 1
43879a732c7Sopenharmony_ci * @tc.type: FUNC
43979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
44079a732c7Sopenharmony_ci */
44179a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddr_004, testing::ext::TestSize.Level0)
44279a732c7Sopenharmony_ci{
44379a732c7Sopenharmony_ci    std::string deviceId = "123345";
44479a732c7Sopenharmony_ci    std::shared_ptr<DeviceInfo> deviceInfo = std::make_shared<DeviceInfo>();
44579a732c7Sopenharmony_ci    std::string connectAddr;
44679a732c7Sopenharmony_ci    constexpr char wlanIp[] = "1.1.1.1";
44779a732c7Sopenharmony_ci    deviceInfo->addrNum = 1;
44879a732c7Sopenharmony_ci    deviceInfo->addr[0].type = CONNECTION_ADDR_WLAN;
44979a732c7Sopenharmony_ci    (void)strncpy_s(deviceInfo->addr[0].info.ip.ip, IP_STR_MAX_LEN, wlanIp, strlen(wlanIp));
45079a732c7Sopenharmony_ci    deviceInfo->addr[0].info.ip.port = 0;
45179a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_[deviceId] = deviceInfo;
45279a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
45379a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddr(deviceId, connectAddr);
45479a732c7Sopenharmony_ci    EXPECT_NE(ret, nullptr);
45579a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_.clear();
45679a732c7Sopenharmony_ci}
45779a732c7Sopenharmony_ci
45879a732c7Sopenharmony_ci/**
45979a732c7Sopenharmony_ci * @tc.name: GetConnectAddr_005
46079a732c7Sopenharmony_ci * @tc.desc:get brMac addr
46179a732c7Sopenharmony_ci * @tc.type: FUNC
46279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
46379a732c7Sopenharmony_ci */
46479a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddr_005, testing::ext::TestSize.Level0)
46579a732c7Sopenharmony_ci{
46679a732c7Sopenharmony_ci    std::string deviceId = "123345";
46779a732c7Sopenharmony_ci    std::shared_ptr<DeviceInfo> deviceInfo = std::make_shared<DeviceInfo>();
46879a732c7Sopenharmony_ci    std::string connectAddr;
46979a732c7Sopenharmony_ci    deviceInfo->addrNum = 1;
47079a732c7Sopenharmony_ci    constexpr char brMac[] = "2:2:2:2";
47179a732c7Sopenharmony_ci    deviceInfo->addr[0].type = CONNECTION_ADDR_BR;
47279a732c7Sopenharmony_ci    (void)strncpy_s(deviceInfo->addr[0].info.br.brMac, IP_STR_MAX_LEN, brMac, strlen(brMac));
47379a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_[deviceId] = deviceInfo;
47479a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
47579a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddr(deviceId, connectAddr);
47679a732c7Sopenharmony_ci    EXPECT_NE(ret, nullptr);
47779a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_.clear();
47879a732c7Sopenharmony_ci}
47979a732c7Sopenharmony_ci
48079a732c7Sopenharmony_ci/**
48179a732c7Sopenharmony_ci * @tc.name: GetConnectAddr_006
48279a732c7Sopenharmony_ci * @tc.desc:get bleMac addr
48379a732c7Sopenharmony_ci * @tc.type: FUNC
48479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
48579a732c7Sopenharmony_ci */
48679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetConnectAddr_006, testing::ext::TestSize.Level0)
48779a732c7Sopenharmony_ci{
48879a732c7Sopenharmony_ci    std::string deviceId = "123345";
48979a732c7Sopenharmony_ci    std::shared_ptr<DeviceInfo> deviceInfo = std::make_shared<DeviceInfo>();
49079a732c7Sopenharmony_ci    std::string connectAddr;
49179a732c7Sopenharmony_ci    constexpr char bleMac[] = "3:3:3:3";
49279a732c7Sopenharmony_ci    deviceInfo->addrNum = 1;
49379a732c7Sopenharmony_ci    deviceInfo->addr[0].type = CONNECTION_ADDR_BLE;
49479a732c7Sopenharmony_ci    (void)strncpy_s(deviceInfo->addr[0].info.ble.bleMac, IP_STR_MAX_LEN, bleMac, strlen(bleMac));
49579a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_[deviceId] = deviceInfo;
49679a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
49779a732c7Sopenharmony_ci    ConnectionAddr *ret = softbusConnector->GetConnectAddr(deviceId, connectAddr);
49879a732c7Sopenharmony_ci    EXPECT_NE(ret, nullptr);
49979a732c7Sopenharmony_ci    SoftbusConnector::discoveryDeviceInfoMap_.clear();
50079a732c7Sopenharmony_ci}
50179a732c7Sopenharmony_ci
50279a732c7Sopenharmony_ci/**
50379a732c7Sopenharmony_ci * @tc.name: ConvertNodeBasicInfoToDmDevice_001
50479a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
50579a732c7Sopenharmony_ci * @tc.type: FUNC
50679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
50779a732c7Sopenharmony_ci */
50879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, ConvertDeviceInfoToDmDevice_001, testing::ext::TestSize.Level0)
50979a732c7Sopenharmony_ci{
51079a732c7Sopenharmony_ci    DeviceInfo deviceInfo = {
51179a732c7Sopenharmony_ci        .devId = "123456",
51279a732c7Sopenharmony_ci        .devType = (DeviceType)1,
51379a732c7Sopenharmony_ci        .devName = "11111"
51479a732c7Sopenharmony_ci    };
51579a732c7Sopenharmony_ci    DmDeviceInfo dm;
51679a732c7Sopenharmony_ci    DmDeviceInfo dm_1 = {
51779a732c7Sopenharmony_ci        .deviceId = "123456",
51879a732c7Sopenharmony_ci        .deviceName = "11111",
51979a732c7Sopenharmony_ci        .deviceTypeId = 1
52079a732c7Sopenharmony_ci    };
52179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
52279a732c7Sopenharmony_ci    softbusConnector->ConvertDeviceInfoToDmDevice(deviceInfo, dm);
52379a732c7Sopenharmony_ci    bool ret = false;
52479a732c7Sopenharmony_ci    if (strcmp(dm.deviceId, dm_1.deviceId) == 0) {
52579a732c7Sopenharmony_ci        ret = true;
52679a732c7Sopenharmony_ci    }
52779a732c7Sopenharmony_ci    EXPECT_EQ(ret, true);
52879a732c7Sopenharmony_ci}
52979a732c7Sopenharmony_ci
53079a732c7Sopenharmony_ci/**
53179a732c7Sopenharmony_ci * @tc.name: OnSoftbusDeviceFound_001
53279a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
53379a732c7Sopenharmony_ci * @tc.type: FUNC
53479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
53579a732c7Sopenharmony_ci */
53679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusDeviceFound_001, testing::ext::TestSize.Level0)
53779a732c7Sopenharmony_ci{
53879a732c7Sopenharmony_ci    DeviceInfo *device = nullptr;
53979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
54079a732c7Sopenharmony_ci    softbusConnector->OnSoftbusDeviceFound(device);
54179a732c7Sopenharmony_ci    bool ret = false;
54279a732c7Sopenharmony_ci    if (listener->ipcServerListener_.req_ != nullptr) {
54379a732c7Sopenharmony_ci        listener->ipcServerListener_.req_ = nullptr;
54479a732c7Sopenharmony_ci        ret = true;
54579a732c7Sopenharmony_ci    }
54679a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
54779a732c7Sopenharmony_ci}
54879a732c7Sopenharmony_ci
54979a732c7Sopenharmony_ci/**
55079a732c7Sopenharmony_ci * @tc.name: OnSoftbusDeviceFound_002
55179a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
55279a732c7Sopenharmony_ci * @tc.type: FUNC
55379a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
55479a732c7Sopenharmony_ci */
55579a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusDeviceFound_002, testing::ext::TestSize.Level0)
55679a732c7Sopenharmony_ci{
55779a732c7Sopenharmony_ci    DeviceInfo device = {
55879a732c7Sopenharmony_ci        .devId = "123456",
55979a732c7Sopenharmony_ci        .devType = (DeviceType)1,
56079a732c7Sopenharmony_ci        .devName = "com.ohos.helloworld"
56179a732c7Sopenharmony_ci    };
56279a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
56379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
56479a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusDiscoveryCallback(pkgName, std::make_shared<SoftbusDiscoveryCallbackTest>());
56579a732c7Sopenharmony_ci    softbusConnector->OnSoftbusDeviceFound(&device);
56679a732c7Sopenharmony_ci    bool ret = false;
56779a732c7Sopenharmony_ci    if (listener->ipcServerListener_.req_ != nullptr) {
56879a732c7Sopenharmony_ci        listener->ipcServerListener_.req_ = nullptr;
56979a732c7Sopenharmony_ci        ret = true;
57079a732c7Sopenharmony_ci    }
57179a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
57279a732c7Sopenharmony_ci}
57379a732c7Sopenharmony_ci
57479a732c7Sopenharmony_ci/**
57579a732c7Sopenharmony_ci * @tc.name: OnSoftbusDiscoveryResult_001
57679a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
57779a732c7Sopenharmony_ci * @tc.type: FUNC
57879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
57979a732c7Sopenharmony_ci */
58079a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusDiscoveryResult_001, testing::ext::TestSize.Level0)
58179a732c7Sopenharmony_ci{
58279a732c7Sopenharmony_ci    int32_t subscribeId = 123456;
58379a732c7Sopenharmony_ci    RefreshResult result = (RefreshResult)1;
58479a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
58579a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
58679a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusDiscoveryCallback(
58779a732c7Sopenharmony_ci        pkgName, std::make_shared<SoftbusDiscoveryCallbackTest>());
58879a732c7Sopenharmony_ci    softbusConnector->OnSoftbusDiscoveryResult(subscribeId, result);
58979a732c7Sopenharmony_ci    bool ret = false;
59079a732c7Sopenharmony_ci    if (listener->ipcServerListener_.req_ != nullptr) {
59179a732c7Sopenharmony_ci        listener->ipcServerListener_.req_ = nullptr;
59279a732c7Sopenharmony_ci        ret = true;
59379a732c7Sopenharmony_ci    }
59479a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
59579a732c7Sopenharmony_ci    softbusConnector->UnRegisterSoftbusDiscoveryCallback(pkgName);
59679a732c7Sopenharmony_ci}
59779a732c7Sopenharmony_ci
59879a732c7Sopenharmony_ci/**
59979a732c7Sopenharmony_ci * @tc.name: OnSoftbusDiscoveryResult_001
60079a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
60179a732c7Sopenharmony_ci * @tc.type: FUNC
60279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK
60379a732c7Sopenharmony_ci */
60479a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusDiscoveryResult_002, testing::ext::TestSize.Level0)
60579a732c7Sopenharmony_ci{
60679a732c7Sopenharmony_ci    int32_t subscribeId = 123456;
60779a732c7Sopenharmony_ci    RefreshResult result = (RefreshResult)0;
60879a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
60979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
61079a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusDiscoveryCallback(
61179a732c7Sopenharmony_ci        pkgName, std::make_shared<SoftbusDiscoveryCallbackTest>());
61279a732c7Sopenharmony_ci    softbusConnector->OnSoftbusDiscoveryResult(subscribeId, result);
61379a732c7Sopenharmony_ci    bool ret = false;
61479a732c7Sopenharmony_ci    if (listener->ipcServerListener_.req_ != nullptr) {
61579a732c7Sopenharmony_ci        listener->ipcServerListener_.req_ = nullptr;
61679a732c7Sopenharmony_ci        ret = true;
61779a732c7Sopenharmony_ci    }
61879a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
61979a732c7Sopenharmony_ci    softbusConnector->UnRegisterSoftbusDiscoveryCallback(pkgName);
62079a732c7Sopenharmony_ci}
62179a732c7Sopenharmony_ci
62279a732c7Sopenharmony_ci/**
62379a732c7Sopenharmony_ci * @tc.name: OnSoftbusPublishResult_001
62479a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
62579a732c7Sopenharmony_ci * @tc.type: FUNC
62679a732c7Sopenharmony_ci * @tc.require: I5N1K3
62779a732c7Sopenharmony_ci */
62879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusPublishResult_001, testing::ext::TestSize.Level0)
62979a732c7Sopenharmony_ci{
63079a732c7Sopenharmony_ci    int32_t publishId = 123456;
63179a732c7Sopenharmony_ci    PublishResult failReason = (PublishResult)1;
63279a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
63379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
63479a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusPublishCallback(
63579a732c7Sopenharmony_ci        pkgName, std::make_shared<SoftbusPublishCallbackTest>());
63679a732c7Sopenharmony_ci    softbusConnector->OnSoftbusPublishResult(publishId, failReason);
63779a732c7Sopenharmony_ci    bool ret = false;
63879a732c7Sopenharmony_ci    if (listener->ipcServerListener_.req_ != nullptr) {
63979a732c7Sopenharmony_ci        listener->ipcServerListener_.req_ = nullptr;
64079a732c7Sopenharmony_ci        ret = true;
64179a732c7Sopenharmony_ci    }
64279a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
64379a732c7Sopenharmony_ci    softbusConnector->UnRegisterSoftbusPublishCallback(pkgName);
64479a732c7Sopenharmony_ci}
64579a732c7Sopenharmony_ci
64679a732c7Sopenharmony_ci/**
64779a732c7Sopenharmony_ci * @tc.name: OnSoftbusPublishResult_004
64879a732c7Sopenharmony_ci * @tc.desc: go to the correct case and return DM_OK
64979a732c7Sopenharmony_ci * @tc.type: FUNC
65079a732c7Sopenharmony_ci * @tc.require: I5N1K3
65179a732c7Sopenharmony_ci */
65279a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusPublishResult_002, testing::ext::TestSize.Level0)
65379a732c7Sopenharmony_ci{
65479a732c7Sopenharmony_ci    int32_t publishId = 123456;
65579a732c7Sopenharmony_ci    std::string pkgName = "com.ohos.helloworld";
65679a732c7Sopenharmony_ci    PublishResult failReason = (PublishResult)0;
65779a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
65879a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusPublishCallback(
65979a732c7Sopenharmony_ci        pkgName, std::make_shared<SoftbusPublishCallbackTest>());
66079a732c7Sopenharmony_ci    softbusConnector->OnSoftbusPublishResult(publishId, failReason);
66179a732c7Sopenharmony_ci    bool ret = false;
66279a732c7Sopenharmony_ci    if (listener->ipcServerListener_.req_ != nullptr) {
66379a732c7Sopenharmony_ci        listener->ipcServerListener_.req_ = nullptr;
66479a732c7Sopenharmony_ci        ret = true;
66579a732c7Sopenharmony_ci    }
66679a732c7Sopenharmony_ci    EXPECT_EQ(ret, false);
66779a732c7Sopenharmony_ci    softbusConnector->UnRegisterSoftbusPublishCallback(pkgName);
66879a732c7Sopenharmony_ci}
66979a732c7Sopenharmony_ci
67079a732c7Sopenharmony_ci/**
67179a732c7Sopenharmony_ci * @tc.name: JoinLnn_001
67279a732c7Sopenharmony_ci * @tc.desc: set deviceId null
67379a732c7Sopenharmony_ci * @tc.type: FUNC
67479a732c7Sopenharmony_ci */
67579a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, JoinLnn_001, testing::ext::TestSize.Level0)
67679a732c7Sopenharmony_ci{
67779a732c7Sopenharmony_ci    std::string deviceId;
67879a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
67979a732c7Sopenharmony_ci    softbusConnector->JoinLnn(deviceId);
68079a732c7Sopenharmony_ci    EXPECT_EQ(SoftbusConnector::discoveryDeviceInfoMap_.empty(), false);
68179a732c7Sopenharmony_ci}
68279a732c7Sopenharmony_ci
68379a732c7Sopenharmony_ci/**
68479a732c7Sopenharmony_ci * @tc.name: ConvertDeviceInfoToDmDevice_002
68579a732c7Sopenharmony_ci * @tc.desc: set deviceInfo not null
68679a732c7Sopenharmony_ci * @tc.type: FUNC
68779a732c7Sopenharmony_ci */
68879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, ConvertDeviceInfoToDmDevice_002, testing::ext::TestSize.Level0)
68979a732c7Sopenharmony_ci{
69079a732c7Sopenharmony_ci    DeviceInfo deviceInfo = {
69179a732c7Sopenharmony_ci        .devId = "123456",
69279a732c7Sopenharmony_ci        .devType = (DeviceType)1,
69379a732c7Sopenharmony_ci        .devName = "11111"
69479a732c7Sopenharmony_ci    };
69579a732c7Sopenharmony_ci    DmDeviceBasicInfo dmDeviceBasicInfo;
69679a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
69779a732c7Sopenharmony_ci    softbusConnector->ConvertDeviceInfoToDmDevice(deviceInfo, dmDeviceBasicInfo);
69879a732c7Sopenharmony_ci    EXPECT_EQ(dmDeviceBasicInfo.deviceTypeId, deviceInfo.devType);
69979a732c7Sopenharmony_ci}
70079a732c7Sopenharmony_ci
70179a732c7Sopenharmony_ci/**
70279a732c7Sopenharmony_ci * @tc.name: OnSoftbusDeviceDiscovery_001
70379a732c7Sopenharmony_ci * @tc.desc: set device null
70479a732c7Sopenharmony_ci * @tc.type: FUNC
70579a732c7Sopenharmony_ci */
70679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusDeviceDiscovery_001, testing::ext::TestSize.Level0)
70779a732c7Sopenharmony_ci{
70879a732c7Sopenharmony_ci    DeviceInfo *device = nullptr;
70979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
71079a732c7Sopenharmony_ci    softbusConnector->OnSoftbusDeviceDiscovery(device);
71179a732c7Sopenharmony_ci    EXPECT_EQ(SoftbusConnector::discoveryDeviceInfoMap_.empty(), false);
71279a732c7Sopenharmony_ci}
71379a732c7Sopenharmony_ci
71479a732c7Sopenharmony_ci/**
71579a732c7Sopenharmony_ci * @tc.name: OnSoftbusDeviceDiscovery_002
71679a732c7Sopenharmony_ci * @tc.desc: set device not null
71779a732c7Sopenharmony_ci * @tc.type: FUNC
71879a732c7Sopenharmony_ci */
71979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusDeviceDiscovery_002, testing::ext::TestSize.Level0)
72079a732c7Sopenharmony_ci{
72179a732c7Sopenharmony_ci    DeviceInfo device = {
72279a732c7Sopenharmony_ci        .devId = "123456",
72379a732c7Sopenharmony_ci        .devType = (DeviceType)1,
72479a732c7Sopenharmony_ci        .devName = "11111"
72579a732c7Sopenharmony_ci    };
72679a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
72779a732c7Sopenharmony_ci    softbusConnector->OnSoftbusDeviceDiscovery(&device);
72879a732c7Sopenharmony_ci    EXPECT_EQ(SoftbusConnector::discoveryDeviceInfoMap_.empty(), false);
72979a732c7Sopenharmony_ci}
73079a732c7Sopenharmony_ci
73179a732c7Sopenharmony_ci/**
73279a732c7Sopenharmony_ci * @tc.name: GetDeviceUdidByUdidHash_001
73379a732c7Sopenharmony_ci * @tc.desc: set udidHash null
73479a732c7Sopenharmony_ci * @tc.type: FUNC
73579a732c7Sopenharmony_ci */
73679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetDeviceUdidByUdidHash_001, testing::ext::TestSize.Level0)
73779a732c7Sopenharmony_ci{
73879a732c7Sopenharmony_ci    std::string udidHash;
73979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
74079a732c7Sopenharmony_ci    std::string str = softbusConnector->GetDeviceUdidByUdidHash(udidHash);
74179a732c7Sopenharmony_ci    EXPECT_EQ(str.empty(), true);
74279a732c7Sopenharmony_ci}
74379a732c7Sopenharmony_ci
74479a732c7Sopenharmony_ci/**
74579a732c7Sopenharmony_ci * @tc.name: RegisterSoftbusStateCallback_001
74679a732c7Sopenharmony_ci * @tc.desc: set callback null
74779a732c7Sopenharmony_ci * @tc.type: FUNC
74879a732c7Sopenharmony_ci */
74979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, RegisterSoftbusStateCallback_001, testing::ext::TestSize.Level0)
75079a732c7Sopenharmony_ci{
75179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
75279a732c7Sopenharmony_ci    std::shared_ptr<ISoftbusStateCallback> callback = std::make_shared<SoftbusStateCallbackTest>();
75379a732c7Sopenharmony_ci    int32_t ret = softbusConnector->RegisterSoftbusStateCallback(callback);
75479a732c7Sopenharmony_ci    EXPECT_EQ(ret, DM_OK);
75579a732c7Sopenharmony_ci}
75679a732c7Sopenharmony_ci
75779a732c7Sopenharmony_ci/**
75879a732c7Sopenharmony_ci * @tc.name: UnRegisterSoftbusStateCallback_001
75979a732c7Sopenharmony_ci * @tc.type: FUNC
76079a732c7Sopenharmony_ci */
76179a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, UnRegisterSoftbusStateCallback_001, testing::ext::TestSize.Level0)
76279a732c7Sopenharmony_ci{
76379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
76479a732c7Sopenharmony_ci    int32_t ret = softbusConnector->UnRegisterSoftbusStateCallback();
76579a732c7Sopenharmony_ci    EXPECT_EQ(ret, DM_OK);
76679a732c7Sopenharmony_ci}
76779a732c7Sopenharmony_ci
76879a732c7Sopenharmony_ci/**
76979a732c7Sopenharmony_ci * @tc.name: OnSoftbusJoinLNNResult_001
77079a732c7Sopenharmony_ci * @tc.desc: set addr null
77179a732c7Sopenharmony_ci * @tc.desc: set networkId null
77279a732c7Sopenharmony_ci * @tc.desc: set result 0
77379a732c7Sopenharmony_ci * @tc.type: FUNC
77479a732c7Sopenharmony_ci */
77579a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, OnSoftbusJoinLNNResult_001, testing::ext::TestSize.Level0)
77679a732c7Sopenharmony_ci{
77779a732c7Sopenharmony_ci    ConnectionAddr *addr = nullptr;
77879a732c7Sopenharmony_ci    char *networkId = nullptr;
77979a732c7Sopenharmony_ci    int32_t result = 0;
78079a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
78179a732c7Sopenharmony_ci    softbusConnector->OnSoftbusJoinLNNResult(addr, networkId, result);
78279a732c7Sopenharmony_ci    EXPECT_EQ(SoftbusConnector::discoveryDeviceInfoMap_.empty(), false);
78379a732c7Sopenharmony_ci}
78479a732c7Sopenharmony_ci
78579a732c7Sopenharmony_ci/**
78679a732c7Sopenharmony_ci * @tc.name: AddMemberToDiscoverMap_001
78779a732c7Sopenharmony_ci * @tc.type: FUNC
78879a732c7Sopenharmony_ci */
78979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, AddMemberToDiscoverMap_001, testing::ext::TestSize.Level0)
79079a732c7Sopenharmony_ci{
79179a732c7Sopenharmony_ci    std::string deviceId;
79279a732c7Sopenharmony_ci    std::shared_ptr<DeviceInfo> deviceInfo = nullptr;
79379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
79479a732c7Sopenharmony_ci    int32_t ret = softbusConnector->AddMemberToDiscoverMap(deviceId, deviceInfo);
79579a732c7Sopenharmony_ci    EXPECT_EQ(ret, ERR_DM_INPUT_PARA_INVALID);
79679a732c7Sopenharmony_ci}
79779a732c7Sopenharmony_ci
79879a732c7Sopenharmony_ci/**
79979a732c7Sopenharmony_ci * @tc.name: AddMemberToDiscoverMap_002
80079a732c7Sopenharmony_ci * @tc.type: FUNC
80179a732c7Sopenharmony_ci */
80279a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, AddMemberToDiscoverMap_002, testing::ext::TestSize.Level0)
80379a732c7Sopenharmony_ci{
80479a732c7Sopenharmony_ci    std::string deviceId = "deviceId";
80579a732c7Sopenharmony_ci    std::shared_ptr<DeviceInfo> deviceInfo = std::make_shared<DeviceInfo>();
80679a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
80779a732c7Sopenharmony_ci    int32_t ret = softbusConnector->AddMemberToDiscoverMap(deviceId, deviceInfo);
80879a732c7Sopenharmony_ci    EXPECT_EQ(ret, DM_OK);
80979a732c7Sopenharmony_ci}
81079a732c7Sopenharmony_ci
81179a732c7Sopenharmony_ci/**
81279a732c7Sopenharmony_ci * @tc.name: SetPkgName_001
81379a732c7Sopenharmony_ci * @tc.type: FUNC
81479a732c7Sopenharmony_ci */
81579a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, SetPkgName_001, testing::ext::TestSize.Level0)
81679a732c7Sopenharmony_ci{
81779a732c7Sopenharmony_ci    std::string pkgName = "pkgName";
81879a732c7Sopenharmony_ci    std::vector<std::string> pkgNameVec;
81979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
82079a732c7Sopenharmony_ci    softbusConnector->SetPkgNameVec(pkgNameVec);
82179a732c7Sopenharmony_ci    softbusConnector->SetPkgName(pkgName);
82279a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->pkgNameVec_.empty(), false);
82379a732c7Sopenharmony_ci}
82479a732c7Sopenharmony_ci
82579a732c7Sopenharmony_ci/**
82679a732c7Sopenharmony_ci * @tc.name: GetDeviceUdidHashByUdid_001
82779a732c7Sopenharmony_ci * @tc.type: FUNC
82879a732c7Sopenharmony_ci */
82979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetDeviceUdidHashByUdid_001, testing::ext::TestSize.Level0)
83079a732c7Sopenharmony_ci{
83179a732c7Sopenharmony_ci    std::string udid = "123456789";
83279a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
83379a732c7Sopenharmony_ci    std::string ret = softbusConnector->GetDeviceUdidHashByUdid(udid);
83479a732c7Sopenharmony_ci    EXPECT_EQ(ret.empty(), false);
83579a732c7Sopenharmony_ci}
83679a732c7Sopenharmony_ci
83779a732c7Sopenharmony_ci/**
83879a732c7Sopenharmony_ci * @tc.name: EraseUdidFromMap_001
83979a732c7Sopenharmony_ci * @tc.type: FUNC
84079a732c7Sopenharmony_ci */
84179a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, EraseUdidFromMap_001, testing::ext::TestSize.Level0)
84279a732c7Sopenharmony_ci{
84379a732c7Sopenharmony_ci    std::string udid = "123456789";
84479a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
84579a732c7Sopenharmony_ci    softbusConnector->EraseUdidFromMap(udid);
84679a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->deviceUdidMap_.empty(), false);
84779a732c7Sopenharmony_ci}
84879a732c7Sopenharmony_ci
84979a732c7Sopenharmony_ci/**
85079a732c7Sopenharmony_ci * @tc.name: GetLocalDeviceName_001
85179a732c7Sopenharmony_ci * @tc.type: FUNC
85279a732c7Sopenharmony_ci */
85379a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetLocalDeviceName_001, testing::ext::TestSize.Level0)
85479a732c7Sopenharmony_ci{
85579a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
85679a732c7Sopenharmony_ci    std::string ret = softbusConnector->GetLocalDeviceName();
85779a732c7Sopenharmony_ci    EXPECT_EQ(ret.empty(), true);
85879a732c7Sopenharmony_ci}
85979a732c7Sopenharmony_ci
86079a732c7Sopenharmony_ci/**
86179a732c7Sopenharmony_ci * @tc.name: GetNetworkIdByDeviceId_001
86279a732c7Sopenharmony_ci * @tc.type: FUNC
86379a732c7Sopenharmony_ci */
86479a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetNetworkIdByDeviceId_001, testing::ext::TestSize.Level0)
86579a732c7Sopenharmony_ci{
86679a732c7Sopenharmony_ci    std::string deviceId = "deviceId";
86779a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
86879a732c7Sopenharmony_ci    std::string ret = softbusConnector->GetNetworkIdByDeviceId(deviceId);
86979a732c7Sopenharmony_ci    EXPECT_EQ(ret.empty(), true);
87079a732c7Sopenharmony_ci}
87179a732c7Sopenharmony_ci
87279a732c7Sopenharmony_ci/**
87379a732c7Sopenharmony_ci * @tc.name: SetPkgNameVec_001
87479a732c7Sopenharmony_ci * @tc.type: FUNC
87579a732c7Sopenharmony_ci */
87679a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, SetPkgNameVec_001, testing::ext::TestSize.Level0)
87779a732c7Sopenharmony_ci{
87879a732c7Sopenharmony_ci    std::vector<std::string> pkgNameVec;
87979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
88079a732c7Sopenharmony_ci    softbusConnector->SetPkgNameVec(pkgNameVec);
88179a732c7Sopenharmony_ci    EXPECT_EQ(pkgNameVec.empty(), true);
88279a732c7Sopenharmony_ci}
88379a732c7Sopenharmony_ci
88479a732c7Sopenharmony_ci/**
88579a732c7Sopenharmony_ci * @tc.name: GetPkgName_001
88679a732c7Sopenharmony_ci * @tc.type: FUNC
88779a732c7Sopenharmony_ci */
88879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetPkgName_001, testing::ext::TestSize.Level0)
88979a732c7Sopenharmony_ci{
89079a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
89179a732c7Sopenharmony_ci    auto ret = softbusConnector->GetPkgName();
89279a732c7Sopenharmony_ci    EXPECT_EQ(ret.empty(), true);
89379a732c7Sopenharmony_ci}
89479a732c7Sopenharmony_ci
89579a732c7Sopenharmony_ci/**
89679a732c7Sopenharmony_ci * @tc.name: ClearPkgName_001
89779a732c7Sopenharmony_ci * @tc.type: FUNC
89879a732c7Sopenharmony_ci */
89979a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, ClearPkgName_001, testing::ext::TestSize.Level0)
90079a732c7Sopenharmony_ci{
90179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
90279a732c7Sopenharmony_ci    softbusConnector->ClearPkgName();
90379a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->pkgNameVec_.empty(), true);
90479a732c7Sopenharmony_ci}
90579a732c7Sopenharmony_ci
90679a732c7Sopenharmony_ci/**
90779a732c7Sopenharmony_ci * @tc.name: HandleDeviceOnline_001
90879a732c7Sopenharmony_ci * @tc.type: FUNC
90979a732c7Sopenharmony_ci */
91079a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, HandleDeviceOnline_001, testing::ext::TestSize.Level0)
91179a732c7Sopenharmony_ci{
91279a732c7Sopenharmony_ci    std::string deviceId = "deviceId";
91379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
91479a732c7Sopenharmony_ci    std::shared_ptr<ISoftbusStateCallback> callback = std::make_shared<SoftbusStateCallbackTest>();
91579a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusStateCallback(callback);
91679a732c7Sopenharmony_ci    softbusConnector->HandleDeviceOnline(deviceId, DmAuthForm::ACROSS_ACCOUNT);
91779a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->pkgNameVec_.empty(), true);
91879a732c7Sopenharmony_ci}
91979a732c7Sopenharmony_ci
92079a732c7Sopenharmony_ci/**
92179a732c7Sopenharmony_ci * @tc.name: HandleDeviceOffline_001
92279a732c7Sopenharmony_ci * @tc.type: FUNC
92379a732c7Sopenharmony_ci */
92479a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, HandleDeviceOffline_001, testing::ext::TestSize.Level0)
92579a732c7Sopenharmony_ci{
92679a732c7Sopenharmony_ci    std::string deviceId = "deviceId";
92779a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
92879a732c7Sopenharmony_ci    std::shared_ptr<ISoftbusStateCallback> callback = std::make_shared<SoftbusStateCallbackTest>();
92979a732c7Sopenharmony_ci    softbusConnector->RegisterSoftbusStateCallback(callback);
93079a732c7Sopenharmony_ci    softbusConnector->HandleDeviceOffline(deviceId);
93179a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->pkgNameVec_.empty(), true);
93279a732c7Sopenharmony_ci}
93379a732c7Sopenharmony_ci
93479a732c7Sopenharmony_ci/**
93579a732c7Sopenharmony_ci * @tc.name: CheckIsOnline_001
93679a732c7Sopenharmony_ci * @tc.type: FUNC
93779a732c7Sopenharmony_ci */
93879a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, CheckIsOnline_001, testing::ext::TestSize.Level0)
93979a732c7Sopenharmony_ci{
94079a732c7Sopenharmony_ci    std::string targetDeviceId = "targetDeviceId";
94179a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
94279a732c7Sopenharmony_ci    softbusConnector->CheckIsOnline(targetDeviceId);
94379a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->pkgNameVec_.empty(), true);
94479a732c7Sopenharmony_ci}
94579a732c7Sopenharmony_ci
94679a732c7Sopenharmony_ci/**
94779a732c7Sopenharmony_ci * @tc.name: GetDeviceInfoByDeviceId_001
94879a732c7Sopenharmony_ci * @tc.type: FUNC
94979a732c7Sopenharmony_ci */
95079a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, GetDeviceInfoByDeviceId_001, testing::ext::TestSize.Level0)
95179a732c7Sopenharmony_ci{
95279a732c7Sopenharmony_ci    std::string deviceId = "deviceId";
95379a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
95479a732c7Sopenharmony_ci    auto ret = softbusConnector->GetDeviceInfoByDeviceId(deviceId);
95579a732c7Sopenharmony_ci    EXPECT_EQ(ret.deviceId == deviceId, false);
95679a732c7Sopenharmony_ci}
95779a732c7Sopenharmony_ci
95879a732c7Sopenharmony_ci/**
95979a732c7Sopenharmony_ci * @tc.name: ConvertNodeBasicInfoToDmDevice_001
96079a732c7Sopenharmony_ci * @tc.type: FUNC
96179a732c7Sopenharmony_ci */
96279a732c7Sopenharmony_ciHWTEST_F(SoftbusConnectorTest, ConvertNodeBasicInfoToDmDevice_001, testing::ext::TestSize.Level0)
96379a732c7Sopenharmony_ci{
96479a732c7Sopenharmony_ci    NodeBasicInfo nodeBasicInfo = {
96579a732c7Sopenharmony_ci        .networkId = "123456",
96679a732c7Sopenharmony_ci        .deviceName = "name",
96779a732c7Sopenharmony_ci    };
96879a732c7Sopenharmony_ci    DmDeviceInfo dmDeviceInfo;
96979a732c7Sopenharmony_ci    std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
97079a732c7Sopenharmony_ci    softbusConnector->ConvertNodeBasicInfoToDmDevice(nodeBasicInfo, dmDeviceInfo);
97179a732c7Sopenharmony_ci    EXPECT_EQ(softbusConnector->pkgNameVec_.empty(), true);
97279a732c7Sopenharmony_ci}
97379a732c7Sopenharmony_ci} // namespace
97479a732c7Sopenharmony_ci} // namespace DistributedHardware
97579a732c7Sopenharmony_ci} // namespace OHOS-