From 63aa6b86c211828c47027145ff405fd7e3fc5c3a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sun, 8 Jun 2025 14:53:13 +0200 Subject: gui: wrap tests in application --- gui/tests/main.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 gui/tests/main.cpp (limited to 'gui/tests/main.cpp') 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 + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#include "main.hpp" + +#include "init.hpp" + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace Turns::gui::tests::globals +{ + Glib::RefPtr app{}; + Glib::RefPtr 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(app); + Glib::signal_idle().connect_once([&session] { + session.run(); + app->quit(); + }); + }); + + return app->run(); +} -- cgit v1.2.3