Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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"
#include "flutter/shell/testing/tester_context.h"
#include "flutter/shell/testing/tester_context_gles_factory.h"
#include "flutter/shell/testing/tester_context_mtl_factory.h"
#include "flutter/shell/testing/tester_context_vk_factory.h"

Go to the source code of this file.

Classes

class  flutter::TesterExternalViewEmbedder
 
class  flutter::TesterGPUSurfaceSoftware
 
class  flutter::TesterPlatformView
 
class  flutter::ScriptCompletionTaskObserver
 

Namespaces

namespace  flutter
 

Macros

#define FML_USED_ON_EMBEDDER
 
#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

◆ EXPORTED

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

Definition at line 467 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 567 of file tester_main.cc.

567 {
568 dart::bin::SetExecutableName(argv[0]);
569 dart::bin::SetExecutableArguments(argc - 1, argv);
570
571 auto command_line = fml::CommandLineFromPlatformOrArgcArgv(argc, argv);
572
573 if (command_line.HasOption(flutter::FlagForSwitch(flutter::Switch::Help))) {
574 flutter::PrintUsage("flutter_tester");
575 return EXIT_SUCCESS;
576 }
577
578 auto settings = flutter::SettingsFromCommandLine(command_line);
579 if (!command_line.positional_args().empty()) {
580 // The tester may not use the switch for the main dart file path. Specifying
581 // it as a positional argument instead.
582 settings.application_kernel_asset = command_line.positional_args()[0];
583 }
584
585 if (settings.application_kernel_asset.empty()) {
586 FML_LOG(ERROR) << "Dart kernel file not specified.";
587 return EXIT_FAILURE;
588 }
589
590 settings.leak_vm = false;
591 settings.enable_platform_isolates = true;
592
593 if (settings.icu_data_path.empty()) {
594 settings.icu_data_path = "icudtl.dat";
595 }
596
597 // The tools that read logs get confused if there is a log tag specified.
598 settings.log_tag = "";
599
600 settings.log_message_callback = [](const std::string& tag,
601 const std::string& message) {
602 if (!tag.empty()) {
603 std::cout << tag << ": ";
604 }
605 std::cout << message << std::endl;
606 };
607
608 settings.task_observer_add = [](intptr_t key, const fml::closure& callback) {
611 callback);
612 return queue_id;
613 };
614
615 settings.task_observer_remove = [](fml::TaskQueueId queue_id, intptr_t key) {
617 key);
618 };
619
620 settings.unhandled_exception_callback = [](const std::string& error,
621 const std::string& stack_trace) {
622 FML_LOG(ERROR) << "Unhandled exception" << std::endl
623 << "Exception: " << error << std::endl
624 << "Stack trace: " << stack_trace;
625 ::exit(1);
626 return true;
627 };
628
629#if defined(FML_OS_WIN)
630 CoInitializeEx(nullptr, COINIT_MULTITHREADED);
631#endif // defined(FML_OS_WIN)
632
633 return flutter::RunTester(settings,
634 command_line.HasOption(flutter::FlagForSwitch(
635 flutter::Switch::RunForever)),
636 command_line.HasOption(flutter::FlagForSwitch(
637 flutter::Switch::ForceMultithreading)));
638}
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 char * 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().