Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::testing::ShellTest Class Reference

#include <shell_test.h>

Inheritance diagram for flutter::testing::ShellTest:
flutter::testing::FixtureTest flutter::testing::DartFixture flutter::testing::ThreadTest flutter::testing::FuchsiaShellTest flutter::testing::ImageDisposeTest flutter::testing::PlatformConfigurationTest

Classes

struct  Config
 

Public Types

enum  ServiceProtocolEnum {
  kGetSkSLs ,
  kEstimateRasterCacheMemory ,
  kSetAssetBundlePath ,
  kRunInView
}
 

Public Member Functions

 ShellTest ()
 
Settings CreateSettingsForFixture () override
 
std::unique_ptr< ShellCreateShell (const Settings &settings, std::optional< TaskRunners > task_runners={})
 
std::unique_ptr< ShellCreateShell (const Config &config)
 
void DestroyShell (std::unique_ptr< Shell > shell)
 
void DestroyShell (std::unique_ptr< Shell > shell, const TaskRunners &task_runners)
 
TaskRunners GetTaskRunnersForFixture ()
 
fml::TimePoint GetLatestFrameTargetTime (Shell *shell) const
 
void SendPlatformMessage (Shell *shell, std::unique_ptr< PlatformMessage > message)
 
void SendSemanticsAction (Shell *shell, int64_t view_id, int32_t node_id, SemanticsAction action, fml::MallocMapping args)
 
void SendEnginePlatformMessage (Shell *shell, std::unique_ptr< PlatformMessage > message)
 
std::shared_ptr< txt::FontCollectionGetFontCollection (Shell *shell)
 
- Public Member Functions inherited from flutter::testing::FixtureTest
 FixtureTest ()
 
 FixtureTest (std::string kernel_filename, std::string elf_filename, std::string elf_split_filename)
 
- Public Member Functions inherited from flutter::testing::DartFixture
 DartFixture ()
 
 DartFixture (std::string kernel_filename, std::string elf_filename, std::string elf_split_filename)
 
void AddNativeCallback (const std::string &name, Dart_NativeFunction callback)
 
void AddFfiNativeCallback (const std::string &name, void *callback_ptr)
 
- Public Member Functions inherited from flutter::testing::ThreadTest
 ThreadTest ()
 
fml::RefPtr< fml::TaskRunnerGetCurrentTaskRunner ()
 Get the task runner for the thread that the current unit-test is running on. This creates a message loop as necessary.
 
fml::RefPtr< fml::TaskRunnerCreateNewThread (const std::string &name="")
 Creates a new thread, initializes a message loop on it, and, returns its task runner to the unit-test. The message loop is terminated (and its thread joined) when the test ends. This allows tests to create multiple named threads as necessary.
 

Static Public Member Functions

static void PlatformViewNotifyCreated (Shell *shell)
 
static void PlatformViewNotifyDestroyed (Shell *shell)
 
static void RunEngine (Shell *shell, RunConfiguration configuration)
 
static void RestartEngine (Shell *shell, RunConfiguration configuration)
 
static void VSyncFlush (Shell *shell, bool *will_draw_new_frame=nullptr)
 
static void SetViewportMetrics (Shell *shell, double width, double height)
 
static void NotifyIdle (Shell *shell, fml::TimeDelta deadline)
 
static void PumpOneFrame (Shell *shell)
 
static void PumpOneFrame (Shell *shell, FrameContent frame_content)
 
static void DispatchFakePointerData (Shell *shell, double x)
 
static void DispatchPointerData (Shell *shell, std::unique_ptr< PointerDataPacket > packet)
 
static bool GetNeedsReportTimings (Shell *shell)
 
static void SetNeedsReportTimings (Shell *shell, bool value)
 
static void StorePersistentCache (PersistentCache *cache, const SkData &key, const SkData &value)
 
static bool IsAnimatorRunning (Shell *shell)
 
static void OnServiceProtocol (Shell *shell, ServiceProtocolEnum some_protocol, const fml::RefPtr< fml::TaskRunner > &task_runner, const ServiceProtocol::Handler::ServiceProtocolMap &params, rapidjson::Document *response)
 
static int UnreportedTimingsCount (Shell *shell)
 
static void TurnOffGPU (Shell *shell, bool value)
 
static bool ShouldDiscardLayerTree (Shell *shell, int64_t view_id, const flutter::LayerTree &tree)
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::testing::DartFixture
void SetSnapshotsAndAssets (Settings &settings)
 
- Protected Attributes inherited from flutter::testing::DartFixture
std::shared_ptr< TestDartNativeResolvernative_resolver_
 
ELFAOTSymbols split_aot_symbols_
 
std::string kernel_filename_
 
std::string elf_filename_
 
fml::UniqueFD assets_dir_
 
ELFAOTSymbols aot_symbols_
 

Detailed Description

Definition at line 63 of file shell_test.h.

Member Enumeration Documentation

◆ ServiceProtocolEnum

Enumerator
kGetSkSLs 
kEstimateRasterCacheMemory 
kSetAssetBundlePath 
kRunInView 

Definition at line 140 of file shell_test.h.

Constructor & Destructor Documentation

◆ ShellTest()

flutter::testing::ShellTest::ShellTest ( )

Definition at line 58 of file shell_test.cc.

59 : thread_host_("io.flutter.test." + GetCurrentTestName() + ".",
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition testing.cc:14

Member Function Documentation

◆ CreateSettingsForFixture()

Settings flutter::testing::ShellTest::CreateSettingsForFixture ( )
overridevirtual

Reimplemented from flutter::testing::DartFixture.

Definition at line 349 of file shell_test.cc.

349 {
350 Settings settings;
351 settings.leak_vm = false;
352 settings.task_observer_add = [](intptr_t key, const fml::closure& handler) {
355 handler);
356 return queue_id;
357 };
358 settings.task_observer_remove = [](fml::TaskQueueId queue_id, intptr_t key) {
360 key);
361 };
362 settings.isolate_create_callback = [this]() {
363 native_resolver_->SetNativeResolverForIsolate();
364 };
365#if OS_FUCHSIA
366 settings.verbose_logging = true;
367#endif
368 SetSnapshotsAndAssets(settings);
369 return settings;
370}
void SetSnapshotsAndAssets(Settings &settings)
std::shared_ptr< TestDartNativeResolver > native_resolver_
static TaskQueueId GetCurrentTaskQueueId()
static MessageLoopTaskQueues * GetInstance()
void AddTaskObserver(TaskQueueId queue_id, intptr_t key, const fml::closure &callback)
void RemoveTaskObserver(TaskQueueId queue_id, intptr_t key)
const gchar FlBinaryMessengerMessageHandler handler
std::function< void()> closure
Definition closure.h:14

References fml::MessageLoopTaskQueues::AddTaskObserver(), fml::MessageLoop::GetCurrentTaskQueueId(), fml::MessageLoopTaskQueues::GetInstance(), handler, flutter::Settings::isolate_create_callback, key, flutter::Settings::leak_vm, fml::MessageLoopTaskQueues::RemoveTaskObserver(), flutter::Settings::task_observer_add, flutter::Settings::task_observer_remove, and flutter::Settings::verbose_logging.

Referenced by flutter::testing::TestSimulatedInputEvents().

◆ CreateShell() [1/2]

std::unique_ptr< Shell > flutter::testing::ShellTest::CreateShell ( const Config config)

Definition at line 395 of file shell_test.cc.

