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 16 #ifndef AUTH_CONNECTION_MOCK_H 17 #define AUTH_CONNECTION_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "auth_connection.h" 22 #include "auth_pre_link.h" 23 24 namespace OHOS { 25 class AuthConnectionInterface { 26 public: AuthConnectionInterface()27 AuthConnectionInterface() {}; ~AuthConnectionInterface()28 virtual ~AuthConnectionInterface() {}; 29 30 virtual int32_t SoftBusGetBtState(void) = 0; 31 virtual int32_t PostAuthEvent(EventType event, EventHandler handler, const void *obj, uint32_t size, 32 uint64_t delayMs) = 0; 33 virtual bool IsHaveAuthIdByConnId(uint64_t connId) = 0; 34 virtual int32_t FindAuthPreLinkNodeById(uint32_t requestId, AuthPreLinkNode *reuseNode) = 0; 35 virtual int32_t SocketSetDevice(int32_t fd, bool isBlockMode) = 0; 36 virtual int32_t SocketPostBytes(int32_t fd, const AuthDataHead *head, const uint8_t *data) = 0; 37 virtual int32_t StartSocketListening(ListenerModule module, const LocalListenerInfo *info) = 0; 38 virtual void DelAuthPreLinkById(uint32_t requestId); 39 }; 40 41 class AuthConnectionInterfaceMock : public AuthConnectionInterface { 42 public: 43 AuthConnectionInterfaceMock(); 44 ~AuthConnectionInterfaceMock() override; 45 46 MOCK_METHOD0(SoftBusGetBtState, int32_t (void)); 47 MOCK_METHOD5(PostAuthEvent, int32_t (EventType, EventHandler, const void *, uint32_t, uint64_t)); 48 MOCK_METHOD1(IsHaveAuthIdByConnId, bool (uint64_t)); 49 MOCK_METHOD2(FindAuthPreLinkNodeById, int32_t (uint32_t, AuthPreLinkNode *)); 50 MOCK_METHOD2(SocketSetDevice, int32_t (int32_t, bool)); 51 MOCK_METHOD3(SocketPostBytes, int32_t (int32_t, const AuthDataHead *, const uint8_t *)); 52 MOCK_METHOD2(StartSocketListening, int32_t (ListenerModule, const LocalListenerInfo *)); 53 MOCK_METHOD1(DelAuthPreLinkById, void (uint32_t)); 54 }; 55 } 56 #endif 57