diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-06-08 14:53:13 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-06-08 14:53:13 +0200 |
| commit | 63aa6b86c211828c47027145ff405fd7e3fc5c3a (patch) | |
| tree | ff77a5279b845b0fa2d5d5ef7c11de97a71c5c96 /gui/tests/main.cpp | |
| parent | 0c5b0e03345d31406963e8ed8348a8c77ebe6352 (diff) | |
| download | turns-63aa6b86c211828c47027145ff405fd7e3fc5c3a.tar.xz turns-63aa6b86c211828c47027145ff405fd7e3fc5c3a.zip | |
gui: wrap tests in application
Diffstat (limited to 'gui/tests/main.cpp')
| -rw-r--r-- | gui/tests/main.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gui/tests/main.cpp b/gui/tests/main.cpp new file mode 100644 index 0000000..5fbc164 --- /dev/null +++ b/gui/tests/main.cpp @@ -0,0 +1,60 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#include "main.hpp" + +#include "init.hpp" + +#include <turnsmm/init.hpp> + +#include <catch2/catch_session.hpp> + +#include <adwaitamm/application.hpp> +#include <adwaitamm/applicationwindow.hpp> +#include <giomm/application.h> +#include <glibmm/main.h> +#include <glibmm/refptr.h> + +#include <libintl.h> + +#include <clocale> +#include <memory> + +namespace Turns::gui::tests::globals +{ + Glib::RefPtr<Adwaita::Application> app{}; + Glib::RefPtr<Adwaita::ApplicationWindow> win{}; +} // namespace Turns::gui::tests::globals + +auto main(int argc, char ** argv) -> int +{ + using namespace Turns::gui::tests::globals; + + auto session = Catch::Session{}; + if (auto error = session.applyCommandLine(argc, argv); error != 0) + { + return error; + } + + setlocale(LC_ALL, ""); + bindtextdomain("turns", TESTLOCALEDIR); + bind_textdomain_codeset("turns", "UTF-8"); + textdomain("turns"); + + app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::DEFAULT_FLAGS); + + Turns::init(); + Turns::gui::init(); + + app->signal_activate().connect([&session] { + win = std::make_shared<Adwaita::ApplicationWindow>(app); + Glib::signal_idle().connect_once([&session] { + session.run(); + app->quit(); + }); + }); + + return app->run(); +} |