395 {
396 TaskRunners task_runners = config.task_runners.has_value()
397 ? config.task_runners.value()
399 Shell::CreateCallback<PlatformView> platform_view_create_callback =
400 config.platform_view_create_callback;
401 if (!platform_view_create_callback) {
402 platform_view_create_callback = ShellTestPlatformViewBuilder({});
403 }
404
405 Shell::CreateCallback<Rasterizer> rasterizer_create_callback =
406 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); };
407
409 task_runners, //
410 config.settings, //
411 platform_view_create_callback, //
412 rasterizer_create_callback, //
413 config.is_gpu_disabled //
414 );
415}
static std::unique_ptr< Shell > Create(const PlatformData &platform_data, const TaskRunners &task_runners, Settings settings, const CreateCallback< PlatformView > &on_create_platform_view, const CreateCallback< Rasterizer > &on_create_rasterizer, bool is_gpu_disabled=false)
Creates a shell instance using the provided settings. The callbacks to create the various shell subco...
Definition shell.cc:222
TaskRunners GetTaskRunnersForFixture()

References flutter::testing::GetTaskRunnersForFixture(), flutter::testing::ShellTest::Config::is_gpu_disabled, flutter::testing::ShellTest::Config::platform_view_create_callback, flutter::testing::ShellTest::Config::settings, and flutter::testing::ShellTest::Config::task_runners.

◆ CreateShell() [2/2]

std::unique_ptr< Shell > flutter::testing::ShellTest::CreateShell ( const Settings settings,
std::optional< TaskRunners task_runners = {} 
)

Definition at line 386 of file shell_test.cc.

388 {
389 return CreateShell({
390 .settings = settings,
391 .task_runners = std::move(task_runners),
392 });
393}
std::unique_ptr< Shell > CreateShell(const Settings &settings, std::optional< TaskRunners > task_runners={})

Referenced by flutter::testing::TestSimulatedInputEvents().

◆ DestroyShell() [1/2]

void flutter::testing::ShellTest::DestroyShell ( std::unique_ptr< Shell shell)

Definition at line 417 of file shell_test.cc.

417 {
418 DestroyShell(std::move(shell), GetTaskRunnersForFixture());
419}
void DestroyShell(std::unique_ptr< Shell > shell)

References flutter::testing::GetTaskRunnersForFixture().

◆ DestroyShell() [2/2]

void flutter::testing::ShellTest::DestroyShell ( std::unique_ptr< Shell shell,
const TaskRunners task_runners 
)

Definition at line 421 of file shell_test.cc.

422 {
424 fml::TaskRunner::RunNowOrPostTask(task_runners.GetPlatformTaskRunner(),
425 [&shell, &latch]() mutable {
426 shell.reset();
427 latch.Signal();
428 });
429 latch.Wait();
430}
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)

References flutter::TaskRunners::GetPlatformTaskRunner(), fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Wait().

◆ DispatchFakePointerData()

void flutter::testing::ShellTest::DispatchFakePointerData ( Shell shell,
double  x 
)
static

Definition at line 277 of file shell_test.cc.

277 {
278 auto packet = std::make_unique<PointerDataPacket>(1);
279 packet->SetPointerData(0, PointerData{
281 .physical_x = x,
282 });
283 DispatchPointerData(shell, std::move(packet));
284}
static void DispatchPointerData(Shell *shell, std::unique_ptr< PointerDataPacket > packet)
int32_t x

References flutter::PointerData::change, and x.

Referenced by flutter::testing::TestSimulatedInputEvents().

◆ DispatchPointerData()

void flutter::testing::ShellTest::DispatchPointerData ( Shell shell,
std::unique_ptr< PointerDataPacket packet 
)
static

Definition at line 286 of file shell_test.cc.

