summaryrefslogtreecommitdiff
path: root/tests/testrc.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-03-23 23:21:30 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-03-23 23:21:30 +0000
commitac879843d0796bea474272842a4e129a2feab2f7 (patch)
treec759d8091ab89874ebce25e1ae9e144be1d997be /tests/testrc.c
parentefbac0906142738366f4264f65987a180f8869be (diff)
downloadgtk+-ac879843d0796bea474272842a4e129a2feab2f7.tar.gz
Support subclasses in RC files. (#142417, Todd Berman, patch based on a
2006-03-23 Matthias Clasen <mclasen@redhat.com> Support subclasses in RC files. (#142417, Todd Berman, patch based on a patch by Benjamin Berg) * gtk/gtkrc.h: * gtk/gtkrc.c: Support <classname> elements in widget_class paths in rc files which match any classes derived from named class. (_gtk_rc_init): Use the new syntax in the default rc string. * gtk/gtkbindings.c: Support the new syntax for bindings too. * tests/testrc.c: Tests for widget_class path matching
Diffstat (limited to 'tests/testrc.c')
-rw-r--r--tests/testrc.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/testrc.c b/tests/testrc.c
new file mode 100644
index 0000000000..a019ae394d
--- /dev/null
+++ b/tests/testrc.c
@@ -0,0 +1,77 @@
+/* GTK - The GIMP Toolkit
+
+ Copyright (C) 2006 Red Hat, Inc.
+ Author: Matthias Clasen <mclasen@redhat.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <string.h>
+#include "gtk/gtk.h"
+
+/* NOTE to compile this test, GTK+ needs to be build without
+ * the _-prefix stripping.
+ */
+struct {
+ gchar *pattern;
+ gchar *test;
+ gboolean match;
+} tests[] = {
+ { "", "", TRUE },
+ { "<GtkCheckButton>", "GtkToggleButton", FALSE },
+ { "<GtkCheckButton>", "GtkCheckButton", TRUE },
+ { "<GtkCheckButton>", "GtkRadioButton", TRUE },
+ { "abc*.<GtkButton>.<GtkLabel>.*foo", "abcx.GtkToggleButton.GtkLabel.foo", TRUE },
+ { "*abc.<GtkButton>.foo*", "abc.GtkToggleButton.bar", FALSE },
+ { "*abc.<GtkButton>.foo*", "xabc.GtkToggleButton.fox", FALSE },
+ { NULL, NULL, FALSE }
+};
+
+static void
+load_types (void)
+{
+ volatile GType type;
+
+ type = gtk_radio_button_get_type ();
+ type = gtk_label_get_type ();
+}
+
+int
+main (int argc, char *argv[])
+{
+ gint i;
+
+ gtk_init (&argc, &argv);
+ load_types ();
+
+ for (i = 0; tests[i].test; i++)
+ {
+ GSList *list;
+ gchar *path, *rpath;
+ gboolean result;
+
+ list = _gtk_rc_parse_widget_class_path (tests[i].pattern);
+ path = g_strdup (tests[i].test);
+ rpath = g_utf8_strreverse (path, -1);
+ result = _gtk_rc_match_widget_class (list, strlen (path), path, rpath);
+ g_print ("%d. \"%s\" \"%s\", expected %d, got %d\n",
+ i, tests[i].pattern, tests[i].test, tests[i].match, result);
+ g_assert (result == tests[i].match);
+ g_free (path);
+ }
+
+ return 0;
+}