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 #include "cooperate_client_test_mock.h"
16 
17 #include "tunnel_client.h"
18 
19 namespace OHOS {
20 namespace Msdp {
21 namespace DeviceStatus {
22 
23 CooperateClientMock *CooperateClientMock::g_mock;
24 
CooperateClientMock()25 CooperateClientMock::CooperateClientMock()
26 {
27     g_mock = this;
28 }
29 
~CooperateClientMock()30 CooperateClientMock::~CooperateClientMock()
31 {
32     g_mock = nullptr;
33 }
34 
~TunnelClient()35 TunnelClient::~TunnelClient()
36 {
37     if (devicestatusProxy_ != nullptr) {
38         auto remoteObject = devicestatusProxy_->AsObject();
39         if (remoteObject != nullptr) {
40             remoteObject->RemoveDeathRecipient(deathRecipient_);
41         }
42     }
43 }
44 
Enable(Intention intention,ParamBase & data,ParamBase & reply)45 int32_t TunnelClient::Enable(Intention intention, ParamBase &data, ParamBase &reply)
46 {
47     return CooperateClientMock::GetMock().Enable(intention, data, reply);
48 }
49 
Disable(Intention intention,ParamBase & data,ParamBase & reply)50 int32_t TunnelClient::Disable(Intention intention, ParamBase &data, ParamBase &reply)
51 {
52     return CooperateClientMock::GetMock().Disable(intention, data, reply);
53 }
54 
Start(Intention intention,ParamBase & data,ParamBase & reply)55 int32_t TunnelClient::Start(Intention intention, ParamBase &data, ParamBase &reply)
56 {
57     return CooperateClientMock::GetMock().Start(intention, data, reply);
58 }
59 
Stop(Intention intention,ParamBase & data,ParamBase & reply)60 int32_t TunnelClient::Stop(Intention intention, ParamBase &data, ParamBase &reply)
61 {
62     return CooperateClientMock::GetMock().Stop(intention, data, reply);
63 }
64 
AddWatch(Intention intention,uint32_t id,ParamBase & data,ParamBase & reply)65 int32_t TunnelClient::AddWatch(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply)
66 {
67     return CooperateClientMock::GetMock().AddWatch(intention, id, data, reply);
68 }
69 
RemoveWatch(Intention intention,uint32_t id,ParamBase & data,ParamBase & reply)70 int32_t TunnelClient::RemoveWatch(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply)
71 {
72     return CooperateClientMock::GetMock().RemoveWatch(intention, id, data, reply);
73 }
74 
SetParam(Intention intention,uint32_t id,ParamBase & data,ParamBase & reply)75 int32_t TunnelClient::SetParam(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply)
76 {
77     return CooperateClientMock::GetMock().SetParam(intention, id, data, reply);
78 }
79 
GetParam(Intention intention,uint32_t id,ParamBase & data,ParamBase & reply)80 int32_t TunnelClient::GetParam(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply)
81 {
82     return CooperateClientMock::GetMock().GetParam(intention, id, data, reply);
83 }
84 
Control(Intention intention,uint32_t id,ParamBase & data,ParamBase & reply)85 int32_t TunnelClient::Control(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply)
86 {
87     return CooperateClientMock::GetMock().Control(intention, id, data, reply);
88 }
89 
90 } // namespace DeviceStatus
91 } // namespace Msdp
92 } // namespace OHOS