diff options
author | Kalev Lember <kalevlember@gmail.com> | 2014-05-20 23:27:21 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2014-05-30 11:12:57 +0200 |
commit | cb9597ac27bd0c629437d61e7dfd1a5582924201 (patch) | |
tree | 285f62f64e9f028980cabf36a659ab5622f7e67c | |
parent | 2616fe3049475fc8797083d3827ae2e433cb791e (diff) | |
download | gnome-desktop-cb9597ac27bd0c629437d61e7dfd1a5582924201.tar.gz |
tests: Add a wall clock test for the notify::clock callback
https://bugzilla.gnome.org/show_bug.cgi?id=730447
-rw-r--r-- | tests/wall-clock.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/wall-clock.c b/tests/wall-clock.c index 6204909e..bb04709e 100644 --- a/tests/wall-clock.c +++ b/tests/wall-clock.c @@ -101,6 +101,50 @@ test_clock_format_setting (void) setlocale (LC_ALL, save_locale); } +static gboolean +on_notify_clock_timeout (gpointer user_data) +{ + g_error ("Timeout waiting for notify::clock"); + g_assert_not_reached (); + return FALSE; +} + +static void +on_clock_changed (GnomeWallClock *clock, + GParamSpec *pspec, + gpointer user_data) +{ + GMainLoop *main_loop = user_data; + + /* Nothing much to do here; the test was just to ensure we get the callback */ + + g_main_loop_quit (main_loop); +} + +static void +test_notify_clock (void) +{ + GMainLoop *main_loop; + GnomeWallClock *clock; + GSettings *settings; + + main_loop = g_main_loop_new (NULL, FALSE); + settings = g_settings_new ("org.gnome.desktop.interface"); + + /* Show seconds so we don't have to wait too long for the callback */ + g_settings_set_boolean (settings, "clock-show-seconds", TRUE); + + clock = gnome_wall_clock_new (); + g_signal_connect (clock, "notify::clock", G_CALLBACK (on_clock_changed), main_loop); + g_timeout_add_seconds (5, on_notify_clock_timeout, NULL); + + g_main_loop_run (main_loop); + + g_main_loop_unref (main_loop); + g_object_unref (clock); + g_object_unref (settings); +} + int main (int argc, char *argv[]) @@ -111,6 +155,7 @@ main (int argc, g_test_add_func ("/wall-clock/colon-vs-ratio", test_colon_vs_ratio); g_test_add_func ("/wall-clock/24h-clock-format", test_clock_format_setting); + g_test_add_func ("/wall-clock/notify-clock", test_notify_clock); return g_test_run (); } |