From fe416c80464d9c89ec73659768585adceea3dc19 Mon Sep 17 00:00:00 2001 From: Edward Moulsdale Date: Sun, 24 Nov 2024 16:23:50 +0000 Subject: [PATCH] Augment unit tests for OptionButton --- tests/scene/test_option_button.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/scene/test_option_button.h b/tests/scene/test_option_button.h index 56c1c7d6112..192ee946662 100644 --- a/tests/scene/test_option_button.h +++ b/tests/scene/test_option_button.h @@ -83,7 +83,7 @@ TEST_CASE("[SceneTree][OptionButton] Single item") { memdelete(test_opt); } -TEST_CASE("[SceneTree][OptionButton] Complex structure") { +TEST_CASE("[SceneTree][OptionButton] Many items") { OptionButton *test_opt = memnew(OptionButton); SUBCASE("Creating a complex structure and checking getters") { @@ -128,6 +128,31 @@ TEST_CASE("[SceneTree][OptionButton] Complex structure") { CHECK(test_opt->get_item_count() == 1); } + SUBCASE("Getters and setters not related to structure") { + test_opt->add_item("regular", 2019); + + Ref 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); }