From c0776b7bb2bd90704b78d846f68ce9dfa19a18d6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 14 May 2016 12:22:10 -0500 Subject: add new tests to exercise the Snap::Response code --- tests/glib-fixture.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/glib-fixture.h') diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index efc8d17..eb2a8c5 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -20,6 +20,7 @@ #ifndef INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H #define INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H +#include #include // std::function #include #include // std::shared_ptr @@ -198,6 +199,29 @@ class GlibFixture : public ::testing::Test } GMainLoop * loop; + + using source_func = std::function; + + void idle_add(source_func&& func) + { + g_idle_add_full( + G_PRIORITY_DEFAULT_IDLE, + [](gpointer gf){return (*static_cast(gf))();}, + new std::function(func), + [](gpointer gf){delete static_cast(gf);} + ); + } + + void timeout_add(source_func&& func, std::chrono::milliseconds msec) + { + g_timeout_add_full( + G_PRIORITY_DEFAULT, + msec.count(), + [](gpointer gf){return (*static_cast(gf))();}, + new std::function(func), + [](gpointer gf){delete static_cast(gf);} + ); + } }; #endif /* INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H */ -- cgit v1.2.3