#include <memory>
#include <set>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "chrome/browser/hid/hid_chooser_context.h"
#include "chrome/browser/hid/hid_chooser_context_factory.h"
#include "chrome/browser/hid/mock_hid_device_observer.h"
#include "chrome/browser/ui/hid/hid_chooser_controller.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/permissions/mock_chooser_controller_view.h"
#include "content/public/browser/hid_chooser.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/web_contents_tester.h"
#include "services/device/public/cpp/hid/hid_switches.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/gtest/include/gtest/gtest.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
RunClosure;
TestFuture;
_;
namespace {
constexpr char kDefaultTestUrl[] = …;
const char* const kTestPhysicalDeviceIds[] = …;
constexpr uint16_t kVendorYubico = …;
constexpr uint16_t kProductYubicoGnubby = …;
constexpr uint16_t kUsageFidoU2f = …;
class HidChooserControllerTest : public ChromeRenderViewHostTestHarness { … };
}
TEST_F(HidChooserControllerTest, EmptyChooser) { … }
TEST_F(HidChooserControllerTest, AddBlockedFidoDevice) { … }
TEST_F(HidChooserControllerTest, AddUnknownFidoDevice) { … }
class HidChooserControllerWithoutBlocklistTest
: public HidChooserControllerTest { … };
TEST_F(HidChooserControllerWithoutBlocklistTest,
BlockedFidoDeviceAllowedWithFlag) { … }
TEST_F(HidChooserControllerTest, AddNamedDevice) { … }
TEST_F(HidChooserControllerTest, AddUnnamedDevice) { … }
TEST_F(HidChooserControllerTest, DeviceIdFilterVendorOnly) { … }
TEST_F(HidChooserControllerTest, DeviceIdFilterVendorAndProduct) { … }
TEST_F(HidChooserControllerTest, UsageFilterUsagePageOnly) { … }
TEST_F(HidChooserControllerTest, UsageFilterUsageAndPage) { … }
TEST_F(HidChooserControllerTest, DeviceIdAndUsageFilterIntersection) { … }
TEST_F(HidChooserControllerTest, DeviceIdAndUsageFilterUnion) { … }
TEST_F(HidChooserControllerTest, ExcludeDeviceIdFilterVendorOnly) { … }
TEST_F(HidChooserControllerTest, ExcludeDeviceIdFilterVendorAndProduct) { … }
TEST_F(HidChooserControllerTest, ExcludeUsageFilterUsagePageOnly) { … }
TEST_F(HidChooserControllerTest, ExcludeUsageFilterUsageAndPage) { … }
TEST_F(HidChooserControllerTest, ExcludeMatchingDeviceIdFilterVendorOnly) { … }
TEST_F(HidChooserControllerTest, ExcludeMatchingUsageFilterPageOnly) { … }
TEST_F(HidChooserControllerTest, OneOptionForSamePhysicalDevice) { … }
TEST_F(HidChooserControllerTest, NoMergeWithDifferentPhysicalDeviceIds) { … }
TEST_F(HidChooserControllerTest, NoMergeWithEmptyPhysicalDeviceId) { … }
TEST_F(HidChooserControllerTest, DeviceConnectAddsOption) { … }
TEST_F(HidChooserControllerTest, DeviceDisconnectRemovesOption) { … }
namespace {
device::mojom::HidDeviceInfoPtr CreateDeviceWithOneCollection(
const std::string& guid) { … }
device::mojom::HidDeviceInfoPtr CreateDeviceWithTwoCollections(
const std::string guid) { … }
}
TEST_F(HidChooserControllerTest, DeviceChangeUpdatesDeviceInfo) { … }
TEST_F(HidChooserControllerTest, ExcludedDeviceChangedToIncludedDevice) { … }
TEST_F(HidChooserControllerTest, DeviceChangedToBlockedDevice) { … }
class HidChooserControllerFidoTest : public HidChooserControllerTest,
public testing::WithParamInterface<bool> { … };
TEST_P(HidChooserControllerFidoTest, FidoDeviceShownWithPrivilegedOrigin) { … }
INSTANTIATE_TEST_SUITE_P(…);