Flutter Engine
 
Loading...
Searching...
No Matches
engine_modifier.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_WINDOWS_TESTING_ENGINE_MODIFIER_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_ENGINE_MODIFIER_H_
7
9
10#include <chrono>
11
12#include "flutter/fml/macros.h"
13
14namespace flutter {
15
16// A test utility class providing the ability to access and alter various
17// private fields in an Engine instance.
18//
19// This simply provides a way to access the normally-private embedder proc
20// table, so the lifetime of any changes made to the proc table is that of the
21// engine object, not this helper.
23 public:
25
26 // Returns the engine's embedder API proc table, allowing for modification.
27 //
28 // Modifications are to the engine, and will last for the lifetime of the
29 // engine unless overwritten again.
30 FlutterEngineProcTable& embedder_api() { return engine_->embedder_api_; }
31
32 // Override the EGL manager used by the engine.
33 //
34 // Modifications are to the engine, and will last for the lifetime of the
35 // engine unless overwritten again.
36 void SetEGLManager(std::unique_ptr<egl::Manager> egl_manager) {
37 engine_->egl_manager_ = std::move(egl_manager);
38 }
39
40 // Override the engine's implicit view. This is the "default" view
41 // that Flutter apps render to.
43 engine_->views_[kImplicitViewId] = view;
44 }
45
46 /// Associate a view with a view id.
48 engine_->views_[viewId] = view;
49 }
50
51 /// Reset the start_time field that is used to align vsync events.
52 void SetStartTime(uint64_t start_time_nanos) {
53 engine_->start_time_ = std::chrono::nanoseconds(start_time_nanos);
54 }
55
56 /// Override the frame interval to the provided nanosecond interval.
57 ///
58 /// This will prevent the windows engine from delegating to dwm to
59 /// discover the true frame interval, which can vary across machines.
60 void SetFrameInterval(uint64_t frame_interval_nanos) {
61 engine_->frame_interval_override_ =
62 std::optional<std::chrono::nanoseconds>(frame_interval_nanos);
63 }
64
65 // Explicitly releases the egl::Manager being used by the
66 // FlutterWindowsEngine instance. This should be used if SetEGLManager is
67 // used to explicitly set to a non-null value (but not a valid object) to test
68 // a successful ANGLE initialization.
69 //
70 // Modifications are to the engine, and will last for the lifetime of the
71 // engine unless overwritten again.
72 void ReleaseEGLManager() { engine_->egl_manager_.release(); }
73
74 // Run the FlutterWindowsEngine's handler that runs right before an engine
75 // restart. This resets the keyboard's state if it exists.
76 void Restart() { engine_->OnPreEngineRestart(); }
77
78 // Initialize they keyboard and text input subsystems or reset them them if
79 // they are already initialized.
80 void InitializeKeyboard() { engine_->InitializeKeyboard(); }
81
82 void SetLifecycleManager(std::unique_ptr<WindowsLifecycleManager>&& handler) {
83 engine_->lifecycle_manager_ = std::move(handler);
84 }
85
86 void SetPlatformViewPlugin(std::unique_ptr<PlatformViewPlugin>&& manager) {
87 engine_->platform_view_plugin_ = std::move(manager);
88 }
89
91 engine_->OnViewFocusChangeRequest(request);
92 }
93
95 engine_->next_view_id_ = view_id;
96 }
97
98 private:
99 FlutterWindowsEngine* engine_;
100
102};
103
104} // namespace flutter
105
106#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_ENGINE_MODIFIER_H_
void SetLifecycleManager(std::unique_ptr< WindowsLifecycleManager > &&handler)
void SetFrameInterval(uint64_t frame_interval_nanos)
EngineModifier(FlutterWindowsEngine *engine)
void OnViewFocusChangeRequest(const FlutterViewFocusChangeRequest *request)
void SetEGLManager(std::unique_ptr< egl::Manager > egl_manager)
void SetStartTime(uint64_t start_time_nanos)
Reset the start_time field that is used to align vsync events.
FlutterEngineProcTable & embedder_api()
void SetViewById(FlutterWindowsView *view, FlutterViewId viewId)
Associate a view with a view id.
void SetNextViewId(FlutterViewId view_id)
void SetPlatformViewPlugin(std::unique_ptr< PlatformViewPlugin > &&manager)
void SetImplicitView(FlutterWindowsView *view)
virtual void OnViewFocusChangeRequest(const FlutterViewFocusChangeRequest *request)
FlutterEngine engine
Definition main.cc:84
FlView * view
const gchar FlBinaryMessengerMessageHandler handler
G_BEGIN_DECLS FlutterViewId view_id
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
constexpr FlutterViewId kImplicitViewId
int64_t FlutterViewId
Function-pointer-based versions of the APIs above.
Definition embedder.h:3704