5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_MOCK_INJECTOR_REGISTRY_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_MOCK_INJECTOR_REGISTRY_H_
8#include <fuchsia/ui/pointerinjector/cpp/fidl.h>
9#include <lib/fidl/cpp/binding_set.h>
11#include <unordered_map>
18 public fuchsia::ui::pointerinjector::Device {
21 fidl::InterfaceRequest<fuchsia::ui::pointerinjector::Registry> registry)
22 : registry_(this,
std::move(registry)) {}
26 fuchsia::ui::pointerinjector::Config
config,
27 fidl::InterfaceRequest<fuchsia::ui::pointerinjector::Device> injector,
28 RegisterCallback
callback)
override {
29 num_register_calls_++;
30 const uint32_t
id = next_id_++;
32 auto [it, success] = bindings_.try_emplace(
id,
this, std::move(injector));
34 it->second.set_error_handler(
35 [
this,
id](zx_status_t status) { bindings_.erase(
id); });
37 config_ = std::move(
config);
43 void Inject(std::vector<fuchsia::ui::pointerinjector::Event>
events,
45 num_events_received_ +=
events.size();
48 events_.push_back(std::move(
event));
58 const fuchsia::ui::pointerinjector::Config&
config()
const {
return config_; }
62 const std::vector<fuchsia::ui::pointerinjector::Event>&
events()
const {
73 uint32_t next_id_ = 0;
75 uint32_t num_events_received_ = 0;
77 uint32_t num_register_calls_ = 0;
79 fuchsia::ui::pointerinjector::Config config_;
81 std::vector<fuchsia::ui::pointerinjector::Event> events_;
83 std::unordered_map<uint32_t,
84 fidl::Binding<fuchsia::ui::pointerinjector::Device>>
87 fidl::Binding<fuchsia::ui::pointerinjector::Registry> registry_;
uint32_t num_register_calls()
void Inject(std::vector< fuchsia::ui::pointerinjector::Event > events, InjectCallback callback) override
void Register(fuchsia::ui::pointerinjector::Config config, fidl::InterfaceRequest< fuchsia::ui::pointerinjector::Device > injector, RegisterCallback callback) override
MockInjectorRegistry(fidl::InterfaceRequest< fuchsia::ui::pointerinjector::Registry > registry)
const std::vector< fuchsia::ui::pointerinjector::Event > & events() const
uint32_t num_events_received() const
const fuchsia::ui::pointerinjector::Config & config() const
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback