Add unit tests for BaseButton and ButtonGroup - #120994
PedroHOCostaa wants to merge 5 commits into
Conversation
|
Did you use AI to write any of the code or the PR description? Please see our contribution guidelines and this post |
| #include "tests/display_server_mock.h" | ||
|
|
||
| namespace TestButton { | ||
|
|
||
| // Tests related to `BaseButton` using `Button` as a concrete implementation. |
There was a problem hiding this comment.
Two reasons: to separate the following tests from the ButtonGroup tests, and because none of them are actually testing the mechanics of the Button class. All of them refer to the BaseButton class, but since BaseButton is an abstract class, I think it feels 'wrong' to instantiate it directly. Perhaps I could change the code so that the tests are separated by namespace.
There was a problem hiding this comment.
I think it's redundant and obvious from the code
There was a problem hiding this comment.
ok, will remove it along with other useless comments
I did use it for assistance in some parts, but not an agent like copilot, and I did in fact use it to create that description, it's for a It was for a university project. And the dead line was yesterday, I wanted to have this pull request created before submitting it. I will make it smaller and more precise (y). |
Thank you yes please do rewrite it yourself to make sure it is valid, and disclose how and where you used AI tools and if it generated any code |
BaseButton and ButtonGroup
Description
This Pull Request attends to issue #43440 implementing unit tests for
BaseButtonandButtonGroupclasses. These tests were developed using specification testing and then structural testing, using branch coverage and code analysis.Changes Covered by New Tests
BaseButtonCore Interaction & State Machineis_pressed()conditions and verified correct state behavior across both action modes (ACTION_MODE_BUTTON_PRESSvsACTION_MODE_BUTTON_RELEASE).pressedandtoggledsignals emit at precise, expected times.set_pressed_no_signal()updates the button state cleanly without triggering any signal listeners (and ensures it is ignored whentoggle_modeis off).get_draw_mode()(DRAW_NORMAL,DRAW_HOVER,DRAW_PRESSED,DRAW_HOVER_PRESSED, andDRAW_DISABLED).Input Gestures & System Notifications
InputEventScreenTouch,InputEventScreenDrag) along with mouse motion events to validate complex pointer interactions under varyingkeep_pressed_outsideconditions.NOTIFICATION_DRAG_BEGIN,NOTIFICATION_SCROLL_BEGIN, and focus loss (NOTIFICATION_FOCUS_EXIT).MouseButtonMask) and tested automatic trigger responses mapped viaShortcutassociations.ButtonGroupMechanics & Lifecycleallow_unpressproperty configuration.get_buttonsinternally and_get_buttonsexposed to GDScript).ButtonGroupwhen destroyed in memory.Core Files Involved
tests/scene/test_button.cpptests/scene/test_button.hResults of the coverage report in
base_button.cpp