chromium/content/browser/usb/web_usb_service_impl_unittest.cc

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

#include "content/browser/usb/web_usb_service_impl.h"

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

#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/test_future.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/usb/usb_test_utils.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/mock_web_contents_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_web_contents_factory.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/test_support/fake_message_dispatch_context.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "services/device/public/cpp/test/fake_usb_device_info.h"
#include "services/device/public/cpp/test/fake_usb_device_manager.h"
#include "services/device/public/mojom/usb_device.mojom.h"
#include "services/device/public/mojom/usb_enumeration_options.mojom.h"
#include "services/device/public/mojom/usb_manager_client.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace content {

namespace {

RunOnceCallback;
RunOnceClosure;
TestFuture;
_;
Combine;
ElementsAre;
NiceMock;
Return;
TestParamInfo;
Values;
WithParamInterface;

enum ServiceCreationType {};

constexpr std::string_view kDefaultTestUrl{};
constexpr std::string_view kCrossOriginTestUrl{};

MATCHER_P(HasGuid, matcher, "") {}

device::mojom::UsbOpenDeviceResultPtr NewUsbOpenDeviceSuccess() {}

std::string ServiceCreationTypeToString(ServiceCreationType type) {}

std::string ClassCodeToString(uint8_t class_code) {}

}  // namespace

class WebUsbServiceImplBaseTest : public testing::Test {};

class WebUsbServiceImplTest : public WebUsbServiceImplBaseTest,
                              public WithParamInterface<ServiceCreationType> {};

TEST_P(WebUsbServiceImplTest, OpenAndCloseDevice) {}

TEST_P(WebUsbServiceImplTest, OpenAndDisconnectDevice) {}

INSTANTIATE_TEST_SUITE_P();

WebUsbServiceImplFrameTest;

TEST_F(WebUsbServiceImplFrameTest, OpenAndNavigateCrossOrigin) {}

TEST_F(WebUsbServiceImplFrameTest, RejectOpaqueOrigin) {}

TEST_F(WebUsbServiceImplFrameTest, RejectOpaqueOriginEmbeddedFrame) {}

class WebUsbServiceImplProtectedInterfaceTest
    : public WebUsbServiceImplBaseTest,
      public WithParamInterface<std::tuple<ServiceCreationType, uint8_t>> {};

TEST_P(WebUsbServiceImplProtectedInterfaceTest, BlockProtectedInterface) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace content