Skip to content

Add tests for FlMouseCursorHandler - #188554

Merged
robert-ancell merged 4 commits into
flutter:masterfrom
robert-ancell:linux-mouse-cursor-handler-tests
Jun 26, 2026
Merged

robert-ancell merged 4 commits into
flutter:masterfrom
robert-ancell:linux-mouse-cursor-handler-tests

Conversation

@robert-ancell

Copy link
Copy Markdown
Contributor

Add unit tests covering cursor kind mapping, the fallback to the default cursor, the cursor-changed signal, and method call error handling for the mouse cursor handler.

Add unit tests covering cursor kind mapping, the fallback to the default
cursor, the cursor-changed signal, and method call error handling for the
mouse cursor handler.
An activateSystemCursor method call whose argument map omits the "kind"
key (or has a non-string value) passes a null kind to the handler, which
was passed straight to g_hash_table_lookup and crashed in g_str_hash.
Guard against a null kind and fall back to the default cursor.

Also guard the channel's fl_value_get_type lookup against a missing
"kind" key, which otherwise triggered a CRITICAL assertion warning.

Add a regression test covering a call with a missing kind.
@robert-ancell
robert-ancell requested a review from a team as a code owner June 25, 2026 06:17
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 25, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically a: desktop Running on desktop team-linux Owned by the Linux platform team labels Jun 25, 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 adds unit tests for FlMouseCursorHandler and introduces null checks in fl_mouse_cursor_channel.cc and fl_mouse_cursor_handler.cc to prevent potential crashes. The review feedback highlights a critical double-free or use-after-free issue in the new test file, where fl_value_set_string takes ownership of kind while it is also managed by g_autoptr. The reviewer suggests refactoring activate_system_cursor to accept a const gchar* and simplifying the test cases to resolve this issue.

mattkae
mattkae previously approved these changes Jun 25, 2026
The activate_system_cursor test helper took the cursor kind as an
FlValue*, requiring each caller to wrap a string in an FlValue. Take the
kind as a string and build the FlValue inside the helper, simplifying
the call sites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD engine flutter/engine related. See also e: labels. 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.

2 participants