diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2016-05-14 12:49:09 -0500 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-07-07 02:27:25 +0200 |
commit | 36bcdc4a83fa488e4eccb4f41ef4da6695dac027 (patch) | |
tree | e3b8ce95673a1775dd3f527c869dc0196979e7a9 /tests/glib-fixture.h | |
parent | c0776b7bb2bd90704b78d846f68ce9dfa19a18d6 (diff) | |
download | ayatana-indicator-datetime-36bcdc4a83fa488e4eccb4f41ef4da6695dac027.tar.gz ayatana-indicator-datetime-36bcdc4a83fa488e4eccb4f41ef4da6695dac027.tar.bz2 ayatana-indicator-datetime-36bcdc4a83fa488e4eccb4f41ef4da6695dac027.zip |
in tests/glib-fixture.h, tweaks to the new idle_add() and timeout_add() helpers
Diffstat (limited to 'tests/glib-fixture.h')
-rw-r--r-- | tests/glib-fixture.h | 16 |
1 files changed, 7 insertions, 9 deletions
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 <http://www.gnu.org/licenses/>. */ -#ifndef INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H -#define INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H +#pragma once #include <chrono> #include <functional> // 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<gboolean()>; - 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<source_func*>(gf))();}, new std::function<gboolean()>(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<source_func*>(gf))();}, @@ -222,6 +219,7 @@ class GlibFixture : public ::testing::Test [](gpointer gf){delete static_cast<source_func*>(gf);} ); } + + GMainLoop* loop {}; }; -#endif /* INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H */ |