diff options
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | core/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | core/tests/glib_test_init.cpp | 28 | ||||
| -rw-r--r-- | core/tests/register_types.cpp | 13 | ||||
| -rw-r--r-- | lang/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | lang/tests/intl_test_init.cpp | 24 | ||||
| -rw-r--r-- | test_support/CMakeLists.txt | 66 | ||||
| -rw-r--r-- | test_support/src/glib_main.cpp | 20 | ||||
| -rw-r--r-- | test_support/src/gtk_main.cpp | 18 | ||||
| -rw-r--r-- | test_support/src/intl_main.cpp | 13 | ||||
| -rw-r--r-- | ui/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | ui/tests/gtk_test_init.cpp | 37 |
12 files changed, 109 insertions, 138 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 37c5081..c44e270 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,6 @@ add_subdirectory("app") add_subdirectory("core") add_subdirectory("lang") add_subdirectory("style") -add_subdirectory("test_support") add_subdirectory("ui") # License diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 245c7f7..034c759 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -30,7 +30,7 @@ enable_coverage("core") # Tests add_executable("core-tests" - "tests/register_types.cpp" + "tests/glib_test_init.cpp" "tests/disposition.cpp" "tests/participant.cpp" @@ -39,10 +39,9 @@ add_executable("core-tests" ) target_link_libraries("core-tests" PRIVATE - "Catch2::Catch2" + "Catch2::Catch2WithMain" "turns::core" - "turns::glib-test-main" ) target_link_options("core-tests" PRIVATE diff --git a/core/tests/glib_test_init.cpp b/core/tests/glib_test_init.cpp new file mode 100644 index 0000000..b521189 --- /dev/null +++ b/core/tests/glib_test_init.cpp @@ -0,0 +1,28 @@ +#include "turns/core/init.hpp" + +#include <catch2/reporters/catch_reporter_event_listener.hpp> +#include <catch2/reporters/catch_reporter_registrars.hpp> + +#include <glibmm/init.h> + +#include <giomm/init.h> + +namespace turns::core::tests +{ + + struct glib_test_init : Catch::EventListenerBase + { + using Catch::EventListenerBase::EventListenerBase; + + auto testRunStarting(Catch::TestRunInfo const &) -> void override + { + Gio::init(); + Glib::init(); + + register_types(); + } + }; + + CATCH_REGISTER_LISTENER(glib_test_init); + +} // namespace turns::core::tests
\ No newline at end of file diff --git a/core/tests/register_types.cpp b/core/tests/register_types.cpp deleted file mode 100644 index 2ad0628..0000000 --- a/core/tests/register_types.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "turns/core/participant.hpp" -#include "turns/core/turn_order.hpp" - -namespace turns::tests -{ - - auto register_types() -> void - { - static_cast<void>(core::participant{}); - static_cast<void>(core::turn_order{}); - } - -} // namespace turns::tests
\ No newline at end of file diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index 303abfe..1842615 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -52,13 +52,20 @@ add_dependencies("lang" "mofiles") # Tests add_executable("lang-tests" + "tests/intl_test_init.cpp" + "tests/messages.cpp" ) target_link_libraries("lang-tests" PRIVATE - "Catch2::Catch2" + "Catch2::Catch2WithMain" + "Intl::Intl" - "turns::intl-test-main" + "turns::lang" +) + +target_compile_definitions("lang-tests" PRIVATE + "TESTLOCALEDIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" ) enable_coverage("lang-tests") diff --git a/lang/tests/intl_test_init.cpp b/lang/tests/intl_test_init.cpp new file mode 100644 index 0000000..6a79040 --- /dev/null +++ b/lang/tests/intl_test_init.cpp @@ -0,0 +1,24 @@ +#include <catch2/reporters/catch_reporter_event_listener.hpp> +#include <catch2/reporters/catch_reporter_registrars.hpp> + +#include <libintl.h> + +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 diff --git a/test_support/CMakeLists.txt b/test_support/CMakeLists.txt deleted file mode 100644 index 447032d..0000000 --- a/test_support/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -get_target_property(TRANSLATIONS_BINARY_DIR "lang" BINARY_DIR) - -# Glib test support - -add_library("test_support-glib" OBJECT - "src/glib_main.cpp" -) - -add_library("turns::glib-test-main" ALIAS "test_support-glib") - -target_compile_features("test_support-glib" PRIVATE - "cxx_std_23" -) - -target_compile_definitions("test_support-glib" PUBLIC - "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\"" -) - -target_link_libraries("test_support-glib" PUBLIC - "PkgConfig::glibmm" - "PkgConfig::giomm" -) - -# GTK test support - -add_library("test_support-gtk" OBJECT - "src/gtk_main.cpp" -) - -add_library("turns::gtk-test-main" ALIAS "test_support-gtk") - -target_compile_features("test_support-gtk" PRIVATE - "cxx_std_23" -) - -target_compile_definitions("test_support-gtk" PUBLIC - "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\"" -) - -target_link_libraries("test_support-gtk" PUBLIC - "turns::lang" - - "PkgConfig::adwaita" - "PkgConfig::gtkmm" -) - -# Intl test support - -add_library("test_support-intl" OBJECT - "src/intl_main.cpp" -) - -add_library("turns::intl-test-main" ALIAS "test_support-intl") - -target_compile_features("test_support-intl" PRIVATE - "cxx_std_23" -) - -target_compile_definitions("test_support-intl" PUBLIC - "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\"" -) - -target_link_libraries("test_support-intl" PUBLIC - "Intl::Intl" - "turns::lang" -) diff --git a/test_support/src/glib_main.cpp b/test_support/src/glib_main.cpp deleted file mode 100644 index c2fe10f..0000000 --- a/test_support/src/glib_main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <catch2/catch_session.hpp> - -#include <glibmm/init.h> - -#include <giomm/init.h> - -namespace turns::tests -{ - auto register_types() -> void; -} // namespace turns::tests - -auto main(int argc, char * argv[]) -> int -{ - Gio::init(); - Glib::init(); - - turns::tests::register_types(); - - return Catch::Session().run(argc, argv); -}
\ No newline at end of file diff --git a/test_support/src/gtk_main.cpp b/test_support/src/gtk_main.cpp deleted file mode 100644 index 4656c12..0000000 --- a/test_support/src/gtk_main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include <catch2/catch_session.hpp> - -#include <gtkmm/init.h> - -#include <adwaita.h> - -auto main(int argc, char * argv[]) -> int -{ - setlocale(LC_ALL, ""); - bindtextdomain("turns", TESTLOCALEDIR); - bind_textdomain_codeset("turns", "UTF-8"); - textdomain("turns"); - - Gtk::init_gtkmm_internals(); - adw_init(); - - return Catch::Session().run(argc, argv); -}
\ No newline at end of file diff --git a/test_support/src/intl_main.cpp b/test_support/src/intl_main.cpp deleted file mode 100644 index 4a74ac5..0000000 --- a/test_support/src/intl_main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include <catch2/catch_session.hpp> - -#include <libintl.h> - -auto main(int argc, char * argv[]) -> int -{ - setlocale(LC_ALL, ""); - bindtextdomain("turns", TESTLOCALEDIR); - bind_textdomain_codeset("turns", "UTF-8"); - textdomain("turns"); - - return Catch::Session().run(argc, argv); -}
\ No newline at end of file diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 2532059..fa4bc02 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -38,20 +38,27 @@ add_subdirectory("res") # Tests +get_target_property(TRANSLATIONS_BINARY_DIR "lang" BINARY_DIR) + add_executable("ui-tests" + "tests/gtk_test_init.cpp" + "tests/widgets/participant_row.cpp" "tests/windows/participant_editor.cpp" "tests/windows/resources.cpp" "tests/windows/tracker.cpp" ) +target_compile_definitions("ui-tests" PUBLIC + "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\"" +) + target_link_libraries("ui-tests" PRIVATE - "Catch2::Catch2" + "Catch2::Catch2WithMain" "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>" "turns::ui" "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>" - "turns::gtk-test-main" ) target_link_options("ui-tests" PRIVATE diff --git a/ui/tests/gtk_test_init.cpp b/ui/tests/gtk_test_init.cpp new file mode 100644 index 0000000..734de2f --- /dev/null +++ b/ui/tests/gtk_test_init.cpp @@ -0,0 +1,37 @@ +#include "turns/core/init.hpp" +#include "turns/ui/init.hpp" + +#include <catch2/reporters/catch_reporter_event_listener.hpp> +#include <catch2/reporters/catch_reporter_registrars.hpp> + +#include <glibmm/i18n.h> + +#include <gtkmm/init.h> + +#include <adwaita.h> + +namespace turns::ui::tests +{ + + struct gtk_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"); + + Gtk::init_gtkmm_internals(); + adw_init(); + + core::register_types(); + ui::register_types(); + } + }; + + CATCH_REGISTER_LISTENER(gtk_test_init); + +} // namespace turns::ui::tests
\ No newline at end of file |
