Flutter Engine
flutter::ScriptCompletionTaskObserver Class Reference

Public Member Functions

 ScriptCompletionTaskObserver (Shell &shell, fml::RefPtr< fml::TaskRunner > main_task_runner, bool run_forever)
 
int GetExitCodeForLastError () const
 
void DidProcessTask ()
 

Detailed Description

Definition at line 35 of file tester_main.cc.

Constructor & Destructor Documentation

◆ ScriptCompletionTaskObserver()

flutter::ScriptCompletionTaskObserver::ScriptCompletionTaskObserver ( Shell shell,
fml::RefPtr< fml::TaskRunner main_task_runner,
bool  run_forever 
)
inline

Definition at line 37 of file tester_main.cc.

40  : shell_(shell),
41  main_task_runner_(std::move(main_task_runner)),
42  run_forever_(run_forever) {}

Member Function Documentation

◆ DidProcessTask()

void flutter::ScriptCompletionTaskObserver::DidProcessTask ( )
inline

Definition at line 48 of file tester_main.cc.

References flutter::Shell::EngineHasLivePorts(), fml::MessageLoop::GetCurrent(), flutter::Shell::GetUIIsolateLastError(), fml::TaskRunner::RunNowOrPostTask(), and fml::MessageLoop::Terminate().

Referenced by flutter::RunTester().

48  {
49  last_error_ = shell_.GetUIIsolateLastError();
50  if (shell_.EngineHasLivePorts()) {
51  // The UI isolate still has live ports and is running. Nothing to do
52  // just yet.
53  return;
54  }
55 
56  if (run_forever_) {
57  // We need this script to run forever. We have already recorded the last
58  // error. Keep going.
59  return;
60  }
61 
62  if (!has_terminated) {
63  // Only try to terminate the loop once.
64  has_terminated = true;
65  fml::TaskRunner::RunNowOrPostTask(main_task_runner_, []() {
67  });
68  }
69  }
static void RunNowOrPostTask(fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
Definition: task_runner.cc:55
bool EngineHasLivePorts() const
Used by embedders to check if the Engine is running and has any live ports remaining. For example, the Flutter tester uses this method to check whether it should continue to wait for a running test or not.
Definition: shell.cc:518
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
std::optional< DartErrorCode > GetUIIsolateLastError() const
Used by embedders to get the last error from the Dart UI Isolate, if one exists.
Definition: shell.cc:498

◆ GetExitCodeForLastError()

int flutter::ScriptCompletionTaskObserver::GetExitCodeForLastError ( ) const
inline

Definition at line 44 of file tester_main.cc.

References flutter::NoError.

Referenced by flutter::RunTester().

44  {
45  return static_cast<int>(last_error_.value_or(DartErrorCode::NoError));
46  }
No error has occurred.

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