diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2016-05-14 12:22:10 -0500 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-07-07 02:23:37 +0200 |
commit | c0776b7bb2bd90704b78d846f68ce9dfa19a18d6 (patch) | |
tree | e609d63fba6f56f07adf318603c6e7347bef79ed /tests/glib-fixture.h | |
parent | 5556233b478145158f12b1a81e87bb20a7b5cff7 (diff) | |
download | ayatana-indicator-datetime-c0776b7bb2bd90704b78d846f68ce9dfa19a18d6.tar.gz ayatana-indicator-datetime-c0776b7bb2bd90704b78d846f68ce9dfa19a18d6.tar.bz2 ayatana-indicator-datetime-c0776b7bb2bd90704b78d846f68ce9dfa19a18d6.zip |
add new tests to exercise the Snap::Response code
Diffstat (limited to 'tests/glib-fixture.h')
-rw-r--r-- | tests/glib-fixture.h | 24 |
1 files changed, 24 insertions, 0 deletions
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 <chrono> #include <functional> // std::function #include <map> #include <memory> // std::shared_ptr @@ -198,6 +199,29 @@ class GlibFixture : public ::testing::Test } GMainLoop * loop; + + using source_func = std::function<gboolean()>; + + void idle_add(source_func&& func) + { + g_idle_add_full( + G_PRIORITY_DEFAULT_IDLE, + [](gpointer gf){return (*static_cast<source_func*>(gf))();}, + new std::function<gboolean()>(func), + [](gpointer gf){delete static_cast<source_func*>(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<source_func*>(gf))();}, + new std::function<gboolean()>(func), + [](gpointer gf){delete static_cast<source_func*>(gf);} + ); + } }; #endif /* INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H */ |