Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
windows_test_config_builder.cc
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
6
7#include <combaseapi.h>
8
9#include <string>
10#include <string_view>
11#include <vector>
12
13#include "flutter/fml/logging.h"
17
18namespace flutter {
19namespace testing {
20
23
25
26void WindowsConfigBuilder::SetDartEntrypoint(std::string_view entrypoint) {
27 if (entrypoint.empty()) {
28 return;
29 }
30 dart_entrypoint_ = entrypoint;
31}
32
37
39 if (arg.empty()) {
40 return;
41 }
42
43 dart_entrypoint_arguments_.emplace_back(std::move(arg));
44}
45
47 FlutterDesktopGpuPreference gpu_preference) {
48 gpu_preference_ = gpu_preference;
49}
50
52 FlutterDesktopAccessibilityMode accessibility_mode) {
53 accessibility_mode_ = accessibility_mode;
54}
55
57 const {
58 FlutterDesktopEngineProperties engine_properties = {};
59 engine_properties.assets_path = context_.GetAssetsPath().c_str();
60 engine_properties.icu_data_path = context_.GetIcuDataPath().c_str();
61
62 // Set Dart entrypoint.
63 engine_properties.dart_entrypoint = dart_entrypoint_.c_str();
64
65 // Set Dart entrypoint argc, argv.
66 std::vector<const char*> dart_args;
67 dart_args.reserve(dart_entrypoint_arguments_.size());
68 for (const auto& arg : dart_entrypoint_arguments_) {
69 dart_args.push_back(arg.c_str());
70 }
71 if (!dart_args.empty()) {
72 engine_properties.dart_entrypoint_argv = dart_args.data();
73 engine_properties.dart_entrypoint_argc = dart_args.size();
74 } else {
75 // Clear this out in case this is not the first engine launch from the
76 // embedder config builder.
77 engine_properties.dart_entrypoint_argv = nullptr;
78 engine_properties.dart_entrypoint_argc = 0;
79 }
80
81 engine_properties.gpu_preference = gpu_preference_;
82 engine_properties.ui_thread_policy = ui_thread_policy_;
83 engine_properties.accessibility_mode = accessibility_mode_;
84
85 return engine_properties;
86}
87
92
94 InitializeCOM();
95
97 if (!engine) {
98 return {};
99 }
100
101 // Register native functions.
102 FlutterWindowsEngine* windows_engine =
103 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
104 windows_engine->SetRootIsolateCreateCallback(
105 context_.GetRootIsolateCallback());
106
107 if (!FlutterDesktopEngineRun(engine.get(), /* entry_point */ nullptr)) {
108 return {};
109 }
110
111 return engine;
112}
113
115 InitializeCOM();
116
118 if (!engine) {
119 return {};
120 }
121
122 // Register native functions.
123 FlutterWindowsEngine* windows_engine =
124 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
125 windows_engine->SetRootIsolateCreateCallback(
126 context_.GetRootIsolateCallback());
127
128 int width = 600;
129 int height = 400;
130
131 // Create a view controller that owns the engine.
132 ViewControllerPtr controller{
134 if (!controller) {
135 return {};
136 }
137
138 return controller;
139}
140
141void WindowsConfigBuilder::InitializeCOM() const {
142 FML_CHECK(SUCCEEDED(::CoInitializeEx(nullptr, COINIT_MULTITHREADED)));
143}
144
145} // namespace testing
146} // namespace flutter
void SetRootIsolateCreateCallback(const fml::closure &callback)
FlutterDesktopEngineProperties GetEngineProperties() const
void SetAccessibilityMode(FlutterDesktopAccessibilityMode accessibility_mode)
void SetDartEntrypoint(std::string_view entrypoint)
void SetUIThreadPolicy(FlutterDesktopUIThreadPolicy policy)
void SetGpuPreference(FlutterDesktopGpuPreference gpu_preference)
const std::wstring & GetIcuDataPath() const
const std::wstring & GetAssetsPath() const
FlutterEngine engine
Definition main.cc:84
FlutterDesktopUIThreadPolicy
FlutterDesktopGpuPreference
FlutterDesktopAccessibilityMode
#define FML_CHECK(condition)
Definition logging.h:104
std::unique_ptr< FlutterDesktopEngine, EngineDeleter > EnginePtr
std::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter > ViewControllerPtr
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 Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy
int32_t height
int32_t width
FlutterDesktopAccessibilityMode accessibility_mode
FlutterDesktopUIThreadPolicy ui_thread_policy
FlutterDesktopGpuPreference gpu_preference
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)
#define SUCCEEDED(hr)