287 {
289 shell->GetTaskRunners().GetPlatformTaskRunner()->PostTask(
290 [&latch, shell, &packet]() {
291 // Goes through PlatformView to ensure packet is corrected converted.
292 shell->GetPlatformView()->DispatchPointerDataPacket(std::move(packet));
293 latch.Signal();
294 });
295 latch.Wait();
296}
static void DispatchPointerDataPacket(JNIEnv *env, jobject jcaller, jlong shell_holder, jobject buffer, jint position)

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetPlatformView(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::PostTask(), fml::AutoResetWaitableEvent::Signal(), and fml::AutoResetWaitableEvent::Wait().

Referenced by flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ GetFontCollection()

std::shared_ptr< txt::FontCollection > flutter::testing::ShellTest::GetFontCollection ( Shell shell)

Definition at line 344 of file shell_test.cc.

345 {
346 return shell->weak_engine_->GetFontCollection().GetFontCollection();
347}

◆ GetLatestFrameTargetTime()

fml::TimePoint flutter::testing::ShellTest::GetLatestFrameTargetTime ( Shell shell) const

Definition at line 382 of file shell_test.cc.

382 {
383 return shell->GetLatestFrameTargetTime();
384}

◆ GetNeedsReportTimings()

bool flutter::testing::ShellTest::GetNeedsReportTimings ( Shell shell)
static

Definition at line 306 of file shell_test.cc.

306 {
307 return shell->needs_report_timings_;
308}

◆ GetTaskRunnersForFixture()

TaskRunners flutter::testing::ShellTest::GetTaskRunnersForFixture ( )

Definition at line 372 of file shell_test.cc.

372 {
373 return {
374 "test",
375 thread_host_.platform_thread->GetTaskRunner(), // platform
376 thread_host_.raster_thread->GetTaskRunner(), // raster
377 thread_host_.ui_thread->GetTaskRunner(), // ui
378 thread_host_.io_thread->GetTaskRunner() // io
379 };
380}
std::unique_ptr< fml::Thread > io_thread
Definition thread_host.h:86
std::unique_ptr< fml::Thread > platform_thread
Definition thread_host.h:83
std::unique_ptr< fml::Thread > raster_thread
Definition thread_host.h:85
std::unique_ptr< fml::Thread > ui_thread
Definition thread_host.h:84

References thread_host_.

Referenced by flutter::testing::TestSimulatedInputEvents().

◆ IsAnimatorRunning()

static bool flutter::testing::ShellTest::IsAnimatorRunning ( Shell shell)
static

◆ NotifyIdle()

void flutter::testing::ShellTest::NotifyIdle ( Shell shell,
fml::TimeDelta  deadline 
)
static

Definition at line 216 of file shell_test.cc.

216 {
218 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
219 [&latch, engine = shell->weak_engine_, deadline]() {
220 if (engine) {
221 engine->NotifyIdle(deadline);
222 }
223 latch.Signal();
224 });
225 latch.Wait();
226}
FlutterEngine engine
Definition main.cc:84

References engine, flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), fml::TaskRunner::PostTask(), and fml::AutoResetWaitableEvent::Signal().

◆ OnServiceProtocol()

void flutter::testing::ShellTest::OnServiceProtocol ( Shell shell,
ServiceProtocolEnum  some_protocol,
const fml::RefPtr< fml::TaskRunner > &  task_runner,
const ServiceProtocol::Handler::ServiceProtocolMap params,
rapidjson::Document *  response 
)
static

Definition at line 316 of file shell_test.cc.

321 {
322 std::promise<bool> finished;
324 task_runner, [shell, some_protocol, params, response, &finished]() {
325 switch (some_protocol) {
327 shell->OnServiceProtocolGetSkSLs(params, response);
328 break;
330 shell->OnServiceProtocolEstimateRasterCacheMemory(params, response);
331 break;
333 shell->OnServiceProtocolSetAssetBundlePath(params, response);
334 break;
336 shell->OnServiceProtocolRunInView(params, response);
337 break;
338 }
339 finished.set_value(true);
340 });
341 finished.get_future().wait();
342}
const EmbeddedViewParams * params

References params, and fml::TaskRunner::RunNowOrPostTask().

◆ PlatformViewNotifyCreated()

void flutter::testing::ShellTest::PlatformViewNotifyCreated ( Shell shell)
static

Definition at line 93 of file shell_test.cc.

93 {
96 shell->GetTaskRunners().GetPlatformTaskRunner(), [shell, &latch]() {
97 shell->GetPlatformView()->NotifyCreated();
98 latch.Signal();
99 });
100 latch.Wait();
101}

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Wait().

