#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
#include "extensions/browser/api/device_permissions_prompt.h"
#include "extensions/browser/api/hid/hid_device_manager.h"
#include "extensions/shell/browser/shell_extensions_api_client.h"
#include "extensions/shell/test/shell_apitest.h"
#include "extensions/test/extension_test_message_listener.h"
#include "services/device/public/cpp/hid/hid_report_descriptor.h"
#include "services/device/public/cpp/test/fake_hid_manager.h"
#include "services/device/public/mojom/hid.mojom.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/dbus/permission_broker/fake_permission_broker_client.h"
#endif
namespace extensions {
namespace {
FakeHidManager;
HidReportDescriptor;
const char* const kTestDeviceGuids[] = …;
const char* const kTestPhysicalDeviceIds[] = …;
const uint8_t kReportDescriptor[] = …;
const uint8_t kReportDescriptorWithIDs[] = …;
constexpr uint16_t kTestVendorId = …;
constexpr uint16_t kTestProductId = …;
}
class TestDevicePermissionsPrompt
: public DevicePermissionsPrompt,
public DevicePermissionsPrompt::Prompt::Observer { … };
class TestExtensionsAPIClient : public ShellExtensionsAPIClient { … };
class HidApiTest : public ShellApiTest { … };
IN_PROC_BROWSER_TEST_F(HidApiTest, HidApp) { … }
IN_PROC_BROWSER_TEST_F(HidApiTest, OnDeviceAdded) { … }
IN_PROC_BROWSER_TEST_F(HidApiTest, OnDeviceRemoved) { … }
namespace {
device::mojom::HidDeviceInfoPtr CreateDeviceWithOneCollection(
const std::string& guid) { … }
device::mojom::HidDeviceInfoPtr CreateDeviceWithTwoCollections(
const std::string guid) { … }
}
IN_PROC_BROWSER_TEST_F(HidApiTest, DeviceAddedChangedRemoved) { … }
}