summaryrefslogtreecommitdiff
path: root/gui/tests/participant_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/tests/participant_editor.cpp')
-rw-r--r--gui/tests/participant_editor.cpp118
1 files changed, 44 insertions, 74 deletions
diff --git a/gui/tests/participant_editor.cpp b/gui/tests/participant_editor.cpp
index 44b2ca4..3efa112 100644
--- a/gui/tests/participant_editor.cpp
+++ b/gui/tests/participant_editor.cpp
@@ -5,6 +5,7 @@
#include "participant_editor.hpp"
+#include "gtk-test.hpp"
#include "messages.hpp"
#include <turnsmm/participant.hpp>
@@ -14,6 +15,7 @@
#include <glib/gi18n.h>
+#include <adwaitamm/applicationwindow.hpp>
#include <adwaitamm/comborow.hpp>
#include <glibmm/i18n.h>
#include <glibmm/ustring.h>
@@ -34,6 +36,7 @@ namespace Turns::gui::tests
SCENARIO("Creating a participant editor", "[gui][windows][lifetime]")
{
+ auto window = Adwaita::ApplicationWindow{gtk_test::application};
auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8", "de_DE.UTF-8", "de_AT.UTF-8");
GIVEN(std::format("An active locale of {}", locale))
@@ -43,6 +46,7 @@ namespace Turns::gui::tests
AND_GIVEN("a participant editor constructed without a participant")
{
auto instance = ParticipantEditor{nullptr};
+ instance.present(&window);
THEN("its title is message::add_participant")
{
@@ -129,16 +133,50 @@ namespace Turns::gui::tests
REQUIRE(instance.get_participant() == participant);
}
- AND_WHEN("a new name is set on the participant")
+ THEN("changing the participant's name also changes the name in the editor")
{
- participant->set_name("Changed Name");
+ auto new_value = "Changed Name";
+ participant->set_name(new_value);
+ REQUIRE(instance.get_name() == new_value);
+ }
- THEN("the editor's name is equal to the new name")
- {
- REQUIRE(instance.get_name() == "Changed Name");
- }
+ THEN("changing the participant's disposition also changes the disposition in the editor")
+ {
+ auto new_value = Participant::Disposition::Hostile;
+ participant->set_disposition(new_value);
+ REQUIRE(instance.get_disposition() == new_value);
+ }
+
+ THEN("changing the participant's priority also changes the priority in the editor")
+ {
+ auto new_value = -10.0f;
+ participant->set_priority(new_value);
+ REQUIRE(instance.get_priority() == new_value);
+ }
+
+ THEN("changing the name in the editor also changes the participant's name")
+ {
+ auto new_value = "Editor Changed Name";
+ instance.set_name(new_value);
+ REQUIRE(participant->get_name() == new_value);
+ }
+
+ THEN("changing the disposition in the editor also changes the participant's disposition")
+ {
+ auto new_value = Participant::Disposition::Secret;
+ instance.set_disposition(new_value);
+ REQUIRE(participant->get_disposition() == new_value);
+ }
+
+ THEN("changing the priority in the editor also changes the participant's priority")
+ {
+ auto new_value = 100.0f;
+ instance.set_priority(new_value);
+ REQUIRE(participant->get_priority() == new_value);
}
}
+
+ instance.close();
}
}
}
@@ -147,76 +185,8 @@ namespace Turns::gui::tests
// auto instance = std::make_shared<ParticipantEditor>(nullptr);
// auto window = Gtk::Window{};
- // WHEN("setting a new participant")
- // {
- // instance->set_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());
// }
// }
-
- // TEST_CASE("A freshly constructed participant editor with a participant", "[windows]")
- // {
- // auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8");
- // setlocale(LC_ALL, locale);
-
- // auto participant = core::Participant::create("Qibi Babblebranch", 12, core::Disposition::Neutral);
- // auto instance = std::make_shared<ParticipantEditor>(participant);
- // auto window = Gtk::Window{};
-
- // SECTION("was successfully constructed")
- // {
- // REQUIRE(instance);
- // }
-
- // SECTION("has a non-empty title")
- // {
- // REQUIRE_FALSE(instance->get_title().empty());
- // }
-
- // SECTION("has its title set according to the active language")
- // {
- // REQUIRE(instance->get_title() == _(lang::edit_participant));
- // }
-
- // SECTION("has its name field set according to its participant")
- // {
- // REQUIRE(instance->get_name() == participant->property_name().get_value());
- // }
-
- // SECTION("has its priority field set according to its participant")
- // {
- // REQUIRE(instance->get_priority() == participant->property_priority());
- // }
-
- // SECTION("allows binding to the finished signal")
- // {
- // REQUIRE((instance->signal_finished().connect([](auto, auto, auto) {})).connected());
- // }
- // }
-
-} // namespace Turns::gui::tests \ No newline at end of file