Referenced by flutter::testing::ValidateShell().

◆ PlatformViewNotifyDestroyed()

void flutter::testing::ShellTest::PlatformViewNotifyDestroyed ( Shell shell)
static

Definition at line 103 of file shell_test.cc.

103 {
106 shell->GetTaskRunners().GetPlatformTaskRunner(), [shell, &latch]() {
107 shell->GetPlatformView()->NotifyDestroyed();
108 latch.Signal();
109 });
110 latch.Wait();
111}

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Wait().

Referenced by flutter::testing::ValidateDestroyPlatformView().

◆ PumpOneFrame() [1/2]

void flutter::testing::ShellTest::PumpOneFrame ( Shell shell)
static

Definition at line 228 of file shell_test.cc.

228 {
230}
static void PumpOneFrame(Shell *shell)
static FrameContent DummyView(double width=1, double height=1)
Definition shell_test.cc:29

◆ PumpOneFrame() [2/2]

void flutter::testing::ShellTest::PumpOneFrame ( Shell shell,
FrameContent  frame_content 
)
static

Definition at line 232 of file shell_test.cc.

232 {
233 // Set viewport to nonempty, and call Animator::BeginFrame to make the layer
234 // tree pipeline nonempty. Without either of this, the layer tree below
235 // won't be rasterized.
238 shell->weak_engine_;
239 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
240 [&latch, engine = shell->weak_engine_, &frame_content,
241 runtime_delegate]() {
242 for (auto& [view_id, view_content] : frame_content) {
243 engine->SetViewportMetrics(view_id, view_content.viewport_metrics);
244 }
245 const auto frame_begin_time = fml::TimePoint::Now();
246 const auto frame_end_time =
247 frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0);
248 std::unique_ptr<FrameTimingsRecorder> recorder =
249 std::make_unique<FrameTimingsRecorder>();
250 recorder->RecordVsync(frame_begin_time, frame_end_time);
251 engine->animator_->BeginFrame(std::move(recorder));
252
253 // The BeginFrame phase and the EndFrame phase must be performed in a
254 // single task, otherwise a normal vsync might be inserted in between,
255 // causing flaky assertion errors.
256
257 for (auto& [view_id, view_content] : frame_content) {
258 auto root_layer = std::make_shared<TransformLayer>(DlMatrix());
259 auto layer_tree = std::make_unique<LayerTree>(
260 root_layer,
261 DlISize(view_content.viewport_metrics.physical_width,
262 view_content.viewport_metrics.physical_height));
263 float device_pixel_ratio = static_cast<float>(
264 view_content.viewport_metrics.device_pixel_ratio);
265 if (view_content.builder) {
266 view_content.builder(root_layer);
267 }
268 runtime_delegate->Render(view_id, std::move(layer_tree),
269 device_pixel_ratio);
270 }
271 engine->animator_->EndFrame();
272 latch.Signal();
273 });
274 latch.Wait();
275}
static constexpr TimeDelta FromSecondsF(double seconds)
Definition time_delta.h:53
static TimePoint Now()
Definition time_point.cc:49
G_BEGIN_DECLS FlutterViewId view_id
impeller::Matrix DlMatrix
impeller::ISize32 DlISize

References engine, fml::TimeDelta::FromSecondsF(), flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), fml::TimePoint::Now(), fml::TaskRunner::PostTask(), fml::AutoResetWaitableEvent::Signal(), and view_id.

◆ RestartEngine()

void flutter::testing::ShellTest::RestartEngine ( Shell shell,
RunConfiguration  configuration 
)
static

Definition at line 127 of file shell_test.cc.

127 {
128 std::promise<bool> restarted;
130 shell->GetTaskRunners().GetUITaskRunner(),
131 [shell, &restarted, &configuration]() {
132 restarted.set_value(shell->engine_->Restart(std::move(configuration)));
133 });
134 ASSERT_TRUE(restarted.get_future().get());
135}

References flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), and fml::TaskRunner::RunNowOrPostTask().

Referenced by flutter::testing::TestSimulatedInputEvents().

◆ RunEngine()

void flutter::testing::ShellTest::RunEngine ( Shell shell,
RunConfiguration  configuration 
)
static

Definition at line 113 of file shell_test.cc.

113 {
116 shell->GetTaskRunners().GetPlatformTaskRunner(),
117 [shell, &latch, &configuration]() {
118 shell->RunEngine(std::move(configuration),
119 [&latch](Engine::RunStatus run_status) {
120 ASSERT_EQ(run_status, Engine::RunStatus::Success);
121 latch.Signal();
122 });
123 });
124 latch.Wait();
125}

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), and fml::TaskRunner::RunNowOrPostTask().

Referenced by flutter::testing::TestSimulatedInputEvents().

◆ SendEnginePlatformMessage()

void flutter::testing::ShellTest::SendEnginePlatformMessage ( Shell shell,
std::unique_ptr< PlatformMessage message 
)

Definition at line 77 of file shell_test.cc.

79 {
82 shell->GetTaskRunners().GetPlatformTaskRunner(),
84 [shell, &latch, message = std::move(message)]() mutable {
85 if (auto engine = shell->weak_engine_) {
86 engine->HandlePlatformMessage(std::move(message));
87 }
88 latch.Signal();
89 }));
90 latch.Wait();
91}
const char * message
internal::CopyableLambda< T > MakeCopyable(T lambda)

References flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetTaskRunners(), fml::MakeCopyable(), message, fml::TaskRunner::RunNowOrPostTask(), and fml::AutoResetWaitableEvent::Signal().

◆ SendPlatformMessage()

void flutter::testing::ShellTest::SendPlatformMessage ( Shell shell,
std::unique_ptr< PlatformMessage message 
)

Definition at line 63 of file shell_test.cc.

64 {
65 shell->OnPlatformViewDispatchPlatformMessage(std::move(message));
66}

References message.

◆ SendSemanticsAction()

void flutter::testing::ShellTest::SendSemanticsAction ( Shell shell,
int64_t  view_id,
int32_t  node_id,
SemanticsAction  action,
fml::MallocMapping  args 
)

Definition at line 68 of file shell_test.cc.

72 {
73 shell->OnPlatformViewDispatchSemanticsAction(view_id, node_id, action,
74 std::move(args));
75}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

References action, args, and view_id.

◆ SetNeedsReportTimings()

void flutter::testing::ShellTest::SetNeedsReportTimings ( Shell shell,
bool  value 
)
static

Definition at line 302 of file shell_test.cc.

302 {
303 shell->SetNeedsReportTimings(value);
304}

References value.

◆ SetViewportMetrics()

void flutter::testing::ShellTest::SetViewportMetrics ( Shell shell,
double  width,
double  height 
)
static

Definition at line 163 of file shell_test.cc.

163 {
164 flutter::ViewportMetrics viewport_metrics = {
165 1, // device pixel ratio
166 width, // physical width
167 height, // physical height
168 0, // min width constraint
169 0, // max width constraint
170 0, // min height constraint
171 0, // max height constraint
172 0, // padding top
173 0, // padding right
174 0, // padding bottom
175 0, // padding left
176 0, // view inset top
177 0, // view inset right
178 0, // view inset bottom
179 0, // view inset left
180 0, // gesture inset top
181 0, // gesture inset right
182 0, // gesture inset bottom
183 0, // gesture inset left
184 22, // physical touch slop
185 std::vector<double>(), // display features bounds
186 std::vector<int>(), // display features type
187 std::vector<int>(), // display features state
188 0, // Display ID
189 0, // display corner radius top left
190 0, // display corner radius top right
191 0, // display corner radius bottom right
192 0, // display corner radius bottom left
193 };
194 // Set viewport to nonempty, and call Animator::BeginFrame to make the layer
195 // tree pipeline nonempty. Without either of this, the layer tree below
196 // won't be rasterized.
198 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
199 [&latch, engine = shell->weak_engine_, viewport_metrics]() {
200 if (engine) {
201 engine->SetViewportMetrics(kImplicitViewId, viewport_metrics);
202 const auto frame_begin_time = fml::TimePoint::Now();
203 const auto frame_end_time =
204 frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0);
205 std::unique_ptr<FrameTimingsRecorder> recorder =
206 std::make_unique<FrameTimingsRecorder>();
207 recorder->RecordVsync(frame_begin_time, frame_end_time);
208 engine->animator_->BeginFrame(std::move(recorder));
209 engine->animator_->EndFrame();
210 }
211 latch.Signal();
212 });
213 latch.Wait();
214}
int32_t height
int32_t width

