From 36bcdc4a83fa488e4eccb4f41ef4da6695dac027 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 14 May 2016 12:49:09 -0500 Subject: in tests/glib-fixture.h, tweaks to the new idle_add() and timeout_add() helpers --- tests/glib-fixture.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index eb2a8c5..840acf2 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -17,8 +17,7 @@ * with this program. If not, see . */ -#ifndef INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H -#define INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H +#pragma once #include #include // std::function @@ -198,13 +197,11 @@ class GlibFixture : public ::testing::Test ASSERT_FALSE(wait_for_name_owned(connection, name, timeout_msec, flags)) << "name: " << name; } - GMainLoop * loop; - using source_func = std::function; - void idle_add(source_func&& func) + guint idle_add(source_func&& func) { - g_idle_add_full( + return g_idle_add_full( G_PRIORITY_DEFAULT_IDLE, [](gpointer gf){return (*static_cast(gf))();}, new std::function(func), @@ -212,9 +209,9 @@ class GlibFixture : public ::testing::Test ); } - void timeout_add(source_func&& func, std::chrono::milliseconds msec) + guint timeout_add(source_func&& func, std::chrono::milliseconds msec) { - g_timeout_add_full( + return g_timeout_add_full( G_PRIORITY_DEFAULT, msec.count(), [](gpointer gf){return (*static_cast(gf))();}, @@ -222,6 +219,7 @@ class GlibFixture : public ::testing::Test [](gpointer gf){delete static_cast(gf);} ); } + + GMainLoop* loop {}; }; -#endif /* INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H */ -- cgit v1.2.3