Flutter Engine
The Flutter Engine
mouse_source.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_MOUSE_SOURCE_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_MOUSE_SOURCE_H_
7
8#include <fuchsia/ui/pointer/cpp/fidl.h>
9
10#include "flutter/fml/logging.h"
11
13
14// A test stub to act as the protocol server. A test can control what is sent
15// back by this server implementation, via the ScheduleCallback call.
16class FakeMouseSource : public fuchsia::ui::pointer::MouseSource {
17 public:
18 // |fuchsia.ui.pointer.MouseSource|
19 void Watch(MouseSource::WatchCallback callback) override {
20 callback_ = std::move(callback);
21 }
22
23 // Have the server issue events to the client's hanging-get Watch call.
24 void ScheduleCallback(std::vector<fuchsia::ui::pointer::MouseEvent> events) {
25 FML_CHECK(callback_) << "require a valid WatchCallback";
26 callback_(std::move(events));
27 }
28
29 private:
30 // Client-side logic to invoke on Watch() call's return. A test triggers it
31 // with ScheduleCallback().
32 MouseSource::WatchCallback callback_;
33};
34
35} // namespace flutter_runner::testing
36
37#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_MOUSE_SOURCE_H_
void ScheduleCallback(std::vector< fuchsia::ui::pointer::MouseEvent > events)
Definition: mouse_source.h:24
void Watch(MouseSource::WatchCallback callback) override
Definition: mouse_source.h:19
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_CHECK(condition)
Definition: logging.h:85