mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 22:52:30 +02:00
test(util): add tests for SafeSignal
Add a fixture for writing tests that require interaction with Glib event loop and a very basic test for SafeSignal.
This commit is contained in:
19
test/GlibTestsFixture.hpp
Normal file
19
test/GlibTestsFixture.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <glibmm/main.h>
|
||||
/**
|
||||
* Minimal Glib application to be used for tests that require Glib main loop
|
||||
*/
|
||||
class GlibTestsFixture : public sigc::trackable {
|
||||
public:
|
||||
GlibTestsFixture() : main_loop_{Glib::MainLoop::create()} {}
|
||||
|
||||
void run(std::function<void()> fn) {
|
||||
Glib::signal_idle().connect_once(fn);
|
||||
main_loop_->run();
|
||||
}
|
||||
|
||||
void quit() { main_loop_->quit(); }
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<Glib::MainLoop> main_loop_;
|
||||
};
|
Reference in New Issue
Block a user