Merge pull request #99632 from wheatear-dev/augment-tests-option-button

Augment unit tests for `OptionButton`
This commit is contained in:
Thaddeus Crews
2025-03-11 09:34:44 -05:00

View File

@ -82,7 +82,7 @@ TEST_CASE("[SceneTree][OptionButton] Single item") {
memdelete(test_opt); memdelete(test_opt);
} }
TEST_CASE("[SceneTree][OptionButton] Complex structure") { TEST_CASE("[SceneTree][OptionButton] Many items") {
OptionButton *test_opt = memnew(OptionButton); OptionButton *test_opt = memnew(OptionButton);
SUBCASE("Creating a complex structure and checking getters") { SUBCASE("Creating a complex structure and checking getters") {
@ -127,6 +127,31 @@ TEST_CASE("[SceneTree][OptionButton] Complex structure") {
CHECK(test_opt->get_item_count() == 1); CHECK(test_opt->get_item_count() == 1);
} }
SUBCASE("Getters and setters not related to structure") {
test_opt->add_item("regular", 2019);
Ref<Texture2D> test_icon = memnew(Texture2D);
test_opt->add_icon_item(test_icon, "icon", 3092);
// item_text.
test_opt->set_item_text(0, "example text");
CHECK(test_opt->get_item_text(0) == "example text");
// item_metadata.
Dictionary m;
m["bool"] = true;
m["String"] = "yes";
test_opt->set_item_metadata(1, m);
CHECK(test_opt->get_item_metadata(1) == m);
// item_tooltip.
test_opt->set_item_tooltip(0, "tooltip guide");
CHECK(test_opt->get_item_tooltip(0) == "tooltip guide");
test_opt->remove_item(1);
test_opt->remove_item(0);
}
memdelete(test_opt); memdelete(test_opt);
} }