Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for OptionButton #93824

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

wheatear-dev
Copy link
Contributor

Further to #43440, this PR contains unit tests for OptionButton in tests/scene/test_option_button.h.

  • Initialization:
    • no selectable items
    • 0 items in total
  • Single item (an icon):
    • (specified) id and index correspond to each other
    • 1 item in total (until removed, then 0)
    • there are selectable items (until removed, then false)
  • Multi-item structure
    • a mixture of 5 icons and items are created and added to the OptionButton
    • they are then steadily deleted and/or disabled, verifying the various properties until none remain

Additionally, an #include directive was added to tests/test_main.cpp, for this new file, to pick up the tests.

@wheatear-dev wheatear-dev force-pushed the test-option-button branch 2 times, most recently from 553ee02 to 9917ee9 Compare July 1, 2024 17:31
Copy link
Member

@Geometror Geometror left a comment

Choose a reason for hiding this comment

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

Looks good to me, I leave it up to you whether you want to implement my suggestions. We can always extend the test cases later.

TEST_CASE("[SceneTree][OptionButton] Complex structure") {
OptionButton *test_opt = memnew(OptionButton);

SUBCASE("Creating a complex structure and checking getters") {
Copy link
Member

Choose a reason for hiding this comment

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

You should add some checks for the item text getters as well.

In addtion, it would be nice if you could also add some checks for item tooltips.

@wheatear-dev
Copy link
Contributor Author

Hi @Geometror 👋

Thanks for the review. I request this is merged as is! 😅

My availability is going to be limited for a while.

Anyone else - please feel free to tag in after 😄

@wheatear-dev wheatear-dev changed the title Add unit tests for OptionButton Add unit tests for OptionButton Jul 18, 2024
@akien-mga akien-mga modified the milestones: 4.x, 4.4 Aug 27, 2024
@akien-mga akien-mga merged commit 8931177 into godotengine:master Aug 27, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@wheatear-dev wheatear-dev deleted the test-option-button branch August 28, 2024 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants