Flutter Engine
tester_main.cc File Reference
#include <cstdlib>
#include <cstring>
#include "flutter/assets/asset_manager.h"
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/fml/build_config.h"
#include "flutter/fml/file.h"
#include "flutter/fml/make_copyable.h"
#include "flutter/fml/message_loop.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/task_runner.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/switches.h"
#include "flutter/shell/common/thread_host.h"
#include "third_party/dart/runtime/include/bin/dart_io_api.h"
#include "third_party/dart/runtime/include/dart_api.h"

Go to the source code of this file.

Classes

class  flutter::ScriptCompletionTaskObserver
 

Namespaces

 flutter
 

Macros

#define FML_USED_ON_EMBEDDER
 

Functions

static void flutter::UnblockSIGPROF ()
 
int flutter::RunTester (const flutter::Settings &settings, bool run_forever, bool multithreaded)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ FML_USED_ON_EMBEDDER

#define FML_USED_ON_EMBEDDER

Definition at line 5 of file tester_main.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 264 of file tester_main.cc.

References fml::MessageLoop::AddTaskObserver(), fml::CommandLineFromArgcArgv(), error, flutter::FlagForSwitch(), FML_LOG, fml::MessageLoop::GetCurrent(), flutter::PrintUsage(), fml::MessageLoop::RemoveTaskObserver(), flutter::RunTester(), and flutter::SettingsFromCommandLine().

264  {
265  dart::bin::SetExecutableName(argv[0]);
266  dart::bin::SetExecutableArguments(argc - 1, argv);
267 
268  auto command_line = fml::CommandLineFromArgcArgv(argc, argv);
269 
270  if (command_line.HasOption(flutter::FlagForSwitch(flutter::Switch::Help))) {
271  flutter::PrintUsage("flutter_tester");
272  return EXIT_SUCCESS;
273  }
274 
275  auto settings = flutter::SettingsFromCommandLine(command_line);
276  if (command_line.positional_args().size() > 0) {
277  // The tester may not use the switch for the main dart file path. Specifying
278  // it as a positional argument instead.
279  settings.application_kernel_asset = command_line.positional_args()[0];
280  }
281 
282  if (settings.application_kernel_asset.size() == 0) {
283  FML_LOG(ERROR) << "Dart kernel file not specified.";
284  return EXIT_FAILURE;
285  }
286 
287  if (settings.icu_data_path.size() == 0) {
288  settings.icu_data_path = "icudtl.dat";
289  }
290 
291  // The tools that read logs get confused if there is a log tag specified.
292  settings.log_tag = "";
293 
294  settings.task_observer_add = [](intptr_t key, fml::closure callback) {
295  fml::MessageLoop::GetCurrent().AddTaskObserver(key, std::move(callback));
296  };
297 
298  settings.task_observer_remove = [](intptr_t key) {
300  };
301 
302  settings.unhandled_exception_callback = [](const std::string& error,
303  const std::string& stack_trace) {
304  FML_LOG(ERROR) << "Unhandled exception" << std::endl
305  << "Exception: " << error << std::endl
306  << "Stack trace: " << stack_trace;
307  ::exit(1);
308  return true;
309  };
310 
311  return flutter::RunTester(settings,
312  command_line.HasOption(flutter::FlagForSwitch(
313  flutter::Switch::RunForever)),
314  command_line.HasOption(flutter::FlagForSwitch(
315  flutter::Switch::ForceMultithreading)));
316 }
void AddTaskObserver(intptr_t key, const fml::closure &callback)
Definition: message_loop.cc:64
FlMethodResponse GError ** error
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)
Definition: command_line.h:222
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
Definition: switches.cc:216
#define FML_LOG(severity)
Definition: logging.h:65
const std::string_view FlagForSwitch(Switch swtch)
Definition: switches.cc:147
std::function< void()> closure
Definition: closure.h:14
void PrintUsage(const std::string &executable_name)
Definition: switches.cc:93
void RemoveTaskObserver(intptr_t key)
Definition: message_loop.cc:68
int RunTester(const flutter::Settings &settings, bool run_forever, bool multithreaded)
Definition: tester_main.cc:96