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 <memory>
17 
18 #include <gtest/gtest.h>
19 
20 #include "extended_vpn_ctl.h"
21 #include "net_manager_constants.h"
22 
23 namespace OHOS {
24 namespace NetManagerStandard {
25 
26 using namespace testing::ext;
27 
28 class ExtendedVpnCtlTest : public testing::Test {
29 public:
30     static inline std::unique_ptr<ExtendedVpnCtl> vpnControl_ = nullptr;
31     static void SetUpTestSuite();
32 };
33 
SetUpTestSuite()34 void ExtendedVpnCtlTest::SetUpTestSuite()
35 {
36     sptr<VpnConfig> config = new (std::nothrow) VpnConfig();
37     if (config == nullptr) {
38         return;
39     }
40     int32_t userId = 0;
41     std::vector<int32_t> activeUserIds;
42     vpnControl_ = std::make_unique<ExtendedVpnCtl>(config, "pkg", userId, activeUserIds);
43 }
44 
45 HWTEST_F(ExtendedVpnCtlTest, SetUp, TestSize.Level1)
46 {
47     EXPECT_EQ(vpnControl_->SetUp(), NETMANAGER_EXT_ERR_INTERNAL);
48 }
49 
50 HWTEST_F(ExtendedVpnCtlTest, Destroy, TestSize.Level1)
51 {
52     EXPECT_EQ(vpnControl_->Destroy(), NETMANAGER_EXT_SUCCESS);
53 }
54 
55 HWTEST_F(ExtendedVpnCtlTest, IsInternalVpn, TestSize.Level1)
56 {
57     EXPECT_EQ(vpnControl_->IsInternalVpn(), false);
58 }
59 
60 } // namespace NetManagerStandard
61 } // namespace OHOS
62