1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17
18 #include "net_conn_service_iface.h"
19 #include "net_conn_constants.h"
20 #include "net_manager_constants.h"
21
22 namespace OHOS {
23 namespace NetManagerStandard {
24 namespace {
25 using namespace testing::ext;
26 constexpr const char *TEST_IDENT = "test_ident";
27 uint32_t g_supplierId = 0;
28 } // namespace
29
30 class NetConnServiceIfaceTest : public testing::Test {
31 public:
32 static void SetUpTestCase();
33 static void TearDownTestCase();
34 void SetUp();
35 void TearDown();
36 static inline NetConnServiceIface instance_;
37 };
38
SetUpTestCase()39 void NetConnServiceIfaceTest::SetUpTestCase() {}
40
TearDownTestCase()41 void NetConnServiceIfaceTest::TearDownTestCase() {}
42
SetUp()43 void NetConnServiceIfaceTest::SetUp() {}
44
TearDown()45 void NetConnServiceIfaceTest::TearDown() {}
46
47 HWTEST_F(NetConnServiceIfaceTest, GetIfaceNamesTest001, TestSize.Level1)
48 {
49 std::list<std::string> ifaceNames;
50 int32_t ret = instance_.GetIfaceNames(NetBearType::BEARER_ETHERNET, ifaceNames);
51 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
52 }
53
54 HWTEST_F(NetConnServiceIfaceTest, GetIfaceNameByTypeTest001, TestSize.Level1)
55 {
56 std::string ifaceName;
57 int32_t ret = instance_.GetIfaceNameByType(NetBearType::BEARER_ETHERNET, TEST_IDENT, ifaceName);
58 EXPECT_EQ(ret, NET_CONN_ERR_NO_SUPPLIER);
59 }
60
61 HWTEST_F(NetConnServiceIfaceTest, RegisterNetSupplierTest001, TestSize.Level1)
62 {
63 uint32_t supplierId = 0;
64 int32_t ret = instance_.UnregisterNetSupplier(supplierId);
65 EXPECT_EQ(ret, NETMANAGER_ERROR);
66 }
67
68 HWTEST_F(NetConnServiceIfaceTest, UpdateNetLinkInfoTest001, TestSize.Level1)
69 {
70 sptr<NetLinkInfo> netLinkInfo = new (std::nothrow) NetLinkInfo();
71 ASSERT_NE(netLinkInfo, nullptr);
72 auto ret = instance_.UpdateNetLinkInfo(g_supplierId, netLinkInfo);
73 EXPECT_EQ(ret, NETMANAGER_ERROR);
74 }
75
76 HWTEST_F(NetConnServiceIfaceTest, UpdateNetSupplierInfoTest001, TestSize.Level1)
77 {
78 sptr<NetSupplierInfo> netSupplierInfo = new (std::nothrow) NetSupplierInfo();
79 ASSERT_NE(netSupplierInfo, nullptr);
80 auto ret = instance_.UpdateNetSupplierInfo(g_supplierId, netSupplierInfo);
81 EXPECT_EQ(ret, NETMANAGER_ERROR);
82 }
83
84 HWTEST_F(NetConnServiceIfaceTest, RestrictBackgroundChangedTest001, TestSize.Level1)
85 {
86 int32_t ret = instance_.RestrictBackgroundChanged(false);
87 EXPECT_EQ(ret, NETMANAGER_ERROR);
88 }
89
90 } // namespace NetManagerStandard
91 } // namespace OHOS