Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
touch_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_TOUCH_SOURCE_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_TOUCH_SOURCE_H_
7
8#include <fuchsia/ui/pointer/cpp/fidl.h>
9
10#include <optional>
11#include <vector>
12
13#include "flutter/fml/logging.h"
14
16
17// A test stub to act as the protocol server. A test can control what is sent
18// back by this server implementation, via the ScheduleCallback call.
19class FakeTouchSource : public fuchsia::ui::pointer::TouchSource {
20 public:
21 // |fuchsia.ui.pointer.TouchSource|
22 void Watch(std::vector<fuchsia::ui::pointer::TouchResponse> responses,
23 TouchSource::WatchCallback callback) override {
24 responses_ = std::move(responses);
25 callback_ = std::move(callback);
26 }
27
28 // Have the server issue events to the client's hanging-get Watch call.
29 void ScheduleCallback(std::vector<fuchsia::ui::pointer::TouchEvent> events) {
30 FML_CHECK(callback_) << "require a valid WatchCallback";
31 callback_(std::move(events));
32 }
33
34 // Allow the test to observe what the client uploaded on the next Watch call.
35 std::optional<std::vector<fuchsia::ui::pointer::TouchResponse>>
37 auto responses = std::move(responses_);
38 responses_.reset();
39 return responses;
40 }
41
42 private:
43 // |fuchsia.ui.pointer.TouchSource|
44 void UpdateResponse(fuchsia::ui::pointer::TouchInteractionId ixn,
45 fuchsia::ui::pointer::TouchResponse response,
46 TouchSource::UpdateResponseCallback callback) override {
48 }
49
50 // Client uploads responses to server.
51 std::optional<std::vector<fuchsia::ui::pointer::TouchResponse>> responses_;
52
53 // Client-side logic to invoke on Watch() call's return. A test triggers it
54 // with ScheduleCallback().
55 TouchSource::WatchCallback callback_;
56};
57
58} // namespace flutter_runner::testing
59
60#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_TOUCH_SOURCE_H_
void ScheduleCallback(std::vector< fuchsia::ui::pointer::TouchEvent > events)
std::optional< std::vector< fuchsia::ui::pointer::TouchResponse > > UploadedResponses()
void Watch(std::vector< fuchsia::ui::pointer::TouchResponse > responses, TouchSource::WatchCallback callback) override
void UpdateResponse(fuchsia::ui::pointer::TouchInteractionId ixn, fuchsia::ui::pointer::TouchResponse response, TouchSource::UpdateResponseCallback callback) override
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_CHECK(condition)
Definition logging.h:85
#define FML_UNREACHABLE()
Definition logging.h:109