diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2016-05-14 12:22:10 -0500 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-29 14:37:39 +0200 |
commit | b8df067a9fa8e5db5fcccc88de5be3071b64b3ec (patch) | |
tree | 6640c52bf3382c6cf52ae4f0c8422e40f1c5c233 /tests/glib-fixture.h | |
parent | 8e58bff9438f67066f72a28cfdf7b421f3345d1e (diff) | |
download | ayatana-indicator-datetime-b8df067a9fa8e5db5fcccc88de5be3071b64b3ec.tar.gz ayatana-indicator-datetime-b8df067a9fa8e5db5fcccc88de5be3071b64b3ec.tar.bz2 ayatana-indicator-datetime-b8df067a9fa8e5db5fcccc88de5be3071b64b3ec.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 */ |