1 /* 2 * Copyright (c) 2024-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 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_1/iusb_ddk.h" 22 23 namespace OHOS { 24 namespace USB { 25 using namespace OHOS::HDI::Usb::Ddk; 26 class UsbDdkServiceMock : public V1_1::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, V1_1::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 V1_1::UsbControlRequestSetup &setup, 39 uint32_t timeout, std::vector<uint8_t> &data)); 40 MOCK_METHOD4(SendControlWriteRequest, int32_t(uint64_t interfaceHandle, const V1_1::UsbControlRequestSetup &setup, 41 uint32_t timeout, const std::vector<uint8_t> &data)); 42 MOCK_METHOD5(SendPipeRequest, int32_t(const V1_1::UsbRequestPipe &pipe, uint32_t size, uint32_t offset, 43 uint32_t length, uint32_t &transferedLength)); 44 MOCK_METHOD2(GetDeviceMemMapFd, int32_t(uint64_t deviceId, int &fd)); 45 MOCK_METHOD3(SendPipeRequestWithAshmem, int32_t(const V1_1::UsbRequestPipe &pipe, const V1_1::UsbAshmem &ashmem, 46 uint32_t &transferredLength)); 47 MOCK_METHOD1(GetDevices, int32_t(std::vector<uint64_t> &deviceIds)); 48 MOCK_METHOD1(UpdateDriverInfo, int32_t(const V1_1::DriverAbilityInfo &driverInfo)); 49 MOCK_METHOD1(RemoveDriverInfo, int32_t(const std::string &driverUid)); 50 }; 51 } // namespace USB 52 } // namespace OHOS 53 #endif