1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <gtk/gtk.h>
typedef struct _Theme Theme;
struct _Theme
{
const char *name;
const char *variant;
};
static void
theme_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
const GError *error,
gpointer unused)
{
char *s = gtk_css_section_to_string (section);
g_test_message ("Theme parsing error: %s: %s",
s,
error->message);
g_free (s);
g_test_fail ();
}
static void
test_theme (gconstpointer data)
{
const Theme *theme = data;
GtkCssProvider *provider;
provider = gtk_css_provider_new ();
g_signal_connect (provider, "parsing-error",
G_CALLBACK (theme_parsing_error), NULL);
gtk_css_provider_load_named (provider, theme->name, theme->variant);
g_object_unref (provider);
}
int
main (int argc, char *argv[])
{
const Theme themes[] = {
{ "Adwaita", NULL },
{ "Adwaita", "dark" },
{ "HighContrast", NULL },
{ "HighContrast", "dark" }
};
guint i;
gtk_init ();
g_test_init (&argc, &argv, NULL);
for (i = 0; i < G_N_ELEMENTS (themes); i++)
{
char *testname;
if (themes[i].variant == NULL)
testname = g_strdup_printf ("/theme-validate/%s", themes[i].name);
else
testname = g_strdup_printf ("/theme-validate/%s-%s", themes[i].name, themes[i].variant);
g_test_add_data_func (testname, &themes[i], test_theme);
g_free (testname);
}
return g_test_run ();
}
|