#include "chrome/browser/hid/chrome_hid_delegate.h"
#include <memory>
#include <string_view>
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/test_future.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "chrome/browser/hid/hid_chooser_context.h"
#include "chrome/browser/hid/hid_chooser_context_factory.h"
#include "chrome/browser/hid/hid_connection_tracker.h"
#include "chrome/browser/hid/hid_connection_tracker_factory.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/embedded_worker_instance_test_harness.h"
#include "content/public/test/web_contents_tester.h"
#include "extensions/buildflags/buildflags.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 "services/device/public/mojom/hid.mojom.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"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
namespace {
RunClosure;
TestFuture;
ElementsAre;
NiceMock;
UnorderedElementsAre;
constexpr std::string_view kDefaultTestUrl{ … };
constexpr std::string_view kCrossOriginTestUrl{ … };
constexpr char kTestUserEmail[] = …;
#if BUILDFLAG(ENABLE_EXTENSIONS)
constexpr std::string_view kPrivilegedExtensionId{ … };
constexpr std::string_view kExtensionDocumentFileName{ … };
#endif
MATCHER_P(HasGuid, matcher, "") { … }
device::mojom::HidDeviceInfoPtr CreateFakeDevice() { … }
device::mojom::HidDeviceInfoPtr CreateIncompleteFakeDevice() { … }
device::mojom::HidDeviceInfoPtr CreateFakeFidoDevice() { … }
class MockHidManagerClient : public HidChooserContext::HidManagerClient { … };
class FakeHidConnectionClient : public device::mojom::HidConnectionClient { … };
class MockHidConnectionTracker : public HidConnectionTracker { … };
class ChromeHidTestHelper { … };
class ChromeHidDelegateRenderFrameTestBase
: public ChromeRenderViewHostTestHarness,
public ChromeHidTestHelper { … };
class ChromeHidDelegateRenderFrameTest
: public ChromeHidDelegateRenderFrameTestBase { … };
class ChromeHidDelegateServiceWorkerTestBase
: public content::EmbeddedWorkerInstanceTestHarness,
public ChromeHidTestHelper { … };
class ChromeHidDelegateServiceWorkerTest
: public ChromeHidDelegateServiceWorkerTestBase { … };
#if BUILDFLAG(ENABLE_EXTENSIONS)
class ChromeHidDelegateExtensionServiceWorkerTest
: public ChromeHidDelegateServiceWorkerTestBase { … };
class ChromeHidDelegateExtensionRenderFrameTest
: public ChromeHidDelegateRenderFrameTestBase { … };
#endif
}
TEST_F(ChromeHidDelegateRenderFrameTest, AddChangeRemoveDevice) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, NoPermissionDevice) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, ReconnectHidService) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, RevokeDevicePermission) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, RevokeDevicePermissionEphemeral) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, ConnectAndDisconnect) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, ConnectAndRemove) { … }
TEST_F(ChromeHidDelegateRenderFrameTest, ConnectAndNavigateCrossDocument) { … }
TEST_F(ChromeHidDelegateServiceWorkerTest, HidServiceNotConnected) { … }
#if BUILDFLAG(ENABLE_EXTENSIONS)
TEST_F(ChromeHidDelegateExtensionRenderFrameTest,
FidoDeviceAllowedWithPrivilegedOrigin) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest, AddChangeRemoveDevice) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest, NoPermissionDevice) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest, ReconnectHidService) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest, RevokeDevicePermission) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest,
RevokeDevicePermissionEphemeral) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest, ConnectAndDisconnect) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest, ConnectAndRemove) { … }
TEST_F(ChromeHidDelegateExtensionRenderFrameTest,
ConnectAndNavigateCrossDocument) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest, AddChangeRemoveDevice) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest, NoPermissionDevice) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest, ReconnectHidService) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest, RevokeDevicePermission) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest,
RevokeDevicePermissionEphemeral) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest, ConnectAndDisconnect) { … }
TEST_F(ChromeHidDelegateExtensionServiceWorkerTest, ConnectAndRemove) { … }
#endif
TEST(ChromeHidDelegateBrowserContextTest, BrowserContextIsNull) { … }