• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef CLIENT_CONNECTION_MOCK_TEST_H
16 #define CLIENT_CONNECTION_MOCK_TEST_H
17 #include <gmock/gmock.h>
18 
19 #include "general_client_connection.h"
20 #include "softbus_adapter_thread.h"
21 
22 namespace OHOS {
23 class ClientConnectionInterface {
24 public:
ClientConnectionInterface()25     ClientConnectionInterface() {};
~ClientConnectionInterface()26     virtual ~ClientConnectionInterface() {};
27     virtual int32_t SoftBusMutexInit(SoftBusMutex *mutex, SoftBusMutexAttr *mutexAttr);
28     virtual int32_t SoftBusMutexLockInner(SoftBusMutex *mutex);
29     virtual int32_t SoftBusMutexUnlockInner(SoftBusMutex *mutex);
30     virtual int32_t InitSoftBus(const char *pkgName);
31     virtual int32_t ServerIpcCreateServer(const char *pkgName, const char *name);
32     virtual int32_t ServerIpcRemoveServer(const char *pkgName, const char *name);
33     virtual int32_t ServerIpcConnect(const char *pkgName, const char *name, const Address *address);
34     virtual int32_t ServerIpcDisconnect(uint32_t handle);
35     virtual int32_t ServerIpcSend(uint32_t handle, const uint8_t *data, uint32_t len);
36     virtual int32_t ServerIpcGetPeerDeviceId(uint32_t handle, char *deviceId, uint32_t len);
37 };
38 
39 class ClientConnectionInterfaceMock : public ClientConnectionInterface {
40 public:
41     ClientConnectionInterfaceMock();
42     ~ClientConnectionInterfaceMock() override;
43     MOCK_METHOD2(SoftBusMutexInit, int32_t(SoftBusMutex *mutex, SoftBusMutexAttr *mutexAttr));
44     MOCK_METHOD1(SoftBusMutexLockInner, int32_t(SoftBusMutex *mutex));
45     MOCK_METHOD1(SoftBusMutexUnlockInner, int32_t(SoftBusMutex *mutex));
46     MOCK_METHOD1(InitSoftBus, int32_t(const char *pkgName));
47     MOCK_METHOD2(ServerIpcCreateServer, int32_t(const char *pkgName, const char *name));
48     MOCK_METHOD2(ServerIpcRemoveServer, int32_t(const char *pkgName, const char *name));
49     MOCK_METHOD3(ServerIpcConnect, int32_t(const char *pkgName, const char *name, const Address *address));
50     MOCK_METHOD1(ServerIpcDisconnect, int32_t(uint32_t handle));
51     MOCK_METHOD3(ServerIpcSend, int32_t(uint32_t handle, const uint8_t *data, uint32_t len));
52     MOCK_METHOD3(ServerIpcGetPeerDeviceId, int32_t(uint32_t handle, char *deviceId, uint32_t len));
53 };
54 } // namespace OHOS
55 #endif // CLIENT_CONNECTION_MOCK_TEST_H