#include "services/device/public/cpp/test/fake_usb_device.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/ranges/algorithm.h"
#include "services/device/public/cpp/test/mock_usb_mojo_device.h"
#include "services/device/public/cpp/usb/usb_utils.h"
namespace device {
void FakeUsbDevice::Create(
scoped_refptr<FakeUsbDeviceInfo> device,
base::span<const uint8_t> blocked_interface_classes,
mojo::PendingReceiver<device::mojom::UsbDevice> receiver,
mojo::PendingRemote<mojom::UsbDeviceClient> client) { … }
FakeUsbDevice::~FakeUsbDevice() { … }
FakeUsbDevice::FakeUsbDevice(
scoped_refptr<FakeUsbDeviceInfo> device,
base::span<const uint8_t> blocked_interface_classes,
mojo::PendingRemote<mojom::UsbDeviceClient> client)
: … { … }
void FakeUsbDevice::CloseHandle() { … }
void FakeUsbDevice::Open(OpenCallback callback) { … }
void FakeUsbDevice::FinishOpen(OpenCallback callback,
mojom::UsbOpenDeviceResultPtr result) { … }
void FakeUsbDevice::Close(CloseCallback callback) { … }
void FakeUsbDevice::SetConfiguration(uint8_t value,
SetConfigurationCallback callback) { … }
void FakeUsbDevice::ClaimInterface(uint8_t interface_number,
ClaimInterfaceCallback callback) { … }
void FakeUsbDevice::ReleaseInterface(uint8_t interface_number,
ReleaseInterfaceCallback callback) { … }
void FakeUsbDevice::SetInterfaceAlternateSetting(
uint8_t interface_number,
uint8_t alternate_setting,
SetInterfaceAlternateSettingCallback callback) { … }
void FakeUsbDevice::Reset(ResetCallback callback) { … }
void FakeUsbDevice::ClearHalt(mojom::UsbTransferDirection direction,
uint8_t endpoint_number,
ClearHaltCallback callback) { … }
void FakeUsbDevice::ControlTransferIn(mojom::UsbControlTransferParamsPtr params,
uint32_t length,
uint32_t timeout,
ControlTransferInCallback callback) { … }
void FakeUsbDevice::ControlTransferOut(
mojom::UsbControlTransferParamsPtr params,
base::span<const uint8_t> data,
uint32_t timeout,
ControlTransferOutCallback callback) { … }
void FakeUsbDevice::GenericTransferIn(uint8_t endpoint_number,
uint32_t length,
uint32_t timeout,
GenericTransferInCallback callback) { … }
void FakeUsbDevice::GenericTransferOut(uint8_t endpoint_number,
base::span<const uint8_t> data,
uint32_t timeout,
GenericTransferOutCallback callback) { … }
void FakeUsbDevice::IsochronousTransferIn(
uint8_t endpoint_number,
const std::vector<uint32_t>& packet_lengths,
uint32_t timeout,
IsochronousTransferInCallback callback) { … }
void FakeUsbDevice::IsochronousTransferOut(
uint8_t endpoint_number,
base::span<const uint8_t> data,
const std::vector<uint32_t>& packet_lengths,
uint32_t timeout,
IsochronousTransferOutCallback callback) { … }
void FakeUsbDevice::OnDeviceRemoved(scoped_refptr<FakeUsbDeviceInfo> device) { … }
void FakeUsbDevice::OnClientConnectionError() { … }
}