diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-05-29 12:31:54 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-05-29 12:31:54 +0200 |
| commit | 4e555fdbda6b9f5ea6c3dc29e16b992a0fe6e556 (patch) | |
| tree | 4cc00cfab080091d4336d7a70b389b451bb73168 | |
| parent | 0a41b826c16a5a0a079c308118ffcf7926df1f45 (diff) | |
| download | turns-4e555fdbda6b9f5ea6c3dc29e16b992a0fe6e556.tar.xz turns-4e555fdbda6b9f5ea6c3dc29e16b992a0fe6e556.zip | |
gui: reintroduce basic testing skeleton
| -rw-r--r-- | .clang-format | 20 | ||||
| -rw-r--r-- | gui/CMakeLists.txt | 33 | ||||
| -rw-r--r-- | gui/src/main.cpp | 4 | ||||
| -rw-r--r-- | gui/tests/gtk-test.cpp (renamed from gui/tests/gtk_test_init.cpp) | 18 | ||||
| -rw-r--r-- | gui/tests/intl_test_init.cpp | 31 |
5 files changed, 45 insertions, 61 deletions
diff --git a/.clang-format b/.clang-format index 187d49c..4301842 100644 --- a/.clang-format +++ b/.clang-format @@ -67,34 +67,34 @@ IncludeBlocks: Regroup IncludeCategories: # Local Headers - Regex: '^"[[:alnum:]_/\-]+\.h(pp)?' - Priority: 200 + Priority: 100 # Catch2 Headers - Regex: '^<catch2/[[:alnum:]_/]+\.hpp' - Priority: 300 + Priority: 200 # sigc++ Headers - Regex: '^<sigc\+\+/[[:alnum:]_/]+\.h(pp)?' - Priority: 340 + Priority: 300 # Glibmm Headers - Regex: '^<glibmm/[[:alnum:]_/]+\.h(pp)?' - Priority: 350 + Priority: 300 # Giomm Headers - Regex: '^<giomm/[[:alnum:]_/]+\.h(pp)?' - Priority: 360 + Priority: 300 # Gdkmm Headers - Regex: '^<gdkmm/[[:alnum:]_/]+\.h(pp)?' - Priority: 365 + Priority: 300 # Gtkmm Headers - Regex: '^<gtkmm/[[:alnum:]_/]+\.h(pp)?' - Priority: 370 + Priority: 300 # Adwaitamm Headers - Regex: '^<adwaitamm/[[:alnum:]_/]+\.hpp?' - Priority: 380 + Priority: 400 # General System Headers - Regex: '^<[[:alnum:]/+-_]+\.h(pp)?' - Priority: 400 + Priority: 500 # STL Headers - Regex: '^<[[:alnum:]_]+>' - Priority: 500 + Priority: 600 IndentCaseLabels: false diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 3753979..928ff1a 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -74,8 +74,17 @@ target_include_directories("gui_impl" PUBLIC target_link_libraries("gui_impl" PUBLIC "resources" + "adwaitamm::adwaitamm" + "turns::mm" + + "PkgConfig::glib" + "PkgConfig::glibmm" + + "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>" + "resources" + "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>" ) target_compile_definitions("gui_impl" PUBLIC @@ -100,15 +109,6 @@ target_include_directories("gui" PUBLIC target_link_libraries("gui" PUBLIC "gui_impl" - - "adwaitamm::adwaitamm" - "PkgConfig::glib" - "PkgConfig::glibmm" - "turns::mm" - - "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>" - "resources" - "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>" ) set_target_properties("gui" PROPERTIES @@ -139,3 +139,18 @@ install(FILES ) install(TARGETS "gui") + +# Tests + +add_executable("gui-tests" + "tests/gtk-test.cpp" +) + +target_link_libraries("gui-tests" PRIVATE + "gui_impl" + "Catch2::Catch2WithMain" +) + +target_compile_definitions("resources" PUBLIC + "TESTLOCALEDIR=\"${CMAKE_CURRENT_BINARY_DIR}/locale>\"" +)
\ No newline at end of file diff --git a/gui/src/main.cpp b/gui/src/main.cpp index 8c20b31..c8830bf 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -3,7 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -#include "settings.hpp" +#include "turnsmm/init.hpp" #include <giomm/application.h> @@ -22,7 +22,7 @@ auto main(int argc, char ** argv) -> int auto app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::HANDLES_OPEN); - [[maybe_unused]] auto settings = Turns::gui::get_settings(); + Turns::init(); return app->run(argc, argv); } diff --git a/gui/tests/gtk_test_init.cpp b/gui/tests/gtk-test.cpp index fdefa74..4eea74a 100644 --- a/gui/tests/gtk_test_init.cpp +++ b/gui/tests/gtk-test.cpp @@ -3,14 +3,13 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -#include "turns/core/init.hpp" -#include "turns/ui/init.hpp" +#include "turnsmm/init.hpp" #include <catch2/reporters/catch_reporter_event_listener.hpp> #include <catch2/reporters/catch_reporter_registrars.hpp> #include <glibmm/i18n.h> - +#include <glibmm/refptr.h> #include <gtkmm/init.h> #include <adwaitamm/application.hpp> @@ -23,7 +22,7 @@ namespace turns::ui::tests { - struct gtk_test_init : Catch::EventListenerBase + struct gtk_test : Catch::EventListenerBase { using Catch::EventListenerBase::EventListenerBase; @@ -34,13 +33,14 @@ namespace turns::ui::tests bind_textdomain_codeset("turns", "UTF-8"); textdomain("turns"); - [[maybe_unused]] auto app = Adwaita::Application::create("ch.arknet.turns.tests.ui"); - - core::register_types(); - ui::register_types(); + m_app = Adwaita::Application::create("ch.arknet.turns.tests.ui"); + Turns::init(); } + + private: + Glib::RefPtr<Adwaita::Application> m_app{}; }; - CATCH_REGISTER_LISTENER(gtk_test_init); + CATCH_REGISTER_LISTENER(gtk_test); } // namespace turns::ui::tests
\ No newline at end of file diff --git a/gui/tests/intl_test_init.cpp b/gui/tests/intl_test_init.cpp deleted file mode 100644 index e7b7c0f..0000000 --- a/gui/tests/intl_test_init.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> - * SPDX-License-Identifier: LGPL-2.1-only - */ - -#include <catch2/reporters/catch_reporter_event_listener.hpp> -#include <catch2/reporters/catch_reporter_registrars.hpp> - -#include <libintl.h> - -#include <clocale> - -namespace turns::lang::tests -{ - - struct intl_test_init : Catch::EventListenerBase - { - using Catch::EventListenerBase::EventListenerBase; - - auto testRunStarting(Catch::TestRunInfo const &) -> void override - { - setlocale(LC_ALL, ""); - bindtextdomain("turns", TESTLOCALEDIR); - bind_textdomain_codeset("turns", "UTF-8"); - textdomain("turns"); - } - }; - - CATCH_REGISTER_LISTENER(intl_test_init); - -} // namespace turns::lang::tests
\ No newline at end of file |
