Procházet zdrojové kódy

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

Augment unit tests for `OptionButton`
Thaddeus Crews před 4 měsíci
rodič
revize
75f131e047
1 změnil soubory, kde provedl 26 přidání a 1 odebrání
  1. 26 1
      tests/scene/test_option_button.h

+ 26 - 1
tests/scene/test_option_button.h

@@ -82,7 +82,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") {
@@ -127,6 +127,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<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);
 }