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);
24  FML_CHECK(result == kSuccess);
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  // Used to explicitly set an `open_gl.fbo_callback`. Using this method will
52  // cause your test to fail since the ctor for this class sets
53  // `open_gl.fbo_callback_with_frame_info`. This method exists as a utility to
54  // explicitly test this behavior.
55  void SetOpenGLFBOCallBack();
56 
57  // Used to explicitly set an `open_gl.present`. Using this method will cause
58  // your test to fail since the ctor for this class sets
59  // `open_gl.present_with_info`. This method exists as a utility to explicitly
60  // test this behavior.
61  void SetOpenGLPresentCallBack();
62 
63  void SetAssetsPath();
64 
65  void SetSnapshots();
66 
67  void SetAOTDataElf();
68 
69  void SetIsolateCreateCallbackHook();
70 
71  void SetSemanticsCallbackHooks();
72 
73  void SetLocalizationCallbackHooks();
74 
75  void SetDartEntrypoint(std::string entrypoint);
76 
77  void AddCommandLineArgument(std::string arg);
78 
79  void AddDartEntrypointArgument(std::string arg);
80 
81  void SetPlatformTaskRunner(const FlutterTaskRunnerDescription* runner);
82 
83  void SetRenderTaskRunner(const FlutterTaskRunnerDescription* runner);
84 
85  void SetPlatformMessageCallback(
86  const std::function<void(const FlutterPlatformMessage*)>& callback);
87 
88  void SetCompositor();
89 
90  FlutterCompositor& GetCompositor();
91 
92  void SetRenderTargetType(
94 
95  UniqueEngine LaunchEngine() const;
96 
97  UniqueEngine InitializeEngine() const;
98 
99  private:
100  EmbedderTestContext& context_;
101  FlutterProjectArgs project_args_ = {};
102  FlutterRendererConfig renderer_config_ = {};
103  FlutterSoftwareRendererConfig software_renderer_config_ = {};
104 #ifdef SHELL_ENABLE_GL
105  FlutterOpenGLRendererConfig opengl_renderer_config_ = {};
106 #endif
107  std::string dart_entrypoint_;
108  FlutterCustomTaskRunners custom_task_runners_ = {};
109  FlutterCompositor compositor_ = {};
110  std::vector<std::string> command_line_arguments_;
111  std::vector<std::string> dart_entrypoint_arguments_;
112 
113  UniqueEngine SetupEngine(bool run) const;
114 
116 };
117 
118 } // namespace testing
119 } // namespace flutter
120 
121 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
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:1218
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)