Flutter Engine
The Flutter Engine
focuser.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_FOCUSER_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_FOCUSER_H_
7
8#include <fuchsia/ui/views/cpp/fidl.h>
9#include <fuchsia/ui/views/cpp/fidl_test_base.h>
10
11#include <string>
12
13#include "flutter/fml/logging.h"
14
16
18
19class FakeFocuser : public fuchsia::ui::views::testing::Focuser_TestBase {
20 public:
21 bool request_focus_called() const { return request_focus_called_; }
22
23 void fail_request_focus(bool fail_request = true) {
24 fail_request_focus_ = fail_request;
25 }
26
27 private:
28 void RequestFocus(fuchsia::ui::views::ViewRef view_ref,
29 RequestFocusCallback callback) override {
30 request_focus_called_ = true;
31 auto result =
32 fail_request_focus_
33 ? fuchsia::ui::views::Focuser_RequestFocus_Result::WithErr(
34 fuchsia::ui::views::Error::DENIED)
35 : fuchsia::ui::views::Focuser_RequestFocus_Result::WithResponse(
36 fuchsia::ui::views::Focuser_RequestFocus_Response());
37 callback(std::move(result));
38 }
39
40 void NotImplemented_(const std::string& name) {
41 FML_LOG(FATAL) << "flutter_runner::Testing::FakeFocuser does not implement "
42 << name;
43 }
44
45 bool request_focus_called_ = false;
46 bool fail_request_focus_ = false;
47};
48
49} // namespace flutter_runner::testing
50
51#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_TESTS_FAKES_FOCUSER_H_
void fail_request_focus(bool fail_request=true)
Definition: focuser.h:23
#define FATAL(error)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
#define FML_LOG(severity)
Definition: logging.h:82
fuchsia::ui::views::Focuser Focuser
Definition: focuser.h:15
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32