Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
flutter_runner_fakes.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_FLUTTER_RUNNER_FAKES_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FLUTTER_RUNNER_FAKES_H_
7
8#include <fuchsia/accessibility/semantics/cpp/fidl.h>
9
10namespace flutter_runner_test {
11using fuchsia::accessibility::semantics::SemanticsManager;
12
14 : public SemanticsManager,
15 public fuchsia::accessibility::semantics::SemanticTree {
16 public:
17 MockSemanticsManager() : tree_binding_(this) {}
18
19 // |fuchsia::accessibility::semantics::SemanticsManager|:
21 fuchsia::ui::views::ViewRef view_ref,
22 fuchsia::accessibility::semantics::SemanticListenerHandle handle,
23 fidl::InterfaceRequest<fuchsia::accessibility::semantics::SemanticTree>
24 semantic_tree) override {
25 tree_binding_.Bind(std::move(semantic_tree));
26 has_view_ref_ = true;
27 }
28
29 fidl::InterfaceRequestHandler<SemanticsManager> GetHandler(
30 async_dispatcher_t* dispatcher) {
31 return bindings_.GetHandler(this, dispatcher);
32 }
33
34 bool RegisterViewCalled() { return has_view_ref_; }
35
36 void ResetTree() {
37 update_count_ = 0;
38 delete_count_ = 0;
39 commit_count_ = 0;
40 last_updated_nodes_.clear();
41 last_deleted_node_ids_.clear();
42 delete_overflowed_ = false;
43 update_overflowed_ = false;
44 }
45
47 std::vector<fuchsia::accessibility::semantics::Node> nodes) override {
48 update_count_++;
49 if (!update_overflowed_) {
50 size_t size = 0;
51 for (const auto& node : nodes) {
52 size += sizeof(node);
53 size += sizeof(node.attributes().label().size());
54 }
55 update_overflowed_ = size > ZX_CHANNEL_MAX_MSG_BYTES;
56 }
57 last_updated_nodes_ = std::move(nodes);
58 }
59
60 void DeleteSemanticNodes(std::vector<uint32_t> node_ids) override {
61 delete_count_++;
62 if (!delete_overflowed_) {
63 size_t size =
64 sizeof(node_ids) +
66 delete_overflowed_ = size > ZX_CHANNEL_MAX_MSG_BYTES;
67 }
68 last_deleted_node_ids_ = std::move(node_ids);
69 }
70
71 const std::vector<uint32_t>& LastDeletedNodeIds() const {
72 return last_deleted_node_ids_;
73 }
74
75 int DeleteCount() const { return delete_count_; }
76 bool DeleteOverflowed() const { return delete_overflowed_; }
77
78 int UpdateCount() const { return update_count_; }
79 bool UpdateOverflowed() const { return update_overflowed_; }
80
81 bool ShouldHoldCommitResponse() const { return should_hold_commit_response_; }
82
83 void SetShouldHoldCommitResponse(bool value) {
84 should_hold_commit_response_ = value;
85 }
86
88 if (commit_callback_) {
89 commit_callback_();
90 }
91 }
92
93 int CommitCount() const { return commit_count_; }
94
95 const std::vector<fuchsia::accessibility::semantics::Node>& LastUpdatedNodes()
96 const {
97 return last_updated_nodes_;
98 }
99
100 void CommitUpdates(CommitUpdatesCallback callback) override {
101 commit_count_++;
102 if (should_hold_commit_response_) {
103 commit_callback_ = std::move(callback);
104 return;
105 }
106 callback();
107 }
108
110 fuchsia::accessibility::semantics::SemanticEvent semantic_event,
111 SendSemanticEventCallback callback) override {
112 last_events_.emplace_back(std::move(semantic_event));
113 callback();
114 }
115
116 std::vector<fuchsia::accessibility::semantics::SemanticEvent>&
118 return last_events_;
119 }
120
121 private:
122 bool has_view_ref_ = false;
123 fidl::BindingSet<SemanticsManager> bindings_;
124 fidl::Binding<SemanticTree> tree_binding_;
125
126 std::vector<fuchsia::accessibility::semantics::Node> last_updated_nodes_;
127 bool update_overflowed_;
128 int update_count_;
129 int delete_count_;
130 bool delete_overflowed_;
131 std::vector<uint32_t> last_deleted_node_ids_;
132 bool should_hold_commit_response_ = false;
133 CommitUpdatesCallback commit_callback_;
134 int commit_count_;
135 std::vector<fuchsia::accessibility::semantics::SemanticEvent> last_events_;
136};
137
138} // namespace flutter_runner_test
139
140#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FLUTTER_RUNNER_FAKES_H_
const std::vector< fuchsia::accessibility::semantics::Node > & LastUpdatedNodes() const
void SendSemanticEvent(fuchsia::accessibility::semantics::SemanticEvent semantic_event, SendSemanticEventCallback callback) override
const std::vector< uint32_t > & LastDeletedNodeIds() const
std::vector< fuchsia::accessibility::semantics::SemanticEvent > & GetLastEvents()
fidl::InterfaceRequestHandler< SemanticsManager > GetHandler(async_dispatcher_t *dispatcher)
void DeleteSemanticNodes(std::vector< uint32_t > node_ids) override
void RegisterViewForSemantics(fuchsia::ui::views::ViewRef view_ref, fuchsia::accessibility::semantics::SemanticListenerHandle handle, fidl::InterfaceRequest< fuchsia::accessibility::semantics::SemanticTree > semantic_tree) override
void UpdateSemanticNodes(std::vector< fuchsia::accessibility::semantics::Node > nodes) override
void CommitUpdates(CommitUpdatesCallback callback) override
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value