1 /*
2  * Copyright (c) 2024 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 #ifndef COMMON_NET_CONN_CALLBACK_TEST_H
17 #define COMMON_NET_CONN_CALLBACK_TEST_H
18 
19 #include "i_net_conn_callback.h"
20 #include "iremote_object.h"
21 #include "net_conn_callback_stub.h"
22 #include "net_manager_constants.h"
23 #include "net_supplier_callback_base.h"
24 #include "net_supplier_callback_stub.h"
25 #include "net_manager_constants.h"
26 #include <iostream>
27 
28 namespace OHOS {
29 namespace NetManagerStandard {
30 class INetConnCallbackTest : public IRemoteStub<INetConnCallback> {
31 public:
NetAvailable(sptr<NetHandle> & netHandle)32     int32_t NetAvailable(sptr<NetHandle> &netHandle)
33     {
34         return NETMANAGER_SUCCESS;
35     }
36 
NetCapabilitiesChange(sptr<NetHandle> & netHandle,const sptr<NetAllCapabilities> & netAllCap)37     int32_t NetCapabilitiesChange(sptr<NetHandle> &netHandle, const sptr<NetAllCapabilities> &netAllCap)
38     {
39         return NETMANAGER_SUCCESS;
40     }
41 
NetConnectionPropertiesChange(sptr<NetHandle> & netHandle,const sptr<NetLinkInfo> & info)42     int32_t NetConnectionPropertiesChange(sptr<NetHandle> &netHandle, const sptr<NetLinkInfo> &info)
43     {
44         return NETMANAGER_SUCCESS;
45     }
46 
NetLost(sptr<NetHandle> & netHandle)47     int32_t NetLost(sptr<NetHandle> &netHandle)
48     {
49         return NETMANAGER_SUCCESS;
50     }
51 
NetUnavailable()52     int32_t NetUnavailable()
53     {
54         return NETMANAGER_SUCCESS;
55     }
56 
NetBlockStatusChange(sptr<NetHandle> & netHandle,bool blocked)57     int32_t NetBlockStatusChange(sptr<NetHandle> &netHandle, bool blocked)
58     {
59         return NETMANAGER_SUCCESS;
60     }
61 };
62 
63 class PreAirplaneCallbackTest : public PreAirplaneCallbackStub {
64 public:
PreAirplaneStart()65     int32_t PreAirplaneStart() override
66     {
67         std::cout << "test PreAirplaneStart" << std::endl;
68         return NETMANAGER_SUCCESS;
69     }
70 };
71 
72 class NetSupplierCallbackBaseTestCb : public NetSupplierCallbackBase {
73 public:
74     virtual ~NetSupplierCallbackBaseTestCb() = default;
75 
76     int32_t RequestNetwork(const std::string &ident, const std::set<NetCap> &netCaps,
77         const NetRequest &netrequest = {}) override
78     {
79         return NETMANAGER_SUCCESS;
80     };
81 
ReleaseNetwork(const std::string & ident,const std::set<NetCap> & netCaps)82     int32_t ReleaseNetwork(const std::string &ident, const std::set<NetCap> &netCaps) override
83     {
84         return NETMANAGER_SUCCESS;
85     };
86 };
87 
88 class NetSupplierCallbackStubTestCb : public NetSupplierCallbackStub {
89 public:
90     NetSupplierCallbackStubTestCb() = default;
~NetSupplierCallbackStubTestCb()91     ~NetSupplierCallbackStubTestCb() {}
92 
93     int32_t RequestNetwork(const std::string &ident, const std::set<NetCap> &netCaps,
94                            const NetRequest &netrequest = {}) override
95     {
96         return NETMANAGER_SUCCESS;
97     }
98 
ReleaseNetwork(const std::string & ident,const std::set<NetCap> & netCaps)99     int32_t ReleaseNetwork(const std::string &ident, const std::set<NetCap> &netCaps) override
100     {
101         return NETMANAGER_SUCCESS;
102     }
103 };
104 
105 class IPreAirplaneCallbackStubTestCb : public PreAirplaneCallbackStub {
106 public:
107     IPreAirplaneCallbackStubTestCb() = default;
108     ~IPreAirplaneCallbackStubTestCb() = default;
109 
PreAirplaneStart()110     int32_t PreAirplaneStart() override
111     {
112         std::cout << "fuzz test PreAirplaneStart" << std::endl;
113         return NETMANAGER_SUCCESS;
114     }
115 };
116 
117 class NetConnCallbackStubCb : public NetConnCallbackStub {
NetAvailable(sptr<NetHandle> & netHandle)118     int32_t NetAvailable(sptr<NetHandle> &netHandle) override
119     {
120         return NETMANAGER_SUCCESS;
121     }
122 
NetCapabilitiesChange(sptr<NetHandle> & netHandle,const sptr<NetAllCapabilities> & netAllCap)123     int32_t NetCapabilitiesChange(sptr<NetHandle> &netHandle, const sptr<NetAllCapabilities> &netAllCap) override
124     {
125         return NETMANAGER_SUCCESS;
126     }
127 
NetConnectionPropertiesChange(sptr<NetHandle> & netHandle,const sptr<NetLinkInfo> & info)128     int32_t NetConnectionPropertiesChange(sptr<NetHandle> &netHandle, const sptr<NetLinkInfo> &info) override
129     {
130         return NETMANAGER_SUCCESS;
131     }
132 
NetLost(sptr<NetHandle> & netHandle)133     int32_t NetLost(sptr<NetHandle> &netHandle) override
134     {
135         return NETMANAGER_SUCCESS;
136     }
137 
NetUnavailable()138     int32_t NetUnavailable() override
139     {
140         return NETMANAGER_SUCCESS;
141     }
142 
NetBlockStatusChange(sptr<NetHandle> & netHandle,bool blocked)143     int32_t NetBlockStatusChange(sptr<NetHandle> &netHandle, bool blocked) override
144     {
145         return NETMANAGER_SUCCESS;
146     }
147 };
148 } // namespace NetManagerStandard
149 } // namespace OHOS
150 #endif // COMMON_NET_CONN_CALLBACK_TEST_H
151