#include <cstddef>
#include <memory>
#include <vector>
#include "base/barrier_closure.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/test_future.h"
#include "content/browser/hid/hid_service.h"
#include "content/browser/hid/hid_test_utils.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/hid_delegate.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/content_client.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_utils.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/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.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_hid_manager.h"
#include "services/device/public/cpp/test/hid_test_util.h"
#include "services/device/public/cpp/test/test_report_descriptors.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/hid/hid.mojom.h"
namespace content {
namespace {
RunClosure;
TestFuture;
_;
ByMove;
ElementsAre;
Expectation;
Invoke;
Return;
enum HidServiceCreationType { … };
const char kTestUrl[] = …;
const char kTestGuid[] = …;
const char kCrossOriginTestUrl[] = …;
std::string HidServiceCreationTypeToString(HidServiceCreationType type) { … }
class FakeHidConnectionClient : public device::mojom::HidConnectionClient { … };
class MockHidManagerClient : public device::mojom::HidManagerClient { … };
class HidServiceTestHelper { … };
class HidServiceBaseTest : public testing::Test, public HidServiceTestHelper { … };
class HidServiceRenderFrameHostTest : public RenderViewHostImplTestHarness,
public HidServiceTestHelper { … };
class HidServiceTest
: public HidServiceBaseTest,
public testing::WithParamInterface<HidServiceCreationType> { … };
class HidServiceFidoTest : public HidServiceBaseTest,
public testing::WithParamInterface<
std::tuple<HidServiceCreationType, bool>> { … };
class HidServiceServiceWorkerBrowserContextDestroyedTest
: public HidServiceBaseTest { … };
}
TEST_P(HidServiceTest, GetDevicesWithPermission) { … }
TEST_P(HidServiceTest, GetDevicesWithoutPermission) { … }
TEST_P(HidServiceTest, RequestDevice) { … }
TEST_P(HidServiceTest, OpenAndCloseHidConnection) { … }
TEST_P(HidServiceTest, OpenHidConnectionFail) { … }
TEST_F(HidServiceRenderFrameHostTest, OpenAndNavigateCrossOrigin) { … }
TEST_P(HidServiceTest, RegisterClient) { … }
TEST_P(HidServiceTest, RevokeDevicePermission) { … }
TEST_P(HidServiceTest, RevokeDevicePermissionWithoutConnection) { … }
TEST_P(HidServiceTest, DeviceRemovedDisconnect) { … }
TEST_P(HidServiceTest, DeviceChangedDoesNotDisconnect) { … }
TEST_P(HidServiceTest, UnblockedDeviceChangedToBlockedDisconnects) { … }
TEST_P(HidServiceTest, BlockedDeviceChangedToUnblockedDispatchesDeviceChanged) { … }
TEST_P(HidServiceTest, Forget) { … }
TEST_P(HidServiceTest, OpenDevicesThenRemoveDevices) { … }
TEST_P(HidServiceTest, OpenDevicesThenRevokePermission) { … }
TEST_P(HidServiceTest, OpenDevicesThenHidServiceReset) { … }
TEST_P(HidServiceFidoTest, FidoDeviceAllowedWithPrivilegedOrigin) { … }
INSTANTIATE_TEST_SUITE_P(…);
const bool kIsFidoAllowed[]{ … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(HidServiceServiceWorkerBrowserContextDestroyedTest, GetDevices) { … }
TEST_F(HidServiceServiceWorkerBrowserContextDestroyedTest, Connect) { … }
TEST_F(HidServiceServiceWorkerBrowserContextDestroyedTest, Forget) { … }
TEST_F(HidServiceServiceWorkerBrowserContextDestroyedTest, RejectOpaqueOrigin) { … }
TEST_P(HidServiceTest, ConnectionFailedWithoutPermission) { … }
}