Remove all remaining use of mock engine (#160635)
Test consistency achieved.
diff --git a/engine/src/flutter/shell/platform/linux/fl_accessible_node_test.cc b/engine/src/flutter/shell/platform/linux/fl_accessible_node_test.cc
index c0f534d..2b59f40 100644
--- a/engine/src/flutter/shell/platform/linux/fl_accessible_node_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_accessible_node_test.cc
@@ -6,11 +6,11 @@
#include "gtest/gtest.h"
#include "flutter/shell/platform/linux/fl_accessible_node.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
// Checks can build a tree of nodes.
TEST(FlAccessibleNodeTest, BuildTree) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) root = fl_accessible_node_new(engine, 0);
g_autoptr(FlAccessibleNode) child1 = fl_accessible_node_new(engine, 1);
@@ -44,7 +44,8 @@
// Checks node name is exposed to ATK.
TEST(FlAccessibleNodeTest, SetName) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
fl_accessible_node_set_name(node, "test");
@@ -53,7 +54,8 @@
// Checks node extents are exposed to ATK.
TEST(FlAccessibleNodeTest, SetExtents) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
fl_accessible_node_set_extents(node, 1, 2, 3, 4);
@@ -68,7 +70,8 @@
// Checks Flutter flags are mapped to appropriate ATK state.
TEST(FlAccessibleNodeTest, SetFlags) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
fl_accessible_node_set_flags(
@@ -87,7 +90,8 @@
// Checks Flutter flags are mapped to appropriate ATK roles.
TEST(FlAccessibleNodeTest, GetRole) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
@@ -120,7 +124,8 @@
// Checks Flutter actions are mapped to the appropriate ATK actions.
TEST(FlAccessibleNodeTest, SetActions) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_node_new(engine, 0);
fl_accessible_node_set_actions(
diff --git a/engine/src/flutter/shell/platform/linux/fl_accessible_text_field_test.cc b/engine/src/flutter/shell/platform/linux/fl_accessible_text_field_test.cc
index 396c4b0..a13eddd 100644
--- a/engine/src/flutter/shell/platform/linux/fl_accessible_text_field_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_accessible_text_field_test.cc
@@ -9,7 +9,6 @@
#include "flutter/shell/platform/linux/fl_accessible_text_field.h"
#include "flutter/shell/platform/linux/fl_engine_private.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_signal_handler.h"
// MOCK_ENGINE_PROC is leaky by design
@@ -25,7 +24,8 @@
// Tests that semantic node value updates from Flutter emit AtkText::text-insert
// and AtkText::text-remove signals as expected.
TEST(FlAccessibleTextFieldTest, SetValue) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
// "" -> "Flutter"
@@ -81,7 +81,8 @@
// AtkText::text-selection-changed and AtkText::text-caret-moved signals as
// expected.
TEST(FlAccessibleTextFieldTest, SetTextSelection) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
// [-1,-1] -> [2,3]
@@ -143,7 +144,13 @@
g_autoptr(GPtrArray) action_datas = g_ptr_array_new_with_free_func(
reinterpret_cast<GDestroyNotify>(fl_value_unref));
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -176,7 +183,8 @@
// Tests AtkText::get_character_count.
TEST(FlAccessibleTextFieldTest, GetCharacterCount) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
EXPECT_EQ(atk_text_get_character_count(ATK_TEXT(node)), 0);
@@ -188,7 +196,8 @@
// Tests AtkText::get_text.
TEST(FlAccessibleTextFieldTest, GetText) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
g_autofree gchar* empty = atk_text_get_text(ATK_TEXT(node), 0, -1);
@@ -208,7 +217,8 @@
// Tests AtkText::get_caret_offset.
TEST(FlAccessibleTextFieldTest, GetCaretOffset) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
EXPECT_EQ(atk_text_get_caret_offset(ATK_TEXT(node)), -1);
@@ -223,7 +233,13 @@
int base = -1;
int extent = -1;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -247,7 +263,8 @@
// Tests AtkText::get_n_selections.
TEST(FlAccessibleTextFieldTest, GetNSelections) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
EXPECT_EQ(atk_text_get_n_selections(ATK_TEXT(node)), 0);
@@ -259,7 +276,8 @@
// Tests AtkText::get_selection.
TEST(FlAccessibleTextFieldTest, GetSelection) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
EXPECT_EQ(atk_text_get_selection(ATK_TEXT(node), 0, nullptr, nullptr),
@@ -296,7 +314,13 @@
int base = -1;
int extent = -1;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -330,7 +354,13 @@
int base = -1;
int extent = -1;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -370,7 +400,13 @@
int base = -1;
int extent = -1;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -405,7 +441,13 @@
TEST(FlAccessibleTextFieldTest, SetTextContents) {
g_autofree gchar* text = nullptr;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -430,7 +472,13 @@
int base = -1;
int extent = -1;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -479,7 +527,13 @@
int extent = -1;
FlutterSemanticsAction act = kFlutterSemanticsActionCustomAction;
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
MOCK_ENGINE_PROC(
DispatchSemanticsAction,
@@ -522,7 +576,8 @@
}
TEST(FlAccessibleTextFieldTest, TextBoundary) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlAccessibleNode) node = fl_accessible_text_field_new(engine, 1);
fl_accessible_node_set_value(node,
diff --git a/engine/src/flutter/shell/platform/linux/fl_binary_messenger_test.cc b/engine/src/flutter/shell/platform/linux/fl_binary_messenger_test.cc
index 3ea11fb..66c3693 100644
--- a/engine/src/flutter/shell/platform/linux/fl_binary_messenger_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_binary_messenger_test.cc
@@ -21,7 +21,6 @@
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -29,16 +28,17 @@
FlutterDataCallback response_callback;
void* response_callback_user_data;
- embedder_api->PlatformMessageCreateResponseHandle = MOCK_ENGINE_PROC(
- PlatformMessageCreateResponseHandle,
- ([&response_callback, &response_callback_user_data](
- auto engine, FlutterDataCallback data_callback, void* user_data,
- FlutterPlatformMessageResponseHandle** response_out) {
- response_callback = data_callback;
- response_callback_user_data = user_data;
- return kSuccess;
- }));
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->PlatformMessageCreateResponseHandle =
+ MOCK_ENGINE_PROC(
+ PlatformMessageCreateResponseHandle,
+ ([&response_callback, &response_callback_user_data](
+ auto engine, FlutterDataCallback data_callback, void* user_data,
+ FlutterPlatformMessageResponseHandle** response_out) {
+ response_callback = data_callback;
+ response_callback_user_data = user_data;
+ return kSuccess;
+ }));
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&response_callback, &response_callback_user_data](
auto engine, const FlutterPlatformMessage* message) {
@@ -83,14 +83,13 @@
TEST(FlBinaryMessengerTest, SendNullptr) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
EXPECT_EQ(error, nullptr);
bool called = false;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called](auto engine, const FlutterPlatformMessage* message) {
called = true;
@@ -113,14 +112,13 @@
TEST(FlBinaryMessengerTest, SendEmpty) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
EXPECT_EQ(error, nullptr);
bool called = false;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called](auto engine, const FlutterPlatformMessage* message) {
called = true;
@@ -143,7 +141,6 @@
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -151,16 +148,17 @@
FlutterDataCallback response_callback;
void* response_callback_user_data;
- embedder_api->PlatformMessageCreateResponseHandle = MOCK_ENGINE_PROC(
- PlatformMessageCreateResponseHandle,
- ([&response_callback, &response_callback_user_data](
- auto engine, FlutterDataCallback data_callback, void* user_data,
- FlutterPlatformMessageResponseHandle** response_out) {
- response_callback = data_callback;
- response_callback_user_data = user_data;
- return kSuccess;
- }));
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->PlatformMessageCreateResponseHandle =
+ MOCK_ENGINE_PROC(
+ PlatformMessageCreateResponseHandle,
+ ([&response_callback, &response_callback_user_data](
+ auto engine, FlutterDataCallback data_callback, void* user_data,
+ FlutterPlatformMessageResponseHandle** response_out) {
+ response_callback = data_callback;
+ response_callback_user_data = user_data;
+ return kSuccess;
+ }));
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&response_callback, &response_callback_user_data](
auto engine, const FlutterPlatformMessage* message) {
@@ -202,13 +200,12 @@
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
EXPECT_EQ(error, nullptr);
- embedder_api->SendPlatformMessage =
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage =
MOCK_ENGINE_PROC(SendPlatformMessage,
([](auto engine, const FlutterPlatformMessage* message) {
EXPECT_STREQ(message->channel, "test");
@@ -237,29 +234,29 @@
TEST(FlBinaryMessengerTest, Receive) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
EXPECT_EQ(error, nullptr);
bool called = false;
- embedder_api->SendPlatformMessageResponse = MOCK_ENGINE_PROC(
- SendPlatformMessageResponse,
- ([&called](auto engine,
- const FlutterPlatformMessageResponseHandle* handle,
- const uint8_t* data, size_t data_length) {
- called = true;
+ fl_engine_get_embedder_api(engine)->SendPlatformMessageResponse =
+ MOCK_ENGINE_PROC(
+ SendPlatformMessageResponse,
+ ([&called](auto engine,
+ const FlutterPlatformMessageResponseHandle* handle,
+ const uint8_t* data, size_t data_length) {
+ called = true;
- int fake_handle = *reinterpret_cast<const int*>(handle);
- EXPECT_EQ(fake_handle, 42);
+ int fake_handle = *reinterpret_cast<const int*>(handle);
+ EXPECT_EQ(fake_handle, 42);
- g_autofree gchar* text =
- g_strndup(reinterpret_cast<const gchar*>(data), data_length);
- EXPECT_STREQ(text, "Polo!");
+ g_autofree gchar* text =
+ g_strndup(reinterpret_cast<const gchar*>(data), data_length);
+ EXPECT_STREQ(text, "Polo!");
- return kSuccess;
- }));
+ return kSuccess;
+ }));
FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(engine);
@@ -301,27 +298,28 @@
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
EXPECT_EQ(error, nullptr);
- embedder_api->SendPlatformMessageResponse = MOCK_ENGINE_PROC(
- SendPlatformMessageResponse,
- ([&loop](auto engine, const FlutterPlatformMessageResponseHandle* handle,
- const uint8_t* data, size_t data_length) {
- int fake_handle = *reinterpret_cast<const int*>(handle);
- EXPECT_EQ(fake_handle, 42);
+ fl_engine_get_embedder_api(engine)->SendPlatformMessageResponse =
+ MOCK_ENGINE_PROC(
+ SendPlatformMessageResponse,
+ ([&loop](auto engine,
+ const FlutterPlatformMessageResponseHandle* handle,
+ const uint8_t* data, size_t data_length) {
+ int fake_handle = *reinterpret_cast<const int*>(handle);
+ EXPECT_EQ(fake_handle, 42);
- g_autofree gchar* text =
- g_strndup(reinterpret_cast<const gchar*>(data), data_length);
- EXPECT_STREQ(text, "Polo!");
+ g_autofree gchar* text =
+ g_strndup(reinterpret_cast<const gchar*>(data), data_length);
+ EXPECT_STREQ(text, "Polo!");
- g_main_loop_quit(loop);
+ g_main_loop_quit(loop);
- return kSuccess;
- }));
+ return kSuccess;
+ }));
FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(engine);
@@ -386,13 +384,12 @@
TEST(FlBinaryMessengerTest, ResizeChannel) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
bool called = false;
FlutterEngineSendPlatformMessageFnPtr old_handler =
- embedder_api->SendPlatformMessage;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage;
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called, old_handler](auto engine,
const FlutterPlatformMessage* message) {
@@ -434,13 +431,12 @@
TEST(FlBinaryMessengerTest, WarnsOnOverflowChannel) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
bool called = false;
FlutterEngineSendPlatformMessageFnPtr old_handler =
- embedder_api->SendPlatformMessage;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage;
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called, old_handler](auto engine,
const FlutterPlatformMessage* message) {
@@ -485,7 +481,6 @@
g_autoptr(FlDartProject) project = fl_dart_project_new();
g_autoptr(FlEngine) engine = fl_engine_new(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -494,8 +489,8 @@
g_autoptr(FlBinaryMessenger) messenger = fl_binary_messenger_new(engine);
bool called = false;
FlutterEngineSendPlatformMessageFnPtr old_handler =
- embedder_api->SendPlatformMessage;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage;
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called, old_handler, loop](auto engine,
const FlutterPlatformMessage* message) {
diff --git a/engine/src/flutter/shell/platform/linux/fl_engine.cc b/engine/src/flutter/shell/platform/linux/fl_engine.cc
index eb3d678..1523906 100644
--- a/engine/src/flutter/shell/platform/linux/fl_engine.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_engine.cc
@@ -8,7 +8,6 @@
#include <cstring>
-#include "flutter/common/constants.h"
#include "flutter/shell/platform/common/engine_switches.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
@@ -493,7 +492,9 @@
self->thread = g_thread_self();
self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
- FlutterEngineGetProcAddresses(&self->embedder_api);
+ if (FlutterEngineGetProcAddresses(&self->embedder_api) != kSuccess) {
+ g_warning("Failed get get engine function pointers");
+ }
// Implicit view is 0, so start at 1.
self->next_view_id = 1;
diff --git a/engine/src/flutter/shell/platform/linux/fl_engine_test.cc b/engine/src/flutter/shell/platform/linux/fl_engine_test.cc
index 083b649..9378799 100644
--- a/engine/src/flutter/shell/platform/linux/fl_engine_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_engine_test.cc
@@ -10,18 +10,21 @@
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_message_codec.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_string_codec.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
// MOCK_ENGINE_PROC is leaky by design
// NOLINTBEGIN(clang-analyzer-core.StackAddressEscape)
// Checks sending window metrics events works.
TEST(FlEngineTest, WindowMetrics) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
bool called = false;
- embedder_api->SendWindowMetricsEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendWindowMetricsEvent = MOCK_ENGINE_PROC(
SendWindowMetricsEvent,
([&called](auto engine, const FlutterWindowMetricsEvent* event) {
called = true;
@@ -33,9 +36,6 @@
return kSuccess;
}));
- g_autoptr(GError) error = nullptr;
- EXPECT_TRUE(fl_engine_start(engine, &error));
- EXPECT_EQ(error, nullptr);
fl_engine_send_window_metrics_event(engine, 1, 3840, 2160, 2.0);
EXPECT_TRUE(called);
@@ -43,11 +43,11 @@
// Checks sending mouse pointer events works.
TEST(FlEngineTest, MousePointer) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&called](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -80,11 +80,11 @@
// Checks sending pan/zoom events works.
TEST(FlEngineTest, PointerPanZoom) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&called](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -118,25 +118,26 @@
// Checks dispatching a semantics action works.
TEST(FlEngineTest, DispatchSemanticsAction) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->DispatchSemanticsAction = MOCK_ENGINE_PROC(
- DispatchSemanticsAction,
- ([&called](auto engine, uint64_t id, FlutterSemanticsAction action,
- const uint8_t* data, size_t data_length) {
- EXPECT_EQ(id, static_cast<uint64_t>(42));
- EXPECT_EQ(action, kFlutterSemanticsActionTap);
- EXPECT_EQ(data_length, static_cast<size_t>(4));
- EXPECT_EQ(data[0], 't');
- EXPECT_EQ(data[1], 'e');
- EXPECT_EQ(data[2], 's');
- EXPECT_EQ(data[3], 't');
- called = true;
+ fl_engine_get_embedder_api(engine)->DispatchSemanticsAction =
+ MOCK_ENGINE_PROC(
+ DispatchSemanticsAction,
+ ([&called](auto engine, uint64_t id, FlutterSemanticsAction action,
+ const uint8_t* data, size_t data_length) {
+ EXPECT_EQ(id, static_cast<uint64_t>(42));
+ EXPECT_EQ(action, kFlutterSemanticsActionTap);
+ EXPECT_EQ(data_length, static_cast<size_t>(4));
+ EXPECT_EQ(data[0], 't');
+ EXPECT_EQ(data[1], 'e');
+ EXPECT_EQ(data[2], 's');
+ EXPECT_EQ(data[3], 't');
+ called = true;
- return kSuccess;
- }));
+ return kSuccess;
+ }));
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -150,13 +151,13 @@
// Checks sending platform messages works.
TEST(FlEngineTest, PlatformMessage) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
FlutterEngineSendPlatformMessageFnPtr old_handler =
- embedder_api->SendPlatformMessage;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage;
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called, old_handler](auto engine,
const FlutterPlatformMessage* message) {
@@ -187,28 +188,30 @@
// Checks sending platform message responses works.
TEST(FlEngineTest, PlatformMessageResponse) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->SendPlatformMessageResponse = MOCK_ENGINE_PROC(
- SendPlatformMessageResponse,
- ([&called](auto engine,
- const FlutterPlatformMessageResponseHandle* handle,
- const uint8_t* data, size_t data_length) {
- called = true;
+ fl_engine_get_embedder_api(engine)->SendPlatformMessageResponse =
+ MOCK_ENGINE_PROC(
+ SendPlatformMessageResponse,
+ ([&called](auto engine,
+ const FlutterPlatformMessageResponseHandle* handle,
+ const uint8_t* data, size_t data_length) {
+ called = true;
- EXPECT_EQ(
- handle,
- reinterpret_cast<const FlutterPlatformMessageResponseHandle*>(42));
- EXPECT_EQ(data_length, static_cast<size_t>(4));
- EXPECT_EQ(data[0], 't');
- EXPECT_EQ(data[1], 'e');
- EXPECT_EQ(data[2], 's');
- EXPECT_EQ(data[3], 't');
+ EXPECT_EQ(
+ handle,
+ reinterpret_cast<const FlutterPlatformMessageResponseHandle*>(
+ 42));
+ EXPECT_EQ(data_length, static_cast<size_t>(4));
+ EXPECT_EQ(data[0], 't');
+ EXPECT_EQ(data[1], 'e');
+ EXPECT_EQ(data[2], 's');
+ EXPECT_EQ(data[3], 't');
- return kSuccess;
- }));
+ return kSuccess;
+ }));
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -224,11 +227,11 @@
// Checks settings handler sends settings on startup.
TEST(FlEngineTest, SettingsHandler) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->SendPlatformMessage = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPlatformMessage = MOCK_ENGINE_PROC(
SendPlatformMessage,
([&called](auto engine, const FlutterPlatformMessage* message) {
called = true;
@@ -277,14 +280,14 @@
// Checks restarting the engine invokes the correct callback.
TEST(FlEngineTest, OnPreEngineRestart) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
OnPreEngineRestartCallback callback;
void* callback_user_data;
bool called = false;
- embedder_api->Initialize = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->Initialize = MOCK_ENGINE_PROC(
Initialize, ([&callback, &callback_user_data, &called](
size_t version, const FlutterRendererConfig* config,
const FlutterProjectArgs* args, void* user_data,
@@ -295,6 +298,8 @@
return kSuccess;
}));
+ fl_engine_get_embedder_api(engine)->RunInitialized =
+ MOCK_ENGINE_PROC(RunInitialized, ([](auto engine) { return kSuccess; }));
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -320,8 +325,6 @@
}
TEST(FlEngineTest, DartEntrypointArgs) {
- g_autoptr(FlDartProject) project = fl_dart_project_new();
-
GPtrArray* args_array = g_ptr_array_new();
g_ptr_array_add(args_array, const_cast<char*>("arg_one"));
g_ptr_array_add(args_array, const_cast<char*>("arg_two"));
@@ -329,13 +332,12 @@
g_ptr_array_add(args_array, nullptr);
gchar** args = reinterpret_cast<gchar**>(g_ptr_array_free(args_array, false));
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, args);
-
- g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->Initialize = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->Initialize = MOCK_ENGINE_PROC(
Initialize, ([&called, &set_args = args](
size_t version, const FlutterRendererConfig* config,
const FlutterProjectArgs* args, void* user_data,
@@ -346,6 +348,8 @@
return kSuccess;
}));
+ fl_engine_get_embedder_api(engine)->RunInitialized =
+ MOCK_ENGINE_PROC(RunInitialized, ([](auto engine) { return kSuccess; }));
g_autoptr(GError) error = nullptr;
EXPECT_TRUE(fl_engine_start(engine, &error));
@@ -359,11 +363,10 @@
g_setenv("LANGUAGE", "de:en_US", TRUE);
g_autoptr(FlDartProject) project = fl_dart_project_new();
- g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->UpdateLocales = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->UpdateLocales = MOCK_ENGINE_PROC(
UpdateLocales, ([&called](auto engine, const FlutterLocale** locales,
size_t locales_count) {
called = true;
@@ -411,11 +414,10 @@
g_setenv("LANGUAGE", "C", TRUE);
g_autoptr(FlDartProject) project = fl_dart_project_new();
- g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->UpdateLocales = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->UpdateLocales = MOCK_ENGINE_PROC(
UpdateLocales, ([&called](auto engine, const FlutterLocale** locales,
size_t locales_count) {
called = true;
@@ -448,11 +450,10 @@
g_setenv("LANGUAGE", "en:en", TRUE);
g_autoptr(FlDartProject) project = fl_dart_project_new();
- g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->UpdateLocales = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->UpdateLocales = MOCK_ENGINE_PROC(
UpdateLocales, ([&called](auto engine, const FlutterLocale** locales,
size_t locales_count) {
called = true;
@@ -490,11 +491,10 @@
g_setenv("LANGUAGE", "de:: :en_US", TRUE);
g_autoptr(FlDartProject) project = fl_dart_project_new();
- g_autoptr(FlEngine) engine = make_mock_engine_with_project(project);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->UpdateLocales = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->UpdateLocales = MOCK_ENGINE_PROC(
UpdateLocales, ([&called](auto engine, const FlutterLocale** locales,
size_t locales_count) {
called = true;
@@ -551,11 +551,11 @@
TEST(FlEngineTest, AddView) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->AddView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->AddView = MOCK_ENGINE_PROC(
AddView, ([&called](auto engine, const FlutterAddViewInfo* info) {
called = true;
EXPECT_EQ(info->view_metrics->width, 123u);
@@ -594,10 +594,10 @@
TEST(FlEngineTest, AddViewError) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
- embedder_api->AddView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->AddView = MOCK_ENGINE_PROC(
AddView, ([](auto engine, const FlutterAddViewInfo* info) {
FlutterAddViewResult result;
result.struct_size = sizeof(FlutterAddViewResult);
@@ -630,10 +630,10 @@
TEST(FlEngineTest, AddViewEngineError) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
- embedder_api->AddView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->AddView = MOCK_ENGINE_PROC(
AddView, ([](auto engine, const FlutterAddViewInfo* info) {
return kInvalidArguments;
}));
@@ -660,11 +660,11 @@
TEST(FlEngineTest, RemoveView) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
bool called = false;
- embedder_api->RemoveView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->RemoveView = MOCK_ENGINE_PROC(
RemoveView, ([&called](auto engine, const FlutterRemoveViewInfo* info) {
called = true;
EXPECT_EQ(info->view_id, 123);
@@ -699,10 +699,10 @@
TEST(FlEngineTest, RemoveViewError) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
- embedder_api->RemoveView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->RemoveView = MOCK_ENGINE_PROC(
RemoveView, ([](auto engine, const FlutterRemoveViewInfo* info) {
FlutterRemoveViewResult result;
result.struct_size = sizeof(FlutterRemoveViewResult);
@@ -733,10 +733,10 @@
TEST(FlEngineTest, RemoveViewEngineError) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
- embedder_api->RemoveView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->RemoveView = MOCK_ENGINE_PROC(
RemoveView, ([](auto engine, const FlutterRemoveViewInfo* info) {
return kInvalidArguments;
}));
@@ -751,11 +751,15 @@
TEST(FlEngineTest, SendKeyEvent) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
bool called;
- embedder_api->SendKeyEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendKeyEvent = MOCK_ENGINE_PROC(
SendKeyEvent,
([&called](auto engine, const FlutterKeyEvent* event,
FlutterKeyEventCallback callback, void* user_data) {
@@ -798,11 +802,15 @@
TEST(FlEngineTest, SendKeyEventNotHandled) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
bool called;
- embedder_api->SendKeyEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendKeyEvent = MOCK_ENGINE_PROC(
SendKeyEvent,
([&called](auto engine, const FlutterKeyEvent* event,
FlutterKeyEventCallback callback, void* user_data) {
@@ -839,11 +847,15 @@
TEST(FlEngineTest, SendKeyEventError) {
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
bool called;
- embedder_api->SendKeyEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendKeyEvent = MOCK_ENGINE_PROC(
SendKeyEvent,
([&called](auto engine, const FlutterKeyEvent* event,
FlutterKeyEventCallback callback, void* user_data) {
diff --git a/engine/src/flutter/shell/platform/linux/fl_framebuffer_test.cc b/engine/src/flutter/shell/platform/linux/fl_framebuffer_test.cc
index de565c5..44f2e78 100644
--- a/engine/src/flutter/shell/platform/linux/fl_framebuffer_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_framebuffer_test.cc
@@ -4,8 +4,6 @@
#include "gtest/gtest.h"
-#include "flutter/common/constants.h"
-#include "flutter/fml/logging.h"
#include "flutter/shell/platform/linux/fl_framebuffer.h"
#include "flutter/shell/platform/linux/testing/mock_epoxy.h"
diff --git a/engine/src/flutter/shell/platform/linux/fl_plugin_registrar_test.cc b/engine/src/flutter/shell/platform/linux/fl_plugin_registrar_test.cc
index 792e324..e9b7772 100644
--- a/engine/src/flutter/shell/platform/linux/fl_plugin_registrar_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_plugin_registrar_test.cc
@@ -10,12 +10,13 @@
#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
#include "flutter/shell/platform/linux/fl_texture_registrar_private.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registrar.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_plugin_registrar.h"
// Checks can make a mock registrar.
TEST(FlPluginRegistrarTest, FlMockRegistrar) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
g_autoptr(FlBinaryMessenger) messenger = fl_binary_messenger_new(engine);
g_autoptr(FlTextureRegistrar) texture_registrar =
fl_texture_registrar_new(engine);
diff --git a/engine/src/flutter/shell/platform/linux/fl_pointer_manager_test.cc b/engine/src/flutter/shell/platform/linux/fl_pointer_manager_test.cc
index 503397e..519b39a 100644
--- a/engine/src/flutter/shell/platform/linux/fl_pointer_manager_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_pointer_manager_test.cc
@@ -5,15 +5,19 @@
#include "flutter/shell/platform/linux/fl_pointer_manager.h"
#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
#include "flutter/shell/platform/linux/fl_engine_private.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "gtest/gtest.h"
-static void log_pointer_events(
- FlEngine* engine,
- std::vector<FlutterPointerEvent>& pointer_events) {
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+TEST(FlPointerManagerTest, EnterLeave) {
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
+ std::vector<FlutterPointerEvent> pointer_events;
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -23,12 +27,6 @@
return kSuccess;
}));
-}
-
-TEST(FlPointerManagerTest, EnterLeave) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
@@ -54,9 +52,24 @@
}
TEST(FlPointerManagerTest, EnterEnter) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
@@ -76,9 +89,24 @@
}
TEST(FlPointerManagerTest, EnterLeaveLeave) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
@@ -107,9 +135,24 @@
}
TEST(FlPointerManagerTest, EnterButtonPress) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
@@ -136,9 +179,24 @@
}
TEST(FlPointerManagerTest, NoEnterButtonPress) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_button_press(
@@ -164,9 +222,24 @@
}
TEST(FlPointerManagerTest, ButtonPressButtonRelease) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_button_press(
@@ -194,9 +267,24 @@
}
TEST(FlPointerManagerTest, ButtonPressButtonReleaseThreeButtons) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
// Press buttons 1-2-3, release 3-2-1
@@ -253,9 +341,24 @@
}
TEST(FlPointerManagerTest, ButtonPressButtonPressButtonRelease) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_button_press(
@@ -287,9 +390,24 @@
}
TEST(FlPointerManagerTest, ButtonPressButtonReleaseButtonRelease) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_button_press(
@@ -321,9 +439,24 @@
}
TEST(FlPointerManagerTest, NoButtonPressButtonRelease) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
// Release without associated press, will be ignored
@@ -335,9 +468,24 @@
}
TEST(FlPointerManagerTest, Motion) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_motion(manager, 1234,
@@ -371,9 +519,24 @@
}
TEST(FlPointerManagerTest, Drag) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_motion(manager, 1234,
@@ -420,9 +583,24 @@
}
TEST(FlPointerManagerTest, DeviceKind) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
fl_pointer_manager_handle_enter(manager, 1234,
diff --git a/engine/src/flutter/shell/platform/linux/fl_scrolling_manager_test.cc b/engine/src/flutter/shell/platform/linux/fl_scrolling_manager_test.cc
index 05fe2ad..047df48 100644
--- a/engine/src/flutter/shell/platform/linux/fl_scrolling_manager_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_scrolling_manager_test.cc
@@ -5,7 +5,6 @@
#include "flutter/shell/platform/linux/fl_scrolling_manager.h"
#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
#include "flutter/shell/platform/linux/fl_engine_private.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include <cstring>
#include <vector>
@@ -30,10 +29,15 @@
}
TEST(FlScrollingManagerTest, DiscreteDirectional) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -96,10 +100,15 @@
}
TEST(FlScrollingManagerTest, DiscreteScrolling) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -134,10 +143,15 @@
}
TEST(FlScrollingManagerTest, Panning) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -198,10 +212,15 @@
}
TEST(FlScrollingManagerTest, Zooming) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -240,10 +259,15 @@
}
TEST(FlScrollingManagerTest, Rotating) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -282,10 +306,15 @@
}
TEST(FlScrollingManagerTest, SynchronizedZoomingAndRotating) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
@@ -341,10 +370,15 @@
// Make sure that zoom and rotate sequences which don't end at the same time
// don't cause any problems.
TEST(FlScrollingManagerTest, UnsynchronizedZoomingAndRotating) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
SendPointerEvent,
([&pointer_events](auto engine, const FlutterPointerEvent* events,
size_t events_count) {
diff --git a/engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc b/engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc
index e8ebd34..b922182 100644
--- a/engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc
@@ -8,7 +8,6 @@
#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
#include "flutter/shell/platform/linux/fl_engine_private.h"
#include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_settings.h"
#include "flutter/testing/testing.h"
@@ -191,16 +190,21 @@
// MOCK_ENGINE_PROC is leaky by design
// NOLINTBEGIN(clang-analyzer-core.StackAddressEscape)
TEST(FlSettingsHandlerTest, AccessibilityFeatures) {
- g_autoptr(FlEngine) engine = make_mock_engine();
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
std::vector<FlutterAccessibilityFeature> calls;
- embedder_api->UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
- UpdateAccessibilityFeatures,
- ([&calls](auto engine, FlutterAccessibilityFeature features) {
- calls.push_back(features);
- return kSuccess;
- }));
+ fl_engine_get_embedder_api(engine)->UpdateAccessibilityFeatures =
+ MOCK_ENGINE_PROC(
+ UpdateAccessibilityFeatures,
+ ([&calls](auto engine, FlutterAccessibilityFeature features) {
+ calls.push_back(features);
+ return kSuccess;
+ }));
g_autoptr(FlSettingsHandler) handler = fl_settings_handler_new(engine);
diff --git a/engine/src/flutter/shell/platform/linux/fl_texture_registrar_test.cc b/engine/src/flutter/shell/platform/linux/fl_texture_registrar_test.cc
index 23e0b7f..b1a5fe9 100644
--- a/engine/src/flutter/shell/platform/linux/fl_texture_registrar_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_texture_registrar_test.cc
@@ -3,10 +3,11 @@
// found in the LICENSE file.
#include "flutter/shell/platform/linux/public/flutter_linux/fl_texture_registrar.h"
+#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
+#include "flutter/shell/platform/linux/fl_engine_private.h"
#include "flutter/shell/platform/linux/fl_texture_registrar_private.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_pixel_buffer_texture.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_texture_gl.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_texture_registrar.h"
#include "gtest/gtest.h"
@@ -95,35 +96,110 @@
// Test that registering a texture works.
TEST(FlTextureRegistrarTest, RegisterTexture) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+ bool register_called = false;
+ fl_engine_get_embedder_api(engine)->RegisterExternalTexture =
+ MOCK_ENGINE_PROC(RegisterExternalTexture,
+ ([®ister_called](auto engine, int64_t texture_id) {
+ register_called = true;
+ return kSuccess;
+ }));
+ bool unregister_called = false;
+ fl_engine_get_embedder_api(engine)->UnregisterExternalTexture =
+ MOCK_ENGINE_PROC(UnregisterExternalTexture,
+ ([&unregister_called](auto engine, int64_t texture_id) {
+ unregister_called = true;
+ return kSuccess;
+ }));
+
g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
- EXPECT_FALSE(fl_texture_registrar_unregister_texture(registrar, texture));
+ // EXPECT_FALSE(fl_texture_registrar_unregister_texture(registrar, texture));
+ EXPECT_FALSE(register_called);
EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
+ EXPECT_TRUE(register_called);
+ EXPECT_FALSE(unregister_called);
EXPECT_TRUE(fl_texture_registrar_unregister_texture(registrar, texture));
+ EXPECT_TRUE(unregister_called);
}
// Test that marking a texture frame available works.
TEST(FlTextureRegistrarTest, MarkTextureFrameAvailable) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+ bool register_called = false;
+ fl_engine_get_embedder_api(engine)->RegisterExternalTexture =
+ MOCK_ENGINE_PROC(RegisterExternalTexture,
+ ([®ister_called](auto engine, int64_t texture_id) {
+ register_called = true;
+ return kSuccess;
+ }));
+ fl_engine_get_embedder_api(engine)->UnregisterExternalTexture =
+ MOCK_ENGINE_PROC(
+ UnregisterExternalTexture,
+ ([](auto engine, int64_t texture_id) { return kSuccess; }));
+ fl_engine_get_embedder_api(engine)->MarkExternalTextureFrameAvailable =
+ MOCK_ENGINE_PROC(MarkExternalTextureFrameAvailable,
+ ([](auto engine, int64_t texture_id) {
+ g_printerr("!\n");
+ return kSuccess;
+ }));
+
g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
- EXPECT_FALSE(
- fl_texture_registrar_mark_texture_frame_available(registrar, texture));
EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
+ EXPECT_TRUE(register_called);
EXPECT_TRUE(
fl_texture_registrar_mark_texture_frame_available(registrar, texture));
}
+// Test handles error marking a texture frame available.
+TEST(FlTextureRegistrarTest, MarkInvalidTextureFrameAvailable) {
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+ fl_engine_get_embedder_api(engine)->RegisterExternalTexture =
+ MOCK_ENGINE_PROC(
+ RegisterExternalTexture,
+ ([](auto engine, int64_t texture_id) { return kSuccess; }));
+ fl_engine_get_embedder_api(engine)->UnregisterExternalTexture =
+ MOCK_ENGINE_PROC(
+ UnregisterExternalTexture,
+ ([](auto engine, int64_t texture_id) { return kSuccess; }));
+ fl_engine_get_embedder_api(engine)->MarkExternalTextureFrameAvailable =
+ MOCK_ENGINE_PROC(MarkExternalTextureFrameAvailable,
+ ([](auto engine, int64_t texture_id) {
+ return kInternalInconsistency;
+ }));
+
+ g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
+ g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
+
+ EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
+ EXPECT_FALSE(
+ fl_texture_registrar_mark_texture_frame_available(registrar, texture));
+}
+
// Test the textures can be accessed via multiple threads without
// synchronization issues.
// TODO(robert-ancell): Re-enable when no longer flaky
// https://github.com/flutter/flutter/issues/138197
TEST(FlTextureRegistrarTest,
DISABLED_RegistrarRegisterTextureInMultipleThreads) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ fl_engine_get_embedder_api(engine)->RegisterExternalTexture =
+ MOCK_ENGINE_PROC(
+ RegisterExternalTexture,
+ ([](auto engine, int64_t texture_id) { return kSuccess; }));
+ fl_engine_get_embedder_api(engine)->UnregisterExternalTexture =
+ MOCK_ENGINE_PROC(
+ UnregisterExternalTexture,
+ ([](auto engine, int64_t texture_id) { return kSuccess; }));
+
g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
pthread_t threads[kThreadCount];
int64_t ids[kThreadCount];
diff --git a/engine/src/flutter/shell/platform/linux/fl_touch_manager_test.cc b/engine/src/flutter/shell/platform/linux/fl_touch_manager_test.cc
index 90d1d46..1b08bfb 100644
--- a/engine/src/flutter/shell/platform/linux/fl_touch_manager_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_touch_manager_test.cc
@@ -5,29 +5,12 @@
#include "flutter/shell/platform/linux/fl_touch_manager.h"
#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
#include "flutter/shell/platform/linux/fl_engine_private.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include <cstring>
#include <vector>
#include "gtest/gtest.h"
-static void log_pointer_events(
- FlEngine* engine,
- std::vector<FlutterPointerEvent>& pointer_events) {
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
- embedder_api->SendPointerEvent = MOCK_ENGINE_PROC(
- SendPointerEvent,
- ([&pointer_events](auto engine, const FlutterPointerEvent* events,
- size_t events_count) {
- for (size_t i = 0; i < events_count; i++) {
- pointer_events.push_back(events[i]);
- }
-
- return kSuccess;
- }));
-}
-
struct _FakeGdkDevice {
GObject parent_instance;
gchar* name;
@@ -45,9 +28,24 @@
}
TEST(FlTouchManagerTest, TouchEvents) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
+
+ g_autoptr(GError) error = nullptr;
+ EXPECT_TRUE(fl_engine_start(engine, &error));
+ EXPECT_EQ(error, nullptr);
+
std::vector<FlutterPointerEvent> pointer_events;
- log_pointer_events(engine, pointer_events);
+ fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
+ SendPointerEvent,
+ ([&pointer_events](auto engine, const FlutterPointerEvent* events,
+ size_t events_count) {
+ for (size_t i = 0; i < events_count; i++) {
+ pointer_events.push_back(events[i]);
+ }
+
+ return kSuccess;
+ }));
g_autoptr(FlTouchManager) manager = fl_touch_manager_new(engine, 0);
diff --git a/engine/src/flutter/shell/platform/linux/fl_view_accessible_test.cc b/engine/src/flutter/shell/platform/linux/fl_view_accessible_test.cc
index 0b6d17a..533346a 100644
--- a/engine/src/flutter/shell/platform/linux/fl_view_accessible_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_view_accessible_test.cc
@@ -7,11 +7,11 @@
#include "flutter/shell/platform/linux/fl_view_accessible.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
-#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_signal_handler.h"
TEST(FlViewAccessibleTest, BuildTree) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlViewAccessible) accessible = fl_view_accessible_new(engine);
int32_t children[] = {111, 222};
@@ -47,7 +47,8 @@
}
TEST(FlViewAccessibleTest, AddRemoveChildren) {
- g_autoptr(FlEngine) engine = make_mock_engine();
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ g_autoptr(FlEngine) engine = fl_engine_new(project);
g_autoptr(FlViewAccessible) accessible = fl_view_accessible_new(engine);
FlutterSemanticsNode2 root_node = {
diff --git a/engine/src/flutter/shell/platform/linux/fl_view_test.cc b/engine/src/flutter/shell/platform/linux/fl_view_test.cc
index e6a5105..61e87a3 100644
--- a/engine/src/flutter/shell/platform/linux/fl_view_test.cc
+++ b/engine/src/flutter/shell/platform/linux/fl_view_test.cc
@@ -68,10 +68,9 @@
FlView* implicit_view = fl_view_new(project);
FlEngine* engine = fl_view_get_engine(implicit_view);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
FlutterViewId view_id = -1;
- embedder_api->AddView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->AddView = MOCK_ENGINE_PROC(
AddView, ([&view_id](auto engine, const FlutterAddViewInfo* info) {
view_id = info->view_id;
FlutterAddViewResult result = {
@@ -97,10 +96,9 @@
FlView* implicit_view = fl_view_new(project);
FlEngine* engine = fl_view_get_engine(implicit_view);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
FlutterViewId view_id = -1;
- embedder_api->AddView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->AddView = MOCK_ENGINE_PROC(
AddView, ([&view_id](auto engine, const FlutterAddViewInfo* info) {
view_id = info->view_id;
return kInvalidArguments;
@@ -121,10 +119,9 @@
FlView* implicit_view = fl_view_new(project);
FlEngine* engine = fl_view_get_engine(implicit_view);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
g_autoptr(GPtrArray) removed_views = g_ptr_array_new();
- embedder_api->RemoveView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->RemoveView = MOCK_ENGINE_PROC(
RemoveView,
([removed_views](auto engine, const FlutterRemoveViewInfo* info) {
g_ptr_array_add(removed_views, GINT_TO_POINTER(info->view_id));
@@ -157,9 +154,8 @@
FlView* implicit_view = fl_view_new(project);
FlEngine* engine = fl_view_get_engine(implicit_view);
- FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
- embedder_api->RemoveView = MOCK_ENGINE_PROC(
+ fl_engine_get_embedder_api(engine)->RemoveView = MOCK_ENGINE_PROC(
RemoveView, ([](auto engine, const FlutterRemoveViewInfo* info) {
return kInvalidArguments;
}));
diff --git a/engine/src/flutter/shell/platform/linux/testing/fl_test.cc b/engine/src/flutter/shell/platform/linux/testing/fl_test.cc
index 6d0888f..3c0da2e 100644
--- a/engine/src/flutter/shell/platform/linux/testing/fl_test.cc
+++ b/engine/src/flutter/shell/platform/linux/testing/fl_test.cc
@@ -60,22 +60,6 @@
return g_string_free(hex_string, FALSE);
}
-FlEngine* make_mock_engine() {
- g_autoptr(FlDartProject) project = fl_dart_project_new();
- return make_mock_engine_with_project(project);
-}
-
-FlEngine* make_mock_engine_with_project(FlDartProject* project) {
- g_autoptr(FlMockRenderer) renderer = fl_mock_renderer_new();
- g_autoptr(FlEngine) engine =
- fl_engine_new_with_renderer(project, FL_RENDERER(renderer));
- g_autoptr(GError) engine_error = nullptr;
- EXPECT_TRUE(fl_engine_start(engine, &engine_error));
- EXPECT_EQ(engine_error, nullptr);
-
- return static_cast<FlEngine*>(g_object_ref(engine));
-}
-
void PrintTo(FlValue* v, std::ostream* os) {
g_autofree gchar* s = fl_value_to_string(v);
*os << s;
diff --git a/engine/src/flutter/shell/platform/linux/testing/fl_test.h b/engine/src/flutter/shell/platform/linux/testing/fl_test.h
index 51b4cb3..1092557 100644
--- a/engine/src/flutter/shell/platform/linux/testing/fl_test.h
+++ b/engine/src/flutter/shell/platform/linux/testing/fl_test.h
@@ -22,13 +22,6 @@
// Helper function to convert GBytes into a hexadecimal string (e.g. "01feab")
gchar* bytes_to_hex_string(GBytes* bytes);
-// Creates a mock engine that responds to platform messages.
-FlEngine* make_mock_engine();
-
-// Creates a mock engine using a specified FlDartProject that responds to
-// platform messages.
-FlEngine* make_mock_engine_with_project(FlDartProject* project);
-
// GTest printer for FlValue.
void PrintTo(FlValue* v, std::ostream* os);
diff --git a/engine/src/flutter/shell/platform/linux/testing/mock_engine.cc b/engine/src/flutter/shell/platform/linux/testing/mock_engine.cc
index b1806e8..b48435a 100644
--- a/engine/src/flutter/shell/platform/linux/testing/mock_engine.cc
+++ b/engine/src/flutter/shell/platform/linux/testing/mock_engine.cc
@@ -20,78 +20,8 @@
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
#include "gtest/gtest.h"
-const int32_t kFlutterSemanticsNodeIdBatchEnd = -1;
-const int32_t kFlutterSemanticsCustomActionIdBatchEnd = -1;
-
-struct _FlutterEngineTexture {
- bool has_new_frame;
-};
-
struct _FlutterEngine {
- bool running = false;
- FlutterPlatformMessageCallback platform_message_callback;
- FlutterTaskRunnerPostTaskCallback platform_post_task_callback;
- void* user_data;
- std::unordered_map<int64_t, _FlutterEngineTexture> textures;
-
- _FlutterEngine(FlutterPlatformMessageCallback platform_message_callback,
- FlutterTaskRunnerPostTaskCallback platform_post_task_callback,
- void* user_data)
- : platform_message_callback(platform_message_callback),
- platform_post_task_callback(platform_post_task_callback),
- user_data(user_data) {}
-};
-
-struct _FlutterPlatformMessageResponseHandle {
- FlutterDataCallback data_callback;
- void* user_data;
- std::string channel;
- bool released;
-
- // Constructor for a response handle generated by the engine.
- explicit _FlutterPlatformMessageResponseHandle(std::string channel)
- : data_callback(nullptr),
- user_data(nullptr),
- channel(std::move(channel)),
- released(false) {}
-
- // Constructor for a response handle generated by the shell.
- _FlutterPlatformMessageResponseHandle(FlutterDataCallback data_callback,
- void* user_data)
- : data_callback(data_callback), user_data(user_data), released(false) {}
-};
-
-struct _FlutterTaskRunner {
- uint64_t task;
- std::string channel;
- const FlutterPlatformMessageResponseHandle* response_handle;
- uint8_t* message;
- size_t message_size;
-
- _FlutterTaskRunner(
- uint64_t task,
- const std::string& channel,
- const FlutterPlatformMessageResponseHandle* response_handle,
- const uint8_t* message,
- size_t message_size)
- : task(task),
- channel(channel),
- response_handle(response_handle),
- message_size(message_size) {
- if (message_size > 0) {
- this->message = static_cast<uint8_t*>(malloc(message_size));
- memcpy(this->message, message, message_size);
- } else {
- this->message = nullptr;
- }
- }
- ~_FlutterTaskRunner() {
- if (response_handle != nullptr) {
- EXPECT_TRUE(response_handle->released);
- delete response_handle;
- }
- free(message);
- }
+ _FlutterEngine() {}
};
namespace {
@@ -99,7 +29,6 @@
FlutterEngineResult FlutterEngineCreateAOTData(
const FlutterEngineAOTDataSource* source,
FlutterEngineAOTData* data_out) {
- *data_out = nullptr;
return kSuccess;
}
@@ -113,29 +42,12 @@
void* user_data,
FLUTTER_API_SYMBOL(FlutterEngine) *
engine_out) {
- EXPECT_NE(config, nullptr);
-
- EXPECT_NE(args, nullptr);
- EXPECT_NE(args->platform_message_callback, nullptr);
- EXPECT_NE(args->custom_task_runners, nullptr);
- EXPECT_NE(args->custom_task_runners->platform_task_runner, nullptr);
- EXPECT_NE(args->custom_task_runners->platform_task_runner->post_task_callback,
- nullptr);
-
- EXPECT_NE(user_data, nullptr);
-
- EXPECT_EQ(config->type, kOpenGL);
-
- *engine_out = new _FlutterEngine(
- args->platform_message_callback,
- args->custom_task_runners->platform_task_runner->post_task_callback,
- user_data);
+ *engine_out = new _FlutterEngine();
return kSuccess;
}
FlutterEngineResult FlutterEngineRunInitialized(
FLUTTER_API_SYMBOL(FlutterEngine) engine) {
- engine->running = true;
return kSuccess;
}
@@ -145,17 +57,7 @@
void* user_data,
FLUTTER_API_SYMBOL(FlutterEngine) *
engine_out) {
- EXPECT_NE(config, nullptr);
- EXPECT_NE(args, nullptr);
- EXPECT_NE(user_data, nullptr);
- EXPECT_NE(engine_out, nullptr);
-
- FlutterEngineResult result =
- FlutterEngineInitialize(version, config, args, user_data, engine_out);
- if (result != kSuccess) {
- return result;
- }
- return FlutterEngineRunInitialized(*engine_out);
+ return kSuccess;
}
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine)
@@ -172,7 +74,6 @@
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
const FlutterWindowMetricsEvent* event) {
- EXPECT_TRUE(engine->running);
return kSuccess;
}
@@ -195,8 +96,6 @@
FlutterEngineResult FlutterEngineSendPlatformMessage(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
const FlutterPlatformMessage* message) {
- EXPECT_TRUE(engine->running);
-
return kSuccess;
}
@@ -205,28 +104,12 @@
FlutterDataCallback data_callback,
void* user_data,
FlutterPlatformMessageResponseHandle** response_out) {
- EXPECT_TRUE(engine->running);
- EXPECT_NE(data_callback, nullptr);
- EXPECT_NE(user_data, nullptr);
-
- _FlutterPlatformMessageResponseHandle* handle =
- new _FlutterPlatformMessageResponseHandle(data_callback, user_data);
-
- *response_out = handle;
return kSuccess;
}
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
FlutterPlatformMessageResponseHandle* response) {
- EXPECT_NE(engine, nullptr);
- EXPECT_NE(response, nullptr);
-
- EXPECT_TRUE(engine->running);
-
- EXPECT_FALSE(response->released);
- response->released = true;
-
return kSuccess;
}
@@ -235,48 +118,12 @@
const FlutterPlatformMessageResponseHandle* handle,
const uint8_t* data,
size_t data_length) {
- EXPECT_NE(engine, nullptr);
- EXPECT_NE(handle, nullptr);
-
- EXPECT_TRUE(engine->running);
-
- EXPECT_FALSE(handle->released);
-
- delete handle;
-
return kSuccess;
}
FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine)
engine,
const FlutterTask* task) {
- EXPECT_NE(engine, nullptr);
- EXPECT_NE(task, nullptr);
- EXPECT_NE(task->runner, nullptr);
-
- FlutterTaskRunner runner = task->runner;
- EXPECT_NE(runner, nullptr);
- const FlutterPlatformMessageResponseHandle* response_handle =
- runner->response_handle;
- if (response_handle != nullptr) {
- EXPECT_NE(response_handle->data_callback, nullptr);
- response_handle->data_callback(runner->message, runner->message_size,
- response_handle->user_data);
- } else {
- _FlutterPlatformMessageResponseHandle* handle =
- new _FlutterPlatformMessageResponseHandle(runner->channel);
-
- FlutterPlatformMessage message;
- message.struct_size = sizeof(FlutterPlatformMessage);
- message.channel = runner->channel.c_str();
- message.message = runner->message;
- message.message_size = runner->message_size;
- message.response_handle = handle;
- engine->platform_message_callback(&message, engine->user_data);
- }
-
- delete runner;
-
return kSuccess;
}
@@ -315,31 +162,18 @@
FlutterEngineResult FlutterEngineRegisterExternalTexture(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier) {
- _FlutterEngineTexture texture;
- texture.has_new_frame = false;
- engine->textures[texture_identifier] = texture;
return kSuccess;
}
FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier) {
- auto val = engine->textures.find(texture_identifier);
- if (val == std::end(engine->textures)) {
- return kInvalidArguments;
- }
- val->second.has_new_frame = true;
return kSuccess;
}
FlutterEngineResult FlutterEngineUnregisterExternalTexture(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier) {
- auto val = engine->textures.find(texture_identifier);
- if (val == std::end(engine->textures)) {
- return kInvalidArguments;
- }
- engine->textures.erase(texture_identifier);
return kSuccess;
}