Flutter Engine
 
Loading...
Searching...
No Matches
tester_main.cc File Reference
#include <cstdlib>
#include <cstring>
#include <iostream>
#include "flutter/assets/asset_manager.h"
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/flow/embedded_views.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 "flutter/shell/gpu/gpu_surface_software.h"
#include "third_party/abseil-cpp/absl/base/no_destructor.h"
#include "third_party/dart/runtime/include/bin/dart_io_api.h"
#include "third_party/dart/runtime/include/dart_api.h"
#include "third_party/skia/include/core/SkSurface.h"

Go to the source code of this file.

Classes

struct  ImpellerVulkanContextHolder
 
class  flutter::TesterExternalViewEmbedder
 
class  flutter::TesterGPUSurfaceSoftware
 
class  flutter::TesterPlatformView
 
class  flutter::ScriptCompletionTaskObserver
 

Namespaces

namespace  flutter
 

Macros

#define FML_USED_ON_EMBEDDER
 
#define ALLOW_IMPELLER   (IMPELLER_SUPPORTS_RENDERING && IMPELLER_ENABLE_VULKAN)
 
#define EXPORTED   __attribute__((visibility("default")))
 

Functions

static void flutter::ConfigureShell (Shell *shell)
 
static void flutter::UnblockSIGPROF ()
 
int flutter::RunTester (const flutter::Settings &settings, bool run_forever, bool multithreaded)
 
EXPORTED Dart_Handle flutter::LoadLibraryFromKernel (const char *path)
 
EXPORTED Dart_Handle flutter::LookupEntryPoint (const char *uri, const char *name)
 
EXPORTED void flutter::Spawn (const char *entrypoint, const char *route)
 
EXPORTED void flutter::ForceShutdownIsolate ()
 
int main (int argc, char *argv[])
 

Variables

static absl::NoDestructor< std::unique_ptr< Shell > > flutter::g_shell
 

Macro Definition Documentation

◆ ALLOW_IMPELLER

#define ALLOW_IMPELLER   (IMPELLER_SUPPORTS_RENDERING && IMPELLER_ENABLE_VULKAN)

Definition at line 34 of file tester_main.cc.

◆ EXPORTED

#define EXPORTED   __attribute__((visibility("default")))

Definition at line 531 of file tester_main.cc.

◆ 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 631 of file tester_main.cc.

631 {
632 dart::bin::SetExecutableName(argv[0]);
633 dart::bin::SetExecutableArguments(argc - 1, argv);
634
635 auto command_line = fml::CommandLineFromPlatformOrArgcArgv(argc, argv);
636
637 if (command_line.HasOption(flutter::FlagForSwitch(flutter::Switch::Help))) {
638 flutter::PrintUsage("flutter_tester");
639 return EXIT_SUCCESS;
640 }
641
642 auto settings = flutter::SettingsFromCommandLine(command_line);
643 if (!command_line.positional_args().empty()) {
644 // The tester may not use the switch for the main dart file path. Specifying
645 // it as a positional argument instead.
646 settings.application_kernel_asset = command_line.positional_args()[0];
647 }
648
649 if (settings.application_kernel_asset.empty()) {
650 FML_LOG(ERROR) << "Dart kernel file not specified.";
651 return EXIT_FAILURE;
652 }
653
654 settings.leak_vm = false;
655 settings.enable_platform_isolates = true;
656
657 if (settings.icu_data_path.empty()) {
658 settings.icu_data_path = "icudtl.dat";
659 }
660
661 // The tools that read logs get confused if there is a log tag specified.
662 settings.log_tag = "";
663
664 settings.log_message_callback = [](const std::string& tag,
665 const std::string& message) {
666 if (!tag.empty()) {
667 std::cout << tag << ": ";
668 }
669 std::cout << message << std::endl;
670 };
671
672 settings.task_observer_add = [](intptr_t key, const fml::closure& callback) {
675 callback);
676 return queue_id;
677 };
678
679 settings.task_observer_remove = [](fml::TaskQueueId queue_id, intptr_t key) {
681 key);
682 };
683
684 settings.unhandled_exception_callback = [](const std::string& error,
685 const std::string& stack_trace) {
686 FML_LOG(ERROR) << "Unhandled exception" << std::endl
687 << "Exception: " << error << std::endl
688 << "Stack trace: " << stack_trace;
689 ::exit(1);
690 return true;
691 };
692
693#if defined(FML_OS_WIN)
694 CoInitializeEx(nullptr, COINIT_MULTITHREADED);
695#endif // defined(FML_OS_WIN)
696
697 return flutter::RunTester(settings,
698 command_line.HasOption(flutter::FlagForSwitch(
699 flutter::Switch::RunForever)),
700 command_line.HasOption(flutter::FlagForSwitch(
701 flutter::Switch::ForceMultithreading)));
702}
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)
G_BEGIN_DECLS GBytes * message
const uint8_t uint32_t uint32_t GError ** error
FlutterDesktopBinaryReply callback
#define FML_LOG(severity)
Definition logging.h:101
char ** argv
Definition library.h:9
int RunTester(const flutter::Settings &settings, bool run_forever, bool multithreaded)
void PrintUsage(const std::string &executable_name)
Definition switches.cc:89
Settings SettingsFromCommandLine(const fml::CommandLine &command_line, bool require_merged_platform_ui_thread)
Definition switches.cc:230
const std::string_view FlagForSwitch(Switch swtch)
Definition switches.cc:146
std::function< void()> closure
Definition closure.h:14
CommandLine CommandLineFromPlatformOrArgcArgv(int argc, const char *const *argv)

References fml::MessageLoopTaskQueues::AddTaskObserver(), argv, callback, fml::CommandLineFromPlatformOrArgcArgv(), error, flutter::FlagForSwitch(), FML_LOG, fml::MessageLoop::GetCurrentTaskQueueId(), fml::MessageLoopTaskQueues::GetInstance(), key, message, flutter::PrintUsage(), fml::MessageLoopTaskQueues::RemoveTaskObserver(), flutter::RunTester(), and flutter::SettingsFromCommandLine().