summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/CMakeLists.txt11
-rw-r--r--ui/tests/gtk_test_init.cpp37
2 files changed, 46 insertions, 2 deletions
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