#include <memory>
#include <string>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/values_test_util.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/device_notifications/device_pinned_notification_renderer.h"
#include "chrome/browser/device_notifications/device_status_icon_renderer.h"
#include "chrome/browser/hid/chrome_hid_delegate.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/notifications/notification_display_service_tester.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/console_message.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/service_worker_context_observer.h"
#include "content/public/browser/service_worker_running_info.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/service_worker_test_helpers.h"
#include "services/device/public/cpp/test/fake_hid_manager.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 "chrome/browser/extensions/extension_browsertest.h"
#include "extensions/common/extension.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_extension_dir.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/hid/hid_pinned_notification.h"
#else
#include "chrome/browser/hid/hid_status_icon.h"
#endif
namespace {
Return;
#if BUILDFLAG(ENABLE_EXTENSIONS)
Extension;
ExtensionId;
TestExtensionDir;
const char kTestExtensionId[] = …;
constexpr const char kTestExtensionKey[] = …;
class TestServiceWorkerContextObserver
: public content::ServiceWorkerContextObserver { … };
class TestServiceWorkerConsoleObserver
: public content::ServiceWorkerContextObserver { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
const AccountId kManagedUserAccountId =
AccountId::FromUserEmail("[email protected]");
#endif
#endif
constexpr char kPolicySetting[] = …;
device::mojom::HidDeviceInfoPtr CreateTestDeviceWithInputAndOutputReports() { … }
}
#if BUILDFLAG(ENABLE_EXTENSIONS)
class WebHidExtensionBrowserTest : public extensions::ExtensionBrowserTest { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_GetDevices …
#else
#define MAYBE_GetDevices …
#endif
IN_PROC_BROWSER_TEST_F(WebHidExtensionBrowserTest, MAYBE_GetDevices) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_RequestDevice …
#else
#define MAYBE_RequestDevice …
#endif
IN_PROC_BROWSER_TEST_F(WebHidExtensionBrowserTest, MAYBE_RequestDevice) { … }
#if (BUILDFLAG(IS_LINUX) && defined(LEAK_SANITIZER)) || \
(BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_CHROMEOS_DEVICE))
#define MAYBE_DeviceConnectAndOpenDeviceWhenServiceWorkerStopped …
#else
#define MAYBE_DeviceConnectAndOpenDeviceWhenServiceWorkerStopped …
#endif
IN_PROC_BROWSER_TEST_F(
WebHidExtensionBrowserTest,
MAYBE_DeviceConnectAndOpenDeviceWhenServiceWorkerStopped) { … }
#if !BUILDFLAG(IS_MAC) && defined(NDEBUG)
#define MAYBE_EventListenerAddedAfterServiceWorkerIsActivated …
#else
#define MAYBE_EventListenerAddedAfterServiceWorkerIsActivated …
#endif
IN_PROC_BROWSER_TEST_F(WebHidExtensionBrowserTest,
MAYBE_EventListenerAddedAfterServiceWorkerIsActivated) { … }
#endif