From 27f8edb8b311de1fee9d9707fc461519a380d140 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 1 May 2025 09:50:42 +0200 Subject: ui: add more tests for ParticipantEditor --- ui/tests/participant_editor.cpp | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/tests/participant_editor.cpp b/ui/tests/participant_editor.cpp index 0d2ab13..b2398de 100644 --- a/ui/tests/participant_editor.cpp +++ b/ui/tests/participant_editor.cpp @@ -31,6 +31,7 @@ namespace turns::ui::tests auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); setlocale(LC_ALL, locale); + auto participant = core::Participant::create("Frederick Thumblewackle", 7.2, core::disposition::friendly); auto instance = std::make_shared(nullptr); auto window = Gtk::Window{}; @@ -59,6 +60,47 @@ namespace turns::ui::tests REQUIRE(instance->get_priority() == 0); } + SECTION("has neutral disposition") + { + REQUIRE(instance->get_disposition() == core::disposition::neutral); + } + + SECTION("has a null participant") + { + REQUIRE_FALSE(instance->get_participant()); + } + + WHEN("setting a new participant") + { + instance->set_participant(participant); + + THEN("getting the participant returns the new one") + { + REQUIRE(instance->get_participant() == participant); + } + + THEN("changes to the name propagate to the participant") + { + CHECK(participant->get_name() != "REPLACED"); + instance->set_name("REPLACED"); + REQUIRE(participant->get_name() == "REPLACED"); + } + + THEN("changes to the priority propagate to the participant") + { + CHECK(participant->get_priority() != 0); + instance->set_priority(0); + REQUIRE(participant->get_priority() == 0); + } + + THEN("changes to the disposition propagate to the participant") + { + CHECK(participant->get_disposition() != core::disposition::secret); + instance->set_disposition(core::disposition::secret); + REQUIRE(participant->get_disposition() == core::disposition::secret); + } + } + SECTION("allows binding to the finished signal") { REQUIRE((instance->signal_finished().connect([](auto, auto, auto) {})).connected()); @@ -105,4 +147,4 @@ namespace turns::ui::tests } } -} // namespace turns::ui::widgets::tests \ No newline at end of file +} // namespace turns::ui::tests \ No newline at end of file -- cgit v1.2.3