diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-05-09 16:16:25 -0300 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-05-09 18:33:18 -0300 |
commit | c23e8f354755144b1ce48e7237855fdc68fc7549 (patch) | |
tree | b1b0294cf58b428682dc6bec973f1471e12d72a2 | |
parent | 0b854910bb806f2662d083d9c5e7bdcc07c61084 (diff) | |
download | gnome-control-center-c23e8f354755144b1ce48e7237855fdc68fc7549.tar.gz |
tests: Rework test-timezone-gfx
-rw-r--r-- | tests/datetime/test-timezone-gfx.c | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/tests/datetime/test-timezone-gfx.c b/tests/datetime/test-timezone-gfx.c index a8f704627..22619c30c 100644 --- a/tests/datetime/test-timezone-gfx.c +++ b/tests/datetime/test-timezone-gfx.c @@ -1,5 +1,6 @@ #include <config.h> #include <locale.h> +#include <gtk/gtk.h> #include "cc-datetime-resources.h" #include "tz.h" @@ -7,58 +8,67 @@ static void test_timezone_gfx (gconstpointer data) { - const char *pixmap_dir = data; - g_autoptr(TzDB) db = NULL; - GPtrArray *locs; - guint i; + g_autoptr(TzDB) db = NULL; + GPtrArray *locs; + const char *pixmap_dir; + guint i; - db = tz_load_db (); - locs = tz_get_locations (db); - for (i = 0; i < locs->len ; i++) { - TzLocation *loc = locs->pdata[i]; - TzInfo *info; - g_autofree gchar *filename = NULL; - g_autofree gchar *path = NULL; - gdouble selected_offset; - char buf[16]; + pixmap_dir = data; + db = tz_load_db (); + locs = tz_get_locations (db); - info = tz_info_from_location (loc); - selected_offset = tz_location_get_utc_offset (loc) - / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0); + for (i = 0; i < locs->len ; i++) + { + g_autofree gchar *filename = NULL; + g_autofree gchar *path = NULL; + TzLocation *location; + TzInfo *info; + gdouble selected_offset; + gchar buf[16]; - filename = g_strdup_printf ("timezone_%s.png", - g_ascii_formatd (buf, sizeof (buf), - "%g", selected_offset)); - path = g_build_filename (pixmap_dir, filename, NULL); + location = locs->pdata[i]; + info = tz_info_from_location (location); + selected_offset = tz_location_get_utc_offset (location) / (60.0 * 60.0) + (info->daylight ? -1.0 : 0.0); - if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) { - g_message ("File '%s' missing for zone '%s'", filename, loc->zone); - g_test_fail (); - } - } + filename = g_strdup_printf ("timezone_%s.png", g_ascii_formatd (buf, sizeof (buf), "%g", selected_offset)); + path = g_build_filename (pixmap_dir, filename, NULL); + + if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) + { + g_message ("File '%s' missing for zone '%s'", filename, location->zone); + g_test_fail (); + } + } } -int main (int argc, char **argv) +gint +main (gint argc, + gchar **argv) { - char *pixmap_dir; + gchar *pixmap_dir; - setlocale (LC_ALL, ""); - g_test_init (&argc, &argv, NULL); + setlocale (LC_ALL, ""); + g_test_init (&argc, &argv, NULL); - g_setenv ("G_DEBUG", "fatal_warnings", FALSE); + g_setenv ("G_DEBUG", "fatal_warnings", FALSE); - g_resources_register (cc_datetime_get_resource ()); + g_resources_register (cc_datetime_get_resource ()); - if (argc == 2) { - pixmap_dir = g_strdup (argv[1]); - } else if (argc == 1) { - pixmap_dir = g_strdup (SRCDIR "/data/"); - } else { - g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]); - return 1; - } + if (argc == 2) + { + pixmap_dir = g_strdup (argv[1]); + } + else if (argc == 1) + { + pixmap_dir = g_strdup (SRCDIR "/data/"); + } + else + { + g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]); + return 1; + } - g_test_add_data_func ("/datetime/timezone-gfx", pixmap_dir, test_timezone_gfx); + g_test_add_data_func ("/datetime/timezone-gfx", pixmap_dir, test_timezone_gfx); - return g_test_run (); + return g_test_run (); } |