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_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 457 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 557 of file tester_main.cc.

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