5#define FML_USED_ON_EMBEDDER
34#include "third_party/skia/include/core/SkSurface.h"
37#if defined(FML_OS_MACOSX)
46static uint64_t NanosFromEpoch(
int millis_from_now) {
49 return (now + delta).ToEpochDelta().ToNanoseconds();
59TEST(EmbedderTestNoFixture, MustNotRunWithInvalidArgs) {
64 ASSERT_FALSE(
engine.is_valid());
68 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
70 context.AddIsolateCreateCallback([&latch]() { latch.
Signal(); });
74 ASSERT_TRUE(
engine.is_valid());
82 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
85 for (
size_t i = 0;
i < 3; ++
i) {
87 ASSERT_TRUE(
engine.is_valid());
88 FML_LOG(INFO) <<
"Engine launch count: " <<
i + 1;
93 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
95 Dart_NativeFunction entrypoint = [](Dart_NativeArguments
args) {
98 context.AddNativeCallback(
"SayHiFromCustomEntrypoint", entrypoint);
104 ASSERT_TRUE(
engine.is_valid());
108 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
115 auto entry1 = [&latch1](Dart_NativeArguments
args) {
116 FML_LOG(INFO) <<
"In Callback 1";
120 context.AddNativeCallback(
"SayHiFromCustomEntrypoint1", native_entry1);
123 auto entry2 = [&latch2](Dart_NativeArguments
args) {
124 FML_LOG(INFO) <<
"In Callback 2";
127 context.AddNativeCallback(
"SayHiFromCustomEntrypoint2",
131 context.AddNativeCallback(
132 "SayHiFromCustomEntrypoint3",
134 FML_LOG(INFO) <<
"In Callback 3";
145 ASSERT_TRUE(
engine.is_valid());
149 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
154 ASSERT_TRUE(
engine.is_valid());
158 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
163 context.AddNativeCallback(
166 Dart_GetNativeArgument(
args, 0));
167 EXPECT_EQ(
"/path/to/binary", dart_string);
183 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
185 bool implicitViewNotNull =
false;
187 context.AddNativeCallback(
190 Dart_GetNativeArgument(
args, 0));
200 EXPECT_TRUE(implicitViewNotNull);
203std::atomic_size_t EmbedderTestTaskRunner::sEmbedderTaskRunnerIdentifiers = {};
206 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
207 auto ui_thread = std::make_unique<fml::Thread>(
"test_ui_thread");
208 auto ui_task_runner = ui_thread->GetTaskRunner();
209 std::mutex ui_task_runner_mutex;
210 bool ui_task_runner_destroyed =
false;
211 auto platform_thread = std::make_unique<fml::Thread>(
"test_platform_thread");
212 auto platform_task_runner = platform_thread->GetTaskRunner();
222 std::scoped_lock lock(ui_task_runner_mutex);
223 if (ui_task_runner_destroyed) {
228 .SetDestructionCallback([&]() {
229 std::scoped_lock lock(ui_task_runner_mutex);
230 ui_task_runner_destroyed =
true;
248 context.AddNativeCallback(
251 ASSERT_TRUE(ui_task_runner->RunsTasksOnCurrentThread());
255 platform_task_runner->PostTask([&]() {
257 const auto ui_task_runner_description =
259 const auto platform_task_runner_description =
267 ASSERT_TRUE(platform_task_runner->RunsTasksOnCurrentThread());
268 signal_latch_platform.
Signal();
272 ASSERT_TRUE(
engine.is_valid());
274 signal_latch_ui.
Wait();
275 signal_latch_platform.
Wait();
278 platform_task_runner->PostTask([&] {
280 platform_task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
288 platform_thread.reset();
292 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
293 auto ui_task_runner = CreateNewThread(
"test_ui_thread");
294 auto platform_task_runner = CreateNewThread(
"test_platform_thread");
295 static std::mutex engine_mutex;
310 std::scoped_lock lock(engine_mutex);
319 platform_task_runner->PostTask([&]() {
321 const auto ui_task_runner_description =
322 test_ui_task_runner.GetFlutterTaskRunnerDescription();
323 const auto platform_task_runner_description =
324 test_platform_task_runner.GetFlutterTaskRunnerDescription();
328 std::scoped_lock lock(engine_mutex);
335 engine_ptr =
engine.get();
345 platform_task_runner->PostTask([&] {
347 platform_task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
353 ui_task_runner->PostDelayedTask([&]() { kill_latch.
Signal(); },
359 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
360 auto task_runner = CreateNewThread(
"test_thread");
373 context.AddNativeCallback(
376 ASSERT_TRUE(task_runner->RunsTasksOnCurrentThread());
377 signal_latch_ui.Signal();
380 task_runner->PostTask([&]() {
382 const auto task_runner_description =
383 test_task_runner.GetFlutterTaskRunnerDescription();
390 ASSERT_TRUE(task_runner->RunsTasksOnCurrentThread());
391 signal_latch_platform.
Signal();
394 ASSERT_TRUE(
engine.is_valid());
396 signal_latch_ui.
Wait();
397 signal_latch_platform.
Wait();
400 task_runner->PostTask([&] {
402 task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
408 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
409 auto ui_task_runner = CreateNewThread(
"test_ui_thread");
423 context.AddNativeCallback(
425 ASSERT_TRUE(ui_task_runner->RunsTasksOnCurrentThread());
426 signal_latch.Signal();
429 ui_task_runner->PostTask([&]() {
431 const auto task_runner_description =
432 test_task_runner.GetFlutterTaskRunnerDescription();
437 ASSERT_TRUE(
engine.is_valid());
442 ui_task_runner->PostTask([&] {
444 ui_task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
450 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
455 auto platform_task_runner = CreateNewThread(
"test_platform_thread");
456 static std::mutex engine_mutex;
457 static bool signaled_once =
false;
458 std::atomic<bool> destruction_callback_called =
false;
465 std::scoped_lock lock(engine_mutex);
476 signaled_once =
true;
477 ASSERT_TRUE(
engine.is_valid());
481 .SetDestructionCallback(
482 [&]() { destruction_callback_called.store(
true); })
485 platform_task_runner->PostTask([&]() {
487 const auto task_runner_description =
492 std::scoped_lock lock(engine_mutex);
494 ASSERT_TRUE(
engine.is_valid());
499 ASSERT_TRUE(
engine.is_valid());
505 std::scoped_lock lock(engine_mutex);
511 platform_task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
515 ASSERT_TRUE(signaled_once);
516 signaled_once =
false;
518 ASSERT_TRUE(destruction_callback_called.load());
519 destruction_callback_called =
false;
522TEST(EmbedderTestNoFixture, CanGetCurrentTimeInNanoseconds) {
531 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
535 ASSERT_TRUE(
engine.is_valid());
542 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
547 std::string isolate_message;
555 if (strcmp(
message->channel,
"flutter/isolate") == 0) {
556 isolate_message = {reinterpret_cast<const char*>(message->message),
557 message->message_size};
561 engine = builder.LaunchEngine();
562 ASSERT_TRUE(
engine.is_valid());
567 ASSERT_EQ(isolate_message.find(
"isolates/"), 0ul);
572 thread.GetTaskRunner()->PostTask(
585 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
589 context.AddNativeCallback(
594 ASSERT_TRUE(
engine.is_valid());
602 ASSERT_NE(response_handle,
nullptr);
617 std::thread::id thread_id;
622 captures.thread_id = std::this_thread::get_id();
623 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
629 context.AddNativeCallback(
632 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
635 ASSERT_TRUE(
engine.is_valid());
637 static std::string kMessageData =
"Hello from embedder.";
642 ASSERT_EQ(
size, kMessageData.size());
643 ASSERT_EQ(strncmp(
reinterpret_cast<const char*
>(kMessageData.data()),
644 reinterpret_cast<const char*
>(
data),
size),
646 auto captures =
reinterpret_cast<Captures*
>(
user_data);
647 ASSERT_EQ(captures->thread_id, std::this_thread::get_id());
648 captures->latch.Signal();
656 message.channel =
"test_channel";
657 message.message =
reinterpret_cast<const uint8_t*
>(kMessageData.data());
658 message.message_size = kMessageData.size();
659 message.response_handle = response_handle;
670 captures.latch.Wait();
679 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
684 const std::string message_data =
"Hello but don't call me back.";
687 context.AddNativeCallback(
690 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
691 context.AddNativeCallback(
692 "SignalNativeMessage",
694 ([&
message, &message_data](Dart_NativeArguments
args) {
696 Dart_GetNativeArgument(
args, 0));
697 ASSERT_EQ(received_message, message_data);
703 ASSERT_TRUE(
engine.is_valid());
708 platform_message.
channel =
"test_channel";
710 reinterpret_cast<const uint8_t*
>(message_data.data());
724 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
730 context.AddNativeCallback(
733 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
734 context.AddNativeCallback(
735 "SignalNativeMessage",
738 Dart_GetNativeArgument(
args, 0));
739 ASSERT_EQ(
"true", received_message);
745 ASSERT_TRUE(
engine.is_valid());
750 platform_message.
channel =
"test_channel";
751 platform_message.
message =
nullptr;
766 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
771 ASSERT_TRUE(
engine.is_valid());
775 platform_message.
channel =
"test_channel";
776 platform_message.
message =
nullptr;
790 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
794 context.SetLogMessageCallback(
795 [&callback_latch](
const char* tag,
const char*
message) {
796 EXPECT_EQ(std::string(tag),
"flutter");
797 EXPECT_EQ(std::string(
message),
"hello world");
801 ASSERT_TRUE(
engine.is_valid());
802 callback_latch.
Wait();
809 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
814 context.SetLogMessageCallback(
815 [&callback_latch](
const char* tag,
const char*
message) {
816 EXPECT_EQ(std::string(tag),
"butterfly");
817 EXPECT_EQ(std::string(
message),
"hello world");
821 ASSERT_TRUE(
engine.is_valid());
822 callback_latch.
Wait();
830 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
849 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
856 std::vector<std::string> callback_args;
857 auto nativeArgumentsCallback = [&callback_args,
858 &callback_latch](Dart_NativeArguments
args) {
859 Dart_Handle exception =
nullptr;
865 context.AddNativeCallback(
"NativeArgumentsCallback",
868 callback_latch.
Wait();
869 ASSERT_EQ(callback_args[0],
"foo");
870 ASSERT_EQ(callback_args[1],
"bar");
883 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
894 ASSERT_TRUE(
engine.is_valid());
898 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
905 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
909 context.GetCompositor().SetNextPresentCallback(
922 event.pixel_ratio = 1.0;
925 ASSERT_TRUE(
engine.is_valid());
930 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
938 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
942 context.GetCompositor().SetNextPresentCallback(
955 event.pixel_ratio = 1.0;
958 ASSERT_TRUE(
engine.is_valid());
967#if FML_OS_MACOSX && FML_ARCH_CPU_ARM64
969 DISABLED_CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor) {
972 CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor) {
975 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
983 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
987 auto scene_image = context.GetNextSceneImage();
989 context.GetCompositor().SetNextPresentCallback(
1007 .rects = paint_region_rects,
1011 .paint_region = &paint_region,
1022 ASSERT_EQ(*
layers[0], layer);
1038 ASSERT_EQ(*
layers[1], layer);
1054 .rects = paint_region_rects,
1058 .paint_region = &paint_region,
1069 ASSERT_EQ(*
layers[2], layer);
1085 ASSERT_EQ(*
layers[3], layer);
1101 .rects = paint_region_rects,
1105 .paint_region = &paint_region,
1116 ASSERT_EQ(*
layers[4], layer);
1122 context.GetCompositor().SetPlatformViewRendererCallback(
1124 ) -> sk_sp<SkImage> {
1127 auto canvas =
surface->getCanvas();
1134 paint.setColor(SK_ColorGREEN);
1135 paint.setAlpha(127);
1138 canvas->drawRect(rect, paint);
1144 paint.setColor(SK_ColorMAGENTA);
1145 paint.setAlpha(127);
1148 canvas->drawRect(rect, paint);
1154 <<
"Test was asked to composite an unknown platform view.";
1157 return surface->makeImageSnapshot();
1160 context.AddNativeCallback(
1163 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1172 event.pixel_ratio = 1.0;
1173 event.physical_view_inset_top = 0.0;
1174 event.physical_view_inset_right = 0.0;
1175 event.physical_view_inset_bottom = 0.0;
1176 event.physical_view_inset_left = 0.0;
1179 ASSERT_TRUE(
engine.is_valid());
1186 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
1194 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1202 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
1206 auto scene_image = context.GetNextSceneImage();
1208 context.GetCompositor().SetNextPresentCallback(
1226 .rects = paint_region_rects,
1230 .paint_region = &paint_region,
1241 ASSERT_EQ(*
layers[0], layer);
1257 ASSERT_EQ(*
layers[1], layer);
1263 context.GetCompositor().SetPlatformViewRendererCallback(
1265 ) -> sk_sp<SkImage> {
1268 auto canvas =
surface->getCanvas();
1275 paint.setColor(SK_ColorGREEN);
1276 paint.setAlpha(127);
1279 canvas->drawRect(rect, paint);
1285 <<
"Test was asked to composite an unknown platform view.";
1288 return surface->makeImageSnapshot();
1291 context.AddNativeCallback(
1294 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1303 event.pixel_ratio = 1.0;
1304 event.physical_view_inset_top = 0.0;
1305 event.physical_view_inset_right = 0.0;
1306 event.physical_view_inset_bottom = 0.0;
1307 event.physical_view_inset_left = 0.0;
1310 ASSERT_TRUE(
engine.is_valid());
1316#if !defined(FML_OS_LINUX)
1317 GTEST_SKIP() <<
"Skipping golden tests on non-Linux OSes";
1320 "compositor_platform_layer_with_no_overlay.png", scene_image));
1323 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
1331 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1339 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
1343 auto scene_image = context.GetNextSceneImage();
1345 context.GetCompositor().SetNextPresentCallback(
1363 .rects = paint_region_rects,
1367 .paint_region = &paint_region,
1378 ASSERT_EQ(*
layers[0], layer);
1394 ASSERT_EQ(*
layers[1], layer);
1400 context.GetCompositor().SetPlatformViewRendererCallback(
1402 ) -> sk_sp<SkImage> {
1405 auto canvas =
surface->getCanvas();
1412 paint.setColor(SK_ColorGREEN);
1413 paint.setAlpha(127);
1416 canvas->drawRect(rect, paint);
1422 <<
"Test was asked to composite an unknown platform view.";
1425 return surface->makeImageSnapshot();
1428 context.AddNativeCallback(
1431 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1440 event.pixel_ratio = 1.0;
1441 event.physical_view_inset_top = 0.0;
1442 event.physical_view_inset_right = 0.0;
1443 event.physical_view_inset_bottom = 0.0;
1444 event.physical_view_inset_left = 0.0;
1447 ASSERT_TRUE(
engine.is_valid());
1453#if !defined(FML_OS_LINUX)
1454 GTEST_SKIP() <<
"Skipping golden tests on non-Linux OSes";
1457 "compositor_platform_layer_with_no_overlay.png", scene_image));
1460 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
1467 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1471 ASSERT_TRUE(
engine.is_valid());
1479 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1483 ASSERT_TRUE(
engine.is_valid());
1494 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1498 ASSERT_TRUE(
engine.is_valid());
1511 event.pixel_ratio = 1.0;
1512 event.physical_view_inset_top = 0.0;
1513 event.physical_view_inset_right = 0.0;
1514 event.physical_view_inset_bottom = 0.0;
1515 event.physical_view_inset_left = 0.0;
1525 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1531 context.AddNativeCallback(
1534 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
1537 context.AddNativeCallback(
"SignalNativeMessage",
1541 Dart_GetNativeArgument(
args, 0));
1546 ASSERT_TRUE(
engine.is_valid());
1552 metrics.
width = 800;
1562 EXPECT_TRUE(result->added);
1565 message_latch.
Wait();
1566 ASSERT_EQ(
"View IDs: [0, 123]",
message);
1573 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1578 context.AddNativeCallback(
1581 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
1584 context.AddNativeCallback(
1585 "SignalNativeCount",
1587 [&check_latch](Dart_NativeArguments
args) { check_latch.
Signal(); }));
1590 ASSERT_TRUE(
engine.is_valid());
1597 metrics.
width = 800;
1607 EXPECT_TRUE(result->added);
1618 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1624 context.AddNativeCallback(
1627 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
1630 context.AddNativeCallback(
"SignalNativeMessage",
1634 Dart_GetNativeArgument(
args, 0));
1639 ASSERT_TRUE(
engine.is_valid());
1646 metrics.
width = 800;
1656 ASSERT_TRUE(result->added);
1659 message_latch.
Wait();
1660 ASSERT_EQ(
message,
"View IDs: [0, 123]");
1667 EXPECT_TRUE(result->removed);
1670 message_latch.
Wait();
1671 ASSERT_EQ(
message,
"View IDs: [0]");
1677 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1679 std::mutex engine_mutex;
1681 auto render_thread = CreateNewThread(
"custom_render_thread");
1684 std::scoped_lock engine_lock(engine_mutex);
1693 &render_task_runner.GetFlutterTaskRunnerDescription());
1696 context.AddNativeCallback(
1699 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
1702 std::scoped_lock lock(engine_mutex);
1706 ASSERT_TRUE(
engine.is_valid());
1714 metrics.
width = 800;
1725 ASSERT_TRUE(result->added);
1726 auto add_view_latch =
1728 add_view_latch->
Signal();
1731 add_view_latch.
Wait();
1733 std::atomic_bool view_available =
true;
1738 render_thread->PostTask([&] {
1739 std::this_thread::sleep_for(std::chrono::milliseconds(50));
1741 EXPECT_TRUE(view_available);
1742 raster_thread_latch.
Signal();
1748 remove_view_info.
view_id = 123;
1749 remove_view_info.
user_data = &remove_view_latch;
1752 ASSERT_TRUE(result->removed);
1753 auto remove_view_latch =
1755 remove_view_latch->
Signal();
1760 remove_view_latch.
Wait();
1764 view_available =
false;
1765 raster_thread_latch.
Wait();
1775 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1780 ASSERT_TRUE(
engine.is_valid());
1795 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1801 context.AddNativeCallback(
1804 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
1807 context.AddNativeCallback(
"SignalNativeMessage",
1811 Dart_GetNativeArgument(
args, 0));
1816 ASSERT_TRUE(
engine.is_valid());
1822 std::atomic<int> count = 0;
1829 metrics.
width = 800;
1840 auto captures =
reinterpret_cast<Captures*
>(result->user_data);
1842 int count = captures->count.fetch_add(1);
1845 ASSERT_TRUE(result->added);
1847 EXPECT_FALSE(result->added);
1848 captures->failure_latch.Signal();
1852 message_latch.
Wait();
1853 ASSERT_EQ(
message,
"View IDs: [0, 123]");
1854 ASSERT_FALSE(captures.failure_latch.IsSignaledForTest());
1858 captures.failure_latch.Wait();
1859 ASSERT_EQ(captures.count, 2);
1867 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1873 context.AddNativeCallback(
1876 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
1879 context.AddNativeCallback(
"SignalNativeMessage",
1883 Dart_GetNativeArgument(
args, 0));
1888 ASSERT_TRUE(
engine.is_valid());
1895 metrics.
width = 800;
1905 ASSERT_TRUE(result->added);
1908 message_latch.
Wait();
1909 ASSERT_EQ(
message,
"View IDs: [0, 123]");
1916 ASSERT_TRUE(result->removed);
1919 message_latch.
Wait();
1920 ASSERT_EQ(
message,
"View IDs: [0]");
1924 message_latch.
Wait();
1925 ASSERT_EQ(
message,
"View IDs: [0, 123]");
1932 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1937 ASSERT_TRUE(
engine.is_valid());
1945 EXPECT_FALSE(result->removed);
1958 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
1964 context.AddNativeCallback(
1967 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
1969 std::atomic<int> message_count = 0;
1970 context.AddNativeCallback(
"SignalNativeMessage",
1972 message_count.fetch_add(1);
1976 ASSERT_TRUE(
engine.is_valid());
1993 metrics123.
width = 800;
2000 metrics456.
width = 800;
2020 auto captures =
reinterpret_cast<Captures*
>(result->user_data);
2022 ASSERT_TRUE(result->added);
2023 ASSERT_FALSE(captures->add_first_view.IsSignaledForTest());
2024 ASSERT_FALSE(captures->add_duplicate_view.IsSignaledForTest());
2025 ASSERT_FALSE(captures->add_second_view.IsSignaledForTest());
2026 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
2028 captures->add_first_view.Signal();
2034 add_duplicate_view_info.
view_id = 123;
2036 add_duplicate_view_info.
user_data = &captures;
2039 auto captures =
reinterpret_cast<Captures*
>(result->user_data);
2041 ASSERT_FALSE(result->added);
2042 ASSERT_TRUE(captures->add_first_view.IsSignaledForTest());
2043 ASSERT_FALSE(captures->add_duplicate_view.IsSignaledForTest());
2044 ASSERT_FALSE(captures->add_second_view.IsSignaledForTest());
2045 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
2047 captures->add_duplicate_view.Signal();
2053 add_second_view_info.
view_id = 456;
2055 add_second_view_info.
user_data = &captures;
2058 auto captures =
reinterpret_cast<Captures*
>(result->user_data);
2060 ASSERT_TRUE(result->added);
2061 ASSERT_TRUE(captures->add_first_view.IsSignaledForTest());
2062 ASSERT_TRUE(captures->add_duplicate_view.IsSignaledForTest());
2063 ASSERT_FALSE(captures->add_second_view.IsSignaledForTest());
2064 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
2066 captures->add_second_view.Signal();
2072 remove_second_view_info.
view_id = 456;
2073 remove_second_view_info.
user_data = &captures;
2076 auto captures =
reinterpret_cast<Captures*
>(result->user_data);
2078 ASSERT_TRUE(result->removed);
2079 ASSERT_TRUE(captures->add_first_view.IsSignaledForTest());
2080 ASSERT_TRUE(captures->add_duplicate_view.IsSignaledForTest());
2081 ASSERT_TRUE(captures->add_second_view.IsSignaledForTest());
2082 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
2084 captures->remove_second_view.Signal();
2094 captures.remove_second_view.Wait();
2095 captures.add_second_view.Wait();
2096 captures.add_duplicate_view.Wait();
2097 captures.add_first_view.Wait();
2098 ASSERT_EQ(message_count, 3);
2105 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2112 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
2115 context.GetCompositor().SetPresentCallback(
2132 ASSERT_TRUE(
engine.is_valid());
2137 metrics0.
width = 800;
2147 metrics123.
width = 800;
2157 ASSERT_TRUE(result->added);
2173 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2174 auto platform_task_runner = CreateNewThread(
"test_platform_thread");
2176 static std::mutex engine_mutex;
2179 std::scoped_lock lock(engine_mutex);
2180 if (!
engine.is_valid()) {
2186 std::vector<FlutterViewFocusChangeRequest> received_requests;
2187 platform_task_runner->PostTask([&]() {
2191 const auto platform_task_runner_description =
2192 test_platform_task_runner.GetFlutterTaskRunnerDescription();
2196 EXPECT_TRUE(platform_task_runner->RunsTasksOnCurrentThread());
2197 received_requests.push_back(*request);
2201 ASSERT_TRUE(
engine.is_valid());
2205 std::vector<FlutterViewFocusChangeRequest> expected_requests{
2211 ASSERT_EQ(received_requests.size(), expected_requests.size());
2212 for (
size_t i = 0;
i < received_requests.size(); ++
i) {
2213 ASSERT_TRUE(received_requests[
i] == expected_requests[
i]);
2218 std::scoped_lock lock(engine_mutex);
2224 platform_task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
2230 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2236 std::string last_event;
2238 context.AddNativeCallback(
2241 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
2242 context.AddNativeCallback(
"NotifyStringValue",
2244 const auto message_from_dart =
2246 Dart_GetNativeArgument(
args, 0));
2247 last_event = message_from_dart;
2252 ASSERT_TRUE(
engine.is_valid());
2267 ASSERT_EQ(last_event,
2268 "1 ViewFocusState.focused ViewFocusDirection.undefined");
2280 ASSERT_EQ(last_event,
2281 "2 ViewFocusState.unfocused ViewFocusDirection.backward");
2302 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2310 context.GetCompositor().GetGrContext(),
2311 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
2314 struct CompositorUserData {
2321 bool second_expected;
2322 bool third_expected;
2324 int backing_stores_created;
2326 CompositorUserData compositor_user_data{
2327 .producer = &producer,
2328 .backing_stores_created = 0,
2333 .
user_data =
reinterpret_cast<void*
>(&compositor_user_data),
2334 .create_backing_store_callback =
2338 EXPECT_TRUE(config->
view_id == 0 ||
2339 config->
view_id == kSecondViewId ||
2340 config->
view_id == kThirdViewId);
2341 auto compositor_user_data =
2342 reinterpret_cast<CompositorUserData*
>(
user_data);
2343 compositor_user_data->backing_stores_created += 1;
2344 bool result = compositor_user_data->producer->Create(
2345 config, backing_store_out);
2348 backing_store_out->user_data =
2349 reinterpret_cast<void*
>(config->
view_id);
2354 .present_layers_callback =
nullptr,
2355 .avoid_backing_store_cache =
false,
2356 .present_view_callback =
2358 EXPECT_EQ(info->layers_count, 1u);
2361 int64_t store_view_id =
reinterpret_cast<int64_t
>(
2362 info->layers[0]->backing_store->user_data);
2363 EXPECT_EQ(store_view_id, info->view_id);
2364 auto compositor_user_data =
2365 reinterpret_cast<CompositorUserData*
>(info->user_data);
2367 switch (info->view_id) {
2369 compositor_user_data->latch_implicit.Signal();
2372 EXPECT_TRUE(compositor_user_data->second_expected);
2373 compositor_user_data->latch_second.Signal();
2376 EXPECT_TRUE(compositor_user_data->third_expected);
2377 compositor_user_data->latch_third.Signal();
2386 compositor_user_data.second_expected =
true;
2387 compositor_user_data.third_expected =
false;
2392 ASSERT_TRUE(
engine.is_valid());
2417 add_view_info.
view_id = kSecondViewId;
2420 ASSERT_TRUE(result->added);
2425 compositor_user_data.latch_implicit.Wait();
2426 compositor_user_data.latch_second.Wait();
2430 compositor_user_data.second_expected =
false;
2431 compositor_user_data.third_expected =
true;
2432 EXPECT_EQ(compositor_user_data.backing_stores_created, 2);
2437 remove_view_info.
view_id = kSecondViewId;
2440 ASSERT_TRUE(result->removed);
2445 add_view_info.
view_id = kThirdViewId;
2446 metrics_add.
view_id = kThirdViewId;
2450 compositor_user_data.latch_implicit.Wait();
2451 compositor_user_data.latch_third.Wait();
2452 EXPECT_EQ(compositor_user_data.backing_stores_created, 3);
2456 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2461 context.AddNativeCallback(
2464 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
2467 context.AddNativeCallback(
2468 "SignalNativeCount",
2471 Dart_GetNativeArgument(
args, 0)),
2477 ASSERT_TRUE(
engine.is_valid());
2496 std::vector<const FlutterLocale*> locales;
2497 locales.push_back(&locale1);
2498 locales.push_back(&locale2);
2515 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2517 context.AddIsolateCreateCallback([&latch]() { latch.
Signal(); });
2521 ASSERT_TRUE(
engine.is_valid());
2526 std::vector<std::string> supported_locales;
2527 supported_locales.push_back(
"es");
2528 supported_locales.push_back(
"MX");
2529 supported_locales.push_back(
"");
2530 auto result = shell.
GetPlatformView()->ComputePlatformResolvedLocales(
2533 ASSERT_EQ((*result).size(), supported_locales.size());
2534 ASSERT_EQ((*result)[0], supported_locales[0]);
2535 ASSERT_EQ((*result)[1], supported_locales[1]);
2536 ASSERT_EQ((*result)[2], supported_locales[2]);
2547 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2555 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
2558 auto rendered_scene = context.GetNextSceneImage();
2561 context.GetCompositor().SetNextPresentCallback(
2578 .rects = paint_region_rects,
2582 .paint_region = &paint_region,
2593 ASSERT_EQ(*
layers[0], layer);
2609 ASSERT_EQ(*
layers[1], layer);
2615 context.GetCompositor().SetPlatformViewRendererCallback(
2617 GrDirectContext* context) -> sk_sp<SkImage> {
2620 auto canvas =
surface->getCanvas();
2627 paint.setColor(SK_ColorGREEN);
2628 paint.setAlpha(127);
2631 canvas->drawRect(rect, paint);
2636 <<
"Test was asked to composite an unknown platform view.";
2639 return surface->makeImageSnapshot();
2649 event.pixel_ratio = 1.0;
2650 event.physical_view_inset_top = 0.0;
2651 event.physical_view_inset_right = 0.0;
2652 event.physical_view_inset_bottom = 0.0;
2653 event.physical_view_inset_left = 0.0;
2656 ASSERT_TRUE(
engine.is_valid());
2663#if !defined(FML_OS_LINUX)
2664 GTEST_SKIP() <<
"Skipping golden tests on non-Linux OSes";
2671 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2678 ASSERT_TRUE(
engine.is_valid());
2690 size_t worker_count = 0;
2697 auto platform_task_runner = CreateNewThread(
"platform_thread");
2699 platform_task_runner->PostTask([&]() {
2700 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2706 ASSERT_TRUE(
engine.is_valid());
2719 const auto engine_threads_count = worker_count + 4u;
2729 std::mutex captures_mutex;
2731 std::set<std::thread::id> thread_ids;
2733 size_t platform_threads_count = 0;
2734 size_t render_threads_count = 0;
2735 size_t ui_threads_count = 0;
2736 size_t worker_threads_count = 0;
2738 explicit Captures(
size_t count) : latch(count) {}
2741 Captures captures(engine_threads_count);
2743 platform_task_runner->PostTask([&]() {
2747 auto captures = reinterpret_cast<Captures*>(baton);
2749 std::scoped_lock lock(captures->captures_mutex);
2751 case kFlutterNativeThreadTypeRender:
2752 captures->render_threads_count++;
2754 case kFlutterNativeThreadTypeWorker:
2755 captures->worker_threads_count++;
2757 case kFlutterNativeThreadTypeUI:
2758 captures->ui_threads_count++;
2760 case kFlutterNativeThreadTypePlatform:
2761 captures->platform_threads_count++;
2764 captures->thread_ids.insert(std::this_thread::get_id());
2766 captures->latch.CountDown();
2772 captures.latch.Wait();
2773 ASSERT_EQ(captures.thread_ids.size(), engine_threads_count);
2774 ASSERT_EQ(captures.platform_threads_count, 1u);
2775 ASSERT_EQ(captures.render_threads_count, 1u);
2776 ASSERT_EQ(captures.ui_threads_count, 1u);
2777 ASSERT_EQ(captures.worker_threads_count, worker_count + 1u );
2778 EXPECT_GE(captures.worker_threads_count - 1, 2u);
2779 EXPECT_LE(captures.worker_threads_count - 1, 4u);
2781 platform_task_runner->PostTask([&]() {
2783 sync_latch.Signal();
2788 ASSERT_FALSE(
engine.is_valid());
2801 ASSERT_EQ(data_out,
nullptr);
2810 ASSERT_EQ(data_out,
nullptr);
2817 ASSERT_EQ(data_in.
elf_path,
nullptr);
2818 ASSERT_EQ(data_out,
nullptr);
2825 ASSERT_EQ(data_out,
nullptr);
2831 ASSERT_EQ(data_in.
elf_path,
"/bin/true");
2832 ASSERT_EQ(data_out,
nullptr);
2840 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2844 EmbedderConfigBuilder::InitializationPreference::kMultiAOTInitialize);
2849 ASSERT_FALSE(
engine.is_valid());
2863 const auto elf_path =
2867 data_in.
elf_path = elf_path.c_str();
2871 ASSERT_EQ(data_in.
elf_path, elf_path.c_str());
2872 ASSERT_NE(data_out,
nullptr);
2882 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2885 context.AddIsolateCreateCallback([&latch]() { latch.
Signal(); });
2889 EmbedderConfigBuilder::InitializationPreference::kAOTDataInitialize);
2894 ASSERT_TRUE(
engine.is_valid());
2901#if defined(__clang_analyzer__)
2902#define TEST_VM_SNAPSHOT_DATA "vm_data"
2903#define TEST_VM_SNAPSHOT_INSTRUCTIONS "vm_instructions"
2904#define TEST_ISOLATE_SNAPSHOT_DATA "isolate_data"
2905#define TEST_ISOLATE_SNAPSHOT_INSTRUCTIONS "isolate_instructions"
2915#if defined(OS_FUCHSIA)
2916 GTEST_SKIP() <<
"Inconsistent paths in Fuchsia.";
2925 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2931 const std::string vm_snapshot_data =
2933 const std::string vm_snapshot_instructions =
2935 const std::string isolate_snapshot_data =
2937 const std::string isolate_snapshot_instructions =
2942 reinterpret_cast<const uint8_t*
>(vm_snapshot_data.c_str());
2944 reinterpret_cast<const uint8_t*
>(vm_snapshot_instructions.c_str());
2946 reinterpret_cast<const uint8_t*
>(isolate_snapshot_data.c_str());
2948 reinterpret_cast<const uint8_t*
>(isolate_snapshot_instructions.c_str());
2971#if defined(OS_FUCHSIA)
2972 GTEST_SKIP() <<
"Inconsistent paths in Fuchsia.";
2981 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
2987 reinterpret_cast<const uint8_t*
>(
"invalid_vm_data");
2989 reinterpret_cast<const uint8_t*
>(
"invalid_vm_instructions");
2991 reinterpret_cast<const uint8_t*
>(
"invalid_snapshot_data");
2993 reinterpret_cast<const uint8_t*
>(
"invalid_snapshot_instructions");
3018 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3024 const std::string vm_snapshot_data =
3026 const std::string vm_snapshot_instructions =
3028 const std::string isolate_snapshot_data =
3030 const std::string isolate_snapshot_instructions =
3035 reinterpret_cast<const uint8_t*
>(vm_snapshot_data.c_str());
3037 reinterpret_cast<const uint8_t*
>(vm_snapshot_instructions.c_str());
3039 reinterpret_cast<const uint8_t*
>(isolate_snapshot_data.c_str());
3041 reinterpret_cast<const uint8_t*
>(isolate_snapshot_instructions.c_str());
3044 ASSERT_TRUE(
engine.is_valid());
3058 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3064 const std::string vm_snapshot_data =
3066 const std::string vm_snapshot_instructions =
3071 reinterpret_cast<const uint8_t*
>(vm_snapshot_data.c_str());
3073 reinterpret_cast<const uint8_t*
>(vm_snapshot_instructions.c_str());
3076 ASSERT_TRUE(
engine.is_valid());
3091 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3097 reinterpret_cast<const uint8_t*
>(
"invalid_snapshot_data");
3099 reinterpret_cast<const uint8_t*
>(
"invalid_snapshot_instructions");
3102 ASSERT_TRUE(
engine.is_valid());
3117 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3127 ASSERT_TRUE(
engine.is_valid());
3131 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3136 ASSERT_TRUE(
engine.is_valid());
3142 event.pixel_ratio = 0.0;
3143 event.physical_view_inset_top = 0.0;
3144 event.physical_view_inset_right = 0.0;
3145 event.physical_view_inset_bottom = 0.0;
3146 event.physical_view_inset_left = 0.0;
3152 event.pixel_ratio = 1.0;
3153 event.physical_view_inset_top = -1.0;
3154 event.physical_view_inset_right = -1.0;
3155 event.physical_view_inset_bottom = -1.0;
3156 event.physical_view_inset_left = -1.0;
3162 event.physical_view_inset_top = 700;
3163 event.physical_view_inset_right = 900;
3164 event.physical_view_inset_bottom = 700;
3165 event.physical_view_inset_left = 900;
3174 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3179 ASSERT_TRUE(
engine.is_valid());
3186 event.pixel_ratio = 1.0;
3187 event.has_constraints =
true;
3188 event.min_width_constraint = 400;
3189 event.max_width_constraint = 1200;
3190 event.min_height_constraint = 300;
3191 event.max_height_constraint = 900;
3200 event_no_constraints.
struct_size =
sizeof(event_no_constraints);
3201 event_no_constraints.
width = 1024;
3202 event_no_constraints.
height = 768;
3219 event_invalid_min.
struct_size =
sizeof(event_invalid_min);
3220 event_invalid_min.
width = 300;
3221 event_invalid_min.
height = 600;
3236 event_invalid_max.
struct_size =
sizeof(event_invalid_max);
3237 event_invalid_max.
width = 1300;
3238 event_invalid_max.
height = 600;
3253 event_invalid_height.
struct_size =
sizeof(event_invalid_height);
3254 event_invalid_height.
width = 800;
3255 event_invalid_height.
height = 200;
3271 std::string entrypoint,
3273 const std::vector<uint8_t>& bytes) {
3278 bool matches =
false;
3280 builder.SetSurface(
DlISize(1, 1));
3281 builder.SetCompositor();
3282 builder.SetDartEntrypoint(std::move(entrypoint));
3283 builder.SetRenderTargetType(
3284 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer2,
3287 auto engine = builder.LaunchEngine();
3288 ASSERT_TRUE(
engine.is_valid());
3290 context.GetCompositor().SetNextPresentCallback(
3298 context.GetCompositor().GetSurface(
layers[0]->backing_store);
3308 event.pixel_ratio = 1.0;
3313 ASSERT_TRUE(matches);
3318template <
typename T>
3321 std::string entrypoint,
3324 uint8_t* bytes =
reinterpret_cast<uint8_t*
>(&pixelvalue);
3326 test, std::move(entrypoint), pixfmt,
3327 std::vector<uint8_t>(bytes, bytes +
sizeof(T)));
3330#define SW_PIXFMT_TEST_F(test_name, dart_entrypoint, pixfmt, matcher) \
3331 TEST_F(EmbedderTest, SoftwareRenderingPixelFormats##test_name) { \
3332 expectSoftwareRenderingOutputMatches(*this, #dart_entrypoint, pixfmt, \
3350 (std::vector<uint8_t>{0xFF, 0x00, 0x00, 0xFF}));
3354 (std::vector<uint8_t>{0x00, 0x00, 0xFF, 0xFF}));
3371 (std::vector<uint8_t>{0x00, 0xFF, 0x00, 0xFF}));
3375 (std::vector<uint8_t>{0x00, 0xFF, 0x00, 0xFF}));
3392 (std::vector<uint8_t>{0x00, 0x00, 0xFF, 0xFF}));
3396 (std::vector<uint8_t>{0xFF, 0x00, 0x00, 0xFF}));
3407 std::shared_ptr<fml::AutoResetWaitableEvent>
latch;
3456 EXPECT_EQ(subject.
type, baseline.
type);
3464 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
3465 uint64_t echoed_char;
3469 auto native_echo_event = [&](Dart_NativeArguments
args) {
3472 Dart_GetNativeArgument(
args, 0)));
3475 Dart_GetNativeArgument(
args, 1)));
3477 Dart_GetNativeArgument(
args, 2));
3479 Dart_GetNativeArgument(
args, 3));
3481 Dart_GetNativeArgument(
args, 4));
3486 Dart_GetNativeArgument(
args, 6)));
3488 message_latch->Signal();
3491 auto platform_task_runner = CreateNewThread(
"platform_thread");
3495 platform_task_runner->PostTask([&]() {
3496 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3505 context.AddNativeCallback(
3508 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
3510 context.AddNativeCallback(
"EchoKeyEvent",
3514 ASSERT_TRUE(
engine.is_valid());
3524 .physical = 0x00070004,
3525 .logical = 0x00000000061,
3527 .synthesized =
false,
3530 platform_task_runner->PostTask([&]() {
3534 message_latch->Wait();
3537 EXPECT_EQ(echoed_char, 0x41llu);
3544 .physical = 0x00070005,
3545 .logical = 0x00000000062,
3547 .synthesized =
false,
3550 platform_task_runner->PostTask([&]() {
3554 message_latch->Wait();
3557 EXPECT_EQ(echoed_char, 0x2206llu);
3562 .timestamp = 1000000,
3564 .physical = 0x00070006,
3565 .logical = 0x00000000063,
3567 .synthesized =
true,
3570 platform_task_runner->PostTask([&]() {
3573 message_latch->Wait();
3576 EXPECT_EQ(echoed_char, 0llu);
3579 platform_task_runner->PostTask([&]() {
3583 shutdown_latch.
Wait();
3587 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
3588 std::vector<FlutterKeyEvent> echoed_events;
3590 auto native_echo_event = [&](Dart_NativeArguments
args) {
3594 Dart_GetNativeArgument(
args, 1))),
3597 Dart_GetNativeArgument(
args, 0))),
3599 Dart_GetNativeArgument(
args, 2)),
3601 Dart_GetNativeArgument(
args, 3)),
3603 Dart_GetNativeArgument(
args, 5)),
3606 Dart_GetNativeArgument(
args, 6))),
3609 message_latch->Signal();
3612 auto platform_task_runner = CreateNewThread(
"platform_thread");
3616 platform_task_runner->PostTask([&]() {
3617 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3626 context.AddNativeCallback(
3629 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
3631 context.AddNativeCallback(
"EchoKeyEvent",
3635 ASSERT_TRUE(
engine.is_valid());
3642 .physical = 0x00070004,
3643 .logical = 0x00000000061,
3645 .synthesized =
false,
3650 sample_event.timestamp = 1.0;
3651 platform_task_runner->PostTask([&]() {
3653 message_latch->Signal();
3655 message_latch->Wait();
3658 EXPECT_EQ(echoed_events.size(), 0u);
3664 nullptr, &response_handle);
3668 .
channel =
"test/starts_echo",
3671 .response_handle = response_handle,
3674 platform_task_runner->PostTask([&]() {
3683 message_latch->Wait();
3685 EXPECT_EQ(echoed_events.size(), 1u);
3688 sample_event.timestamp = 10.0;
3689 platform_task_runner->PostTask([&]() {
3692 message_latch->Wait();
3695 EXPECT_EQ(echoed_events.size(), 2u);
3698 platform_task_runner->PostTask([&]() {
3702 shutdown_latch.
Wait();
3714 auto platform_task_runner = CreateNewThread(
"platform_thread");
3716 platform_task_runner->PostTask([&]() {
3717 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3721 context.AddNativeCallback(
3724 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
3725 context.AddNativeCallback(
3729 ASSERT_TRUE(
engine.is_valid());
3741 .physical = 0x00070005,
3742 .logical = 0x00000000062,
3748 .
latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3751 event.synthesized =
true;
3752 platform_task_runner->PostTask([&]() {
3761 [](
bool handled,
void* untyped_user_data) {
3762 KeyEventUserData* user_data =
3763 reinterpret_cast<KeyEventUserData*>(untyped_user_data);
3764 EXPECT_EQ(handled, true);
3765 user_data->latch->Signal();
3769 user_data1.latch->Wait();
3771 platform_task_runner->PostTask([&]() {
3775 shutdown_latch.
Wait();
3787 auto platform_task_runner = CreateNewThread(
"platform_thread");
3789 platform_task_runner->PostTask([&]() {
3790 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3794 context.AddNativeCallback(
3797 [&ready](Dart_NativeArguments
args) { ready.
Signal(); }));
3799 context.AddNativeCallback(
3803 ASSERT_TRUE(
engine.is_valid());
3815 .physical = 0x00070005,
3816 .logical = 0x00000000062,
3818 .synthesized =
false,
3825 .
latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3829 .
latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3832 auto callback23 = [](
bool handled,
void* untyped_user_data) {
3835 EXPECT_EQ(handled,
false);
3839 platform_task_runner->PostTask([&]() {
3843 user_data2.latch->Wait();
3844 user_data3.latch->Wait();
3846 EXPECT_TRUE(user_data2.returned);
3847 EXPECT_TRUE(user_data3.returned);
3850 platform_task_runner->PostTask([&]() {
3854 shutdown_latch.
Wait();
3872 auto platform_task_runner = CreateNewThread(
"platform_thread");
3874 platform_task_runner->PostTask([&]() {
3875 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3876 context.SetVsyncCallback([&](intptr_t baton) {
3877 platform_task_runner->PostTask([baton = baton, &
engine, &vsync_latch]() {
3879 NanosFromEpoch(32));
3883 context.AddNativeCallback(
3893 ASSERT_TRUE(
engine.is_valid());
3900 event.pixel_ratio = 1.0;
3907 present_latch.
Wait();
3910 platform_task_runner->PostTask([&]() {
3914 shutdown_latch.
Wait();
3918 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3923 context.AddNativeCallback(
3926 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
3929 context.AddNativeCallback(
3930 "SignalNativeCount",
3932 [&check_latch](Dart_NativeArguments
args) { check_latch.
Signal(); }));
3935 ASSERT_TRUE(
engine.is_valid());
3946 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
3952 ASSERT_TRUE(
engine.is_valid());
3960 callback_latch->
Signal();
3972 event.pixel_ratio = 1.0;
3973 event.physical_view_inset_top = 0.0;
3974 event.physical_view_inset_right = 0.0;
3975 event.physical_view_inset_bottom = 0.0;
3976 event.physical_view_inset_left = 0.0;
3980 callback_latch.
Wait();
3983#if defined(FML_OS_MACOSX)
3986 pthread_t tid = pthread_self();
3987 struct sched_param param;
3988 int policy = SCHED_OTHER;
3991 param.sched_priority = 10;
3994 param.sched_priority = 1;
3996 pthread_setschedparam(tid,
policy, ¶m);
3999TEST_F(EmbedderTest, EmbedderThreadHostUseCustomThreadConfig) {
4002 nullptr, MockThreadConfigSetter);
4006 struct sched_param ui_param;
4008 thread_host->GetTaskRunners().GetUITaskRunner()->PostTask([&] {
4009 pthread_t current_thread = pthread_self();
4010 pthread_getschedparam(current_thread, &ui_policy, &ui_param);
4011 ASSERT_EQ(ui_param.sched_priority, 10);
4017 struct sched_param io_param;
4018 thread_host->GetTaskRunners().GetIOTaskRunner()->PostTask([&] {
4019 pthread_t current_thread = pthread_self();
4020 pthread_getschedparam(current_thread, &io_policy, &io_param);
4021 ASSERT_EQ(io_param.sched_priority, 1);
4033 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
4039 context.AddNativeCallback(
4042 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
4043 context.AddNativeCallback(
4044 "SignalNativeCount",
4047 Dart_GetNativeArgument(
args, 0));
4048 ASSERT_EQ(count, 1);
4051 context.AddNativeCallback(
4052 "SignalNativeMessage",
4055 Dart_GetNativeArgument(
args, 0));
4056 ASSERT_EQ(
"PointerData(viewId: 0, x: 123.0, y: 456.0)",
message);
4061 ASSERT_TRUE(
engine.is_valid());
4068 pointer_event.
x = 123;
4069 pointer_event.
y = 456;
4070 pointer_event.
timestamp =
static_cast<size_t>(1234567890);
4078 message_latch.
Wait();
4084 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
4090 context.AddNativeCallback(
4093 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
4094 context.AddNativeCallback(
4095 "SignalNativeMessage",
4098 Dart_GetNativeArgument(
args, 0));
4099 ASSERT_EQ(
"ViewID: 2",
message);
4104 ASSERT_TRUE(
engine.is_valid());
4110 metrics.
width = 800;
4120 EXPECT_TRUE(result->added);
4123 add_view_latch->
Signal();
4127 add_view_latch.
Wait();
4133 pointer_event.
x = 123;
4134 pointer_event.
y = 456;
4135 pointer_event.
timestamp =
static_cast<size_t>(1234567890);
4142 message_latch.
Wait();
4146 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
4152 context.AddNativeCallback(
4155 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
4156 context.AddNativeCallback(
4157 "SignalNativeMessage",
4160 Dart_GetNativeArgument(
args, 0));
4161 ASSERT_EQ(
"Changed: [0]",
message);
4166 ASSERT_TRUE(
engine.is_valid());
4176 event.pixel_ratio = 1.5;
4183 message_latch.
Wait();
4187 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
4193 context.AddNativeCallback(
4196 [&ready_latch](Dart_NativeArguments
args) { ready_latch.
Signal(); }));
4198 context.AddNativeCallback(
4199 "SignalNativeMessage",
4202 Dart_GetNativeArgument(
args, 0));
4206 ASSERT_EQ(
"Changed: [0]",
message);
4211 ASSERT_TRUE(
engine.is_valid());
4219 bad_event.
width = 200;
4233 event.pixel_ratio = 1.5;
4239 message_latch.
Wait();
4243 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
4247 bool listening =
false;
4248 context.AddNativeCallback(
4252 EXPECT_STREQ(update->
channel,
"test/listen");
4263 ASSERT_TRUE(
engine.is_valid());
4270 ASSERT_TRUE(listening);
4274 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
4277 static std::thread::id ffi_call_thread_id;
4278 static void (*ffi_signal_native_test)() = []() ->
void {
4279 ffi_call_thread_id = std::this_thread::get_id();
4283 Dart_FfiNativeResolver ffi_resolver = [](
const char*
name,
4284 uintptr_t args_n) ->
void* {
4285 if (std::string_view(
name) ==
"FFISignalNativeTest") {
4286 return reinterpret_cast<void*
>(ffi_signal_native_test);
4294 context.AddNativeCallback(
4296 Dart_SetFfiNativeResolver(Dart_RootLibrary(), ffi_resolver);
4299 auto platform_task_runner = CreateNewThread(
"test_platform_thread");
4305 if (!
engine.is_valid()) {
4311 std::thread::id platform_thread_id;
4312 platform_task_runner->PostTask([&]() {
4313 platform_thread_id = std::this_thread::get_id();
4316 const auto task_runner_description =
4317 test_task_runner.GetFlutterTaskRunnerDescription();
4323 ASSERT_TRUE(
engine.is_valid());
4332 platform_task_runner->PostTask([&kill_latch] { kill_latch.
Signal(); });
4337 ASSERT_EQ(platform_thread_id, ffi_call_thread_id);
static size_t GetVMLaunchCount()
The number of times the VM has been launched in the process. This call is inherently racy because the...
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
std::shared_ptr< fml::ConcurrentMessageLoop > GetConcurrentMessageLoop()
The concurrent message loop hosts threads that are used by the engine to perform tasks long running b...
const TaskRunners & GetTaskRunners() const
static std::unique_ptr< EmbedderThreadHost > CreateEmbedderOrEngineManagedThreadHost(const FlutterCustomTaskRunners *custom_task_runners, const flutter::ThreadConfigSetter &config_setter=fml::Thread::SetCurrentThreadName)
DartVM * GetDartVM()
Get a pointer to the Dart VM used by this running shell instance.
const Settings & GetSettings() const override
fml::WeakPtr< PlatformView > GetPlatformView()
Platform views may only be accessed on the platform task runner.
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
void SetPlatformTaskRunner(const FlutterTaskRunnerDescription *runner)
void SetSurface(DlISize surface_size)
void SetupVsyncCallback()
void SetLogTag(std::string tag)
void SetExecutableName(std::string executable_name)
void SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType type, FlutterSoftwarePixelFormat software_pixfmt=kFlutterSoftwarePixelFormatNative32)
void SetDartEntrypoint(std::string entrypoint)
void AddCommandLineArgument(std::string arg)
void SetViewFocusChangeRequestCallback(const std::function< void(const FlutterViewFocusChangeRequest *)> &callback)
FlutterProjectArgs & GetProjectArgs()
void SetRenderTaskRunner(const FlutterTaskRunnerDescription *runner)
void AddDartEntrypointArgument(std::string arg)
void SetUITaskRunner(const FlutterTaskRunnerDescription *runner)
FlutterCompositor & GetCompositor()
UniqueEngine LaunchEngine() const
void SetCompositor(bool avoid_backing_store_cache=false, bool use_present_layers_callback=false)
UniqueEngine InitializeEngine() const
void SetPlatformMessageCallback(const std::function< void(const FlutterPlatformMessage *)> &callback)
EmbedderTestTaskRunnerBuilder & SetRealTaskRunner(fml::RefPtr< fml::TaskRunner > task_runner)
EmbedderTestTaskRunnerBuilder & SetTaskExpiryCallback(EmbedderTestTaskRunner::TaskExpiryCallback callback)
A task runner that we expect the embedder to provide but whose implementation is a real FML task runn...
const FlutterTaskRunnerDescription & GetFlutterTaskRunnerDescription()
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
void RunExpiredTasksNow()
virtual void PostTask(const fml::closure &task) override
virtual void PostDelayedTask(const fml::closure &task, fml::TimeDelta delay)
@ kDisplay
Suitable for threads which generate data for the display.
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
static constexpr TimeDelta FromMilliseconds(int64_t millis)
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterTask *task)
Inform the engine to run the specified task. This task has been given to the embedder via the Flutter...
FlutterEngineResult FlutterEngineOnVsync(FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos)
Notify the engine that a vsync event occurred. A baton passed to the platform via the vsync callback ...
FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count)
Notify a running engine instance that the locale has been updated. The preferred locale must be the f...
FlutterEngineResult FlutterEngineSendViewFocusEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterViewFocusEvent *event)
Notifies the engine that platform view focus state has changed.
FlutterEngineResult FlutterEngineScheduleFrame(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Schedule a new frame to redraw the content.
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
uint64_t FlutterEngineGetCurrentTime()
Get the current time in nanoseconds from the clock used by the flutter engine. This is the system mon...
FlutterEngineResult FlutterEngineSetNextFrameCallback(FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *user_data)
Schedule a callback to be called after the next frame is drawn. This must be called from the platform...
FLUTTER_EXPORT FlutterEngineResult FlutterEngineDeinitialize(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Stops running the Flutter engine instance. After this call, the embedder is also guaranteed that no m...
FlutterEngineResult FlutterEnginePostCallbackOnAllNativeThreads(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterNativeThreadCallback callback, void *user_data)
Schedule a callback to be run on all engine managed threads. The engine will attempt to service this ...
FLUTTER_EXPORT FlutterEngineResult FlutterEngineAddView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterAddViewInfo *info)
Adds a view.
FlutterEngineResult FlutterPlatformMessageCreateResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out)
Creates a platform message response handle that allows the embedder to set a native callback for a re...
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
FlutterEngineResult FlutterEngineSendPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *flutter_message)
bool FlutterEngineRunsAOTCompiledDartCode(void)
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading re...
FlutterEngineResult FlutterEngineReloadSystemFonts(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Reloads the system fonts in engine.
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
FlutterEngineResult FlutterEngineRunInitialized(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize....
FlutterEngineResult FlutterEngineNotifyLowMemoryWarning(FLUTTER_API_SYMBOL(FlutterEngine) raw_engine)
Posts a low memory notification to a running engine instance. The engine will do its best to release ...
FlutterEngineResult FlutterEngineSendKeyEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Sends a key event to the engine. The framework will decide whether to handle this event in a synchron...
FlutterEngineResult FlutterEngineSendPlatformMessageResponse(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Send a response from the native side to a platform message from the Dart Flutter application.
FLUTTER_EXPORT FlutterEngineResult FlutterEngineRemoveView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterRemoveViewInfo *info)
Removes a view.
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
Collects the handle created using FlutterPlatformMessageCreateResponseHandle.
FlutterEngineResult FlutterEngineCreateAOTData(const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)
Creates the necessary data structures to launch a Flutter Dart application in AOT mode....
FlutterKeyEventDeviceType
@ kFlutterKeyEventDeviceTypeKeyboard
@ kFlutterKeyEventDeviceTypeDirectionalPad
@ kFlutterKeyEventDeviceTypeHdmi
@ kFlutterKeyEventDeviceTypeJoystick
@ kFlutterKeyEventDeviceTypeGamepad
@ kFlutterLayerContentTypePlatformView
Indicates that the contents of this layer are determined by the embedder.
@ kFlutterLayerContentTypeBackingStore
FlutterEngineAOTDataSourceType
AOT data source type.
@ kFlutterEngineAOTDataSourceTypeElfPath
FlutterSoftwarePixelFormat
@ kFlutterSoftwarePixelFormatRGBA4444
@ kFlutterSoftwarePixelFormatRGBA8888
@ kFlutterSoftwarePixelFormatBGRA8888
@ kFlutterSoftwarePixelFormatGray8
@ kFlutterSoftwarePixelFormatRGB565
void(* VoidCallback)(void *)
@ kFlutterKeyEventTypeDown
@ kFlutterKeyEventTypeRepeat
@ kFlutterBackingStoreTypeSoftware2
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
FlutterSize FlutterSizeMake(double width, double height)
FlutterRect FlutterRectMakeLTRB(double l, double t, double r, double b)
FlutterPoint FlutterPointMake(double x, double y)
flutter::EmbedderEngine * ToEmbedderEngine(const FlutterEngine &engine)
#define SW_PIXFMT_TEST_F(test_name, dart_entrypoint, pixfmt, matcher)
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_LOG(severity)
#define FML_CHECK(condition)
#define FML_UNREACHABLE()
TEST_F(DisplayListTest, Defaults)
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
sk_sp< SkSurface > CreateRenderSurface(const FlutterLayer &layer, GrDirectContext *context)
FlutterKeyEventType UnserializeKeyEventType(uint64_t kind)
bool SurfacePixelDataMatchesBytes(SkSurface *surface, const std::vector< uint8_t > &bytes)
const char * GetSourcePath()
bool ImageMatchesFixture(const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image, int allowable_different_pixels)
testing::EmbedderTest EmbedderTest
void ExpectKeyEventEq(const FlutterKeyEvent &subject, const FlutterKeyEvent &baseline)
constexpr const char * kDefaultAOTAppELFFileName
TEST(NativeAssetsManagerTest, NoAvailableAssets)
static void expectSoftwareRenderingOutputMatches(EmbedderTest &test, std::string entrypoint, FlutterSoftwarePixelFormat pixfmt, const std::vector< uint8_t > &bytes)
FlutterKeyEventDeviceType UnserializeKeyEventDeviceType(uint64_t source)
constexpr int64_t kFlutterImplicitViewId
impeller::ISize32 DlISize
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
bool operator==(const ViewportMetrics &a, const ViewportMetrics &b)
TEST_F(EngineAnimatorTest, AnimatorAcceptsMultipleRenders)
std::string JoinPaths(std::initializer_list< std::string > components)
internal::CopyableLambda< T > MakeCopyable(T lambda)
impeller::ShaderType type
FlutterAddViewCallback add_view_callback
FlutterViewId view_id
The identifier for the view to add. This must be unique.
const FlutterWindowMetricsEvent * view_metrics
FlutterBackingStoreType type
Specifies the type of backing store.
FlutterSoftwareBackingStore software
The description of the software backing store.
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStorePresentInfo).
An update to whether a message channel has a listener set or not.
bool listening
True if a listener has been set, false if one has been cleared.
const char * channel
The name of the channel.
FlutterEngineAOTDataSourceType type
const char * elf_path
Absolute path to an ELF library file.
size_t struct_size
The size of this struct. Must be sizeof(FlutterKeyEvent).
FlutterKeyEventDeviceType device_type
The source device for the key event.
FlutterKeyEventType type
The event kind.
FlutterLayerContentType type
const FlutterBackingStore * backing_store
FlutterBackingStorePresentInfo * backing_store_present_info
const FlutterPlatformView * platform_view
size_t struct_size
This size of this struct. Must be sizeof(FlutterLayer).
FlutterSize size
The size of the layer (in physical pixels).
const char * language_code
size_t struct_size
This size of this struct. Must be sizeof(FlutterLocale).
const char * country_code
const char * variant_code
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
FlutterViewId view_id
The identifier of the view that received the pointer event.
double y
The y coordinate of the pointer event in physical pixels.
double x
The x coordinate of the pointer event in physical pixels.
FlutterPointerPhase phase
const uint8_t * isolate_snapshot_data
const uint8_t * vm_snapshot_data
size_t isolate_snapshot_instructions_size
const uint8_t * vm_snapshot_instructions
size_t isolate_snapshot_data_size
size_t vm_snapshot_instructions_size
size_t vm_snapshot_data_size
const uint8_t * isolate_snapshot_instructions
A structure to represent a rectangle.
A region represented by a collection of non-overlapping rectangles.
size_t struct_size
The size of this struct. Must be sizeof(FlutterRegion).
FlutterRemoveViewCallback remove_view_callback
size_t height
The number of rows in the allocation.
FlutterViewFocusState state
The focus state of the view.
FlutterViewId view_id
The identifier of the view that received the focus event.
FlutterViewFocusDirection direction
The direction in which the focus transitioned across [FlutterView]s.
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
size_t height
Physical height of the window.
size_t min_height_constraint
size_t min_width_constraint
int64_t view_id
The view that this event is describing.
double pixel_ratio
Scale factor for the physical screen.
size_t max_width_constraint
size_t max_height_constraint
size_t width
Physical width of the window.
MappingCallback isolate_snapshot_instr
MappingCallback isolate_snapshot_data
MappingCallback vm_snapshot_data
MappingCallback vm_snapshot_instr
MappingCallback dart_library_sources_kernel
std::shared_ptr< fml::AutoResetWaitableEvent > latch
The ThreadConfig is the thread info include thread name, thread priority.
#define CREATE_NATIVE_ENTRY(native_entry)