• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #define private public
18 #include "net_manager_constants.h"
19 #include "net_supplier_callback_base.h"
20 #include "net_supplier_callback_stub.h"
21 namespace OHOS {
22 namespace NetManagerStandard {
23 using namespace testing::ext;
24 class NetSupplierCallbackBaseTest : public testing::Test {
25 public:
26     static void SetUpTestCase();
27     static void TearDownTestCase();
28     void SetUp();
29     void TearDown();
30 
31     static inline std::shared_ptr<NetSupplierCallbackBase> supplierCbStub_ =
32         std::make_shared<NetSupplierCallbackBase>();
33 };
34 
SetUpTestCase()35 void NetSupplierCallbackBaseTest::SetUpTestCase() {}
36 
TearDownTestCase()37 void NetSupplierCallbackBaseTest::TearDownTestCase() {}
38 
SetUp()39 void NetSupplierCallbackBaseTest::SetUp() {}
40 
TearDown()41 void NetSupplierCallbackBaseTest::TearDown() {}
42 
43 HWTEST_F(NetSupplierCallbackBaseTest, RequestNetwork001, TestSize.Level1)
44 {
45     std::string ident = "testsupid";
46     std::set<NetCap> netCaps;
47     netCaps.insert(NetCap::NET_CAPABILITY_NOT_METERED);
48     int32_t ret = supplierCbStub_->RequestNetwork(ident, netCaps);
49     EXPECT_EQ(ret, NETMANAGER_SUCCESS);
50 }
51 
52 HWTEST_F(NetSupplierCallbackBaseTest, ReleaseNetwork001, TestSize.Level1)
53 {
54     std::string ident = "testsupid";
55     std::set<NetCap> netCaps;
56     netCaps.insert(NetCap::NET_CAPABILITY_NOT_METERED);
57     int32_t ret = supplierCbStub_->ReleaseNetwork(ident, netCaps);
58     EXPECT_EQ(ret, NETMANAGER_SUCCESS);
59 }
60 
61 HWTEST_F(NetSupplierCallbackBaseTest, AddRequest001, TestSize.Level1)
62 {
63     NetRequest netrequest;
64     int32_t ret = supplierCbStub_->AddRequest(netrequest);
65     EXPECT_EQ(ret, NETMANAGER_SUCCESS);
66 }
67 HWTEST_F(NetSupplierCallbackBaseTest, RemoveRequest001, TestSize.Level1)
68 {
69     NetRequest netrequest;
70     int32_t ret = supplierCbStub_->RemoveRequest(netrequest);
71     EXPECT_EQ(ret, NETMANAGER_SUCCESS);
72 }
73 } // namespace NetManagerStandard
74 } // namespace OHOS