Skip to content

[Linux] Use fixture tests in remaining unit tests#188142

Merged
robert-ancell merged 20 commits into
flutter:masterfrom
robert-ancell:linux-test-fixtures
Jun 25, 2026
Merged

[Linux] Use fixture tests in remaining unit tests#188142
robert-ancell merged 20 commits into
flutter:masterfrom
robert-ancell:linux-test-fixtures

Conversation

@robert-ancell

@robert-ancell robert-ancell commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Refactor the Linux embedder C++ unit tests to use GoogleTest fixture classes (TEST_F) instead of repeating object setup boilerplate in each TEST. Common setup (engine, project, mock binary messenger, mock GTK/ epoxy, settings portal, etc.) is moved into fixture SetUp()/destructors.

Also rename the misplaced FlValue tests that were under the FlDartProjectTest suite to FlValueTest to avoid a suite-name clash with the new fixture.

@robert-ancell
robert-ancell requested a review from a team as a code owner June 18, 2026 01:27
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 18, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. platform-linux Building on or for Linux specifically a: desktop Running on desktop team-linux Owned by the Linux platform team labels Jun 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors numerous Linux platform test files by migrating standalone TEST cases to TEST_F fixture-based tests, consolidating common setup and teardown logic. The review feedback identifies a recurring issue across several new test fixtures where member pointers are not initialized to nullptr. If an assertion fails during SetUp(), the destructors will attempt to unreference these uninitialized pointers, potentially causing segmentation faults and crashing the test runner. To prevent this, all member pointers in the test fixtures should be initialized to nullptr and safely checked before being unreferenced.

Comment thread engine/src/flutter/shell/platform/linux/fl_accessibility_handler_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_key_channel_responder_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_settings_portal_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_binary_messenger_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_view_test.cc Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 18, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 18, 2026
Refactor the Linux embedder C++ unit tests to use GoogleTest fixture
classes (TEST_F) instead of repeating object setup boilerplate in each
TEST. Common setup (engine, project, mock binary messenger, mock GTK/
epoxy, settings portal, etc.) is moved into fixture SetUp()/destructors.

Also rename the misplaced FlValue tests that were under the
FlDartProjectTest suite to FlValueTest to avoid a suite-name clash with
the new fixture.
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 18, 2026
@robert-ancell robert-ancell added the CICD Run CI/CD label Jun 18, 2026
@robert-ancell

Copy link
Copy Markdown
Contributor Author

/gemini review

@robert-ancell
robert-ancell requested a review from mattkae June 18, 2026 01:56

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Linux platform unit tests by introducing GTest test fixtures across multiple test files, centralizing common setup and teardown operations such as engine initialization and messenger creation. The review feedback suggests further simplifying these test fixtures by removing the redundant engine parameter from the StartEngine helper methods, as well as moving fl_binary_messenger_shutdown calls into the destructors of the respective fixtures to eliminate repetitive cleanup boilerplate.

Comment thread engine/src/flutter/shell/platform/linux/fl_accessible_text_field_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_binary_messenger_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_key_embedder_responder_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_pointer_manager_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_scrolling_manager_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_settings_handler_test.cc
mattkae
mattkae previously approved these changes Jun 18, 2026

@mattkae mattkae left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please 🙏

@mattkae
mattkae added this pull request to the merge queue Jun 18, 2026
@mattkae
mattkae removed this pull request from the merge queue due to a manual request Jun 18, 2026
@mattkae

mattkae commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

I will let you consider Gemini's feedback :)

Move the fl_binary_messenger_shutdown calls from individual tests into
the fixture destructor for the four test fixtures that hold a messenger
member, removing the repeated per-test calls.
Move the view created in every FlAccessibilityHandlerTest test, and the
platform handler created in the FlPlatformHandlerTest tests, into their
fixture SetUp so they are created once rather than in each test.
In fixtures where the engine is a member, StartEngine always used the
fixture engine, so drop the argument and use the member directly.
Move the task runner, OpenGL manager, renderable and compositor that
were created identically in every test into the fixture SetUp.
Move the task runner and compositor that were created identically in
every test into the fixture SetUp.
@robert-ancell robert-ancell added CICD Run CI/CD and removed CICD Run CI/CD labels Jun 23, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 24, 2026
@loic-sharma loic-sharma added the CICD Run CI/CD label Jun 24, 2026
mattkae
mattkae previously approved these changes Jun 24, 2026
StartEngine() now defaults to starting the fixture's engine member when
no engine is given, so most tests no longer need to pass it explicitly.
Tests that start a different engine (e.g. a view-owned engine) still pass
it.
@robert-ancell robert-ancell added the CICD Run CI/CD label Jun 24, 2026
@robert-ancell
robert-ancell added this pull request to the merge queue Jun 25, 2026
Merged via the queue into flutter:master with commit 38c2dab Jun 25, 2026
202 checks passed
@robert-ancell
robert-ancell deleted the linux-test-fixtures branch June 25, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD engine flutter/engine related. See also e: labels. f: scrolling Viewports, list views, slivers, etc. platform-linux Building on or for Linux specifically team-linux Owned by the Linux platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants