From 3ff5bd46952144926d9bd9beedf50023a51913ee Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 29 Apr 2025 16:33:32 +0200 Subject: ui: flatten namespace hierarchy --- ui/tests/participant_editor.cpp | 108 ++++++++++++++++++++++++++++++++ ui/tests/participant_row.cpp | 30 +++++++++ ui/tests/resources.cpp | 14 +++++ ui/tests/tracker.cpp | 77 +++++++++++++++++++++++ ui/tests/widgets/participant_editor.cpp | 108 -------------------------------- ui/tests/widgets/participant_row.cpp | 30 --------- ui/tests/windows/resources.cpp | 14 ----- ui/tests/windows/tracker.cpp | 77 ----------------------- 8 files changed, 229 insertions(+), 229 deletions(-) create mode 100644 ui/tests/participant_editor.cpp create mode 100644 ui/tests/participant_row.cpp create mode 100644 ui/tests/resources.cpp create mode 100644 ui/tests/tracker.cpp delete mode 100644 ui/tests/widgets/participant_editor.cpp delete mode 100644 ui/tests/widgets/participant_row.cpp delete mode 100644 ui/tests/windows/resources.cpp delete mode 100644 ui/tests/windows/tracker.cpp (limited to 'ui/tests') diff --git a/ui/tests/participant_editor.cpp b/ui/tests/participant_editor.cpp new file mode 100644 index 0000000..d222598 --- /dev/null +++ b/ui/tests/participant_editor.cpp @@ -0,0 +1,108 @@ +#include "turns/ui/participant_editor.hpp" + +#include "turns/core/disposition.hpp" +#include "turns/core/participant.hpp" +#include "turns/lang/messages.hpp" + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include + +namespace turns::ui::tests +{ + + TEST_CASE("A freshly constructed participant editor without a participant", "[windows]") + { + auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); + setlocale(LC_ALL, locale); + + auto instance = std::make_shared(nullptr); + 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::add_participant)); + } + + SECTION("has an empty name") + { + REQUIRE(instance->get_name().empty()); + } + + SECTION("has a zero priority") + { + REQUIRE(instance->get_priority() == 0); + } + + 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(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::ui::widgets::tests \ No newline at end of file diff --git a/ui/tests/participant_row.cpp b/ui/tests/participant_row.cpp new file mode 100644 index 0000000..5d89c42 --- /dev/null +++ b/ui/tests/participant_row.cpp @@ -0,0 +1,30 @@ +#include "turns/ui/participant_row.hpp" + +#include "turns/core/disposition.hpp" +#include "turns/core/participant.hpp" + +#include + +#include + +#include + +#include + +namespace turns::ui::tests +{ + + TEST_CASE("A freshly constructed participant row") + { + SECTION("can be created without a participant") + { + REQUIRE(std::make_shared(Glib::RefPtr{})); + } + + SECTION("can be created with a participant") + { + REQUIRE(std::make_shared(core::participant::create("Tazmyla Fireforge", 13, core::disposition::secret))); + } + } + +} // namespace turns::ui::widgets::tests \ No newline at end of file diff --git a/ui/tests/resources.cpp b/ui/tests/resources.cpp new file mode 100644 index 0000000..07c026a --- /dev/null +++ b/ui/tests/resources.cpp @@ -0,0 +1,14 @@ +#include + +#include +#include + +TEST_CASE("GResource for tracker") +{ + auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/tracker.ui"); + + SECTION("can create Gtk.Builder for the tracker window UI definition") + { + REQUIRE(builder); + } +} diff --git a/ui/tests/tracker.cpp b/ui/tests/tracker.cpp new file mode 100644 index 0000000..4065a6b --- /dev/null +++ b/ui/tests/tracker.cpp @@ -0,0 +1,77 @@ +#include "turns/ui/tracker.hpp" + +#include "turns/core/settings.hpp" +#include "turns/lang/messages.hpp" + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include + +namespace turns::ui::tests +{ + + TEST_CASE("A freshly constructed tracker window", "[windows]") + { + auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); + setlocale(LC_ALL, locale); + + auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/tracker.ui"); + auto instance = Gtk::Builder::get_widget_derived(builder, "tracker", core::get_settings()); + + SECTION("was successfully constructed") + { + REQUIRE(instance); + } + + SECTION("has a non-empty subtitle") + { + auto widget = builder->get_widget("title"); + REQUIRE_FALSE(widget->get_subtitle().empty()); + } + + SECTION("has its subtitle set according to the active language") + { + auto widget = builder->get_widget("title"); + REQUIRE(widget->get_subtitle() == _(lang::no_active_turn_order)); + } + + SECTION("has a non-empty title") + { + auto widget = builder->get_widget("title"); + REQUIRE_FALSE(widget->get_title().empty()); + } + + SECTION("has its title set according to the active language") + { + auto widget = builder->get_widget("title"); + REQUIRE(widget->get_title() == _(lang::turns)); + } + + SECTION("has its add_participant button's tooltip set according to the active language") + { + auto widget = builder->get_widget("add_participant"); + REQUIRE(widget->get_tooltip_text() == _(lang::add_participant)); + } + + SECTION("as its open_main_menu button's tooltip set according to the active language") + { + auto widget = builder->get_widget("open_main_menu"); + REQUIRE(widget->get_tooltip_text() == _(lang::main_menu)); + } + + instance->destroy(); + delete instance; + } + +} // namespace turns::ui::tests \ No newline at end of file diff --git a/ui/tests/widgets/participant_editor.cpp b/ui/tests/widgets/participant_editor.cpp deleted file mode 100644 index 41ba5bd..0000000 --- a/ui/tests/widgets/participant_editor.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "turns/ui/widgets/participant_editor.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" -#include "turns/lang/messages.hpp" - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -namespace turns::ui::widgets::tests -{ - - TEST_CASE("A freshly constructed participant editor without a participant", "[windows]") - { - auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); - setlocale(LC_ALL, locale); - - auto instance = std::make_shared(nullptr); - 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::add_participant)); - } - - SECTION("has an empty name") - { - REQUIRE(instance->get_name().empty()); - } - - SECTION("has a zero priority") - { - REQUIRE(instance->get_priority() == 0); - } - - 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(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::ui::widgets::tests \ No newline at end of file diff --git a/ui/tests/widgets/participant_row.cpp b/ui/tests/widgets/participant_row.cpp deleted file mode 100644 index 491dcc8..0000000 --- a/ui/tests/widgets/participant_row.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "turns/ui/widgets/participant_row.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" - -#include - -#include - -#include - -#include - -namespace turns::ui::widgets::tests -{ - - TEST_CASE("A freshly constructed participant row") - { - SECTION("can be created without a participant") - { - REQUIRE(std::make_shared(Glib::RefPtr{})); - } - - SECTION("can be created with a participant") - { - REQUIRE(std::make_shared(core::participant::create("Tazmyla Fireforge", 13, core::disposition::secret))); - } - } - -} // namespace turns::ui::widgets::tests \ No newline at end of file diff --git a/ui/tests/windows/resources.cpp b/ui/tests/windows/resources.cpp deleted file mode 100644 index 022f3c4..0000000 --- a/ui/tests/windows/resources.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#include -#include - -TEST_CASE("GResource for tracker") -{ - auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/windows/tracker.ui"); - - SECTION("can create Gtk.Builder for the tracker window UI definition") - { - REQUIRE(builder); - } -} diff --git a/ui/tests/windows/tracker.cpp b/ui/tests/windows/tracker.cpp deleted file mode 100644 index 0f79000..0000000 --- a/ui/tests/windows/tracker.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "turns/ui/windows/tracker.hpp" - -#include "turns/core/settings.hpp" -#include "turns/lang/messages.hpp" - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace turns::ui::windows::tests -{ - - TEST_CASE("A freshly constructed tracker window", "[windows]") - { - auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); - setlocale(LC_ALL, locale); - - auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/windows/tracker.ui"); - auto instance = Gtk::Builder::get_widget_derived(builder, "tracker", core::get_settings()); - - SECTION("was successfully constructed") - { - REQUIRE(instance); - } - - SECTION("has a non-empty subtitle") - { - auto widget = builder->get_widget("title"); - REQUIRE_FALSE(widget->get_subtitle().empty()); - } - - SECTION("has its subtitle set according to the active language") - { - auto widget = builder->get_widget("title"); - REQUIRE(widget->get_subtitle() == _(lang::no_active_turn_order)); - } - - SECTION("has a non-empty title") - { - auto widget = builder->get_widget("title"); - REQUIRE_FALSE(widget->get_title().empty()); - } - - SECTION("has its title set according to the active language") - { - auto widget = builder->get_widget("title"); - REQUIRE(widget->get_title() == _(lang::turns)); - } - - SECTION("has its add_participant button's tooltip set according to the active language") - { - auto widget = builder->get_widget("add_participant"); - REQUIRE(widget->get_tooltip_text() == _(lang::add_participant)); - } - - SECTION("as its open_main_menu button's tooltip set according to the active language") - { - auto widget = builder->get_widget("open_main_menu"); - REQUIRE(widget->get_tooltip_text() == _(lang::main_menu)); - } - - instance->destroy(); - delete instance; - } - -} // namespace turns::ui::windows::tests \ No newline at end of file -- cgit v1.2.3