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 USB_DDK_SERVICE_MOCK_H 17 #define USB_DDK_SERVICE_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include <gtest/gtest.h> 21 #include "v1_0/iusb_ddk.h" 22 23 namespace OHOS { 24 namespace USB { 25 using namespace OHOS::HDI::Usb::Ddk::V1_0; 26 class UsbDdkServiceMock : public IUsbDdk { 27 public: 28 UsbDdkServiceMock() = default; 29 ~UsbDdkServiceMock() = default; 30 int32_t GetConfigDescriptor(uint64_t deviceId, uint8_t configIndex, std::vector<uint8_t> &configDesc) override; 31 MOCK_METHOD0(Init, int32_t()); 32 MOCK_METHOD0(Release, int32_t()); 33 MOCK_METHOD2(GetDeviceDescriptor, int32_t(uint64_t deviceId, UsbDeviceDescriptor &desc)); 34 MOCK_METHOD3(ClaimInterface, int32_t(uint64_t deviceId, uint8_t interfaceIndex, uint64_t &interfaceHandle)); 35 MOCK_METHOD1(ReleaseInterface, int32_t(uint64_t interfaceHandle)); 36 MOCK_METHOD2(SelectInterfaceSetting, int32_t(uint64_t interfaceHandle, uint8_t settingIndex)); 37 MOCK_METHOD2(GetCurrentInterfaceSetting, int32_t(uint64_t interfaceHandle, uint8_t &settingIndex)); 38 MOCK_METHOD4(SendControlReadRequest, int32_t(uint64_t interfaceHandle, const UsbControlRequestSetup &setup, 39 uint32_t timeout, std::vector<uint8_t> &data)); 40 MOCK_METHOD4(SendControlWriteRequest, int32_t(uint64_t interfaceHandle, const UsbControlRequestSetup &setup, 41 uint32_t timeout, const std::vector<uint8_t> &data)); 42 MOCK_METHOD5(SendPipeRequest, int32_t(const UsbRequestPipe &pipe, uint32_t size, uint32_t offset, uint32_t length, 43 uint32_t &transferedLength)); 44 MOCK_METHOD2(GetDeviceMemMapFd, int32_t(uint64_t deviceId, int &fd)); 45 MOCK_METHOD3(SendPipeRequestWithAshmem, int32_t(const UsbRequestPipe &pipe, const UsbAshmem &ashmem, 46 uint32_t &transferredLength)); 47 }; 48 } // namespace USB 49 } // namespace OHOS 50 #endif