2011-02-02 21:52:15 +01:00
|
|
|
#include <config.h>
|
|
|
|
#include <locale.h>
|
|
|
|
|
2010-09-29 13:28:17 +01:00
|
|
|
#include "tz.h"
|
|
|
|
|
2016-06-10 14:33:32 +02:00
|
|
|
static void
|
|
|
|
test_timezone_gfx (gconstpointer data)
|
2010-09-29 13:28:17 +01:00
|
|
|
{
|
2016-06-10 14:33:32 +02:00
|
|
|
const char *pixmap_dir = data;
|
2017-09-26 21:02:36 -04:00
|
|
|
g_autoptr(TzDB) db = NULL;
|
2010-09-29 13:28:17 +01:00
|
|
|
GPtrArray *locs;
|
|
|
|
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;
|
2017-09-26 21:02:36 -04:00
|
|
|
g_autofree gchar *filename = NULL;
|
|
|
|
g_autofree gchar *path = NULL;
|
2010-09-29 13:28:17 +01:00
|
|
|
gdouble selected_offset;
|
2011-02-02 21:52:15 +01:00
|
|
|
char buf[16];
|
2010-09-29 13:28:17 +01:00
|
|
|
|
|
|
|
info = tz_info_from_location (loc);
|
|
|
|
selected_offset = tz_location_get_utc_offset (loc)
|
|
|
|
/ (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
|
|
|
|
|
2011-02-02 21:52:15 +01:00
|
|
|
filename = g_strdup_printf ("timezone_%s.png",
|
|
|
|
g_ascii_formatd (buf, sizeof (buf),
|
|
|
|
"%g", selected_offset));
|
2010-09-29 13:28:17 +01:00
|
|
|
path = g_build_filename (pixmap_dir, filename, NULL);
|
|
|
|
|
|
|
|
if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
|
|
|
|
g_message ("File '%s' missing for zone '%s'", filename, loc->zone);
|
2016-06-10 14:33:32 +02:00
|
|
|
g_test_fail ();
|
2010-09-29 13:28:17 +01:00
|
|
|
}
|
|
|
|
}
|
2016-06-10 14:33:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
char *pixmap_dir;
|
|
|
|
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
|
|
|
|
g_setenv ("G_DEBUG", "fatal_warnings", FALSE);
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
pixmap_dir = g_strdup (argv[1]);
|
|
|
|
} else if (argc == 1) {
|
2016-09-13 12:34:13 +02:00
|
|
|
pixmap_dir = g_strdup (SRCDIR "/data/");
|
2016-06-10 14:33:32 +02:00
|
|
|
} else {
|
|
|
|
g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_test_add_data_func ("/datetime/timezone-gfx", pixmap_dir, test_timezone_gfx);
|
2010-09-29 13:28:17 +01:00
|
|
|
|
2016-06-10 14:33:32 +02:00
|
|
|
return g_test_run ();
|
2010-09-29 13:28:17 +01:00
|
|
|
}
|