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
18 #include "net_manager_constants.h"
19 #include "net_supplier_callback_base.h"
20 #include "net_supplier_callback_stub.h"
21
22 namespace OHOS {
23 namespace NetManagerStandard {
24 using namespace testing::ext;
25 class NetSupplierCallbackBaseTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp();
30 void TearDown();
31
32 static inline std::shared_ptr<NetSupplierCallbackBase> supplierCbStub_ =
33 std::make_shared<NetSupplierCallbackBase>();
34 };
35
SetUpTestCase()36 void NetSupplierCallbackBaseTest::SetUpTestCase() {}
37
TearDownTestCase()38 void NetSupplierCallbackBaseTest::TearDownTestCase() {}
39
SetUp()40 void NetSupplierCallbackBaseTest::SetUp() {}
41
TearDown()42 void NetSupplierCallbackBaseTest::TearDown() {}
43
44 HWTEST_F(NetSupplierCallbackBaseTest, RequestNetwork001, TestSize.Level1)
45 {
46 std::string ident = "testsupid";
47 std::set<NetCap> netCaps;
48 netCaps.insert(NetCap::NET_CAPABILITY_NOT_METERED);
49 int32_t ret = supplierCbStub_->RequestNetwork(ident, netCaps);
50 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
51 }
52
53 HWTEST_F(NetSupplierCallbackBaseTest, ReleaseNetwork001, TestSize.Level1)
54 {
55 std::string ident = "testsupid";
56 std::set<NetCap> netCaps;
57 netCaps.insert(NetCap::NET_CAPABILITY_NOT_METERED);
58 int32_t ret = supplierCbStub_->ReleaseNetwork(ident, netCaps);
59 EXPECT_EQ(ret, NETMANAGER_SUCCESS);
60 }
61 } // namespace NetManagerStandard
62 } // namespace OHOS