]> Pileus Git - ~andy/gtk/blob - tests/testrc.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testrc.c
1 /* GTK - The GIMP Toolkit
2
3    Copyright (C) 2006 Red Hat, Inc.
4    Author: Matthias Clasen <mclasen@redhat.com>
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Library General Public License as
8    published by the Free Software Foundation; either version 2 of the
9    License, or (at your option) any later version.
10
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
15
16    You should have received a copy of the GNU Library General Public
17    License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <string.h>
21 #include "gtk/gtk.h"
22
23 /* NOTE to compile this test, GTK+ needs to be build without
24  * the _-prefix stripping.
25  */
26 struct {
27   gchar    *pattern;
28   gchar    *test;
29   gboolean  match;
30 } tests[] = {
31   { "", "", TRUE },
32   { "<GtkCheckButton>", "GtkToggleButton", FALSE },
33   { "<GtkCheckButton>", "GtkCheckButton", TRUE },
34   { "<GtkCheckButton>", "GtkRadioButton", TRUE },
35   { "abc*.<GtkButton>.<GtkLabel>.*foo", "abcx.GtkToggleButton.GtkLabel.foo", TRUE },
36   { "*abc.<GtkButton>.foo*", "abc.GtkToggleButton.bar", FALSE },
37   { "*abc.<GtkButton>.foo*", "xabc.GtkToggleButton.fox", FALSE },
38   { NULL, NULL, FALSE }
39 };
40
41 static void
42 load_types (void)
43 {
44   volatile GType type;
45
46   type = gtk_radio_button_get_type ();
47   type = gtk_label_get_type ();
48 }
49
50 int
51 main (int argc, char *argv[])
52 {
53   gint i;
54
55   gtk_init (&argc, &argv);
56   load_types ();
57
58   for (i = 0; tests[i].test; i++)
59     {
60       GSList *list;
61       gchar *path, *rpath;
62       gboolean result;
63       
64       list = _gtk_rc_parse_widget_class_path (tests[i].pattern);
65       path = g_strdup (tests[i].test);
66       rpath = g_utf8_strreverse (path, -1);
67       result = _gtk_rc_match_widget_class (list, strlen (path), path, rpath);
68       g_print ("%d. \"%s\" \"%s\", expected %d, got %d\n",
69                i, tests[i].pattern, tests[i].test, tests[i].match, result);
70       g_assert (result == tests[i].match);
71       g_free (path);
72     }
73
74   return 0;
75 }