chromium/services/device/usb/mojo/device_impl_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "services/device/usb/mojo/device_impl.h"

#include <stddef.h>
#include <stdint.h>

#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/containers/queue.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted_memory.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "services/device/usb/mock_usb_device.h"
#include "services/device/usb/mock_usb_device_handle.h"
#include "services/device/usb/usb_descriptors.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
Invoke;

namespace device {

UsbControlTransferRecipient;
UsbControlTransferType;
UsbIsochronousPacketPtr;
UsbTransferDirection;
UsbTransferStatus;

namespace usb {

namespace {

constexpr size_t kUsbTransferLengthLimit =;

MATCHER_P(BufferSizeIs, size, "") {}

class ConfigBuilder {};

void ExpectResultAndThen(bool expected_result,
                         base::OnceClosure continuation,
                         bool actual_result) {}

void ExpectTransferInAndThen(mojom::UsbTransferStatus expected_status,
                             const std::vector<uint8_t>& expected_bytes,
                             base::OnceClosure continuation,
                             mojom::UsbTransferStatus actual_status,
                             base::span<const uint8_t> actual_bytes) {}

void ExpectPacketsOutAndThen(
    const std::vector<uint32_t>& expected_packets,
    base::OnceClosure continuation,
    std::vector<UsbIsochronousPacketPtr> actual_packets) {}

void ExpectPacketsInAndThen(
    const std::vector<uint8_t>& expected_bytes,
    const std::vector<uint32_t>& expected_packets,
    base::OnceClosure continuation,
    base::span<const uint8_t> actual_bytes,
    std::vector<UsbIsochronousPacketPtr> actual_packets) {}

void ExpectTransferStatusAndThen(mojom::UsbTransferStatus expected_status,
                                 base::OnceClosure continuation,
                                 mojom::UsbTransferStatus actual_status) {}

class MockUsbDeviceClient : public mojom::UsbDeviceClient {};

class USBDeviceImplTest : public testing::Test {};

}  // namespace

TEST_F(USBDeviceImplTest, Disconnect) {}

TEST_F(USBDeviceImplTest, Open) {}

TEST_F(USBDeviceImplTest, OpenFailure) {}

TEST_F(USBDeviceImplTest, OpenDelayedFailure) {}

TEST_F(USBDeviceImplTest, MultipleOpenNotAllowed) {}

TEST_F(USBDeviceImplTest, Close) {}

TEST_F(USBDeviceImplTest, SetInvalidConfiguration) {}

TEST_F(USBDeviceImplTest, SetValidConfiguration) {}

// Verify that the result of Reset() reflects the underlying UsbDeviceHandle's
// ResetDevice() result.
TEST_F(USBDeviceImplTest, Reset) {}

TEST_F(USBDeviceImplTest, ClaimAndReleaseInterface) {}

TEST_F(USBDeviceImplTest, ClaimProtectedInterface) {}

TEST_F(USBDeviceImplTest, SetInterfaceAlternateSetting) {}

TEST_F(USBDeviceImplTest, ControlTransfer) {}

TEST_F(USBDeviceImplTest, GenericTransfer) {}

TEST_F(USBDeviceImplTest, IsochronousTransfer) {}

TEST_F(USBDeviceImplTest, IsochronousTransferOutBufferSizeMismatch) {}

TEST_F(USBDeviceImplTest, IsochronousTransferPacketLengthsOverflow) {}

TEST_F(USBDeviceImplTest, ControlTransferInLengthOverLimit) {}

TEST_F(USBDeviceImplTest, ControlTransferOutLengthOverLimit) {}

TEST_F(USBDeviceImplTest, GenericTransferInLengthOverLimit) {}

TEST_F(USBDeviceImplTest, GenericTransferOutLengthOverLimit) {}

TEST_F(USBDeviceImplTest, IsochronousTransferInLengthOverLimit) {}

TEST_F(USBDeviceImplTest, IsochronousTransferOutLengthOverLimit) {}

class USBDeviceImplSecurityKeyTest : public USBDeviceImplTest,
                                     public testing::WithParamInterface<bool> {};

TEST_P(USBDeviceImplSecurityKeyTest, SecurityKeyControlTransferBlocked) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace usb
}  // namespace device