References engine, flutter::Shell::GetTaskRunners(), flutter::TaskRunners::GetUITaskRunner(), height, fml::TaskRunner::PostTask(), fml::AutoResetWaitableEvent::Signal(), and width.

◆ ShouldDiscardLayerTree()

bool flutter::testing::ShellTest::ShouldDiscardLayerTree ( Shell shell,
int64_t  view_id,
const flutter::LayerTree tree 
)
static

Definition at line 436 of file shell_test.cc.

438 {
439 return shell->ShouldDiscardLayerTree(view_id, tree);
440}

References view_id.

◆ StorePersistentCache()

void flutter::testing::ShellTest::StorePersistentCache ( PersistentCache cache,
const SkData &  key,
const SkData &  value 
)
static

Definition at line 310 of file shell_test.cc.

312 {
313 cache->store(key, value);
314}

References key, and value.

◆ TurnOffGPU()

void flutter::testing::ShellTest::TurnOffGPU ( Shell shell,
bool  value 
)
static

Definition at line 432 of file shell_test.cc.

432 {
433 shell->is_gpu_disabled_sync_switch_->SetSwitch(value);
434}

References value.

◆ UnreportedTimingsCount()

int flutter::testing::ShellTest::UnreportedTimingsCount ( Shell shell)
static

Definition at line 298 of file shell_test.cc.

298 {
299 return shell->unreported_timings_.size();
300}

◆ VSyncFlush()

void flutter::testing::ShellTest::VSyncFlush ( Shell shell,
bool *  will_draw_new_frame = nullptr 
)
static

Issue as many VSYNC as needed to flush the UI tasks so far, and reset the content of will_draw_new_frame to true if it's not nullptr.

Definition at line 137 of file shell_test.cc.

137 {
140 shell->GetTaskRunners().GetPlatformTaskRunner(),
141 [shell, will_draw_new_frame, &latch] {
142 // The following UI task ensures that all previous UI tasks are flushed.
143 fml::AutoResetWaitableEvent ui_latch;
144 shell->GetTaskRunners().GetUITaskRunner()->PostTask(
145 [&ui_latch, will_draw_new_frame]() {
146 if (will_draw_new_frame != nullptr) {
147 *will_draw_new_frame = true;
148 }
149 ui_latch.Signal();
150 });
151
152 ShellTestPlatformView* test_platform_view =
153 static_cast<ShellTestPlatformView*>(shell->GetPlatformView().get());
154 do {
155 test_platform_view->SimulateVSync();
156 } while (ui_latch.WaitWithTimeout(fml::TimeDelta::FromMilliseconds(1)));
157
158 latch.Signal();
159 });
160 latch.Wait();
161}
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition time_delta.h:46

References fml::TimeDelta::FromMilliseconds(), flutter::TaskRunners::GetPlatformTaskRunner(), flutter::Shell::GetPlatformView(), flutter::Shell::GetTaskRunners(), fml::TaskRunner::RunNowOrPostTask(), fml::AutoResetWaitableEvent::Signal(), and flutter::testing::ShellTestPlatformView::SimulateVSync().

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TestSimulatedInputEvents().


The documentation for this class was generated from the following files: