Flutter Engine
embedder_config_builder.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_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
6 #define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "flutter/fml/unique_object.h"
10 #include "flutter/shell/platform/embedder/embedder.h"
11 #include "flutter/shell/platform/embedder/tests/embedder_test.h"
12 #include "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"
13 
14 namespace flutter {
15 namespace testing {
16 
18  static FlutterEngine InvalidValue() { return nullptr; }
19 
20  static bool IsValid(const FlutterEngine& value) { return value != nullptr; }
21 
22  static void Free(FlutterEngine& engine) {
23  auto result = FlutterEngineShutdown(engine);
25  }
26 };
27 
29 
31  public:
33  kSnapshotsInitialize,
34  kAOTDataInitialize,
35  kMultiAOTInitialize,
36  kNoInitialize,
37  };
38 
40  InitializationPreference preference =
41  InitializationPreference::kSnapshotsInitialize);
42 
44 
45  FlutterProjectArgs& GetProjectArgs();
46 
47  void SetSoftwareRendererConfig(SkISize surface_size = SkISize::Make(1, 1));
48 
49  void SetOpenGLRendererConfig(SkISize surface_size);
50 
51  void SetMetalRendererConfig(SkISize surface_size);
52 
53  // Used to explicitly set an `open_gl.fbo_callback`. Using this method will
54  // cause your test to fail since the ctor for this class sets
55  // `open_gl.fbo_callback_with_frame_info`. This method exists as a utility to
56  // explicitly test this behavior.
57  void SetOpenGLFBOCallBack();
58 
59  // Used to explicitly set an `open_gl.present`. Using this method will cause
60  // your test to fail since the ctor for this class sets
61  // `open_gl.present_with_info`. This method exists as a utility to explicitly
62  // test this behavior.
63  void SetOpenGLPresentCallBack();
64 
65  void SetAssetsPath();
66 
67  void SetSnapshots();
68 
69  void SetAOTDataElf();
70 
71  void SetIsolateCreateCallbackHook();
72 
73  void SetSemanticsCallbackHooks();
74 
75  // Used to set a custom log message handler.
76  void SetLogMessageCallbackHook();
77 
78  // Used to set a custom log tag.
79  void SetLogTag(std::string tag);
80 
81  void SetLocalizationCallbackHooks();
82 
83  void SetDartEntrypoint(std::string entrypoint);
84 
85  void AddCommandLineArgument(std::string arg);
86 
87  void AddDartEntrypointArgument(std::string arg);
88 
89  void SetPlatformTaskRunner(const FlutterTaskRunnerDescription* runner);
90 
91  void SetRenderTaskRunner(const FlutterTaskRunnerDescription* runner);
92 
93  void SetPlatformMessageCallback(
94  const std::function<void(const FlutterPlatformMessage*)>& callback);
95 
96  void SetCompositor(bool avoid_backing_store_cache = false);
97 
98  FlutterCompositor& GetCompositor();
99 
100  void SetRenderTargetType(
102 
103  UniqueEngine LaunchEngine() const;
104 
105  UniqueEngine InitializeEngine() const;
106 
107  private:
108  EmbedderTestContext& context_;
109  FlutterProjectArgs project_args_ = {};
110  FlutterRendererConfig renderer_config_ = {};
111  FlutterSoftwareRendererConfig software_renderer_config_ = {};
112 #ifdef SHELL_ENABLE_GL
113  FlutterOpenGLRendererConfig opengl_renderer_config_ = {};
114 #endif
115 #ifdef SHELL_ENABLE_METAL
116  void InitializeMetalRendererConfig();
117  FlutterMetalRendererConfig metal_renderer_config_ = {};
118 #endif
119  std::string dart_entrypoint_;
120  FlutterCustomTaskRunners custom_task_runners_ = {};
121  FlutterCompositor compositor_ = {};
122  std::vector<std::string> command_line_arguments_;
123  std::vector<std::string> dart_entrypoint_arguments_;
124  std::string log_tag_;
125 
126  UniqueEngine SetupEngine(bool run) const;
127 
129 };
130 
131 } // namespace testing
132 } // namespace flutter
133 
134 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
KeyCallType type
static bool IsValid(const FlutterEngine &value)
Dart_NativeFunction function
Definition: fuchsia.cc:51
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embed...
Definition: embedder.cc:1377
GAsyncResult * result
FlKeyEvent FlKeyResponderAsyncCallback callback
uint8_t value
#define FML_CHECK(condition)
Definition: logging.h:68
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
static void Free(FlutterEngine &engine)